albatross / Mbed 2 deprecated ControlYokutan2017

Dependencies:   Control_Yokutan_CANver1 ADXL345_I2C mbed MPU6050

Fork of Souda_Yokutan_ver528TF by albatross

Files at this revision

API Documentation at this revision

Comitter:
YusukeWakuta
Date:
Wed Mar 29 04:52:00 2017 +0000
Branch:
mpu????????
Parent:
49:8522856fe0cd
Child:
51:eafff055a3f4
Commit message:
calcPulse???????????????????

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Mar 29 04:37:27 2017 +0000
+++ b/main.cpp	Wed Mar 29 04:52:00 2017 +0000
@@ -235,7 +235,14 @@
 
 double calcPulse(float analog)
 {
-    return (0.0006+(analog)*(0.00240-0.00060));
+    double min = 0.0006;
+    double max = 0.00240;
+    if(analog >= max)
+        analog = max;
+    else if(analog <= min)
+        analog = min;
+        
+    return (min+(analog)*(max-min));
     /*
         int start=510, end=2390;
     while(1) {
@@ -259,7 +266,7 @@
     led2 =  1;
     if(EDstatePin) {
         eruronTrim = eruronAna.read();
-    eruronServo.pulsewidth(calcPulse(eruronTrim));
+        eruronServo.pulsewidth(calcPulse(eruronTrim));
     } else {
         drugTrim = drugAna.read();
         drugServo.pulsewidth(calcPulse(drugTrim));