Line Level to ADC?

Go To Last Post
11 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am trying to monitor a line level signal (sound card 3.5mm stereo out) using an AVR ADC to assign values to the varying amplitude curve over time.

I don't understand how to get the signal. If I monitor it with a voltmeter, I see nothing. If I use a software oscilloscope looped back into the soundcard input, I see the wave from -1 to +1V. There is obviously something going on in between.

Can someone help out? Thanks.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Are you measuring AC voltage with your voltmeter? That should show something, especially if the frequency of the signal is low enough. If you have the Voltmeter set to read DC volts, then naturally it will show nothing as the audio signal is referenced to ground.

To get back to the AVR ADC thing. The ADC handles positive voltages only. So you'll need to set up a virtual analog ground, eg. 1.2 Volt DC, and AC couple the audio signal to that so the audio signal is riding on the 1.2 Volt bias. You can then use the ADC on that signal, with the 1.2 V as reference voltage.

If you think education is expensive, try ignorance.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, it's hard to tell without seeing your schematic and software.

But at least a voltmeter should indicate there is something on the output pins. Do you measure DC or AC and what frequency? Normal multimeters can only measure 50 or 60 Hz AC, and the DC portion may be low-pass filtered so basically the output revolves around 0VDC so the multimeter will show 0VDC.

So how do you connect the audio to AVR? A capacitor in series in the input to block DC and resistor divider to rebias the signal to half of the VCC? Can you read anything with the ADC like a potentiometer?

Do you read the ADCH and ADCL registers in the correct order?

- Jani

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I was using a normal multimeter on DC, expecting to see the voltage on the positive side.

Quote:
So you'll need to set up a virtual analog ground, eg. 1.2 Volt DC, and AC couple the audio signal to that so the audio signal is riding on the 1.2 Volt bias. You can then use the ADC on that signal, with the 1.2 V as reference voltage.

I'm kind of following you on this, but not really sure how to set it up.

Regarding the ADC, I do have that tested using a pot on ADC0 to adjust PWM on another pin. I have ADCH/ADCL left adjusted to use 8-bit depth, and I am only reading from ADCH.

Again, still fuzzy on the hookup from the 3.5mm, which I simply tried hooking up the tip to the ADC0 pin, ground to ground. Also tried using the AVR internal 1.1V reference.

Also, if I am correct the ADC is set to 125kHz (1Mhz freq. setting in AVR studio config and ADC prescaler set to 8 ).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Use 2 100k Rs in series from 5V to gnd.... there is 2.5V in the center for a/d bias.... put a 1uf cap on input

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks, I'll try it when I get home, and thanks for your help earlier too.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes you can think of the audio signal like sine wave, it has positive peaks and negative peaks (+1 and -1 volts for example) and the average voltage is 0. And you can't feed negative voltages to AVR ADC.

 
                   VCC (or AREF)
                     |
                    [ ] 100k
                1uF  |
audio input o---||---o----[ ADC0 pin
                     |
                    [ ] 100k
                     |
                    GND

Audio in example: 1VAC+0VDC

then ADC pin has 1VAC + 2.5VDC

- Jani

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hmmmm, still not a success. Is this anywhere near the right track? (see attached image) I'm still trying to wrap my head around virtual ground. Is it moving my 0 ground to 2.5 in this case so that a -1 to +1 volt source hovers in the 1.5 to 3.5V range? If so, does that mean I need to narrow the window a bit to take advantage of the full range of ADC? :shock:

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

just somehow missed your schematic on top of mine :) . I'll try rewiring like that.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Not exactly. You should move your 0.1uF cap from the AVR ADC to the L side of the 3.5mm jack, and increase it's value to something bigger. I would say 1uF or 10uF, plus side (if you use electrolytic) to the resistor divider, minus side to the stereo jack.

AREF to a 0.1uF cap, to GND.

Guillem.
"Common sense is the least common of the senses" Anonymous.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I wonder if the guy sending the line out likes getting 2.5V stuck up his tush? Thats what the cap was for! DC blocking!

Imagecraft compiler user