Exp5_FSRcalibrate

Dependencies:   TextLCD mbed

Revision:
1:37707fc10edc
Parent:
0:a7fdac873af3
--- a/main.cpp	Tue Aug 02 19:25:21 2011 +0000
+++ b/main.cpp	Wed Aug 03 05:57:57 2011 +0000
@@ -1,32 +1,33 @@
-#include "mbed.h"
-#include "TextLCD.h"
-
-AnalogIn FSR(p17);
-TextLCD lcd(p24, p26, p27, p28, p29, p30);
-float CalEq;
-
-int main() {
-
-// Motor RPM average initialization and index
-    float ForceV[10] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
-    int i; i = 0;
-    
-    while(1) {
-    
-    // Index and reset Motor Average Counter
-       if(i > 9)
-       i = 0;
-       
-       
-       CalEq = 1.0;
-       ForceV[i] = FSR*CalEq;          // Use AnalogIn (FSR) reading in an equation of Force versus FSR values
-       float ForceAvg = (ForceV[0] + ForceV[1] + ForceV[2] + ForceV[3] + ForceV[4] + ForceV[5] + ForceV[6] + ForceV[7] + ForceV[8] + ForceV[9]) / 10 ;
-       lcd.cls();
-       lcd.locate(0, 0);
-       lcd.printf("Calibrate FSR");
-       lcd.locate(0, 1);
-       lcd.printf("V=%f", ForceAvg);
-       ++i;
-       wait(0.25);    
-    }
-}
+#include "mbed.h"
+#include "math.h"
+#include "TextLCD.h"
+
+AnalogIn FSR(p17);
+TextLCD lcd(p24, p26, p27, p28, p29, p30);
+float CalEq;
+
+int main() {
+
+// Motor RPM average initialization and index
+    double ForceV[10] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
+    int i; i = 0;
+    
+    while(1) {
+    
+    // Index and reset Motor Average Counter
+       if(i > 9)
+       i = 0;
+       
+       
+       double FSRconst = FSR;
+       ForceV[i] = 6.3713*pow(97.6207, FSRconst) ;          // Use AnalogIn (FSR) reading in an equation of Force versus FSR values
+       float ForceAvg = (ForceV[0] + ForceV[1] + ForceV[2] + ForceV[3] + ForceV[4] + ForceV[5] + ForceV[6] + ForceV[7] + ForceV[8] + ForceV[9]) / 10 ;
+       lcd.cls();
+       lcd.locate(0, 0);
+       lcd.printf("Calibrate FSR");
+       lcd.locate(0, 1);
+       lcd.printf("V=%f", ForceAvg);
+       ++i;
+       wait(0.25);    
+    }
+}