Oud verslag voor Biquad.

Dependencies:   Biquad HIDScope QEI angleandposition controlandadjust mbed

Fork of includeair by Jasper Gerth

Revision:
39:ebcf0a60f58b
Parent:
38:df0b0abea598
Child:
40:8b25c0531340
--- a/main.cpp	Thu Oct 29 13:05:36 2015 +0000
+++ b/main.cpp	Thu Oct 29 14:03:35 2015 +0000
@@ -28,7 +28,7 @@
 QEI encoder2(D10,D11,NC,cpr_sensor);// first is pin a, pin b and the second is pin b, pin a so the encoders give positive rotation when the pod is moved forward
 
 const double PIE=3.14159265359; // pi, for calculations
-const float counttorad=((2*PIE)/cpr_shaft);// to convert counts to rotation in rad
+const double counttorad=((2*PIE)/cpr_shaft);// to convert counts to rotation in rad
 
 
 /////////////////////////////////CALIBRATION (MODE)
@@ -67,7 +67,7 @@
 Ticker control_ticker;//ticker for the controller
 const double Ts_control=1.0/control_frequency;//sample time of the controller
 
-float error1=0,//controller error storage variables
+double error1=0,//controller error storage variables
       error2=0;
 
 InterruptIn valuechangebutton(PTC6);//button to change filter gains per arm via Serial 
@@ -79,7 +79,7 @@
 Ticker safetyandthreshold_ticker; // ticker to read potmeters
 const double safetyandthreshold_frequency=1; // frequency for the ticker
 
-float threshold_value=1;//initial threshold value
+double threshold_value=1;//initial threshold value
 
 ////////////////////////////////FILTER
 const double filter_frequency=500; // frequency at which the emg signal is filtered
@@ -95,10 +95,10 @@
 
 volatile double filteredsignal1=0;//the first filtered emg signal
 volatile double filteredsignal2=0;//the second filtered emg signal
-float filter_extragain1=1,filter_extragain2=1; // this is a factor to increase the gain per arm, adustable via serial
+double filter_extragain1=1,filter_extragain2=1; // this is a factor to increase the gain per arm, adustable via serial
 
 
-//////////////////////////////// POSITION AND ANGLE SHIZZLE
+//////////////////////////////// POSITION AND ANGLE 
 const double safetymarginfield=0.1; //adjustable, tweak for maximum but safe range
 const double mm_per_sec_emg=0.1;// move the pod 100 mm per sec if muscle is flexed
 const double y_start=0.145;//starting y position of the pod
@@ -115,7 +115,7 @@
 
 angleandposition anglepos;// initiate the angle and position calculation library
 
-const float radtodeg=(180/PIE); // to convert radians to degrees
+const double radtodeg=(180/PIE); // to convert radians to degrees
 
 //////////////////////GO FLAGS AND ACTIVATION FUNCTIONS
 volatile bool scopedata_go=false,
@@ -447,8 +447,8 @@
                 desired_angle1=anglepos.positiontoangle1(desired_position,y_start);
                 desired_angle2=anglepos.positiontoangle2(desired_position,y_start);
 
-                float error1=(desired_angle1-counttorad*encoder1.getPulses());
-                float error2=(desired_angle2-counttorad*encoder2.getPulses());
+                double error1=(desired_angle1-counttorad*encoder1.getPulses());
+                double error2=(desired_angle2-counttorad*encoder2.getPulses());
                 mycontroller.PID(error1,error2,Kp_move,Ki_move,Kd_move);
                 control_go=false;
             }