Expand description
Texas Instruments INA226 high-side or low-side current, voltage, and power monitor.
The INA226 measures the voltage across a shunt resistor and the bus voltage on common-mode voltages from 0 V to 36 V and, once its calibration register is programmed, computes current and power on the chip. It adds programmable conversion times and averaging, and an alert pin driven by a single limit register. This module builds the calibration and configuration values and decodes each register into a physical quantity, following the datasheet’s equations and its worked example, so a battery-balancer or rack-power node reads amps and watts directly.
Shunt voltages are returned in nanovolts, bus voltages in microvolts, and current
and power in microamps and microwatts, so the 2.5 µV and 1.25 mV register LSBs
convert exactly without floating point. f32 conveniences sit beside them.
Modules§
- register
- The INA226 register pointer addresses.
Structs§
- Configuration
- The configuration register (0x00), decoded into its fields.
- DieId
- The die ID register (0xFF), split into its device and revision fields.
- Mask
Enable - The Mask/Enable register (0x06): which alert function drives the pin, how the pin behaves, and the status flags the chip reports back.
Enums§
- Address
Pin - What an address pin is tied to; each of A1 and A0 takes one of four levels.
- Alert
Function - The five limit comparisons the alert pin can be assigned to.
- Averaging
- The number of samples the ADC averages before updating the result registers.
- Conversion
Time - The ADC conversion time for one shunt or bus voltage measurement.
- Mode
- The operating mode: which inputs are converted, and whether once or continuously.
Constants§
- BASE_
ADDRESS - The base I2C address, selected when both address pins are tied to ground.
- BUS_
LSB_ MICROVOLTS - The bus voltage register LSB, 1.25 mV, in microvolts.
- CONFIG_
RESET - The power-on value of the configuration register (0x4127): averaging off, 1.1 ms conversion time for both bus and shunt, and continuous shunt-and-bus conversion.
- DEVICE_
ID - The 12-bit device ID carried in bits 15:4 of the die ID register.
- MANUFACTURER_
ID - The value the manufacturer ID register always reads (0x5449, “TI”).
- POWER_
LSB_ RATIO - The fixed ratio between the power LSB and the programmed current LSB.
- SHUNT_
LSB_ NANOVOLTS - The shunt voltage register LSB, 2.5 µV, in nanovolts.
Functions§
- address
- Returns the 7-bit I2C address selected by the A1 and A0 pins.
- bus_
microvolts - Decodes the bus voltage register to microvolts.
- bus_
register - Builds the bus voltage register a monitor reports for a bus voltage.
- bus_
volts_ f32 - Decodes the bus voltage register to volts as a float.
- calibration
- Computes the calibration register value for a chosen current resolution and shunt.
- current_
amps_ f32 - Decodes the current register to amps as a float.
- current_
microamps - Decodes the current register to microamps for a given current LSB.
- current_
register - Builds the current register a monitor reports for a current.
- current_
register_ from_ shunt - Reproduces the chip’s current calculation from a shunt reading and calibration.
- identify
- Checks that the identification registers belong to an INA226.
- minimum_
current_ lsb_ microamps - Returns the smallest current LSB, in microamps, that still spans a full-scale current.
- power_
microwatts - Decodes the power register to microwatts for a given current LSB.
- power_
register - Builds the power register a monitor reports for a power.
- power_
register_ from_ current - Reproduces the chip’s power calculation from the current and bus registers.
- power_
watts_ f32 - Decodes the power register to watts as a float.
- shunt_
millivolts_ f32 - Decodes the shunt voltage register to millivolts as a float.
- shunt_
nanovolts - Decodes the shunt voltage register to nanovolts.
- shunt_
register - Builds the shunt voltage register a monitor reports for a shunt voltage.