alles ingevoegd

Dependencies:   FastPWM HIDScope MODSERIAL QEI mbed biquadFilter

Fork of deelPID by Laurence B

Revision:
4:93c4e826d11d
Parent:
3:53fb8bd0a448
Child:
5:8e326d07f125
--- a/main.cpp	Wed Oct 31 11:47:36 2018 +0000
+++ b/main.cpp	Wed Oct 31 12:05:10 2018 +0000
@@ -9,7 +9,7 @@
 DigitalOut gpo(D0);
 DigitalOut led(LED_RED);
 AnalogIn pot1(A4);                  //POORTEN VERANDEREN
-//AnalogIn pot2();         //Beneden is I control op 0 gezet.   //POORTEN veranderen
+AnalogIn pot2(A3);         //Beneden is I control op 0 gezet.   //POORTEN veranderen
 AnalogIn pot3(A5);                  //POORTEN VERANDEREN
 QEI encoder1(D10, D11, NC, 32);
 QEI encoder2(D12, D13, NC, 32);
@@ -21,7 +21,7 @@
 AnalogIn    a0(A0);
 AnalogIn    a1(A1);
 AnalogIn    a2(A2);
-AnalogIn    a3(A3);
+//AnalogIn    a3(A3);
 
 MODSERIAL pc(USBTX, USBRX);
 
@@ -69,12 +69,12 @@
 double IntegralErrorq2 = 0.0;
 double DerivativeErrorq1 = 0.0;
 double DerivativeErrorq2 = 0.0;
-double GainP1 = 2.0;
-double GainI1 = 1.2;
-double GainD1 = 0.0;
-double GainP2 = 2.0;
-double GainI2 = 2.0;
-double GainD2 = 2.0;
+double GainP1 = 3.0;
+double GainI1 = 0.0;
+double GainD1 = 0.235;
+double GainP2 = 3.0;
+double GainI2 = 0.0;
+double GainD2 = 0.235;
 double TickerPeriod = 1.0/400.0;
 // Global variables EMG
 double EMGdata1;
@@ -100,8 +100,8 @@
 int countstep = 0;
 
 //Demo variabelen
-double vxMax = 3.0;
-double vyMax = 3.0;
+double vxMax = 2.0;
+double vyMax = 2.0;
 int DemoStage = 0;
 
 
@@ -113,7 +113,7 @@
     EMGdata1 = a0.read(); // store values in the scope
     EMGdata2 = a1.read();
     EMGdata3 = a2.read();
-    EMGdata4 = a3.read();
+    EMGdata4 = 0.0; //a3.read();
 }
 
 // EMG High pass filters
@@ -358,11 +358,11 @@
 {
         //Motor 1 
         //Keep signal within bounds
-        if (PIDerrorq1 > 0.6){  //tijdelijk 0.6, hoort 1.0 te zijn
-            PIDerrorq1 = 0.6;
+        if (PIDerrorq1 > 1.0){  //tijdelijk 0.6, hoort 1.0 te zijn
+            PIDerrorq1 = 1.0;
             }
-        else if (PIDerrorq1 < -0.6){
-            PIDerrorq1 = -0.6;
+        else if (PIDerrorq1 < -1.0){
+            PIDerrorq1 = -1.0;
             }     
         //Direction    
         if (PIDerrorq1 <= 0){
@@ -376,11 +376,11 @@
         
         //Motor 2 
         //Keep signal within bounds
-        if (PIDerrorq2 > 0.6){
-            PIDerrorq2 = 0.6;
+        if (PIDerrorq2 > 1.0){
+            PIDerrorq2 = 1.0;
             }
-        else if (PIDerrorq2 < -0.6){
-            PIDerrorq2 = -0.6;
+        else if (PIDerrorq2 < -1.0){
+            PIDerrorq2 = -1.0;
             }     
         //Direction           
           
@@ -491,9 +491,9 @@
      //scope.set(0, q1Pos);
      //scope.set(1, q1Ref);
      
-     GainP1 = 3.0; //pot3.read() * 10;
-     GainI1 = 0; //pot2.read() * 10;
-     GainD1 = 0.235;//pot1.read() ;
+     //GainP1 = pot3.read() * 10;
+     //GainI1 = pot2.read() * 10;
+     //GainD1 = pot1.read() ;
           
      countstep++;
      counter++;