This demo will read the Voltage and Current from the "AttoPilot Voltage and Current Sense Board," convert the raw ADC data to Volts and Amps and display them as floating point numbers on the Serial Enabled LCD. (If you would like to do without the Serial LCD, I have included commented code for reading the results through the Serial Terminal.)

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
gert_lauritsen
Date:
Wed Feb 17 22:09:53 2016 +0000
Commit message:
; This demo will read the Voltage and Current from the "AttoPilot Voltage and Current Sense Board,"; convert the raw ADC data to Volts and Amps and display them as floating point numbers on the; Serial Enabled LCD. (If you would like to do without the S

Changed in this revision

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 40a765d1b46b main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Feb 17 22:09:53 2016 +0000
@@ -0,0 +1,30 @@
+#include "mbed.h"
+
+RawSerial pc(USBTX, USBRX);
+AnalogIn   Ain1(p19);// --- AttoPilot "V"
+AnalogIn   Ain2(p20);// --- AttoPilot "I"
+
+int VRaw; //This will store our raw ADC data
+int IRaw;
+float VFinal; //This will store the converted data
+float IFinal;
+
+int main()
+{
+    while(1) {
+        VRaw = Ain1.read_u16();
+        IRaw = Ain2.read_u16();
+
+        //Conversion
+        VFinal = VRaw/49.44; //45 Amp board
+        //VFinal = VRaw/12.99; //90 Amp board
+        //VFinal = VRaw/12.99; //180 Amp board
+
+        IFinal = IRaw/14.9; //45 Amp board
+        //IFinal = IRaw/7.4; //90 Amp board
+        //IFinal = IRaw/3.7; //180 Amp board
+        pc.printf("%.1   Volts\r\n",VFinal);
+        pc.printf("%.1f   Amps\r\n\r\n\r\n",IFinal);
+        wait(0.2);
+    }
+}
diff -r 000000000000 -r 40a765d1b46b mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Feb 17 22:09:53 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/252557024ec3
\ No newline at end of file