??? 04/11/09 10:37 Read: times |
#164534 - Addendum Responding to: ???'s previous message |
Just an addendum - if you think that it is ok to stop the motor in any phase, then the 8 stop states can be empty in the switch statement - either just:
switch (state & 0x0f) { case FWD_STOP_S1: case FWD_STOP_S2: case FWD_STOP_S3: case FWD_STOP_S4: case BKW_STOP_S1: case BKW_STOP_S2: case BKW_STOP_S3: case BKW_STOP_S4: // Nothing to do - just waiting for a running state. break; case FWD_S1: . . }or doing: switch (state & 0x0f) { case FWD_S1: . . break; . . default: // Stopped - just wait for a running state. ; }Just make sure that all processed bits of the state variable gets processed or normalized, so that you can't get into an invalid state that locks up your state machine. |