Werkt

Dependencies:   Encoder HIDScope MODSERIAL QEI mbed

Fork of Inverse_kinematics_PIDController by Casper Kroon

Revision:
0:dc2c63f663f8
Child:
1:fc216448bb57
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Oct 15 13:28:55 2018 +0000
@@ -0,0 +1,49 @@
+#include "mbed.h"
+#include "MODSERIAL.h"
+
+DigitalIn button(SW2);
+DigitalOut directionpin1(D7);
+DigitalOut directionpin2(D8);
+MODSERIAL pc(USBTX, USBRX);
+
+volatile bool emg0;
+volatile bool emg1;
+volatile bool emg2;
+volatile bool y_direction;
+volatile int motor1_angle;
+volatile int motor2_angle;
+    
+int main() {
+    pc.printf(" ** program reset **\n\r");
+    while (true) {
+        
+        //x direction
+        if (emg0 || emg1){
+            motor1_angle++;
+            //cos function of motor1_angle
+            motor2_angle++;
+            //sin function of motor2_angle
+            if (emg0 && !emg1) {
+                directionpin1 = true;
+            }
+            else if (!emg0 && emg1) {
+                directionpin1 = false;
+            }
+        }
+              
+        //y direction
+        if (emg2) {
+            motor2_angle++;
+            if (y_direction) {
+                directionpin2 = true;
+            }
+            else if (!y_direction) {
+                directionpin2 = false;
+            }
+        }
+        
+        pc.printf("motor1 angle: %i\n\r", motor1_angle);
+        pc.printf("motor2 angle: %i\n\r\n", motor2_angle);
+        wait(0.5f);
+    }
+}
\ No newline at end of file