Pages: [1]   Go Down
Author Topic: audio input thoughts...  (Read 742 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've been searching around but can't really figure out a simple way to get a bit decent sine-level detection on the analog input.

I enter a audio sinewave into the arduino to get max voltage difference (.7v) but the output is giving 'erratic' results.

I understand that sound is something different than a nice and steady voltage level on e.g. potmeter but at the moment I can't really detect anything useful from the audio level.

Is there a simple way - hardware wise - to just flatten out the sound a bit so it's easier readable by the arduino? I don't really care about the fact that I have to 'upscale' the sound level internally which degrades resolution. I would rather not use any active components on the input.

Where I'm thinking at now is to use a diode to remove the negative volts, probably leaving .35 volts in level difference and then? A capacitor in leveling out the sines? I'd probably need to set a sound frequency in which the capacitor works at it's best?

And would the sinewave be best to use? (I could also use a square wave but remembering AC/DC conversion-lessons in the past I thought sines would work best flattening out)

Am I in the right directon here or has someone been-there-done-that and advises me to leave this be?
Logged

CO, USA
Offline Offline
God Member
*****
Karma: 5
Posts: 711
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you're putting negative voltage on an Arduino input pin, that won't work. You will need to rectify it first. But, I think you'll have trouble. You mention max V diff. of .7V, so I infer that your peak +V is .35V. A diode typically has a forward voltage drop of .7V, so there goes your whole signal.

It is true that once you've rectified it, you can use a capacitor to filter and get closer to DC, but your voltage will still have ripples.

More description of what it is, functionally, you're trying to do, would likely help here. Since you mention using square wave instead, it would seem you're generating the sine wave as well. What is it that's generating the signal?
Logged

... it is poor civic hygiene to install technologies that could someday
facilitate a police state. -- Bruce Schneier

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 525
Posts: 26538
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You try running your AC thru a cap to two 10K resistors from +5 to Gnd, the resulting level is 2.5V, your AC would wiggle the 2.5 V up & down.
Keep in mind the 10K sampling rate of the ADC limits your usable audio to 5K max. (Nyquist theory, need sampling to be fast enough to catch at  least 1 high sample and 1 low sample to be able to recreate the incoming wave).
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the input, indeed - lifting the whole signal would be a much better idea. I'm trying to control a light on the audio output level of an iPad. I'm using synthesizer software to generate sound levels. Just sliding the volume would brighten/dim the light. Using left and right channels seperately I could even try and control 2 channel output.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 604
Posts: 33419
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You need a peak detector.
http://en.wikipedia.org/wiki/Precision_rectifier
Or google for lots of schematics.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
  Take a look here http://interface.khm.de/index.php/lab/experiments/arduino-realtime-audio-processing/ there are some schematics and sketchs to sample audio signal. Then you can use these sketchs and instead of the output part you may substract the offset, calculate some power values, and output the values on the light. The function analogWrite() might be disabled in this sketch but PWM works on pin 11 (pin 11 is used to output audio cf sketch).

Hope I have been helpful smiley
Logged

Montreal
Offline Offline
Faraday Member
**
Karma: 27
Posts: 2573
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Keep in mind the 10K sampling rate of the ADC limits your usable audio to 5K max. (Nyquist theory, need sampling to be fast enough to catch at  least 1 high sample and 1 low sample to be able to recreate the incoming wave).
Exactly, we have to follow 2*F rules when we need to know spectral content or when incoming waveform should be restored after passing communication line. But it's not the case for magnitude (RMS) measurements, and 10K sampling works works great with input analog frequencies up to 20 kHz, or even higher.
http://coolarduino.wordpress.com/2012/06/28/stereo-audio-vu-meter-on-arduino/
 
Logged

Pages: [1]   Go Up
Jump to: