step-ladder-sequence
step-ladder-sequence
step-ladder-sequence
step-ladder-sequence
step-ladder-sequence

How to write a PLC step sequence program

June 14, 2017
Define a machine's control modes, main cycles and sequence steps before a program is written, or you'll just write scatter code and confuse others

Many programmers in the automation industry struggle with what is the best way to write a PLC program for machine automation. There are also many programmers who know the best way or right tool to use and proceed to use many of the IEC 61131 programs on a single machine. Whether it's the inexperienced or the experienced writing the PLC program, simple ladder logic and a step sequence is often the best solution.

No doubt there are arguments for using a variety of programming methods to control a machine, but breaking down a machine cycle into modular pieces of code and defining the automatic sequence steps before writing a single line of code is a great starting point. Then, using ladder diagram programming, and maybe few function blocks or add-on instructions, the program can be quickly written, and it will be easy to support for the long term.

It is necessary to define the machine's mode control and functions to start, stop, pause or exit a machine cycle. Write it down. Then break down the step sequence into manageable size cycles, often two or more per machine or station, and type up a software functional document detailing what triggers a cycle, what its home position is and each cycle's step sequence.

In its basic form, a machine automation sequence typically has two to four control modes. Typical control modes include automatic, step, manual and no mode. While starting, running, waiting, faulted and stopping may be machine states, they’re not modes and are a subject outside the scope of this column.

Automatic mode continuously cycles the machine during production. Step mode runs each step or several steps of a sequence each time a step button is pressed and is useful during machine setup and troubleshooting. Manual mode allows actuators to be moved through use of HMI buttons or operator pushbuttons.

Modes enable program logic such as ok to start a cycle, automatic sequence in cycle and step sequence cycle, pause cycle and cycle stop functions. Where the work happens is in the automatic step sequence.

For example, a pick and place (P&P) machine may have two automatic cycles, a pick sequence and a place sequence. Each cycle begins with steps to home the machine or station automation and then typically waits at mid-sequence step until a machine condition or tooling position is met or based on part presence or absence. While there may be many other requirements to continue a sequence to the next step, logically, a part present at pickup bit and no part in gripper bit will start the pick sequence. Logically, for the place cycle to start, a part present in gripper bit and no part at the place position bit will start the sequence. 

For this discussion, the motions used in this pick and place machine include a gripper raise and lower cylinder, a gripper extend and retract cylinder and a gripper open and close actuator, all with the related end of travel sensors.

With no part in the gripper, the home position for the P&P is with the gripper raised, retracted and open. However, the home position may vary. With a part in the gripper, the home position is with the gripper raised, extended and closed. The sequence simply moves the tooling to the correct position at the start of a cycle, enabling the tooling to be in any position when the cycle begins.

When triggered, the pick sequence homes the P&P moving it above the pickup position using the following sequence steps: raise gripper, move to pickup, open gripper. When at the home position, the next step waits for a part present at pickup. With a part present, the step sequence continues with lower gripper, close gripper, set part present memory, raise gripper and move to above the place position where the pick cycle complete bit is set ending the pick sequence, resetting all step output coils and the sequence repeats. A fault followed by a reset button press can complete a cycle, as well.

The place step sequence operates in a similar fashion but is only started when a part is present in the gripper, and the pick sequence is not in cycle. In any step sequence, it is important to include steps at the beginning and perhaps the end of the cycle to home the machine and tooling before work is performed, and part tracking bits are set and reset.

Feel free to add steps to the end of a pick sequence that are the same as at the start of a place sequence; the program will only need one scan to solve the logic, but it will confirm a home position and may speed up the machine by getting the tooling closer to the work step.

The completed step sequence ladder diagram coils must be readable as the sequence of operation, in order, from top to bottom of the program logic. Don't create scatter code. Feel free to add steps such as check part tracking for good part, wait for dial to index and save part status. Make the logic clearly shows current work being done and then tie it to outputs logically as Step A and not Step B.

There is much more to writing a proper machine PLC program, but a well-written and documented step sequence can tolerate poorly defined memory usage and other program issues. Its simplicity helps encourage adding extra sequence steps to highlight the work being done at any point in the cycle.

About the author
Dave Perkon is technical editor for Control Design. He has engineered and managed automation projects for Fortune 500 companies in the medical, automotive, semiconductor, defense and solar industries.
About the Author

Dave Perkon | Technical Editor

Dave Perkon is contributing editor for Control Design. He has engineered and managed automation projects for Fortune 500 companies in the medical, automotive, semiconductor, defense and solar industries.