Can ATMEGA16 read negative voltage on ADC?

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

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

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

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

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

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!

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

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

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

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

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

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

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

This is the usual way to do it:


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

Leon

Leon Heller G1HSM

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

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

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

Yes.

Leon

Leon Heller G1HSM

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

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.

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

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