Gert Lauritsen / Mbed 2 deprecated AttoPilotSense

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 RawSerial pc(USBTX, USBRX);
00004 AnalogIn   Ain1(p19);// --- AttoPilot "V"
00005 AnalogIn   Ain2(p20);// --- AttoPilot "I"
00006 
00007 int VRaw; //This will store our raw ADC data
00008 int IRaw;
00009 float VFinal; //This will store the converted data
00010 float IFinal;
00011 
00012 int main()
00013 {
00014     while(1) {
00015         VRaw = Ain1.read_u16();
00016         IRaw = Ain2.read_u16();
00017 
00018         //Conversion
00019         VFinal = VRaw/49.44; //45 Amp board
00020         //VFinal = VRaw/12.99; //90 Amp board
00021         //VFinal = VRaw/12.99; //180 Amp board
00022 
00023         IFinal = IRaw/14.9; //45 Amp board
00024         //IFinal = IRaw/7.4; //90 Amp board
00025         //IFinal = IRaw/3.7; //180 Amp board
00026         pc.printf("%.1   Volts\r\n",VFinal);
00027         pc.printf("%.1f   Amps\r\n\r\n\r\n",IFinal);
00028         wait(0.2);
00029     }
00030 }