Robot tryout

Dependencies:   mbed QEI biquadFilter MODSERIAL FastPWM ttmath Math

Revision:
16:2ad161f709f6
Parent:
14:b813ddfbcd71
Child:
17:6da57acb7bea
diff -r b813ddfbcd71 -r 2ad161f709f6 Motor_tryout.cpp
--- a/Motor_tryout.cpp	Mon Oct 07 13:56:24 2019 +0000
+++ b/Motor_tryout.cpp	Mon Oct 14 07:36:10 2019 +0000
@@ -2,28 +2,15 @@
 #include "MODSERIAL.h"
 #include "QEI.h"
 
-// ALLE INPUT EN OUTPUT SIGNALEN
-DigitalOut motor1_pwm(PTC2);    // aansturen motor 1, via poort PTC2
-DigitalOut motor1_dir(PTC3);    // richting motor 1
-DigitalOut motor2_pwm(PTA2);    // aansturen motor 2, via poort PTA2
-DigitalOut motor2_dir(PTB23);   // richting motor 2
-DigitalOut motor3_pwm(PTA0);    // aansturen motor 3, via poort PTA2
-DigitalOut motor3_dir(PTC4);   // richting motor 3
-DigitalIn motor1_1(PTD1);       // data vanuit motor 1
-DigitalIn motor1_2(PTD3);       // data vanuit motor 1
-AnalogIn input(PTB3);           // input van ECG
+DigitalOut motor_pwm(PTC2);
+DigitalOut motor_dir(PTC3);
 MODSERIAL pc(USBTX, USBRX);
-\\QEI Encoder(D12,D13,NC,64,QEI::X4_ENCODING);
-\\QEI Encoder(D12,D13,NC,64,QEI::X4_ENCODING);
-QEI Encoder(D2,D3,NC,64,QEI::X4_ENCODING);
+QEI Encoder(D12,D13,NC,64,QEI::X4_ENCODING);
 
-// Global variables
 int quit;
 int counts = 0;
 int limit_pos = 8400;
 
-
-// DE TICKERS, deze ticker
 Ticker pulse;
 void pulseget()
 {
@@ -34,44 +21,37 @@
         }
     }
 
-Ticker signal;
-void get_signal()
-{
-    int signal = 0;
-    }
-
-
 // DE MAIN FUNCTIE
 int main(void)
 {
-    pc.baud(115200);
-    pc.printf("In main\r\n");
-    
+    pc.baud(115200);    
     while(true)
     {
         quit = 0;
         counts = 0;
-        char cc = pc.getc();    
-        while(cc == 'g')
+        char cc = pc.getc();
         {
+            pc.printf("in while");
             int frequency_pwm = 10000; //10 kHz PWM
-            PwmOut motor3_pwm(PTC2);
-            PwmOut motor2_pwm(PTA2);
-            motor1_pwm.period(1.0/(double)frequency_pwm); // T=1/f
-            motor1_dir.write(0); // positief
-            motor1_pwm.write(0.56); // write Duty Cycle  
+            PwmOut motor_pwm(PTC2);
+            PwmOut motor_dir(PTC3);
+            motor_pwm.period(1.0/(double)frequency_pwm); // T=1/f
+            motor_dir.write(0); // positief
+            motor_pwm.write(0.8); // write Duty Cycle  
             pulse.attach(pulseget,1.0/10000);
             if(quit == 1)
             {
                 pulse.detach();
-                motor1_pwm.write(0);
+                motor_pwm.write(0);
                 pc.printf("The motor is off with counts is %i\n\r",counts);               
                 break;
                 }
-            wait(1.0/1000);
+            wait(1.0/10000);
             }
         cc = pc.getc();
         counts = 0;
         pc.printf("The motor is in final state and counts is %i\n\r",counts);
         }
-    }
\ No newline at end of file
+    }
+
+