Text Size
Main

This article describe the use of the INA209 Arduino Library to control a Texas Instruments INA209 through I2C BUS communication with Arduino open-source electronics prototyping platform.

INA209 Hardware description

The INA209 is a high-side current shunt and power monitor with an I2C interface. The INA209 monitors both shunt drop and shunt bus voltage. A programmable calibration value, combined with an internal multiplier, enables direct readouts in amperes. An additional multiplying register calculates power in watts. The INA209 features two separate, onboard watchdog capabilities: a warning comparator and an over-limit comparator. The warning comparator is useful for monitoring lower warning limits and incorporates a user-defined delay. The over-limit comparator assists with monitoring upper limits that could require immediate system shutdown.

The INA209 also includes an analog comparator and a programmable digital-to-analog converter (DAC) that combine to provide the fastest possible responses to current overload conditions. The INA209 can be used together with hot swap controllers that already use a current sense resistor. The INA209 full-scale range can be selected to be either within the hot-swap controller sense limits, or wide enough to include them.

The INA209 senses across shunts on buses that can vary from 0V to 26V. The device uses a single +3V to +5.5V supply, drawing a maximum of 1.5mA of supply current. It is specified for operation from –25°C to +85°C.

Features

  • Senses BUS Voltage from 0V to +26V
  • Reports Current, Voltage, Power and stores Peaks
  • Triple Watchdog Limit:
    • Lower Warning with Delay
    • Upper Over-Limit, No Delay
    • Fast Analog Critical
  • High Accuracy: 1% Max Over Temp

Application

Servers, Telecom Equipment, Automotive, Power Management, Battery Chargers, Welding Equipment, Power Supplies, Test Equipment.

Absolute Maximum Ratings

INA209 Absolute Maximum Ratings

(1) Stresses above these ratings may cause permanent damage. Exposure to absolute maximum conditions for extended periods may degrade device reliability. These are stress ratings only, and functional operation of the device at these or any other conditions beyond those specified is not implied.
(2) VIN+ and VIN– may have a differential voltage of –26V to +26V; however, the voltage at these pins must not exceed the range –0.3V to +26V

Electrical Characteristics at Vs=+3.3V

Boldface limits apply over the specified temperature range, TA = –25°C to +85°C.
At TA = +25°C, VIN+ = 12V, VSENSE = (VIN+ – VIN–) = 32mV, PGA = ÷ 1, and BRNG(1) = 1, unless otherwise noted.

INA209 Electrical Characteristics

(1) BRNG is bit 13 of the Configuration Register.
(2) This parameter only expresses the full-scale range of the ADC scaling. In no event should more than 26V be applied to this device.
(3) Referred-to-input (RTI).
(4) User-programmable. See the Critical Comparator and Register sections.
(5) SMBus timeout in the INA209 resets the interface any time SCL or SDA is low for over 28ms.

PIN Configuration

INA209 PIN Configuration

PIN Description

INA209 PIN Configuration

 Tipical Application Circuit

INA209 Tipical Application Circuit

Multichannel Data Acquisition with Simultaneous Sampling

The INA209 can be used in multiple current measurement channels where the controlling processor sums the currents of all the channels for a total current. Often these current measurements must occur simultaneously. Use the GPIO output from one of the INA209s and connect it to the Convert pin of the other INA209s.

INA209 Multichannel Data Acquisition with Simultaneous Sampling

Software Library Description

The INA209 Arduino Library use the Arduino Wire Library for I2C communication. For I2C communication, Arduino works as a Master device and the INA209 works as a Slave device.

The INA209 has two address pins, A0 and A1. Table 1 describes the pin logic levels for each of the 16 possible addresses. First of all you have to set the slave address by connecting A0 and A1 pins as specified in the table below.

INA209 SLAVE ADDRESS

Table1 - Slave Adress

This is the electrical connections, I have used an Arduino UNO and an INA209:

      INA209 PIN 1 (Vin+)    to positive side of 0,1 Ohm shunt resistor
      INA209 PIN 2 (Vin-)    to negative side of 0,1 Ohm shunt resistor
      INA209 PIN 4 (GND)     to power supply ground
      INA209 PIN 5 (Vs+)     to power supply 3V to 5,5V
      INA209 PIN 10 (Vs+)    to power supply 3V to 5,5V
      INA209 PIN 11 (GND)    to power supply ground
      INA209 PIN 12 (SCL)    ANALOG PIN 5 for ARDUINO UNO
      INA209 PIN 13 (SDA)    ANALOG PIN 4 for ARDUINO UNO
      INA209 PIN 14 (A0)     to power supply ground for set slave address to 0x40 (example)
      INA209 PIN 15 (A1)     to power supply ground for set slave address to 0x40 (example)

Download the library files.

Download INA209 Arduino Library Rev.1.0:  INA209_Arduino_Library.rar

For use the INA209 library you have to copy the entire INA209 directory with INA209.h and INA209.cpp files in the Arduino "/libraries" directory.

Now you can start Arduino software (I have used ver. 1.0.1) and create a new sketch.

Add this in your sketch:


// include the library code:
#include         //I2C library
#include

INA209 ina209a(0x40);    // creation of an instance of the INA209 class called ina209a with I2C slave address = 0x40

When you create an istance of the INA209 class you have to set the slave address that you have setted by A0 and A1 pins of INA209 chip.

Start I2C BUS communication and set Arduino as a Master device with Wire.begin(); as follow:


void setup() {
 
  Serial.begin(9600);    //  setup serial
  Wire.begin();         // join i2c bus

Now you have to write the General Configuration Register. You have to see the datasheet.

For example if you want this parameters:

Bus Voltage Range = 32V
PGA (Shunt Voltage Only) = +/- 320mV
BADC Bus ADC Resolution/Averaging = 12bit
SADC Shunt ADC Resolution/Averaging = 12bit
Operating Mode = Shunt and Bus, Continuos

You have to write the decimal value of 14751 = 11100110011111 bin = 399F hex


ina209a.writeCfgReg(14751);       //  Default settings

If you want the current and power direct reading you have to calculate the calibration value and write the Calibration Register (see the datasheet).

For example:
            Vbus_max = 32V
            Vshunt_max = 0,32V
            Rshunt = 0,1 Ohm
       ->  Max Expected Current = +/- 3A
            Current LSB = 100uA
            Calibration Reg = 4096
            Power LSB = 2mW
            Mas Power = 102,4W


ina209a.writeCal(4096);

You can set the warnig limit that trigger flags in the Status Register and activate the Warning pin (see the datasheet).

For example you can set:


ina209a.writeShuntVolPwrn(30000);        // set Shunt Voltage Positive Warning limit to 30000 (= 300mV)
ina209a.writeShuntVolNwrn(-500);         // set Shunt Voltage Negative Warning limit to -500 (= -5mV)
ina209a.writePowerWrn(10000);            // set Power Warning limit
ina209a.writeBusOVwrn(52000);            // set Bus Over-Voltage Warning limit, if you want a limit of 26V you have to set 26000*2 = 52000    
ina209a.writeBusUVwrn(10000);            // set Bus Under-Voltage Warning limit, if you want a limit of 5V you have to set 5000*2 = 10000

You can set the over-limit and critical DAC limits that trigger flags to be set in the Status Register and activate the Overlimit pin or the Critical pin (see the datasheet).


ina209a.writePowerOL(12000);             // set Power Over-Limit
ina209a.writeBusOVOL(60000);             // set Bus Over-Voltage Over-Limit, if you want a limit of 30V you have to set 30000*2 = 60000 (see the datasheet for other functions)
ina209a.writeBusUVOL(6000);              // set Bus Under-Voltage Over-Limit, if you want a limit of 3V you have to set 3000*2 = 6000
ina209a.writeCrShuntPV(51200);           // set Critical DAC+ Register (Critical Shunt Positive Voltage). No sign bit (sets a positive limit only). At full-scale range = 255mV; LSB = 1mV; 8-bit.
                                           // if you want a limit of +200mV you have to set 200*256 = 51200;
                                           // this register control GPIO PIN, see the datasheet.
ina209a.writeCrShuntNV(51200);           // set Critical DAC– Register (Critical Shunt Negative Voltage). No sign bit (sets negative limit only). At full-scale range = –255mV; LSB = 1mV; 8-bit.
                                           // if you want a limit of -200mV you have to set 200*256 = 51200;
                                           // this register control DAC Comparator output filter, see the datasheet.
 
}

Now you can read all the INA209 registers and see the values:


void loop() {

  // ----------------------- CONFIG AND STATUS REGISTERS ----------------------------------
  Serial.println(" Configuration Register ");
  Serial.println(ina209a.readCfgReg());
  Serial.println(" Status Register ");
  Serial.println(ina209a.statusReg());
  Serial.println(" SMBus Alert ");
  Serial.println(ina209a.readSMBusCtrlReg());
 
  // ----------------------- DATA OUTPUT REGISTERS ----------------------------------------
  Serial.println(" Bus Voltage ");
  Serial.println(ina209a.busVol());            // returns integer value Bus Voltage measurement in mV (Bus Voltage LSB=4mV)
  Serial.println(" Shunt Voltage ");
  Serial.println(ina209a.shuntVol());          // returns integer value Shunt Voltage measurement data with LSB=10uV
  Serial.println(" Current ");
  Serial.println(ina209a.current());          // returns integer value of the Current flowing through the shunt resistor with LSB=100uA (= ShuntVoltage * CalReg / 4096)
  Serial.println(" Power ");
  Serial.println(ina209a.power() << 1);       // returns integer value Power measurement in mW (in this example = register value * Power LSB=2mW)
 
  // ----------------------- PEAK-HOLD REGISTERS -----------------------------------------
  // Note: All peak-hold registers are cleared and reset to POR values by writing a '1' into the respective D0 bits.  
  ina209a.writeShuntVolPpk(0x01);            // clear Shunt Voltage Positive Peak Register
  ina209a.writeShuntVolNpk(0x01);
  ina209a.writeBusVolMaxPk(0x01);
  ina209a.writeBusVolMinPk(0x01);
  ina209a.writePowerPk(0x01);
  Serial.println(" Shunt Voltage Positive Peak  ");
  Serial.println(ina209a.readShuntVolPpk());            // mirrors highest voltage reading of the Shunt Voltage Register
  Serial.println(" Shunt Voltage Negative Peak ");
  Serial.println(ina209a.readShuntVolNpk());
  Serial.println(" Bus Voltage Maximum Peak  ");
  Serial.println(ina209a.readBusVolMaxPk());
  Serial.println(" Bus Voltage Minimum Peak  ");
  Serial.println(ina209a.readBusVolMinPk());
  Serial.println(" Power Peak ");
  Serial.println(ina209a.readPowerPk());      // returns integer value Power Peak in mW (in this example = register value * Power LSB=2mW)
 
  // ----------------------- WARNING WATCHDOG REGISTERS ----------------------------------
  // These registers set warning limits that trigger flags in the Status Register and activate the Warning pin.
  Serial.println(" Shunt Voltage Positive Warning ");
  Serial.println(ina209a.readShuntVolPwrn());
  Serial.println(" Shunt Voltage Negative Warning ");
  Serial.println(ina209a.readShuntVolNwrn());
  Serial.println(" Power Warning ");
  Serial.println(ina209a.readPowerWrn());
  Serial.println(" Bus Over-Voltage Warning ");
  Serial.println(ina209a.readBusOVwrn());
  Serial.println(" Bus Under-Voltage Warning ");
  Serial.println(ina209a.readBusUVwrn());
 
  // ----------------------- OVER-LIMIT/CRITICAL WATCHDOG REGISTERS ----------------------
  // These registers set the over-limit and critical DAC limits that trigger flags to be set in the Status Register and
  // activate the Overlimit pin or the Critical pin.
  Serial.println(" Power Over-Limit ");
  Serial.println(ina209a.readPowerOL());
  Serial.println(" Bus Over-Voltage Over-Limit ");
  Serial.println(ina209a.readBusOVOL());
  Serial.println(" Bus Under-Voltage Over-Limit ");
  Serial.println(ina209a.readBusUVOL());
  Serial.println(" Critical Shunt Positive Voltage ");
  Serial.println(ina209a.readCrShuntPV());
  Serial.println(" Critical Shunt Negative Voltage ");
  Serial.println(ina209a.readCrShuntNV());
   
}

 

Bibliography

Texas Instruments INA209 Datasheet - High-Side Measurement, Bi-Directional Current/Power Monitor with I2C Interface (Rev. B)  (PDF , 1491 KB)   27 Mar 2009 - http://www.ti.com/lit/ds/symlink/ina209.pdf - Some information, material and related graphics ("Materials") available on this pageare provided by Texas Instruments Incorporated web site. This Materials are only for informational use.

Category: Arduino
Bottom