The objective of this final project was to make a motor run in the presence of a loud noise by using the output of a microphone. This project focused heavily on integrating two separate devices into a single working product and utilizing different capabilities of the A3BU board and peripheral hardware. We were also able to reinforce the ideas presented in previous labs such as using the ADC input and controlling a motor through the use of PWM signals. We wanted to do something in which all members could learn and understand all parts, rather than just the parts that dealt directly with their major.
We implemented several ASF libraries, such as the libraries for ADC and PWM, to achieve the above results. As displayed by the code below, once the program was loaded onto the A3BU, the program would essentially be put into a “sleep mode” until the board read a result on the ADC1 pin. This result would come from the output of the microphone that sends a voltage that depends on the sound level it detects. Then a callback method, adc_handler, is triggered which contains all of the essential conditional logic as mentioned above. To avoid the spinning of the fan at lower, unintentional, sound levels there’s an if statement that uses that threshold value and compares it to the result that is passed into the callback handler method.
Above is a video of the microphone’s output when a sound is made. This value was then incorporated into our code to aide with the turning on of the motor.
We would begin by designing the circuit we used for Lab 4 to drive the motor. The circuit is given below. We would test the motor output with an oscilloscope to verify a signal Add Newis displayed. As this is correct, we would move on to test the microphone and the pre-amp circuit that will send an output to the A3BU board.
Below are the schematics for the microphone and motor.
Below is our fully functioning circuit for both the microphone and the motor.