 # How to read a negative voltage

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

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

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

I can source/sink 20ma max.

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

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.

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.

Why do you think that then?

Because I'm not that smart, which is why I am asking you guys. ;)

Thanks

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.

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.

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

Thanks

Do some calculations before ordering parts. ;)

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?

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.

Hi

try R pu = R pd = 1K

and Vref =2.5V

you should get full range

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

Ok, I understand the concept here, but would anyone want to explain to me what is actually happening with this divider on an elementury level? I like to understand the "why" instead of just "because".

Thanks, and thanks for both youe help.

Voltage divider is simple : Let have two voltages : Vminus and Vplus, if I understand you have them as -5V and +5V. Mark resistors as Ra and Rb. A current through divider is I = (Vplus - Vminus) / (Ra + Rb) It creates a voltage drop on Ra resistor : Vdrop = I * Ra So you have on analog input pin : Vminus + I * Ra

Practical example, with your values -5V and +5V and let say both 10 kOhm resistors : I = (5 - - 5) / (10 + 10) = 10 / 20 = 0.5mA Voltage on resistor V = 0.5mA * 10 kOhm = 5V

## Added to -5V you have -5 + 5 = 0 V

Let your input voltage is 0V : I = (5 - 0) / (10 + 10) kOhm = 0.25mA On resistor V = 0.25 mA * 10 kOhm = 2.5V Added to OV : 0 + 2.5 = 2.5V

Practical remark : to have stable results, +5V supply must be stabilized nad 2.5V reference voltage (TL 431, LM336 ...) is recomended for full range conversion result.

Thanks Pepe34, single voltage dividers I know, but I couldn't get the math right with the neg voltage.