0.4.3 INA226

This commit is contained in:
Rob Tillaart 2023-05-24 12:54:25 +02:00
parent d524d01876
commit 8aba6bb95d
8 changed files with 40 additions and 10 deletions

View File

@ -6,8 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [0.4.2] - 2023-04-03
## [0.4.3] - 2023-05-07
- add constant INA226_MINIMAL_SHUNT
## [0.4.2] - 2023-04-03
- added **getBusVoltage_uV()** for completeness
- INA226_test_I2C.ino to prep performance tests
- fix changelog.md
@ -17,7 +20,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- update license 2023
- minor edits
## [0.4.1] - 2022-11-12
- Add RP2040 support to build-CI.
- Add CHANGELOG.md, replaces release_notes to be consistent over my libraries.

View File

@ -1,6 +1,6 @@
// FILE: INA226.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.4.2
// VERSION: 0.4.3
// DATE: 2021-05-18
// PURPOSE: Arduino library for INA226 power sensor
// URL: https://github.com/RobTillaart/INA226
@ -195,9 +195,9 @@ int INA226::setMaxCurrentShunt(float maxCurrent, float shunt, bool normalize)
// fix #16 - datasheet 6.5 Electrical Characteristics
// rounded value to 80 mV
float shuntVoltage = abs(maxCurrent * shunt);
if (shuntVoltage > 0.080) return INA226_ERR_SHUNTVOLTAGE_HIGH;
if (maxCurrent < 0.001) return INA226_ERR_MAXCURRENT_LOW;
if (shunt < 0.001) return INA226_ERR_SHUNT_LOW;
if (shuntVoltage > 0.080) return INA226_ERR_SHUNTVOLTAGE_HIGH;
if (maxCurrent < 0.001) return INA226_ERR_MAXCURRENT_LOW;
if (shunt < INA226_MINIMAL_SHUNT) return INA226_ERR_SHUNT_LOW;
_current_LSB = maxCurrent * 3.0517578125e-5; // maxCurrent / 32768;

View File

@ -1,7 +1,7 @@
#pragma once
// FILE: INA226.h
// AUTHOR: Rob Tillaart
// VERSION: 0.4.2
// VERSION: 0.4.3
// DATE: 2021-05-18
// PURPOSE: Arduino library for INA226 power sensor
// URL: https://github.com/RobTillaart/INA226
@ -14,7 +14,7 @@
#include "Wire.h"
#define INA226_LIB_VERSION (F("0.4.2"))
#define INA226_LIB_VERSION (F("0.4.3"))
// set by setAlertRegister
@ -39,6 +39,9 @@
#define INA226_ERR_SHUNT_LOW 0x8002
// See issue #26
#define INA226_MINIMAL_SHUNT (0.001)
class INA226
{

View File

@ -287,6 +287,26 @@ The alert line falls when alert is reached.
- **uint16_t getRegister(uint8_t reg)** fetch registers directly, for debugging only.
## Adjusting the range of the INA226
**use at own risk**
In issue #26 a hack is made to scale the INA226 to 300A by using a very small shunt.
The library has a minimal limit for the shunt of 0.001 ohm.
This limit can be overruled to support other ranges like the one discussed in #26.
Overruling can be done by patching the following value in the INA226.h file.
```cpp
#define INA226_MINIMAL_SHUNT (0.001)
```
Be aware that
- **you should NOT do this unless you understand the implications**.
- you do this at your own risk.
- the resistance of wires used affect measurements with very small shunts.
- solder might change the resistance too.
- you do this at your own risk.
## Operational
See examples..

View File

@ -82,3 +82,6 @@ INA226_ERR_SHUNTVOLTAGE_HIGH LITERAL1
INA226_ERR_MAXCURRENT_LOW LITERAL1
INA226_ERR_SHUNT_LOW LITERAL1
INA226_MINIMAL_SHUNT LITERAL1

View File

@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/INA226.git"
},
"version": "0.4.2",
"version": "0.4.3",
"license": "MIT",
"frameworks": "arduino",
"platforms": "*",

View File

@ -1,5 +1,5 @@
name=INA226
version=0.4.2
version=0.4.3
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for INA226 power sensor

View File

@ -78,6 +78,8 @@ unittest(test_constants)
assertEqual(0x8000, INA226_ERR_SHUNTVOLTAGE_HIGH);
assertEqual(0x8001, INA226_ERR_MAXCURRENT_LOW);
assertEqual(0x8002, INA226_ERR_SHUNT_LOW);
assertEqualFloat(0.001, INA226_MINIMAL_SHUNT, 0.0001);
}