Operation Mode State Machine plus homing for StateMachinePTR
Dependencies: MODSERIAL QEI biquadFilter mbed
Fork of Controller by
Diff: OperationMode.cpp
- Revision:
- 13:9125d359619c
- Parent:
- 12:cae29e41ac2e
- Child:
- 14:771cd444764b
--- a/OperationMode.cpp Wed Oct 31 21:21:13 2018 +0000 +++ b/OperationMode.cpp Thu Nov 01 08:23:55 2018 +0000 @@ -49,7 +49,7 @@ } if (button_sw3 == false) { CurrentOperationState = OPSet; - TimreLoop.reset(); + TimerLoop.reset(); } break; @@ -57,11 +57,11 @@ LedRed = 1; //turqoise LedGreen = 0; LedBlue = 0; - if (PositionRef2 > -0.853*(6.380)) { + if (PositionRef2 > -0.733*(6.380)) { PositionRef2 -= 0.0005*(6.380); } - if (PositionRef2 < -0.853*(6.380) && TimerLoop > 2) { - CurrentOperationState = OPState1; + if (PositionRef2 < -0.733*(6.380) && TimerLoop > 2) { + CurrentOperationState = OPWait; TimerLoop.reset(); } break; @@ -83,10 +83,10 @@ LedRed = 0; //white LedGreen = 0; LedBlue = 0; - if (PositionRef2 > -0.40*(6.380)) { + if (PositionRef2 > -1.133*(6.380)) { PositionRef2 -= 0.0005*(6.380); } - if ((PositionRef2 < -0.40*(6.380)) && (TimerLoop >= 4.0)) { + if ((PositionRef2 < -1.133*(6.380)) && (TimerLoop >= 4.0)) { CurrentOperationState = OPState3; TimerLoop.reset(); } @@ -99,10 +99,10 @@ if (PositionRef > -0.15*(6.380)) { PositionRef -= 0.0005*(6.380); } - if (PositionRef2 > -0.75*(6.380)) { + if (PositionRef2 > -1.483*(6.380)) { PositionRef2 -= 0.0002*(6.380); } - if ((PositionRef < -0.15*(6.380)) && (PositionRef2 < -0.75*(6.380)) && (TimerLoop >= 4.0)) { + if ((PositionRef < -0.15*(6.380)) && (PositionRef2 < -1.483*(6.380)) && (TimerLoop >= 4.0)) { CurrentOperationState = OPState4; TimerLoop.reset(); } @@ -112,10 +112,10 @@ LedRed = 1; //blue LedGreen = 1; LedBlue = 0; - if (PositionRef2 > -1.4*(6.380)) { + if (PositionRef2 > -2.133*(6.380)) { PositionRef2 -= 0.005*(6.380); } - if ((PositionRef2 < -1.4*(6.380)) && (TimerLoop > 4)) { + if ((PositionRef2 < -2.133*(6.380)) && (TimerLoop > 4)) { TimerLoop.reset(); CurrentOperationState = OPHoming; } @@ -128,10 +128,10 @@ if (PositionRef < 0) { PositionRef += 0.003*(6.380); } - if (PositionRef2 < 0) { + if (PositionRef2 < -0.733*(6.380)) { PositionRef2 += 0.001*(6.380); } - if ((PositionRef > 0) && (PositionRef2 > 0) && (TimerLoop > 4)) { + if ((PositionRef > 0) && (PositionRef2 > -0.733*(6.380)) && (TimerLoop > 4)) { CurrentOperationState = OPWait; } break;