Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong Values @ 0.001Ohm Shunt, value overrun? #4

Open
Jim4Beam opened this issue Jul 2, 2015 · 1 comment
Open

Wrong Values @ 0.001Ohm Shunt, value overrun? #4

Jim4Beam opened this issue Jul 2, 2015 · 1 comment

Comments

@Jim4Beam
Copy link

Jim4Beam commented Jul 2, 2015

Hello,

I am using the INA219 and this nice Library at a 24V Battery System (20V to 27V) at a 0.001Ohm (1milli Ohm) Shunt with a current of +30A (charging) and up to -120A (discharging).

Please find my Code attached/below.

The measurement of voltage above 16V is working due to the changes of “unsigned int temp;” to “int temp;” in “float INA219::busVoltage()// returns the bus voltage in volts ” in file INA219.cpp. (described in Issue #3)

But I still have problems with the measurement of the Current and Power values.

When I apply 25.1V and -5.2A (is -5.2mV at the shunt, measured with multimeter) I get the following results:


raw shunt voltage: 697

raw bus voltage: -15166

shunt voltage: 3.9000 mV
shunt current: 177.5542 mA
bus voltage: 25.1720 V
bus power: 4468.9951 mW

Does it my be a problem of value overflow? What might be the problem?
Thank you very much.

I have set the following default settings in INA219.h:

define D_I2C_ADDRESS 0x40 // I2C Adresse(64)

define D_RANGE 1 // 0: 0-16V, 1:0-32V

define D_GAIN 3 // Range: 2: +-160mV, 3: +-320mV

define D_SHUNT_ADC 10 // ADC 3: 12-bit, single sample, 532uS conversion time 6:8x 4,2ms

define D_BUS_ADC 10 // -||-

define D_MODE 7 // 7: continuous conversion

define D_SHUNT 0.001 // R-Shung [Ohm]

define D_V_BUS_MAX 28 // U-Bus-Max [V]

define D_V_SHUNT_MAX 0.160 // U-Shunt_Max exp. [V]

define D_I_MAX_EXPECTED 130 // I-Max exp. [A]

My Code:
/**********************************************

  • INA219 library example
  • 10 May 2012 by johngineer
  • this code is public domain.
    **********************************************/

include <Wire.h>

include "INA219.h"

INA219 monitor;

void setup()
{
Serial.begin(115200);
monitor.begin(64);
// U-Range 0: 16V, 1:32V; I-Gain 2: 160mV, 3: 320mV; Bit/Avr U; Bit/AVR I; D_MODE 7: cont.
monitor.configure(1, 2, 10, 10, 7);

// Shunt[Ohm]; max Shunt [V]; max U [V]; max ecp. I [A]
monitor.calibrate(0.001, 0.160, 30, 130);

}

void loop()
{

Serial.println("******************");

Serial.print("raw shunt voltage: ");
Serial.println(monitor.shuntVoltageRaw());

Serial.print("raw bus voltage: ");
Serial.println(monitor.busVoltageRaw());

Serial.println("--");

Serial.print("shunt voltage: ");
Serial.print(monitor.shuntVoltage() * 1000, 4);
Serial.println(" mV");

Serial.print("shunt current: ");
Serial.print(monitor.shuntCurrent() * 1000, 4);
Serial.println(" mA");

Serial.print("bus voltage: ");
Serial.print(monitor.busVoltage(), 4);
Serial.println(" V");

Serial.print("bus power: ");
Serial.print(monitor.busPower() * 1000, 4);
Serial.println(" mW");

Serial.println(" ");
Serial.println(" ");

delay(1000);

}

@Jim4Beam
Copy link
Author

Any thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant