10 posts / 0 new
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

If you want to read +-10v for example, you need to attenuate by 1/4th to get the 20v range down to 5v, then you must add 2.5v to bias the signal in the middle of the 0-5v range. Some smart person can draw us a picture of the circuit to do this.

Imagecraft compiler user

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

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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

Hoyt

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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

Hoyt

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

This is the usual way to do it:

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

Leon

Leon Heller G1HSM

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

Yes.

Leon

Leon Heller G1HSM

leon_heller wrote:
This is the usual way to do it:

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

Leon

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

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

Computers don't make errors - What they do they do on purpose.