## Joule Thief #021 - INA219 Datasheet Annotation [[!Joule Thief]] **Contents:** - [[#INA219 Annotated Datasheet]] - [[#INA219 Datasheet Annotation]] - [[#Larry's Pop Quiz]] --- ### INA219 Annotated Datasheet ![[INA219.pdf]] ### INA219 Datasheet Annotation #### Some Terms SMBUS - System Management Bus - Derived from I2C - Designed for low-bandwidth, low-speed embeddeds, system monitoring, smart batteries - SDA, SDL, 7-bit addressing, up to 100kHz - Stricter than I2C with voltage levels, speed, messaging protocols - More robust for high reliability applications PGA - Programmable Gain Amplifier - Represents the different gain settings the PGA has, for measuring shunt voltage/currents with different levels of precision. Lower ranges provide finer resolution, but limit the maximum current that can be accurately measured without saturation. BRNG - Bus Voltage Range - Can be 16V or 32V, but this parameter only expresses the full-scale range of the ADC. - The max input voltage is still 26V RTI - Referred to Input - Voltage Offset can be given as RTI or RTO - RTO = RTI x Gain m% - Millipercent (0.001% = 0.00001) ![[Pasted image 20250227065021.png]] #### Note on Bias Current vs. Input Impedance [[4 - Mist/!PRIVATE/Haze 1/2-Other/Input Impedance, DC vs. AC Parameters]] DC: 20uA Bias Current AC: 320kΩ Load Impedance ![[Pasted image 20250227082250.png]] #### ADC Resolution ![[Pasted image 20250227083454.png]] This checks out: Shunt Voltage: 40mV / 2^12 = 9.76uV Bus Voltage: 16V / 2^12 = 3.91mV #### Power Supply - 3-5.5V - 1mA max Iq - 15uA max low power mode #### Feature Descriptions *There are no special considerations for power-supply sequencing (for example, a bus voltage can be present with the supply voltage off, and vice-versa* Shunt Voltage: Measured across the input terminals Bus Voltage: Measured from `IN-` to `GND` *The Mode control in the Configuration register also permits selecting modes to convert only voltage or current, either continuously or in response to an event (triggered).* #### TPS249x - Positive High-Voltage Power-Limiting Hot Swap Controller Basically a fault detection and inrush manager for hot-swapping load modules safely to ensure uptime. Can be used in tandem with the INA219 to produce a robust Monitoring & Protection scheme. [[TPS2490.pdf]] #### Device Functional Modes The INA219 offers several options for filtering by choosing resolution and averaging in the Configuration register. These filtering options can be set independently for either voltage or current measurement. *It must be remembered that removing a short to ground can result in inductive kickbacks that could exceed the 26V differential and common-mode rating of the INA219. Inductive kickback voltages are best dealt with by zener-type transient-absorbing devices combined with sufficient energy storage capacitance.* An inductive kickback from removing a short in a circuit with insufficient energy storage electrolytics on either side of the shunt may cause enough dV/dt to activate the INA219's ESD protection circuitry. #### Programming the INA219 The device measures both the differential voltage applied between the `IN+` and `IN-` pins, and the voltage at the `IN-` pin. The user must program the resolution of the Current Register (`Current_LSB`) and the shunt resistor value. The highest resolution for the Current Register can be obtained by using the smallest allowable `Current_LSB` based on the maximum expected current: ![[Pasted image 20250227110127.png]] This method will produce the highest possible resolution, but it's common to round the selected `Current_LSB` value to the nearest round number to simplify future conversions. ![[Pasted image 20250227110416.png]] **Shunt Voltage** is calculated by multiplying the `Shunt Voltage Register`'s contents with the `Shunt Voltage LSB` of 10uV. >Unsure how to describe these **Calibration Register** - in equation 1 **Power_LSB** - 20 x `Current_LSB` The Calibration Register (Equation 1) is used to calculate the **Current Register**. ![[Pasted image 20250227110820.png]] To obtain a value in amperes, the Current register value is multiplied by the programmed `Current_LSB`. The Power Register uses the Current Register and Bus Voltage Register. ![[Pasted image 20250227111017.png]] To obtain a value in watts, the Power Register is multiplied by the `Power_LSB`, which is equal to `20 x Current_LSB`. #### Calibration Register and Scaling The **Calibration Register** can be used to scale the Current Register (and subsequently, the Power Register) to the most useful value for a given application. *The purpose is to set the Calibration Register such that the largest possible number is generated within the Current Register at the expected full-scale point.* After determining the exact current by using an external ammeter, the value of the Calibration Register can then be adjusted based on the measured current result of the INA219 to cancel the total system error (Equation 6). ![[Pasted image 20250227131719.png]] #### Default Programming The INA219 can be used without any programming if it is only necessary to read a shunt voltage drop and bus voltage with the default 12-bit resolution, 320mV shunt full-scale range (PGA = /8), 32V bus full-scale range, and continuous conversion of shunt and bus voltage. *Without programming, current is measured by reading the shunt voltage. The Current register and Power register are only available if the Calibration register contains a programmed value.* #### INA219 Address Pins and Slave Addresses ![[Pasted image 20250227133514.png]] The INA219 only has two address pins, but they have 4 possible states: 1. GND 2. VS+ 3. SDA 4. SCL I've never seen something like that before, so it's pretty cool. The SDA and SCL pins feature integrated spike suppression filters and Schmitt triggers to minimize the effects of input spikes and bus noise. #### Read/Write with the INA219 Access a register by writing the appropriate value to the Register Pointer. **Write Operation:** Slave Address Byte (Write) -> Register Pointer Byte -> Payload MSB -> Payload LSB **Read Operation:** Slave Address Byte (Read) -> Payload MSB -> Payload LSB **Change Read Address:** Slave Address Byte (Write) -> Register Pointer Byte *If repeated reads from the same register are desired, it is not necessary to continually send the register pointer bytes - the INA219 retains the register pointer value until it is changed by the next write operation.* *Recall that the Bus Voltage register bits are not right-aligned. In order to compute the value of the Bus Voltage, the contents of the Bus Voltage Register must be shifted right by three bits.* #### Register Maps The INA219 register bank contains: - Configuration Settings - Measurement Results - Maximum/Minimum Limits - Status Information *Register contents are updated 4us after a WRITE is completed. When working at speeds >1MHz, a delay is required before a subsequent READ of the same register. * ![[Pasted image 20250227135739.png]] Calibration and Configuration are **Read-Write** Shunt Voltage, Bus Voltage, Current, and Power are all **Read-Only** Again, the calibration register must be programmed on each startup in order to use the Current and Power registers. All of the INA219's 16-bit registers are two 8-bit bytes through I2C. #### Configuration Register ![[Pasted image 20250227140152.png]] Note the default/reset value of the Configuration Register: 00111001 10011111 (0x399F) ##### Configuration Register Bit Descriptions ![[Pasted image 20250227140434.png]] ![[Pasted image 20250227140624.png]] ![[Pasted image 20250227140635.png]] ##### ADC There are only four resolution options (9, 10, 11, 12-bit), so the least two bits select the resolution, while the most two bits determine whether the ADC **Resolution Mode:** Good for fast measurements with moderately precise readings. **Averaging/Sampling Mode:** Ideal for smooth, stable readings of static conditions where noise reduction is critical. Really what's going on here is the ADC can measure more precisely by using more bits, at the cost going slower. After all the bits are being used though, the next best thing it can do is take more maximally precise measurements and average them. So the ADC settings table has 4 bits that represent a progressive increase in measurement fidelity at the expense of taking progressively longer to produce each measurement. #### Shunt Voltage Register (01h) The Shunt Voltage Register is another 16-bit / 2-byte register. The MSB is the sign bit. The PGA setting determines whether the ADC reading is (9,10,11,12-bit). The Shunt Voltage Reading is stored as a whole number multiple of the LSB of 10uV. 2^12 = 4096 The INA219 has 12-bit resolution, but only in the ±40mV range. 40mV / 4096 = 9.76uV step size The LSB is 10uV. So 4096 x 10uV is 40.96, or closer to 41mV really. In this case, I think it's appropriate to take the 10uV as exact, and the ±40mV spec as a rough approximate. Then, the ADC can expand into ±80mV territory, but loses one bit of resolution. In the 11-bit mode, the LSB is thus 80mV / 2048 = 40uV So we can extrapolate here and make the table, just to really spell it out. | ADC Resolution (n) | Number of Levels (2^n) | Full Scale | LSB Formula | LSB Value | | ------------------ | ---------------------- | ---------- | ------------ | --------- | | 9 bits | 512 | ±320mV | 320mV / 512 | 320uV | | 10 bits | 1024 | ±160mV | 160mV / 1024 | 160uV | | 11 bits | 2048 | ±80mV | 80mV / 2048 | 40uV | | 12 bits | 4096 | ±40mV | 40mV / 4096 | 10uV | The reason the LSB goes up by 4x for each bit is because the Full Scale doubles at the same time that the Number of Levels halves. And then as the ADC resolution decreases, those extra bits are made into clones of the MSB Sign Bit. ##### Shunt Voltage Register Format ![[Pasted image 20250227203923.png]] #### Bus Voltage Register ![[Pasted image 20250227205525.png]] I don't think I can make this any simpler than it already is. Worth noting there's no resolution or LSB change between 16V and 32V mode. The ceiling just changes. #### Power Register Read only. Full scale range and LSB are set through the Calibration Register. Recall Equation 5: ![[Pasted image 20250227205850.png]] #### Current Register Read only. Full scale range and LSB are set through the Calibration Register. Recall Equation 4: ![[Pasted image 20250227110820.png]] #### Calibration Register ![[Pasted image 20250227210028.png]] Current and power calibration are set by bits `FS15` to `FS1`. This register sets the current that corresponds to a full-scale drop across the shunt. Note that this register defaults to 0. Recall Equation 1 for setting the Calibration Register: ![[Pasted image 20250227210711.png]] #### Typical Application The example conditions are: - Max Load Current = 15A - Nominal Load Current = 10A - V_CM = 12V - R_shunt = 2mΩ - FSR = 40mV (PGA =/1) - BRNG = 0 (VBUS Range 0-16V) So we have a 10A load going through a 2mΩ resistor, where the `VIN-` terminal sits at 12V. Thus we have a 20mV drop across the shunt. Using Equation 2, we can calculate an appropriate `Current_LSB` for this application: Current_LSB = 15A / 2^15 = 457.78uA/bit We can round it up to 1mA/bit to make our lives easier when we convert this. Now that we have defined `Current_LSB = 1mA`, we can figure out what to program the Calibration Register with using Equation 1. Equation 1 yields Cal = 0.04096 / (0.001A * 0.002Ω) = 20480. Converting this 20480 number into hex and binary, we get `5000h` or `0101 0000 0000 0000 b`. This is the value we WRITE into the Calibration Register. For measuring the 12V Bus Voltage, we can check the Bus Voltage Register. But first, that register's bits are not right-aligned, so they must be shifted right 3 bits, and then the shifted value can be multiplied by the bus voltage register's fixed 4mV LSB to get the final voltage reading. The current is automatically calculated and loaded into the Current Register. In this case a value of 10000 (2710h), which corresponds to 10000 x 1mA/bit = 10A. The Power Register will yield 5990 (1766h). The Power LSB is 20 x `Current_LSB`, or 20mW. So a value of 5990 x 20mW means the power register provides a 119.8W reading. ##### Example - Register Results ![[Pasted image 20250227212026.png]] #### Layout Guidelines Connect the input pins IN+ and IN- to the sensing resistor using a Kelvin connection or 4-wire connection. These connection techniques ensure that only the current-sensing resistor impedance is detected between the input pins. ![[Pasted image 20250227212208.png]] ### Larry's Pop Quiz #### 1-1. What's the sampling frequency of the device? Delta-sigma frontend at 500kHz (±30%) Transients that occur at or very close to the sampling rate's harmonics can cause problems (1Mhz and above). These can be filtered with some RC filtering at the input. ![[Pasted image 20250228082644.png]] #### 1-2. What is the maximum frequency of signal that can theoretically be measured? Since the sampling rate is listed at 500kHz, so my first thought is the Nyquist rate at half that (250kHz), but there's also a Conversion Time table that indicates it resolves the final data points much slower (84us -> 12kHz). So I'd say 6kHz is the upper limit before distortion/aliasing. ![[Pasted image 20250228083456.png]] #### 2. Would you use this device to measure a signal of 5-50kHz if you didn't know what the frequency content was? Seems unwise #### 3. How should the traces be connected to the shunt resistor? (draw footprint for a SMD shunt). Why? What would happen if it were not connected this way? It recommends a kelvin/4wire connection to ensure the shunt resistor is the only impedance being measured. Otherwise you get additional trace/lead resistance in the measurement that skews it. ![[Pasted image 20250228084627.png]]