Vanmorgen aan gewerkt

Dependencies:   FastPWM HIDScope MODSERIAL QEI biquadFilter mbed

Fork of Project_BioRobotics by Jordi Luong

Revision:
8:78d8ccf84a38
Parent:
7:757e95b4dc46
Child:
10:a9e344e440b8
--- a/main.cpp	Mon Oct 23 09:42:21 2017 +0000
+++ b/main.cpp	Mon Oct 23 12:25:07 2017 +0000
@@ -66,7 +66,7 @@
 // EMG /////////////////////////////////////////////////////////////////////////
 void EmgSample()
 {
-    double emgFiltered = bqc.step(emg.read());                                  // Filters the EMG signal
+    double emgFiltered = bqc.step(emg.read());                                  // Filter the EMG signal
 }
 
 // BIQUAD FILTER FOR DERIVATIVE OF ERROR ///////////////////////////////////////
@@ -92,11 +92,11 @@
  const double f_b1, const double f_b2)
 {
     // Derivative
-    double e_der = (e - e_prev)/Ts;                                             // Calculates the derivative of error
+    double e_der = (e - e_prev)/Ts;                                             // Calculate the derivative of error
     e_der = biquad(e_der, f_v1, f_v2, f_a1, f_a2, f_b0, f_b1, f_b2);            // Filter the derivative of error
     e_prev = e;
     // Integral
-    e_int = e_int + Ts*e;                                                       // Calculates the integral of error
+    e_int = e_int + Ts*e;                                                       // Calculate the integral of error
     // PID
     return Kp*e + Ki*e_int + Kd*e_der;
 }
@@ -104,7 +104,7 @@
 // MOTOR 1 /////////////////////////////////////////////////////////////////////
 void RotateMotor1(double motor1Value)
 {
-    if(currentState == MOVING)                                                  // Checks if state is MOVING
+    if(currentState == MOVING)                                                  // Check if state is MOVING
     {
         if(motor1Value >= 0) motor1DirectionPin = 1;                            // Rotate motor 1 CW
         else motor1DirectionPin = 0;                                            // Rotate motor 1 CCW
@@ -118,7 +118,7 @@
 // MOTOR 1 P-CONTROLLER ////////////////////////////////////////////////////////
 void Motor1PController()
 {
-    double position1 = radPerPulse * Encoder1.getPulses();                      // Calculates the rotation of motor 1
+    double position1 = radPerPulse * Encoder1.getPulses();                      // Calculate the rotation of motor 1
     double motor1Value = P_Controller(reference1 - position1, motor1_KP);
     RotateMotor1(motor1Value);
 }
@@ -217,11 +217,11 @@
     
     pc.printf("START \r\n");
     
-    bqc.add(&bq1).add(&bq2);
+    bqc.add(&bq1).add(&bq2);                                                    // Make BiQuad Chain
     
     controllerTicker.attach(&Motor1PController, controller_Ts);                 // Ticker to control motor 1
     //controllerTicker.attach(&Motor1Controller, controller_Ts);
-    emgSampleTicker.attach(&EmgSample, emg_Ts);
+    emgSampleTicker.attach(&EmgSample, emg_Ts);                                 // Ticker to sample EMG
     
     while(true)
     {