Algorithmus

Dependencies:   mbed

Revision:
3:076dd7ec7eb4
Parent:
1:2b5f79285a3e
Child:
10:84534846e1f1
Child:
21:41997651337a
--- a/IRSensor.cpp	Thu Apr 19 11:26:51 2018 +0000
+++ b/IRSensor.cpp	Fri Apr 20 13:37:21 2018 +0000
@@ -18,7 +18,8 @@
     float a6 =  445.1f;
     
 
-    float d2 = a1*pow(distance,5) + a2*pow(distance,4) + a3*pow(distance,3) + a4*pow(distance,2) + a5*distance + a6;
+    //float d2 = a1*pow(distance,5) + a2*pow(distance,4) + a3*pow(distance,3) + a4*pow(distance,2) + a5*distance + a6;
+    float d2 = 10.2817f*(1/(pow(distance,1.212121f)));
     
     return d2;
     
@@ -33,21 +34,24 @@
     float b5 = -2519.0f;
     float b6 = 310.8f;
     
-    float d1 = b1*pow(distance,5) + b2*pow(distance,4) + b3*pow(distance,3) + b4*pow(distance,2) + b5*distance + b6;
+    //float d1 = b1*pow(distance,5) + b2*pow(distance,4) + b3*pow(distance,3) + b4*pow(distance,2) + b5*distance + b6;
+    float d1 = 11.6037f*(1/(pow(distance,1.111111f)));
     
     return d1;
 }
 
 float IRSensor::readC(){
     //Vorne B4
-    float c1 = -2.681f*pow(10.0f,4.0f);
-    float c2 = 6.007f*pow(10.0f,4.0f);
-    float c3 = -5.32f*pow(10.0f,4.0f);
-    float c4 = 2.377f*pow(10.0f,4.0f);
-    float c5 = -5686.0f;
-    float c6 = 697.8f;
+    double c1 = -2.352f*pow(10.0f,4.0f);
+    double c2 =  5.44f*pow(10.0f,4.0f);
+    double c3 = -4.955f*pow(10.0f,4.0f);
+    double c4 = 2.268f*pow(10.0f,4.0f);
+    double c5 = -5538.0f;
+    double c6 = 690.5f;
     
-    float d4 = c1*pow(distance,5) + c2*pow(distance,4) + c3*pow(distance,3) + c4*pow(distance,2) + c5*distance + c6;
+    //double d4 = c1*pow(distance,5) + c2*pow(distance,4) + c3*pow(distance,3) + c4*pow(distance,2) + c5*distance + c6;
+    //float d4 = distance;
+    float d4 = 28.053f*(1.0f/distance);
     
     return d4;
     }