Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 4:15402b7eddf7, committed 2020-08-21
- Comitter:
- MPPT51
- Date:
- Fri Aug 21 08:28:43 2020 +0000
- Parent:
- 3:a122073b93e2
- Commit message:
- 20200821_motacon_ver4
Changed in this revision
| INA226.cpp | Show annotated file Show diff for this revision Revisions of this file |
| INA226.hpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/INA226.cpp Mon Aug 03 03:20:17 2020 +0000
+++ b/INA226.cpp Fri Aug 21 08:28:43 2020 +0000
@@ -81,5 +81,11 @@
int INA226::setCurrentCalibration(unsigned short val)
{
- return rawWrite(0x05,val);
+ return rawWrite(0x05,val); //datasheet(p.21)より0x05はCalibrationResisterへの書き込みを指定している
}
+int INA226::setConfigResister(unsigned short config)
+{
+ return rawWrite(0x00,config); //0x00でINA226のConfigResisterに書き込める(datasheet p.21)
+ //configの値はINA226.hで設定している。configの値を変更することで変換時間と平均回数などを変更できる。
+ //変換時間、値の平均回数が大きいほどノイズの影響を受けづらいが、データ取得時間が長くなる。実装システムに合わせて調整。
+}
--- a/INA226.hpp Mon Aug 03 03:20:17 2020 +0000
+++ b/INA226.hpp Fri Aug 21 08:28:43 2020 +0000
@@ -23,7 +23,7 @@
* @param addr_ I2C slave address.
* @param freq_ I2C frequency.
*/
- INA226(I2C &i2c_,int addr_ = 0x94,int freq_ = 100000);
+ INA226(I2C &i2c_,int addr_ = 0x9E,int freq_ = 100000); //GNDGND(G-G):0x80, Vs+Vs+(1-1):0x8A, SDASDA(D-D):0x94, SCLSCL(C-C):0x9E, GNDVs+(G-1):0x82
/**
* Check INA226 exist.
*
@@ -67,8 +67,9 @@
* @param val write value;
* @return 0:Read OK / !0:Read NG
*/
- int setCurrentCalibration(unsigned short val = 0x0A00);
-
+ int setCurrentCalibration(unsigned short val = 0x1AAA); //2mohmの場合0x0A00, 0.75mohmの場合0x1AAA
+ int setConfigResister(unsigned short config = 0x456F); //0x456F=>0b 0100 010 101 101 111(datasheet pp21-23確認)
+
private:
I2C &i2c;
int i2c_addr;