![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
4 directional EMG control of the XY table. Made during my bachelor end assignment.
Dependencies: C12832_lcd HIDScope mbed-dsp mbed
Diff: main.cpp
- Revision:
- 10:7f94cd65c910
- Parent:
- 9:649229691351
- Child:
- 11:74ae4e5e11ab
--- a/main.cpp Tue Apr 28 08:48:31 2015 +0000 +++ b/main.cpp Tue Apr 28 10:02:45 2015 +0000 @@ -1,29 +1,38 @@ #include "mbed.h" +#include "C12832_lcd.h" DigitalOut Dir(p21); PwmOut Step(p22); DigitalOut MS1(p27); DigitalOut MS2(p28); DigitalOut MS3(p29); - +AnalogIn Pot1(p19); +C12832_LCD lcd; - +BusIn Joystick(p12,p13,p14,p15,p16); +DigitalIn Up(p15); +DigitalIn Down(p12); int main() { - float setpoint = 10000; + float setpoint = 5000; float step_freq = 1; MS1 = 1; MS2 = 0; MS3 = 0; + int p1; 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% - Dir = 1; // Dir 1 is naar boven, Dir 0 naar onder. + // Dir = Pot1; // Dir 1 is naar boven, Dir 0 naar onder. while (1) { + p1 = Pot1.read(); + Dir = Pot1; float new_step_freq; new_step_freq = (0.0001*setpoint) + (0.9999*step_freq); step_freq = new_step_freq; Step.period(1.0/step_freq); - wait(0.01); + lcd.printf("Pot1 : %d \n", p1); + wait(0.01); //Hier nog ticker inbouwen + } } \ No newline at end of file