ADS1115 measuring negative values

Thread Starter

FeliceM

Joined Jun 19, 2021
8
Hi there,
it is clear to me that the ADS1115 cannot measure negative values.
I am trying to measure the current on a battery connected to a UPS which can be positive or negative (charging-draining).
I am using a LEM which reverse the polarity of the output according to the current flow.
The output of the LEM module is from -4.6 V to + 4.6 V equivalent to -10A to 10A
Reading about other people experience in measuring negative voltage with an ADC, I ended up on this post: https://tlfong01.blog/2020/02/29/ads1256-reading-negative-values/
I have designed my circuit to avoid negative values in all conditions. The ADC is on Raspberry circuit (3.3V).
So, my voltage divider is like this (simulating -4.6V input):
Schermata 2021-06-19 alle 06.03.16.png

With the above voltage I get, on the ADC, 0.275V. With +4.6V input I get 3.725V onto eADC input. So I never end up in negative voltage on the ADC input.
Up to here seems all clear to me.
The confusion comes at software level. I do I calculate the real voltage input from the LEM?
Thanks for helping
 
Last edited by a moderator:

Thread Starter

FeliceM

Joined Jun 19, 2021
8
No no not about right or wrong just a typo, I do it all the time. With that said. I hate to give you the bad news.
The ADS1115 is able to measure negative values or voltages even though it only operates using a single supply.
Although the ADS1115 has 16 bit resolution capability, it uses twos complement to represent a value (the MSB represents the sign bit). This is really a 15bit resolution ADC capable of negative and positive voltage measurement (within the GND to VDD supply limitation. Sorry about that.
Now I am really lost! Are you saying that I can input -4V relative to its ground on the ADS1115?
 

Thread Starter

FeliceM

Joined Jun 19, 2021
8
Thank you for pointing me out to some good reading. I am not an electronic guy. I decided to give a go to this small project to learn something about a practical application of the Pi doing some measurement, then the appetite comes heating.
I have an inverter in the garage and some batteries. :) I decided to measure voltage, temperature and the intention is also to measure the current. Each sensor has a common ground connected to the GND of the 3.3 V on the Pi. I am using the Adafruit library in Python.
For the voltage I have a LEM transducer 0 to 150V on the HV side translate to 0 to 4 V on the low voltage side. I am reading it without problems on the ADS1115 A0 to GND. I did set a conversion factor. Very fine reading.
For the temperature I have a LM35, I can read it and get the correct temperature (A1 to GND).

I am facing problems reading the current. It is connected to A2-GND. The sensor I am using outputs 0 to 4 volts linearly (10A = 4V). All fine and very accurate reading if the inverter is not charging the batteries. As soon as the current flow reverse than the output would go to negative. I did not try it in this configuration because my understanding from the literature I have read is that the ADS1115 can read negative value in my configuration only up to -256 mV.
Instead of changing all other sensors and configuration of the system, I thought about using a voltage divider as per my post above.
I have not tested it yet, but on the paper looks like the solution to my problem. I am not sure if there is another way to use the sensor I have available.

I would appreciate advise on how I have sized the voltage divider in this context, and how to calculate the factor I should use in the software to convert the measurement from the voltage divider (R1-R2) in the real measurement.

As I said, I am not an electronic guy but I am willing to learn.
 

ericgibbs

Joined Jan 29, 2010
14,190
hi F,
Download your original image, I will run a LTSpice simulation.
What is the full voltage range of the V2 source voltage.??
also
what voltage range for the ADC input.??

E
 

Thread Starter

FeliceM

Joined Jun 19, 2021
8
hi F,
Download your original image, I will run a LTSpice simulation.
What is the full voltage range of the V2 source voltage.??
also
what voltage range for the ADC input.??

E
The maximum current I intend to read is 10 A. However, my intention was to size the voltage divider to max. 20A (4V output).
The range for the ADS I am trying to get is 0V =-4V output from the sensor and +4V= +4V output from the sensor. 2 Volts on the ADS would then be 0 Amps. The other side of the voltage divider is the 3.3 V of the Raspberry power supply.
Schermata 2021-06-19 alle 17.32.21.png
 
Last edited:

Thread Starter

FeliceM

Joined Jun 19, 2021
8
hi F,
I understood that you wanted to Offset a -4.6v to be above 0v ie: shifted to a +V Range for the ADC.?

This is what LTSpice shows for your circuit for a Vsource -4.5v thru +4.5v
E

Added a 2nd Image for 4/-4v as per your 10Amps = 4V
Thats perfect. So my attempt to size the voltage divider was correct. Thanks a million for confirming.
I am still stuck on how I convert the value on the ADS (Vadc) to the real measurement. Can you help?
 

ericgibbs

Joined Jan 29, 2010
14,190
hi F,

As your Vadc range is from approx 0v thru +3.3V, I would use the Single ended input , not differential.

I do not use Python, but I would suggest you Read the the Output value for the ADS1115 when the Vsrc is say 3.3V/2 , use a small variable supply or battery with a pot to give the 3.3v/2...

Save this ADC value and use it as the 0V reference, so any ADC value greater that this 0Vreference value will be a Positive Current and values less than the 0V reference will be Negative Current.

By varying the test variable supply to give +4Vinp and -4Vinp , note the ADC value output for these limits,,
These limits will give you an indication of the Span Calibration

Knowing the Calibration factors your program should be able to calculate all the intermediate values of current from -10A thru +10Amps.

Do you follow ok.?

E



Update:
Look here.
https://github.com/adafruit/Adafruit_Python_ADS1x15

https://learn.adafruit.com/raspberry-pi-analog-to-digital-converters/ads1015-slash-ads1115
 
Last edited:

Thread Starter

FeliceM

Joined Jun 19, 2021
8
hi F,

As your Vadc range is from approx 0v thru +3.3V, I would use the Single ended input , not differential.

I do not use Python, but I would suggest you Read the the Output value for the ADS1115 when the Vsrc is say 3.3V/2 , use a small variable supply or battery with a pot to give the 3.3v/2...

Save this ADC value and use it as the 0V reference, so any ADC value greater that this 0Vreference value will be a Positive Current and values less than the 0V reference will be Negative Current.

By varying the test variable supply to give +4Vinp and -4Vinp , note the ADC value output for these limits,,
These limits will give you an indication of the Span Calibration

Knowing the Calibration factors your program should be able to calculate all the intermediate values of current from -10A thru +10Amps.

Do you follow ok.?

E



Update:
Look here.
https://github.com/adafruit/Adafruit_Python_ADS1x15

https://learn.adafruit.com/raspberry-pi-analog-to-digital-converters/ads1015-slash-ads1115
I do follow you. What confuse me is the directions given by the writer of the post in the link I referenced above https://tlfong01.blog/2020/02/29/ads1256-reading-negative-values/

"In terms of software, that’s V_real = 2*V_meas - 5*K_1Volt, where K_1Volt is the numeric value corresponding to 1V."
He was dealing with different voltages, however the last part "..K_1Volt is the numeric value corresponding to 1V..." that's the part I cannot figure out.

Thanks a million for your help.
 

ericgibbs

Joined Jan 29, 2010
14,190
hi F,
Please post a simple sketch showing the connections for the Shunt resistor circuit and connection to the MCU.

If you use a Single ended input voltage of 0V thru +3.3V as input to the ADS, it will give a output value of 0h thru 7FFFh [ 32767 decimal] .
So 3.3V/2 as the virtual zero will be 3FFFh , values higher that this are Positive amps, ,, less than this Negative amps.

If you have a Python program, please post it.

E
What Gain setting have you chosen.?

OT: Hope the weather is OK in RSA.;)
 

Attachments

Thread Starter

FeliceM

Joined Jun 19, 2021
8
hi F,
Please post a simple sketch showing the connections for the Shunt resistor circuit and connection to the MCU.

If you use a Single ended input voltage of 0V thru +3.3V as input to the ADS, it will give a output value of 0h thru 7FFFh [ 32767 decimal] .
So 3.3V/2 as the virtual zero will be 3FFFh , values higher that this are Positive amps, ,, less than this Negative amps.

If you have a Python program, please post it.

E
What Gain setting have you chosen.?

OT: Hope the weather is OK in RSA.;)
Thanks a million for your help. Now I need to start testing and adjust things from there.
RSA weather is great but at present is cold. 3rd wave of COVID climbing quickly. Good luck in UK, I see you have also some issue there.
Thanks
 
Top