Thursday 29 September 2011

Mic Based Interrupts

Problem:
We need to be able to wake the Arduino when the koala starts calling. The initial test is a volume test. We want the Arduino to wake up when the mic registers a load noise.

To wake the Arduino from sleep an interrupt must be generated and sent to pin 2 or 3.
Although the attach interrupt method allows various parameters to be set for the interrupt (high, low, faling etc) in any mode except "Idle" only Low can be used.

This poses a problem as we need to generate a low signal when the mic reading reaches a certain threshold. Also, as LOW is defined as 0-2V the ambient reading from the mic is actually a LOW signal and it continually wakes the Arduino. Pulling the PIN high with a pull-up resistor pulls it high, but only while nothing is connected. Once the sensor is plugged back in the pin reads normal values. Though in some cases (sound sensor) the pull-up resistor affected the reading.

Solution:
Using and operational pre-amp to set a threshold voltage and generate a low signal when the signal crosses the threshold. An Operational Amplifier (op-amp) is designed to amplify the difference between the V+ and V- input pins. Since the amplifier has very high gain, in this configuration its output is either fully on, or fully off, depending on whether the input (in this case on V-) is greater than, or less than, the reference voltage we put on V+. I am using the LM358



 LM358
PIN1 to Arduino interrupt pin. This output will snap low when the input exceeds the reference voltage.

PIN 2 to Mic Signal Output. This is the signal we will monitor

PIN3 to POT signal Out. The pot provides an adjustable reference voltage.

PIN 4 to ground

PIN 5, 6, 7 provide a second input

PIN 8 5V Power supply

Both Mic and Pot are connected through pull-up resistors. Once a threshold V has been calculated we might replace the pot with resistors and hard wire it in.

1 comment: