Exp5_FSRcalibrate

Dependencies:   TextLCD mbed

Committer:
ddamato31
Date:
Tue Aug 02 19:25:21 2011 +0000
Revision:
0:a7fdac873af3
Child:
1:37707fc10edc

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ddamato31 0:a7fdac873af3 1 #include "mbed.h"
ddamato31 0:a7fdac873af3 2 #include "TextLCD.h"
ddamato31 0:a7fdac873af3 3
ddamato31 0:a7fdac873af3 4 AnalogIn FSR(p17);
ddamato31 0:a7fdac873af3 5 TextLCD lcd(p24, p26, p27, p28, p29, p30);
ddamato31 0:a7fdac873af3 6 float CalEq;
ddamato31 0:a7fdac873af3 7
ddamato31 0:a7fdac873af3 8 int main() {
ddamato31 0:a7fdac873af3 9
ddamato31 0:a7fdac873af3 10 // Motor RPM average initialization and index
ddamato31 0:a7fdac873af3 11 float ForceV[10] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
ddamato31 0:a7fdac873af3 12 int i; i = 0;
ddamato31 0:a7fdac873af3 13
ddamato31 0:a7fdac873af3 14 while(1) {
ddamato31 0:a7fdac873af3 15
ddamato31 0:a7fdac873af3 16 // Index and reset Motor Average Counter
ddamato31 0:a7fdac873af3 17 if(i > 9)
ddamato31 0:a7fdac873af3 18 i = 0;
ddamato31 0:a7fdac873af3 19
ddamato31 0:a7fdac873af3 20
ddamato31 0:a7fdac873af3 21 CalEq = 1.0;
ddamato31 0:a7fdac873af3 22 ForceV[i] = FSR*CalEq; // Use AnalogIn (FSR) reading in an equation of Force versus FSR values
ddamato31 0:a7fdac873af3 23 float ForceAvg = (ForceV[0] + ForceV[1] + ForceV[2] + ForceV[3] + ForceV[4] + ForceV[5] + ForceV[6] + ForceV[7] + ForceV[8] + ForceV[9]) / 10 ;
ddamato31 0:a7fdac873af3 24 lcd.cls();
ddamato31 0:a7fdac873af3 25 lcd.locate(0, 0);
ddamato31 0:a7fdac873af3 26 lcd.printf("Calibrate FSR");
ddamato31 0:a7fdac873af3 27 lcd.locate(0, 1);
ddamato31 0:a7fdac873af3 28 lcd.printf("V=%f", ForceAvg);
ddamato31 0:a7fdac873af3 29 ++i;
ddamato31 0:a7fdac873af3 30 wait(0.25);
ddamato31 0:a7fdac873af3 31 }
ddamato31 0:a7fdac873af3 32 }