I want to detect the audio signal from my iPad. With a jack plug connection the unloaded ac voltage is about 270 mV RMS and lasts for about 3 secs.
I’m a novice Arduino user. Can a UNO 3 sketch detect this reliably (to proceed with the simple task of closing a relay) or must I first use a pre-amp and rectifier circuit please?
Terry, UK
You can actually try it anyway you want and see if it works!
Paul
the unloaded ac voltage is about 270 mV RMS and lasts for about 3 secs.
That can work but it should go higher than that with the volume turned-up. It might actually be higher than that and maybe your meter doesn't have time to respond accurately.
The main thing is that you should protect the Arduino from the negative half of the AC audio signal. Technically up to -0.5V is OK, but it's still a good idea to be safe. (270mV RMS has 380mV positive & negative peaks.) There are (at least) 3 ways to do this:
1. In your application, I'd recommend a [u]Protection Circuit[/u]. D2 in the 2nd schematic protects against negative voltages. Use a Schottky diode. Since you are not worried about going over +5V, you can leave-out D3. 100 Ohms is OK for a headphone output, but 10K will allow you use a line-level or headphone-level audio signal.
With the default 5V reference you'll get ~5mV resolution so 270mV (380mV peak) would read about 78 (peak) on the ADC. If you use the optional 1.1V reference it should read about 350 (peak).
Don't forget that you are reading an AC "wave" that's constantly changing and negative half of the time (half of your readings will read zero). Your readings will "look random", within a range.
2. The "standard" solution is to [u]bias the input[/u] so you can read the negative half of the signal. That gives you an undistorted signal for FFT, etc. But, since the bias is 2.5V you can't use the 1.1V reference to increase the sensitivity.
3. A [u]Peak Detector[/u] (AKA Envelope Follower) gives you a varying DC voltage equal to the positive peaks. It requires and op-amp so the hardware is more complicated but your software doesn't have to "find" the peaks. And of course, you only get "loudness" information so you loose all of the frequency information and can't use FFT, etc.
Many thanks DVDdoug, appreciate that detailed advice.
But I now think I’ll just front end the Arduino circuit with a simple preamp and half-wave rectifier. Its output (either close to 0V or above a volt or two) would then be easier to work with for this novice!
Terry
Add a diode and an RC circuit to the output of that pre-amp and you have a crude peak detector. Makes it even easier to detect the presence of an audio signal.