Total control sjoel robot

Dependencies:   HIDScope MODSERIAL QEI TextLCD mbed

Files at this revision

API Documentation at this revision

Comitter:
RichardRoos
Date:
Tue Oct 20 13:54:54 2015 +0000
Parent:
36:549d1ce7b96b
Commit message:
Kalibratie rotatie werkt nog niet zo goed. Blijft vast zitten in aim calibration

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 549d1ce7b96b -r 090ba5b1e655 main.cpp
--- a/main.cpp	Tue Oct 20 09:06:18 2015 +0000
+++ b/main.cpp	Tue Oct 20 13:54:54 2015 +0000
@@ -15,7 +15,7 @@
 PwmOut servo(D3);                   // PwmOut servo
 AnalogIn emgL(A0), emgR(A1);        // Analog input of EMG, left and right
 AnalogIn potL(A2), potR(A3);        // Potential meter left and right
-AnalogIn KS(A4);                    // Killswitch
+AnalogIn KS(A5);                    // Killswitch
 HIDScope scope(6);                  // Hidscope, amount of scopes           
 Ticker EMGticker, tickerControl, tickerBreak, tickerLcd;   // Ticker for EMG, regulator and break
 // QEI Encoder(port 1, port 2, ,counts/rev
@@ -35,7 +35,7 @@
 int maxCounts = 13000;                   // max richt motor counts Aim motor
 int breakPerc = 0;
 const double servoL = 0.001, servoR = 0.0011;    // Range servo,between servoL en servoR  (= pulsewidth pwm servo) 
-const double tControl = 0.005, tBreak = 0.1, tLcd = 1;     // tickers  
+const double tControl = 0.005, tBreak = 0.1, tLcd = 2;     // tickers  
 const double Fs = 50;                           //Sample frequency Hz
 double t = 1/ Fs;                               // time EMGticker
 double thresholdlowL= 0, thresholdmidL = 0, thresholdhighL= 0;
@@ -224,27 +224,29 @@
             case CALIBRATE_AIM: {
                 pwmM2.period(1/100000);                 // period motor 2
                 printf("Position is kalibrating\r\n");  // terminal
-                PRINT("Wait a moment,   please");       // LCD                           
+                PRINT("Wait a moment,   please");       // LCD                          
                 dirM2.write(0);                         // direction aim motor
-                pwmM2.write(0.25);                      // percentage motor power
+                pwmM2.write(0.1);                      // percentage motor power
                 bool calibrated = false;                //                       
                 while(state==CALIBRATE_AIM){                    
                     pc.printf("Killswitch: %f\r\n", KS.read()); // terminal
-                    if(KS.read() > 0.5 && !calibrated){                // Killswitch?
+                    if(KS.read() > 0.5){                // Killswitch? //2* gedaan, zodat breuk uit de if-statement is
                         pwmM2.write(0);                 // Aim motor freeze
                         enc2.reset();                   // Reset encoder 
                         PRINT("Aim calibrated");        // LCD                        
                         calibrated = true;              // 
-                        dirM2.write(0);                 // direction aim motor
-                        pwmM2.write(0.25);              // percentage motor power, turn it on                        
-                        }                    
+                        state = CALIBRATE_PEND;       // next state
+                        //dirM2.write(1);                 // direction aim motor
+                        //pwmM2.write(0.25);              // percentage motor power, turn it on                     
+                        }  
+                        /*                  
                     if(controlFlag && calibrated){       // motor regelen op GoFlag
-                        controlFlag = false;                  
+                        controlFlag = false;                    
                         if(enc1.getPulses() > maxCounts/2){  // rotate aim motor to midi position
                             pwmM2.write(0);                 // Aim motor freeze
                             state = CALIBRATE_PEND;       // next state
                             }                      
-                        }        
+                        }    */ 
                     }
                 break;
                 }