Axis status of motion control



In a motion control system, the operational status of an axis is divided into several logical states, and the transition between each logical state requires specific conditions or designated motion control (MC) instructions to trigger. This segmentation strategy significantly enhances the controllability and stability of the system. At any given moment, an axis can only be in a single logical state, and the state transition must follow predefined rules, thus avoiding operational chaos caused by the misfiring of different MC instructions.

State machine enumeration variables

The axis data structure variable (Axis.nAxisState) is used to indicate the current operational status of an axis. This variable Axis.nAxisState is an enumerated type, with a total of 8 states as follows:

  1. Poweroff — The axis is not enabled. Before motion, the MC_Power instruction needs to be executed to enable the axis.
  2. Errorstop — The axis is in an error state. The MC_Reset instruction needs to be executed to reset the axis.
  3.  Stopping — The axis is in a stopping state.
  4.  Standstill — The axis is in a stationary state.
  5. Discrete Motion — The axis is in a discrete motion state.
  6. Continuous Motion — The axis is in continuous operation.
  7. Synchronized Motion — The axis is in synchronized operation.
  8.  Homing — The axis is in homing operation, waiting for the homing operation to complete.

State Machine Transition Conditions

The axis state transition diagram is depicted below, detailing the transition process between different logical states of the axis. In these state transitions, each transition relies on specific conditions to trigger, such as executing specific MC (Motion Control) instructions or the occurrence of external faults. Users cannot directly force the state of the axis, ensuring the safety and stability of the system. During programming, it is crucial to strictly adhere to these logical requirements, ensuring that relevant instructions are executed in the correct order and under the right conditions, to guarantee that the axis can smoothly move through the state transition diagram as expected.

  • When the axis is in the Standstill state (Axis.nAxisState=3), it can be switched to various operating states through the motion function block;
  • When in the Continuous_Motion or Synchronized_Motion state, the axis needs to transition to the Standstill state through MC_Halt;
  • If a servo axis encounters an alarm (Errorstop, i.e., Axis.nAxisState=1), the MC_Reset command must be executed first to reset the axis error;
  • The Homing state (Axis.nAxisState=7) cannot be interrupted by other motion commands and can only be stopped by MC_Stop;
  • If MC commands are not used to command the axis movement in the manner shown in the diagram above, the axis will not respond, and an error message related to the MC function block will be received.

Application of nAxisState in Programming

When needing to confirm whether an axis is in an idle state, meaning it is ready to move and not occupied by other motion commands, you can check if Axis.nAxisState equals 3 (Standstill state). Axis.nAxisState being equal to 3 indicates that the axis is currently stationary and is not executing any motion commands.

To determine if an axis can move (able to interrupt other motion commands), you can check if Axis.nAxisState is greater than or equal to 3 and less than or equal to 6.

During debugging, monitoring the Axis.nAxisState variable is a very useful method as it visually displays the transitions of the axis state machine, helping to determine if the axis has an alarm, and what type of motion mode the axis is currently in (such as discrete, continuous, or synchronized).

In the program, judging the state of an axis based on Axis.nAxisState is usually more accurate and reliable compared to relying solely on the Done signal of the MC function block. This is because Axis.nAxisState provides detailed information about the current state of the axis, while the Done signal may only indicate whether the previous MC command has completed, not involving the actual state of the axis.


Therefore, familiarizing yourself with the transition conditions of the axis state diagram and carefully considering the usage logic and sequence of MC commands during programming is crucial for writing stable and reliable applications. This not only ensures the correct operation of the axis but also improves the efficiency and safety of the entire system.



Like my work? Consider a donation! 👇