4 directional EMG control of the XY table. Made during my bachelor end assignment.
Dependencies: C12832_lcd HIDScope mbed-dsp mbed
Revision 68:2b778b6da923, committed 2015-06-19
- Comitter:
- jessekaiser
- Date:
- Fri Jun 19 09:19:43 2015 +0000
- Parent:
- 67:fba5b64bb295
- Child:
- 69:a1ba54587b35
- Commit message:
- Homing 7. It works!!
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Jun 19 09:11:25 2015 +0000 +++ b/main.cpp Fri Jun 19 09:19:43 2015 +0000 @@ -235,15 +235,17 @@ wait(1); Enablex = 0; Enabley = 0; - while(errorx > 0.03 && errory > 0.03) { + while(errorx > 0.03 || errory > 0.03) { lcd.printf("%.0f %.2f \n", hstep_freqx, hstep_freqy ); Ps_x = Posx.read(); Ps_y = Posy.read(); + errorx = fabs(Pt_x - Ps_x); + errory = fabs(Ps_y - Pt_y); if (Ps_x < 0.88 && errorx > 0.03) { Dirx = 0; - errorx = Pt_x - Ps_x; + //errorx = Pt_x - Ps_x; cx = errorx * H_Gain; float hnew_step_freqx; @@ -254,7 +256,30 @@ } if (Ps_y > 0.25 && errory > 0.03) { Diry = 0; - errory = Ps_y - Pt_y; + //errory = Ps_y - Pt_y; + cy = errory * H_Gain; + + float hnew_step_freqy; + hnew_step_freqy = ((1-P_Gain)*setpoint*cy) + (P_Gain*hstep_freqy); + hstep_freqy = hnew_step_freqy; + Stepy.period(1.0/hstep_freqy); + wait(0.01); + } + + if (Ps_x > 0.88 && errorx > 0.03) { + Dirx = 1; + //errorx = Pt_x - Ps_x; + cx = errorx * H_Gain; + + float hnew_step_freqx; + hnew_step_freqx = ((1-P_Gain)*setpoint*cx) + (P_Gain*hstep_freqx); + hstep_freqx = hnew_step_freqx; + Stepx.period(1.0/hstep_freqx); + wait(0.01); + } + if (Ps_y < 0.25 && errory > 0.03) { + Diry = 1; + //errory = Ps_y - Pt_y; cy = errory * H_Gain; float hnew_step_freqy;