2
\$\begingroup\$

On the project I am working on, I have 3 line-level audio signals, and I need to determine on an arduino if a non-silent signal exists on each line and act appropriately (in my case, "unplugging" a device from mains voltage). My first over-engineered idea is to amplify each signal, add a dc bias, then do some expensive operations on the arduino to determine if an audio signal exists.

Each audio signal is a mono signal consisting of a ground wire and an AC, low voltage, audio wire.

Now I don't remember much from my analog class from university, but my gut instinct is this can be simply done using analog componenets where I can feed the result (an psuedo digital signal where high would be above voltage x and low would be below voltage y) and do much easier computation on the microcontroller to determine if a signal exists.

The frequency of the audio signal is between 10 to 22,000 Hz The peak to peak voltage (of the consumer level line level) is 894mV, but the circuit should be able to handle as low as 10mV peak to peak

Any ideas?

\$\endgroup\$
  • 1
    \$\begingroup\$ Sounds like an op-amp peak detector with some appropriate decay and maybe some gain followed by a comparator would do the trick. \$\endgroup\$ – John D Feb 7 '15 at 20:43
4
\$\begingroup\$

This would be easier if you were detecting signals at your -10 dBV maximum level. But since you want this to detect levels as low as 10mV, you need to use comparitors. You get 4 comparitors in a 14-pin package (LM339).

Couple of things to note:

1) you need to ensure that the voltage differential that you want to measure is greater than the worst-case input offset voltage of your chosen comparitor. A quick check with my old National Semiconductor datasheet says that the worst case offset voltage for the LM339 is 2mV.

2) these comparitors are open-collector. They need pullup resistors to whatever supply voltage you need (+5V or whatever). This is actually an advantage because it makes adding a peak-hold detector easy.

3) you need to bias the input to the comparitors HIGHER than your maximum expected negative peak signal and LESS than your maximum expected positive peak signal. I usually set the bias to the power supply mid-point.

4) this going to be really expensive (grin). Total BOM cost should be about a dollar for 4 channels.

I'll do a quicky schematic here. Note that you will need to use 1% resistors in the input bias and comparitor reference section to get anything close to 10 mV sensitivity.

schematic

simulate this circuit – Schematic created using CircuitLab

Turns out that about the best sensitivity this will do is about 11 mV peak (22 mV P-P) and it will tolerate input signals up to about 2.5V peak. You can improve the sensitivity by changing the bottom resistor on the reference voltage divider to the same 22.1K resistor used everywhere else and adding a low-value pot in series with that resistor. Adjust the pot for your desired sensitivity.

Note that this detector includes peak hold. The output goes LO every time the detected audio exceeds the reference voltage and decays back towards +5V when the audio goes away. The time constant is currently close to 1 second but can be easily changed by modifying the RC network values at the output pins.

\$\endgroup\$
1
\$\begingroup\$

The Arduino Leonardo might work, within limits, without complex external circuits, as it has a differential ADC with additional gain.

Solution:

1) DC bias each input signal with a two resistors (voltage divider between GND and 5V) and a capacitor, another voltage divider to a common reference pin ADC. The ADC reference voltage should be set to about 100mv (voltage divider + capacitor). The ADC will saturate at signals above ±100mV, but you aren't interested in how much the threshold is exceeded.

2) The ADC allows 15k samples per second, to low in case you have signals with only very high frequencies. It is possible to overclock the ADC, at the price of reduced precision. ±10mv at 100mv full scale is about 5 bits. According to Overclocking AVR ADC 2 MHz ADC clock rate still gives 8.5 bits precision. One conversion needs 14 ADC clock cycles, so about 142k samples per second or 47kHz per channel.

3) The algorithm would be something like "N consecutive samples above threshold".

Issues:

None of this is supported by the Arduino libraries, you have to do all the low level AVR register access yourself. Depending on your knowledge and experience, a steep learning curve might be ahead.

AVR 32U4 datasheet Arduino to 32U4 pin mapping

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.