@@ -161,50 +161,66 @@ Helper functions for the micro scale.
161161
162162#### Configuration
163163
164- Note: the conversion time runs in the background and if done value is stored in a register.
165- The core functions read from the registers, so they are not blocked.
166- They return the same value if no new data is available / ready.
164+ ** Note:**
165+ The internal conversions runs in the background in the device.
166+ If a conversion is finished the measured value is stored in the appropriate register.
167+ The last obtained values can always be read from the registers, so they will not block.
168+ Result can be that you get the very same value if no new data is available yet.
169+ This is especially true if you increase the number of samples.
170+ (See also discussion in INA219 issue 11).
171+
172+ Using more samples reduces the noise level, but one will miss the faster
173+ changes in voltage or current.
174+ Depending on your project needs you can choose one over the other.
175+
176+ As a rule of thumb one could take the time between two I2C reads of
177+ a register as an upper limit.
178+ This would result in a fresh measurement every time one reads the register.
179+ NB it is always possible to average readings fetched from the device
180+ in your own code.
181+
167182
168183- ** bool reset()** software power on reset.
169184This implies calibration with ** setMaxCurrentShunt()** needs to be redone.
170185Returns true upon success.
171- - ** bool setAverage(uint8_t avg = 0 )** see table below.
186+ - ** bool setAverage(uint8_t avg = INA226_1_SAMPLE )** see table below.
172187(0 = default ==> 1 read), returns false if parameter > 7.
173188- ** uint8_t getAverage()** returns the value set. See table below.
174189Note this is not the count of samples.
175- - ** bool setBusVoltageConversionTime(uint8_t bvct = 4 )** see table below.
190+ - ** bool setBusVoltageConversionTime(uint8_t bvct = INA226_1100_us )** see table below.
176191(4 = default ==> 1.1 ms), returns false if parameter > 7.
177192- ** uint8_t getBusVoltageConversionTime()** return the value set.
178193Note the value returned is not a unit of time.
179- - ** bool setShuntVoltageConversionTime(uint8_t svct = 4 )** see table below.
194+ - ** bool setShuntVoltageConversionTime(uint8_t svct = INA226_1100_us )** see table below.
180195(4 = default ==> 1.1 ms), returns false if parameter > 7.
181196- ** uint8_t getShuntVoltageConversionTime()** return the value set.
182197Note the value returned is not a unit of time.
183198
184199
185- | Average | # samples | notes |
186- | :-------:| ----------:| --------:|
187- | 0 | 1 | default |
188- | 1 | 4 | |
189- | 2 | 16 | |
190- | 3 | 64 | |
191- | 4 | 128 | |
192- | 5 | 256 | |
193- | 6 | 512 | |
194- | 7 | 1024 | |
200+ | enum description | value | # samples | notes |
201+ | :--------------------:| :-----:| ----------:| --------:|
202+ | INA226_1_SAMPLE | 0 | 1 | default
203+ | INA226_4_SAMPLES | 1 | 4 |
204+ | INA226_16_SAMPLES | 2 | 16 |
205+ | INA226_64_SAMPLES | 3 | 64 |
206+ | INA226_128_SAMPLES | 4 | 128 |
207+ | INA226_256_SAMPLES | 5 | 256 |
208+ | INA226_512_SAMPLES | 6 | 512 |
209+ | INA226_1024_SAMPLES | 7 | 1024 |
210+
195211
196212
213+ | enum description | BVCT SVCT | time | notes |
214+ | :------------------:| :---------:| ----------:| --------:|
215+ | INA226_140_us | 0 | 140 us |
216+ | INA226_204_us | 1 | 204 us |
217+ | INA226_332_us | 2 | 332 us |
218+ | INA226_588_us | 3 | 588 us |
219+ | INA226_1100_us | 4 | 1.1 ms | default
220+ | INA226_2100_us | 5 | 2.1 ms |
221+ | INA226_4200_us | 6 | 4.2 ms |
222+ | INA226_8300_us | 7 | 8.3 ms |
197223
198- | BVCT SVCT | time | notes |
199- | :---------:| ----------:| --------:|
200- | 0 | 140 us |
201- | 1 | 204 us |
202- | 2 | 332 us |
203- | 3 | 588 us |
204- | 4 | 1.1 ms | default |
205- | 5 | 2.1 ms |
206- | 6 | 4.2 ms |
207- | 7 | 8.3 ms |
208224
209225Note: times are typical, check datasheet for operational range.
210226(max is ~ 10% higher)
@@ -249,13 +265,13 @@ See https://github.com/RobTillaart/INA226/pull/29 for details of the discussion.
249265
250266#### Error codes setMaxCurrentShunt
251267
252- | descriptive name error | value | meaning |
253- | :------------------------------| ---------:| :----------|
254- | INA226_ERR_NONE | 0x0000 | OK
255- | INA226_ERR_SHUNTVOLTAGE_HIGH | 0x8000 | maxCurrent \* shunt > 80 mV
256- | INA226_ERR_MAXCURRENT_LOW | 0x8001 | maxCurrent < 0.001
257- | INA226_ERR_SHUNT_LOW | 0x8002 | shunt < 0.001
258- | INA226_ERR_NORMALIZE_FAILED | 0x8003 | not possible to normalize.
268+ | descriptive name error | value | meaning |
269+ | :------------------------------- | ---------:| :----------|
270+ | INA226_ERR_NONE | 0x0000 | OK
271+ | INA226_ERR_SHUNTVOLTAGE_HIGH | 0x8000 | maxCurrent \* shunt > 80 mV
272+ | INA226_ERR_MAXCURRENT_LOW | 0x8001 | maxCurrent < 0.001
273+ | INA226_ERR_SHUNT_LOW | 0x8002 | shunt < 0.001
274+ | INA226_ERR_NORMALIZE_FAILED | 0x8003 | not possible to normalize.
259275
260276
261277#### Operating mode
@@ -293,23 +309,23 @@ Returns true if write to register successful.
293309- ** uint16_t getAlertLimit()** returns the limit set by ** setAlertLimit()** .
294310
295311
296- | description alert register | value | a.k.a. |
297- | :---------------------------| -------:| -------:|
298- | INA226_SHUNT_OVER_VOLTAGE | 0x8000 | SOL |
299- | INA226_SHUNT_UNDER_VOLTAGE | 0x4000 | SUL |
300- | INA226_BUS_OVER_VOLTAGE | 0x2000 | BOL |
301- | INA226_BUS_UNDER_VOLTAGE | 0x1000 | BUL |
302- | INA226_POWER_OVER_LIMIT | 0x0800 | POL |
303- | INA226_CONVERSION_READY | 0x0400 | |
312+ | description alert register | value | a.k.a. |
313+ | :----------------------------- | -- -------:| -------:|
314+ | INA226_SHUNT_OVER_VOLTAGE | 0x8000 | SOL |
315+ | INA226_SHUNT_UNDER_VOLTAGE | 0x4000 | SUL |
316+ | INA226_BUS_OVER_VOLTAGE | 0x2000 | BOL |
317+ | INA226_BUS_UNDER_VOLTAGE | 0x1000 | BUL |
318+ | INA226_POWER_OVER_LIMIT | 0x0800 | POL |
319+ | INA226_CONVERSION_READY | 0x0400 | |
304320
305321
306- | description alert flags | value |
307- | :-------------------------------| -------:|
308- | INA226_ALERT_FUNCTION_FLAG | 0x0010 |
309- | INA226_CONVERSION_READY_FLAG | 0x0008 |
310- | INA226_MATH_OVERFLOW_FLAG | 0x0004 |
311- | INA226_ALERT_POLARITY_FLAG | 0x0002 |
312- | INA226_ALERT_LATCH_ENABLE_FLAG | 0x0001 |
322+ | description alert flags | value |
323+ | :--------------------------------- | -- -------:|
324+ | INA226_ALERT_FUNCTION_FLAG | 0x0010 |
325+ | INA226_CONVERSION_READY_FLAG | 0x0008 |
326+ | INA226_MATH_OVERFLOW_FLAG | 0x0004 |
327+ | INA226_ALERT_POLARITY_FLAG | 0x0002 |
328+ | INA226_ALERT_LATCH_ENABLE_FLAG | 0x0001 |
313329
314330
315331The alert line falls when alert is reached.
0 commit comments