Pages: [1] 2   Go Down
Author Topic: How to read a negative voltage  (Read 7827 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Sr. Member
****
Karma: 1
Posts: 415
MEGA_Stick_II is here
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I haven't seen it mentioned anywhare, but I would assume the Arduino Analog input can only read a positive voltage.

So what would be the best way to reverse the polarity on a analog signal from -5volts to 0 to a positive voltage of 0 to +5v so it can be read by an ADC?

I would search for it, but I am not sure what to search for, is there such a thing as an Analog flipflop? I feel I should know the answer to this, so I feel a bit silly asking the question.  :-/

Thanks
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 132
Posts: 6746
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

An op-amp "inverting amplifier" (perhaps with a gain of 1) will do this, given appropriate power supplies.
Logged

0
Offline Offline
Sr. Member
****
Karma: 1
Posts: 415
MEGA_Stick_II is here
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
An op-amp "inverting amplifier" (perhaps with a gain of 1) will do this, given appropriate power supplies.

I can source/sink 20ma max.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 27
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi
With 2 resistors

+5V----[2K]----(analog_read_pin)-----[3K]-----(-5V to 0) Vss for testing

if Vss = 0V you should read 3V
if Vss = -5V you should read 1V

ratio for the value from 0 to -5v
Logged

0
Offline Offline
Sr. Member
****
Karma: 1
Posts: 415
MEGA_Stick_II is here
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Tektro69, But I will loose a lot accuracy that way.
I think the Op-Amp is a better way to go to maintain accuracy and I won't need to do any internale scaling in the software.
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 619
Posts: 33983
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
But I will loose a lot accuracy that way.

Why do you think that then? You can always change the values if you want to change the range. With equal resistors you will get the same voltage range. Watch out for negative voltages and put a catcher diode on the input.
Logged

0
Offline Offline
Sr. Member
****
Karma: 1
Posts: 415
MEGA_Stick_II is here
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Why do you think that then?

Because I'm not that smart, which is why I am asking you guys.  smiley-wink

Thanks
Logged

0
Offline Offline
Sr. Member
****
Karma: 1
Posts: 415
MEGA_Stick_II is here
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

GrumpyMike,

If I use 2 equal values of resistors, then wouldn't that make the voltage between 0 snd 2.5 volts?

If the input is 0, then the +5 should be dropped equal across the 2 resistors, would it not? Assuming the 0 input is the same potential as ground.
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 619
Posts: 33983
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
then wouldn't that make the voltage between 0 snd 2.5 volts?

Yes it would, sorry I was having a bad day.

You have to make the pull up larger than the pull down to extend the range over half. It should be possible to easily get a 4v range if not a bit bigger, keep the pull down to something like 470R and see where you get.
Logged

0
Offline Offline
Sr. Member
****
Karma: 1
Posts: 415
MEGA_Stick_II is here
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think it is time to order some parts and start playing.

Thanks
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 619
Posts: 33983
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Do some calculations before ordering parts.  smiley-wink
Logged

0
Offline Offline
Sr. Member
****
Karma: 1
Posts: 415
MEGA_Stick_II is here
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Do some calculations before ordering parts

 Oh for sure, but I will need the main parts regardless - and I got tons of resistors to play with.

If my volt divider Calculator is correct, 200K pu and a 1K pd should give me about a 0.02 to 4.8 volt range. Does that sound right?
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 619
Posts: 33983
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Yes it would, sorry I was having a bad day.

I think my bad day is today.

If the resistors are equal then you will get a value of 0V to the Arduino's input when you have -5V in.
Therefore when you change this to 0V there will be only +2.5V on the analogue input, as you rightly pointed out.

Any less in the bottom bit and you will have a negative input on the Arduino's analogue input with the full -5V input.

However what you could do is to change the Vref to 1.1V and get the full digitisation range with a smaller swing. Then you make the bottom resistor bigger.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 27
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi

try R pu = R pd = 1K

and Vref =2.5V

you should get full range
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 27
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

but your measurement is reverse
Vref =2.5V

if Vss = 0v => Vin = 2.5v => analog read = 1023

if Vss = -5v => Vin = 0v => analog read = 0
« Last Edit: October 06, 2009, 09:05:35 am by tektro69 » Logged

Pages: [1] 2   Go Up
Jump to: