Signa-bot code for project BioRobotics, at University of Twente.

Dependencies:   mbed QEI MODSERIAL FastPWM ttmath Math

Revision:
11:7c2d492466c2
Parent:
6:4dbd0d12e0f7
Parent:
9:61bdf58f856e
--- a/Motor_tryout.cpp	Mon Oct 07 12:42:33 2019 +0000
+++ b/Motor_tryout.cpp	Mon Oct 07 13:52:56 2019 +0000
@@ -1,20 +1,74 @@
 #include "mbed.h" 
 #include "MODSERIAL.h"
 
-DigitalOut motor1_pwm(D3);
+// test, hallo
+
+DigitalOut motor1_pwm(PTC2);    // aansturen motor 1, via poort PTC2
+DigitalIn motor1_1(PTD1);       // data vanuit motor 1
+DigitalIn motor1_2(PTD3);       // data vanuit motor 1
+
+
+DigitalOut motor2_pwm(PTA2);    // aansturen motor 2, via poort PTA2
+AnalogIn input(PTB3);           // input van ECG
 MODSERIAL pc(USBTX, USBRX);
+
 int main(void)
-{   
-    int frequency_pwm = 10000; //10 kHz PWM
-    PwmOut motor1_pwm(D3);
-    motor1_pwm.period(1.0/frequency_pwm); // T=1/f
-    while(true)
+    {   
+    pc.baud(115200);
+    char c = pc.getc();
+    pc.printf("In de main, check\r\n");
+    if (c == 'm')
+        {
+        pc.printf("In de if, check\r\n");
+        pc.baud(115200);
+        int frequency_pwm = 10000; //10 kHz PWM
+        PwmOut motor1_pwm(PTC2);
+        PwmOut motor2_pwm(PTA2);
+        motor1_pwm.period(1.0/(double)frequency_pwm); // T=1/f
+        motor2_pwm.period(1.0/(double)frequency_pwm); // T=1/f
+        while(true)
+            {   
+            pc.printf("In de while, check\r\n");
+            int DataM[1000];
+            for(int pct = 0 ; pct <= 100 ; pct += 10)
+                {
+                pc.printf("Motor 1\r\n");
+                motor1_pwm.write(pct/100.0); // write Duty Cycle
+                wait(1.0f);
+                //for(int tijd = 0 ; pct <= 100 ; pct += 1)
+                //    {
+                //       int tijd2 = tijd + pct/10*10;
+                //        int Outm1 = motor1_1.read();
+                //        DataM[tijd2] = Outm1;
+                //        wait(0.1f);
+                //        }
+                      }
+            for (int pr = 0 ; pr <= 100; pr += 1);
+            {
+                int value = DataM[pr];
+                pc.printf("Data motor 1 is %i", value);
+                }
+            motor1_pwm.write(0.0f); // motor 1 off again
+            pc.printf("Motor 1 off\r\n");
+            for(int pct = 0 ; pct <= 100 ; pct += 10)
+                {
+                pc.printf("Motor 2\r\n");
+                motor2_pwm.write(pct/100.0); // write Duty Cycle
+                wait(1.0f);
+                }
+            motor2_pwm.write(0.0f); // motor 2 off again
+            pc.printf("Motor 2 off\r\n");
+            }
+        }
+    if (c == 'e')
     {
-        for(int pct = 0 ; pct <= 100 ; pct = pct +10)
+        pc.printf("In de tweede if, check");
+        while (true)
         {
-            motor1_pwm.write(pct/100.0); // write Duty Cycle
-            wait(0.1);
-        }
+            int sample = input.read();
+            pc.printf("Input is %i \r\n", sample);
+            wait(1.0f);
+        }  
     }
 }
 // Comment kkd
\ No newline at end of file