States and Errors

States and Errors Treatment

The State and Error Treatments image shows how states and errors are treated.

Figure 1: State and Error Treatments

StateChange (state manager): Activates the new state required by M1_ReqState.

StateName (state macro).

State

Description

Init State

  • Initializes exceptions on new state M1_CmdState <> M1_ReqState and on errors set in M1_StatusWord.
  • Goes to exit state when an exception occurs.
  • Performs all actions to properly enter this state (e.g., init variables, pipes, etc.)
  • Sends commands to the submitted axis modules by:
    • Setting Ai_CmdState to StateName.
    • Waiting for their acknowledgment in Ai_AckState.
  • Acknowledges end of initialization by setting M1_AckState to M1_ReqState.

Run State

  • Waits for any function calls.
  • Activates function if called.

Exit State

  • Performs all actions to properly leave this state.
  • Acknowledges running by setting M1_AckState to busy.
  • If error stop occurs, activates STATE_ErrStop.
    • Otherwise, sets new requested state M1_ReqState to M1_CmdState and activates StateChange.

Add a New State

  1. Copy a similar existing state sequence.
  2. Replace the old state name by the new one (e.g., Standby replaced with MyState).
  3. Modify both init and exit sections of the new state to perform the relevant actions.
  4. Insert the needed function calls into the states run part.
  5. Add the state call command line into the state change sequence.
  6. Add the state definition values to the general declaration.