## How to convert an audio signal to 0-5v

17 posts / 0 new
Author
Message

Good night every body.
I know this may be a re-re-re-post about this subject, but I cant find anything even using the all mighty google on how to convert the negative and positive audio signal from a pc or an mp3 player to a single ended 0-5v signal to feed into an avr adc.

The simplest would be to run the audio through a capacitor to block DC then to the adc input. Set the DC voltage to 2.5V with a two resistor voltage divider. You will have low frequency roll off.
Resistor values of 51K and capacitor of 10uF should get you started.

```          +
|
-----/\/\/--- +5
|
-----/\/\/--- gnd```

Can I then buffer it using an op-amp configured to unity gain to optimize the adc load?

The adc input is relatively high impedance. If you want to just experiment, the above circuit should work OK. The input voltage swing should be about +- 2.5 volts for full adc range.

You could use the 1.1v ref for a +- .55 v swing. You would need a voltage divider that has a .55 volt output. Maybe a 33K to ground and a 270K pull up.

For an ideal circuit, a bit more work would need to be done.

Check the adc conversion rate of the device you are using. The Atmega88 has a max conversion of 15ksps at max resolution and the ideal clock frequency. That would work OK for voice, rather marginal for music.

Have fun!

There are no single line input standards, but one relatively often seen standard is 2Vrms output into 10kohm load.

So, that gives about 5.6v peak to peak, time to go shopping and then some measures.
Thanks for the help provided.

Quote:
Can I then buffer it using an op-amp configured to unity gain to optimize the adc load?

Yes, but make sure you pick a "rail-to-rail" op amp if you intend to power it from +5V/Gnd.

JC

DocJC wrote:
Quote:
Can I then buffer it using an op-amp configured to unity gain to optimize the adc load?

Yes, but make sure you pick a "rail-to-rail" op amp if you intend to power it from +5V/Gnd.

JC

I do not think ADC is necessary if you make a 10kohms input impedance, the ADC sees less thar 10kohms or less anyway. But for range scaling the opamp is nice.

Inverting op-amp configuration is nice because you can bias opamp inputs half of the supply voltage, so you don't need rail-to-rail inputs, only rail-to-rail output.

Allready ordered some samples of rail to rail op-amps, when they arrive I will test it.

At the arduino forum someone sugested this circuit:

Can I use it, it looks correct?

That should work. Gain would be about -R1/R4 or 1, offset would be 5V*R3/(R2+R3) or 1.25V. If you want to take a 1V PP signal (max level) and use the ADC at +5V reference, you probably would want the offset to be 2.5V, so use R2=R3 or 10K-100K each. A gain of 5 would bring the swing from 1VPP to 5VPP, so, make R4=150K and R1=30K. If your input signal is close to 1VPP, then you might want a slightly lower gain, maybe 3-4. So, set R4 = 3-4 X of R1.

With a 10bit ADC, if you get values close to 0x000 or 0x3ff, you may be over driving the ADC and might want to back off the gain (R4/R1 ratio), adjust the offset (R2/(R2+R3)) or both. Conversely, if your values are within few hundred counts of each other, increase the gain.

As a note, this probably will not be a problem: While this is a rail to rail op amp, its drive goes to zero as the output approaches the rails. it would probably be best to keep the output signal a bit within the 0-5V range. You may not actually see the ADC near 0 or 0x3ff

Very very very thanks mr Jwinkler for all the help provided and for your good explanation about all I should do :D

Just one more little thing, can I use an LM358 instead of the op-amp shown in the image, or NE5532, or even TL072?

Unfortunately, these op amps are not rail-to-rail. Their voltage range is limited and the output will not swing to the full 0-5V range with a +5V only supply. For instance, the LM358 "high level output voltage" is guaranteed to Vcc-1.5 or less for a load > 2K ohm. I.e. at +5V, you might only get 3.5V out of it.

If you power a LM358, NE5532, or TL072 op amp with +-12 or +-15 volts, they would have a voltage swing of at least 0-5V. However, if your output goes outside of the 0-5V ground to power range of the ADC input, the AVR might be destroyed. There are ways around this, but be careful! One reason that rail-to-rail opamps exist is to allow use with a single +5V only supply and avoid the expense and power consumption of an extra power supply or two.

Once again here I come asking for a little help, can you name some commonly available rail to rail op-amps?
Thanks again for all you answers and how detailed they are, you sir are the best!

That is a big question. Of the "rail-to-rail" variety, there are hundreds, at least, that could be construed as "commonly available". There are many factors that would narrow it down to one type (or less). Design factors would include: GBP, AC or batteries, frequency, slew rate, gain, output load, noise, CMRR, package, etc. You might want to go to ti.com and look through their opamps. Also, digikey.com has a good search engine.

A pragmatic solution would be to search online for circuits that are close to what you want. The TLV2371 is a good choice for audio without too much gain.

I believe the LM2904 is made specifically for low-voltage, single-supply applications, and is suitable for audio.

Plus, I think you can get them relatively cheap at Jameco (don't quote me on that one).