measuring current in both directions

Hi
I know that to measure current you put a shunt resistor on the negative wire and measure the voltage drop across the 2 pins of the resistor with a ADC, with the small voltages to be read a 16(15)bit ads1115 is an ideal choice.
My problem is the use I am putting this circuit to. I am measuring the current flow in a battery on my electric bike with a single pair of wires coming out of the battery these 2 wires are used for both charging and discharging ( the battery pack is lithium).

My problem is that the ADS1115 does not recognise negative voltages when discharging everything works how I would expect the voltage drop over the resistor is a positive value and can be worked out on the arduino with no problems(a multimeter measurement of the shunt voltage read less than half a volt), charging causes a negative value that the ADS1115 cannot read.

how can I get round this problem, one school of thought is to move the gnd reference high enough so the highest charging value still returns a positive value from the ADS1115.

kendrick

You need an opamp differential amplifier circuit to boost and level shift relative to a reference
voltage of your choosing. Differential amplifier - Wikipedia

IIRC ADS1115 does measure negative voltages.

Smajdalf:
IIRC ADS1115 does measure negative voltages.

after reading your post I read the data sheets till I found the correct part on page 26 section 9.5.4, I did know that although the ADS1115 is a 16 bit AtoD converter every video I looked at on youtube said it was actually a 15 bit without clarifying that the most significant bit denotes if the voltage is negative (1)or positive(0) if you think about the logical conclusion is since the returned number is signed t follows that a negative value can be read.
time to build a test circuit.
kendrick

It can read negative when using two ADC inputs, in differential mode.

No, the ADS1115 can't measure negative voltages.
It can measure a differential voltage, but both inputs must be positive for that (within it's supply/ground limits).

What is the voltage of your battery.
Can use an INA219 high-side (in the + line) if battery is <=24volt.
Or an INA169 (<=60volt) to convert from high-side to low-side, and then use the ADS1115 to measure.
Both breakout boards are available from Adafruit (or ebay).
Leo..

you all have relevant points. the ADS1115 CAN return negative reading results it must do or the outputted number would not be signed, BUT there is a catch COMMON GROUND this is where the problem is.

example,a simple problem
measure the voltage in a single lithium cell (max voltage 4.2v) the voltage is well within the range of the ADS1115 if you setup the arduino powered from say usb connect the ADS1115 to it and program it to take readings across A0 and A1 a differential mode if the positive went to A1 you would get a positive number if the positive went to A0 you would get a negative reading, you are only measuring the difference in voltage between A0 and A1 and as long as that difference is not over 5v you are ok. This is how the signed output value was to be used.

What would not work is if you had a common ground say you powered the arduino off the battery with a step up DC DC converter connected a ADS1115 to the arduino then decided to check the batteries voltage by connecting positive to A0 and negative to A1 result would be smoke,short and a new ADS1115.
hope you understand that.
for my own predicament I think I have a solution I can't use a seperate power supply, arduino and ADS1115 but I Ian isolate them take the I2C bus and put it through an isolating chip that is specially designed with the I2C bus in mind one is the ADM1250 ad to that an isolating 5vDC in 5vDC out isolator on the power line to the ADS115 and that should be the problem sorted maybe add a capacitor in there to take out any noise.

kendrick

Level shifting of the two shunt voltages would be easier (post#1).

Another problem could be the sensitivity of the ADS1115 (±256mV).
That requires a shunt with a rather high resistance.
Could get hot with high currents.
Leo..

Wawa:
Level shifting of the two shunt voltages would be easier (post#1).

Another problem could be the sensitivity of the ADS1115 (±256mV).
That requires a shunt with a rather high resistance.
Could get hot with high currents.
Leo..

The differential amp configuration has any gain you like...