INA monitors/What the chip does with it/05. Two numbers and a product
What the chip does with it · 05 of 11

Two numbers and a product

A library hands you four numbers and only two of them were measured. Current is a division by a resistance you told the chip about, and power is a multiplication — which is why a wrong shunt value leaves the voltage perfect and the current out by exactly the size of the mistake.

Which numbers are real

Two measurements, two sums
ready
Conversion, 12-bit
532 µs
Shunt, one count
10 µV
Bus, one count
4 mV
Press the button. Watch which of the four numbers the chip actually measures.

Press the button and watch the order. The converter takes two measurements: the shunt voltage, which is the difference between the two ends of the resistor, and the bus voltage, which is the load side of the resistor measured down to the chip's own ground.

Then it does two sums. Current is the shunt voltage divided by a resistance. Power is the current times the bus voltage.

The resistance is a number you supply

The chip has no idea what resistor is fitted. It is told, once, by a value written into its calibration register, or kept in your sketch — which is what a line like ina219.setCalibration_32V_2A() or a SHUNT_OHMS = 0.05 is doing. On this set the two numbers are different: 0.1 for the TK119 and 0.05 for the INA3221.

That is the whole explanation for the commonest complaint about these parts. Get the resistance wrong and:

  • the shunt voltage stays correct, because it was measured;
  • the bus voltage stays correct, for the same reason;
  • the current is wrong by exactly the ratio of the mistake;
  • and the power is wrong by the same ratio, because it was built on the current.

So the diagnostic is quick. If the voltage agrees with a meter and the current does not, stop looking at the wiring.

The bus voltage is the load's, not the supply's

Worth saying plainly because it surprises people: the chip measures the bus voltage at IN−, the load side of the shunt. At 1 A that is 100 millivolts below what the supply is producing on the TK119, and 50 on the INA3221.

That is the more useful of the two. What a load is actually receiving is the number that explains why a motor is slow or a regulator is dropping out. If you want the supply's own voltage instead, add the shunt voltage back on — the chip gives you both.

The INA219's extra register

The INA219 keeps a power register and updates it every conversion, so watts arrive with no arithmetic on your side. It also means the multiplication happens on two values taken at the same instant, which a sketch reading current and voltage in two separate calls cannot promise.

The INA3221 has no power register at all. Read its bus voltage and its shunt voltage for a channel, multiply, and you have the same thing to the same accuracy — one line, and the reason the set has two chips in it rather than three of one.

Conversion time, and what averaging costs

One 12-bit conversion on the INA219 takes about 532 microseconds. The INA3221's eight settings run from 140 microseconds to 8.2 milliseconds, and it can average up to 1024 of them.

A fast reading catches a spike and reports a lot of noise. A slow, averaged one reports a steady number and misses the spike entirely. Which you want depends on whether you are looking for a motor's stall current or a board's idle draw, and it is one register either way.

When it does not work

The current is exactly half, or exactly double, what it should be

A factor of exactly two is the shunt value in your sketch rather than the hardware, and this set makes it easy to get: the TK119 has 0.1 Ω and the INA3221 has 0.05 Ω. Leave an INA3221 sketch at 0.1 Ω and every current reads half; put 0.05 Ω into a TK119 sketch and it reads double. Check the bus voltage against a meter: if the voltage agrees and the current does not, it is arithmetic every time.

The voltage is lower than my supply says

It should be. The bus voltage is measured on the load side of the shunt, so it is the supply minus whatever the shunt is dropping — 100 mV at 1 A on the TK119, 50 mV on the INA3221. That is the honest number: it is what the load is actually getting. If the difference is far larger than the current × the shunt, look for a loose screw or a thin wire, not a faulty board.

The power reading on the INA3221 is always zero

It has no power register. The INA219 computes watts in hardware and a library reads them straight out; the INA3221 gives you a bus voltage and a shunt voltage per channel and nothing else. Multiply the two yourself — one line, and exactly as accurate as the chip's own would be.

The numbers jump around on a load that is not changing

Each reading is one conversion of about half a millisecond on the INA219, which sees whatever the load was doing in that instant. Switching supplies and PWM make that instant unrepresentative. The INA219 can average up to 128 samples and the INA3221 up to 1024 — turn averaging up and the jitter goes, at the cost of a slower reading.

Edit this page — content/books/inaset/two-numbers-and-a-product.mdx

Community

Questions about this product

See what other owners have asked, and read their solutions.

This page covers several products. Choose yours to see the right discussions.

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse Modules and blocks on the forum