Wil je hier nog je PID controler kort uitleggen plus waarden aanpassen?

Dependencies:   HIDScope MODSERIAL QEI biquadFilter mbed

Fork of a_pid_kal_end by Daniqe Kottelenberg

Revision:
34:e788565f5d70
Parent:
31:9333d3f48c88
--- a/main.cpp	Fri Oct 28 09:35:32 2016 +0000
+++ b/main.cpp	Fri Oct 28 10:23:06 2016 +0000
@@ -35,8 +35,8 @@
 double signal_right_arm;                    //signal right arm
 double max_biceps;                          //calibration maximum biceps
 double max_triceps;                         //calibration maximum triceps
-int n = 0;                                  //start of counter is zero, to make switch work. It depens on even and odd. 
- 
+int count_switch = 0;                        //start of counter is zero, to make switch work. It depens on even and odd. 
+int n ;
 double emg_biceps_right;                    //emg biceps signal in, arm 1
 double emg_triceps_right;                   //emg triceps signal in, arm 1
 double emg_biceps_left;                     //emg biceps signal in, arm 2
@@ -70,8 +70,9 @@
 void SwitchN() {                        // maakt simpele functie die 1 bij n optelt
     if(switch_signal_leftarm==1)
     {
-        n++;
+        count_switch++;
         wait(0.5f);
+        pc.printf("switch\r\n");
     }    
     }
     
@@ -200,7 +201,7 @@
        
     if (onoffsignal_rightarm==1)                           // als s ingedrukt wordt gebeurd het volgende
     {
-         if (n%2==0)                     // als s ingedrukt wordt en het getal is even gebeurd het onderstaande
+         if (count_switch%2==0)                     // als s ingedrukt wordt en het getal is even gebeurd het onderstaande
          {
            
            richting_motor1 = 2.5;
@@ -219,11 +220,11 @@
     }
     else if (onoffsignal_rightarm==-1)                     // als d ingedrukt wordt gebeurd het volgende
     {
-         if (n%2==0)                     // als d is ingedrukt en n is even dan gebeurd het volgende
+         if (count_switch%2==0)                     // als d is ingedrukt en n is even dan gebeurd het volgende
          {
        
            richting_motor1 = 0;
-           pwm_motor1 = 1;
+           pwm_motor1 = 0.5;
            
         } 
          else                           // als d is ingedrukt maar het getal is niet even (dus oneven) gebeurdt het onderstaande