4 directional EMG control of the XY table. Made during my bachelor end assignment.

Dependencies:   C12832_lcd HIDScope mbed-dsp mbed

Files at this revision

API Documentation at this revision

Comitter:
jessekaiser
Date:
Thu Jun 11 09:22:32 2015 +0000
Parent:
54:abb7f76a0473
Child:
56:6ea03cce1175
Commit message:
Working test setup3;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Jun 10 17:17:37 2015 +0000
+++ b/main.cpp	Thu Jun 11 09:22:32 2015 +0000
@@ -7,7 +7,7 @@
 PwmOut Step(p24);
 AnalogIn Pos1(p17); 
 AnalogIn Pos2(p18); 
-DigitalOut Enable(p16);
+DigitalOut Enable(p25);
 DigitalOut MS1(p27);
 DigitalOut MS2(p28);
 DigitalOut MS3(p29);
@@ -19,8 +19,8 @@
 
 int main()
 {
-    Enable = 0;
-    float setpoint = 7000; //Frequentie 
+    
+    float setpoint = 6500; //Frequentie 
     float step_freq = 1;
     MS1 = 1;
     MS2 = 0;
@@ -28,16 +28,17 @@
     
     Step.period(1./step_freq); // 1 kHz, vanaf 2,5 kHz doet de motor het niet meer.
     Step.write(0.5); // Duty cycle van 50%
-   
-    Enable = 1;
+
     while (1) {
-        Dir = 0;
+        Dir = 1;
+        float rpm;
         float new_step_freq;
         new_step_freq = ((1-P_GAIN)*setpoint) + (P_GAIN*step_freq);
         step_freq = new_step_freq;
         Step.period(1.0/step_freq);
+        rpm = (step_freq/400)*60;
         
-        pc.printf("%.2f %.0f \n", Pos1.read(), step_freq);
+        pc.printf("%.2f %.0f \n", Pos1.read(), rpm);
         wait(0.01); //Hier nog ticker inbouwen
 
     }