電流電圧センサINA226のライブラリ

Dependents:   Hybrid_IZU2021_MAIN_OS5 Hybrid_IZU2021_MAIN

Files at this revision

API Documentation at this revision

Comitter:
tanahashi
Date:
Mon Mar 08 16:48:44 2021 +0000
Parent:
0:4c315fe513d0
Commit message:
fixed LSB

Changed in this revision

PQ_INA226.cpp Show annotated file Show diff for this revision Revisions of this file
PQ_INA226.h Show annotated file Show diff for this revision Revisions of this file
--- a/PQ_INA226.cpp	Tue Dec 15 15:37:10 2020 +0000
+++ b/PQ_INA226.cpp	Mon Mar 08 16:48:44 2021 +0000
@@ -45,7 +45,7 @@
     cmd[0] = INA226_CURRENT;
     _i2c->write(_addr, cmd, 1);
     _i2c->read(_addr, buff, 2);
-    *current = (short)(buff[0] << 8 | buff[1]);
+    *current = (short)(buff[0] << 8 | buff[1]) * INA226_CURRENT_LSB;
 }
 
 void INA226::read_power(float *power)
--- a/PQ_INA226.h	Tue Dec 15 15:37:10 2020 +0000
+++ b/PQ_INA226.h	Mon Mar 08 16:48:44 2021 +0000
@@ -7,9 +7,10 @@
 #define INA226_CALIBRATION 0x05
 #define INA226_WHO_AM_I 0xFF
 #define INA226_VOLTAGE_LSB 1.25
+#define INA226_CURRENT_LSB 1.25
 #define INA226_POWER_LSB 25
 
-/** 電圧電流センサINA226のライブラリ
+/** 電圧電流センサINA226のライブラリ(シャント抵抗0.002Ω)
  * @code
 #include "mbed.h"
 #include "PQ_INA226.h"