Professional Documents
Culture Documents
Programming
PowerTools Pro
Applications using
State Machine
Techniques
Most all programmable devices can benefit from using a State Machine programming technique. The
general concept of a State Machine is to structure the program so that it simply moves from one state
to the next, without the ability to move anywhere else.
Program flow is very easily tracked and documented, and race conditions in program logic can be
eliminated.
This application note show how a State Machine is programmed into a user program, where the master
axis, which contains the state machine program, issues Modbus Master commands to a slave axis.
While Modbus Master messaging is used in this example, any type of commands or machine control
can be sequenced with a State Machine.
This application note simply is intended to show the reader the State Machine techniques, it does not
detail how the Modbus message commands function, how user variables are configured or how the
program syntax functions.
Basic Setup
To understand our application example, a few screen shots are show below.
Explanation:
When the Y axis receives a binary one on Modbus register 1, the Y axis will initiate its home routine.
When the Y axis receives a status request on Modbus register 10001, the Y axis will return a 1 if the
AbsolutePositionValid register is true, or will return a 0 if false.
Now that the Y axis registers are mapped, the X axis can be programmed with the state machine.
The program location and flow can easily be monitored by monitoring the var.MachState variable in the
watch window. A state machine can be forced into a particular state by simply using the watch window
and writing the desired value to the variable var.
MachState
The entire state machine program can be viewed in the PowerTools application files accompanying this
application note.