4 directional EMG control of the XY table. Made during my bachelor end assignment.
Dependencies: C12832_lcd HIDScope mbed-dsp mbed
Revision 76:627b0537110e, committed 2015-06-22
- Comitter:
- jessekaiser
- Date:
- Mon Jun 22 10:17:32 2015 +0000
- Parent:
- 75:9fa809932adf
- Child:
- 77:f3290f86ae4f
- Commit message:
- Motor-x control 3
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Jun 22 10:04:51 2015 +0000 +++ b/main.cpp Mon Jun 22 10:17:32 2015 +0000 @@ -22,8 +22,8 @@ #define EMG_tresh3 0.01 #define EMG_tresh4 0.01 #define H_Gain 3.5 -#define Pt_x 0.50 -#define Pt_y 0.50 +#define Pt_x 0.83 + #define error_tresh 0.01 //Motor control @@ -163,9 +163,9 @@ Enablex = 1; wait(1); - lcd.printf("Start homing"); + pc.printf("Start homing"); wait(2); - lcd.cls(); + wait(1); Enablex = 0; @@ -174,10 +174,10 @@ Ps_x = Posx.read(); errorx = fabs(Pt_x - Ps_x); - lcd.printf("%.2f \n", Stepx.read()); + pc.printf("%.2f \n", Stepx.read()); - if (Ps_x < 0.83 && errorx > error_tresh) { + if (Ps_x < Pt_x && errorx > error_tresh) { Dirx = 0; cx = errorx * H_Gain; float hnew_step_freqx; @@ -187,7 +187,7 @@ wait(0.01); } - if (Ps_x > 0.83 && errorx > error_tresh) { + if (Ps_x > Pt_x && errorx > error_tresh) { Dirx = 1; cx = errorx * H_Gain; float hnew_step_freqx; @@ -197,15 +197,15 @@ wait(0.01); } } - lcd.printf("Done"); + pc.printf("Done"); wait(5); - lcd.cls(); + wait(1); Enablex = 1; wait(3); - lcd.printf("Start EMG Control"); + pc.printf("Start EMG Control"); wait(2); - lcd.cls(); + wait(1); Enablex = 0; @@ -234,8 +234,8 @@ while (1) { - //lcd.printf("x %.2f, y %.2f \n", Posx.read(), Posy.read()); -// lcd.printf("%.2f %.2f \n", Stepx.read(), step_freq2); + //pc.printf("x %.2f, y %.2f \n", Posx.read(), Posy.read()); +// pc.printf("%.2f %.2f \n", Stepx.read(), step_freq2); wait(0.01); }