Course Home

 

Course Information

 

Schedule and Assignments

Lab 2: Level sensing program

Introduction

In this lab, you will create a program that senses the level of the microphone input and lights an LED on the board when the level is above a threshold. .

Make your own application

You can use the bp program as a starting point for a simple level-sensing program. You will turn on the FLAG1 LED on the board when you sense inputs over a certain level.

The function spr0_asserted() contains the code that grabs the ADC input, runs the filter code, and forwards the result to the DAC. You can insert level-sensing code here. Create

Create a global variable of type float to hold the current energy. The filter_input variable holds the current sample. Use a simple averager to determine the average level over the last second or so.. After making sure that all values are non-negative (either using abs() or by squaring), form the average of the last 10 to 20 samples. You will need to create a circular buffer to hold the samples for averaging. Given the average, you can compare against a threshold to determine whether the level is high enough. Experiment with threshold values, but start with a threshold in the range 5000-10000.

The LED can be turned on with this function call: set_flag(SET_FLAG1,CLR_FLAG). (For some reason, CLR_FLAG turns on the LED.)

Turn in

A listing of your (well-commented) program.

Copyright ã 1998, 2000 Wayne Wolf