Hello,

I was wondering if anyone knows how to read a negative input voltage on any of the ADC pins of the atmega16. Ideally, I would like to do this with only using a positive (7805) power supply. Any ideas would be appreciated.

thanks,

Andy

Author

Message

Hello,

I was wondering if anyone knows how to read a negative input voltage on any of the ADC pins of the atmega16. Ideally, I would like to do this with only using a positive (7805) power supply. Any ideas would be appreciated.

thanks,

Andy

You might get away with just 2 resitors....

Connect them in series & the common between them goes to the a/d.

Call the top resistor T going to the high positive voltage H.

The bottom resistor B goes to the low voltage L.

The voltage going to the a/d will be:

(HB + LT)/(T+B)

L is your negative voltage (so it really ends up subtracting). H is probably your +5 V supply.

For even better performance, use a level shifting opamp circuit.

Hoyt

so for Bob's example if H=5 volts and B=1000 ohms

If T=500 ohms then

L=0 volts GIVES 3.333 V AT A/D

L=-10 volts GIVES 0.00 V AT A/D

If T=400 ohms

L=0 volts GIVES 3.57 V AT A/D

L=-10 volts GIVES 0.714 V AT A/D

etc etc etc

Excel is your friend

Hoyt

so for Bob's example if H=5 volts and B=1000 ohms

If T=500 ohms then

L=0 volts GIVES 3.333 V AT A/D

L=-10 volts GIVES 0.00 V AT A/D

If T=400 ohms

L=0 volts GIVES 3.57 V AT A/D

L=-10 volts GIVES 0.714 V AT A/D

etc etc etc

Excel is your friend

Hoyt

Level: Raving Lunatic

Joined: Fri. Jul 27, 2001

Posts: 7680 View posts

Location: St. Leonards-on-Sea (UK)

This is the usual way to do it:

Vcc | 2R | bipolar--R-- |--- unipolar | | 2R | Gnd

Leon

Leon,

Given the circuit diagram shown, is "bipolar" supposed to be the voltage input? Is "unipolar" supposed to be the voltage into the adc?

thanks,

Andy

Level: Raving Lunatic

Joined: Fri. Jul 27, 2001

Posts: 7680 View posts

Location: St. Leonards-on-Sea (UK)

Yes.

Leon

This is the usual way to do it:Vcc | 2R | bipolar--R-- |--- unipolar | | 2R | GndLeon

I was try to simulate this and correct values of resistors is here:

Vcc | R | bipolar--2R--| |--- unipolar | | 2R | Gnd

Thanks for your help. I did notice the error in resistor placement. Using 5k as R, I get -10 to +10 inputs to produce adc inputs of 0 to 5 volts. This is exactly what I wanted. Thanks again.

Andy