Wayne Taylor / Mbed 2 deprecated INA260_Test

Dependencies:   INA260 mbed

Files at this revision

API Documentation at this revision

Comitter:
Waynan
Date:
Sun Dec 10 15:10:36 2017 +0000
Commit message:
INA260 test app

Changed in this revision

INA260.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
diff -r 000000000000 -r 4b5308027f1e INA260.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/INA260.lib	Sun Dec 10 15:10:36 2017 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/Waynan/code/INA260/#a1b8d2c9420d
diff -r 000000000000 -r 4b5308027f1e main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Dec 10 15:10:36 2017 +0000
@@ -0,0 +1,44 @@
+/* INA260 test app*/
+
+#include "mbed.h"
+#include "INA260.hpp"
+
+// Host PC Communication channels
+Serial pc(USBTX, USBRX); // tx, rx
+//i2c setup
+I2C i2c(PB_9,PB_8);
+INA260 VCmonitor(i2c); 
+DigitalIn ALT(PA_8); //Alert pin
+DigitalIn button(PC_13); //button
+int main() { 
+
+    double V,C,P;
+    int count = 1;  
+    // Sets 4 samples average and sampling time for voltage and current to 8.244ms
+    VCmonitor.setConfig(0x0600 | 0x01C0 | 0x0038 | 0x0007); //INA260_CONFIG_AVGRANGE_64|INA260_CONFIG_BVOLTAGETIME_8244US|INA260_CONFIG_SCURRENTTIME_8244US|INA260_CONFIG_MODE_SANDBVOLT_CONTINUOUS
+    pc.printf("INA260 TEST!\n");
+    pc.printf(""__DATE__" , "__TIME__"\n");
+    pc.printf("%d Config register\n",0x0600 | 0x01C0 | 0x0038 | 0x0007); //prints the COnfig reg value to PC COM port
+    VCmonitor.setAlert(0x8001); //set current value as alert, latch alert pin
+    VCmonitor.setLim(0x8); //set limit to 10mA (10/1.25)
+
+    wait_ms(3000);
+while(1)
+{
+         //get ina260 settings
+         if((VCmonitor.getVoltage(&V) == 0) && (VCmonitor.getCurrent(&C) == 0) && (VCmonitor.getPower(&P) == 0))
+         {
+         pc.printf("%d,V,%f,C,%f,P,%f\n",count,V,C,P);
+         }
+         count++;
+         if(ALT==0)
+         {
+         pc.printf("Overcurrent!!!!");             
+         }
+         if (button == 0)
+         {
+             VCmonitor.readAlert(); //read Alert register to clear latched alert
+         }
+         wait_ms(1000);
+}   
+}
\ No newline at end of file
diff -r 000000000000 -r 4b5308027f1e mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Dec 10 15:10:36 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e7ca05fa8600
\ No newline at end of file