Test

Dependencies:   INA226 mbed

Fork of INA226TEST by Toshihisa T

Files at this revision

API Documentation at this revision

Comitter:
tosihisa
Date:
Sat Nov 24 18:15:23 2012 +0000
Child:
1:a942950ac282
Commit message:
1st;

Changed in this revision

INA226.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/INA226.lib	Sat Nov 24 18:15:23 2012 +0000
@@ -0,0 +1,1 @@
+INA226#3a05c5755625
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Nov 24 18:15:23 2012 +0000
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2011 Toshihisa T
+ * Released under the MIT License: http://mbed.org/license/mit
+ */
+
+#include "mbed.h"
+#include "INA226.hpp"
+
+Serial debug(USBTX,USBRX);
+DigitalOut myled(LED1);
+I2C i2c(p28,p27);
+INA226 VCmonitor(i2c);
+
+int main() {
+    unsigned short val;
+    double V,C;
+    int count = 1;
+
+    debug.format(8,ParityNone,1);
+    debug.baud(115200);
+    debug.printf("VCmonitor INA226 TEST Program. (BUILD:[" __DATE__ "/" __TIME__ "])\n");
+
+    if(!VCmonitor.isExist()){
+        debug.printf("VCmonitor NOT FOUND\n");
+        while(1){}
+    }
+    debug.printf("VCmonitor FOUND\n");
+
+    val = 0;
+    if(VCmonitor.rawRead(0x00,&val) != 0){
+        debug.printf("VCmonitor READ ERROR\n");
+        while(1){}
+    }
+    debug.printf("VCmonitor Reg 0x00 : 0x%04x\n",val);
+
+    VCmonitor.setCurrentCalibration();
+
+    while(1) {
+        if((VCmonitor.getVoltage(&V) == 0) && (VCmonitor.getCurrent(&C) == 0)){
+            debug.printf("%d,V,%f,C,%f\n",count,V,C);
+        }
+        myled = 1;
+        wait(0.5);
+        myled = 0;
+        wait(0.5);
+        count++;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Nov 24 18:15:23 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/3d775a932e1d
\ No newline at end of file