How to write a sequence of operations for a PLC program, with a worked example
What a sequence of operations is
It is the machine's behaviour in words and tables: the inputs and outputs, the steps in order, what ends each step, how long each step may take, and what the machine does when something does not arrive. It says what the machine does. It does not say how the program does it: timers, step numbers and interlock logic are the programmer's work.
The example in this guide is a clamp-and-press fixture: the operator loads a part and presses start, a clamp holds the part, a press comes down, holds for a second and returns, and the clamp releases. It is a made-up machine for this guide, small enough to show every idea once.
1. List every input and output
Start with what is wired, not with the steps. For each point, say what is connected and how it behaves. The PLC address can be left out if you do not know it.
| Type | What is connected | How it behaves |
|---|---|---|
| Input | Start push button | Normally open |
| Input | Part present sensor | PNP, on when a part is in the nest |
| Input | Clamp forward reed switch | PNP |
| Input | Clamp back reed switch | PNP |
| Input | Press down reed switch | PNP |
| Input | Press up reed switch | PNP |
| Input | Safety relay healthy | On when the emergency stop and guard are closed |
| Input | Air pressure switch | On when air is above the minimum |
| Output | Clamp valve | Single solenoid: on = forward, off = back |
| Output | Press valve, down coil | Double solenoid |
| Output | Press valve, up coil | Double solenoid |
| Output | Green lamp | Cycle complete |
| Output | Red lamp | Alarm |
- Sensors: PNP or NPN, and normally open or normally closed.
- Valves: single or double solenoid. A single-solenoid valve goes back when its output goes off, and the cylinder with it. A double-solenoid valve stays where it was last sent. The program must know which.
- Every cylinder end that has a switch. A cylinder with no switch can only be timed, never confirmed. Say so, and the step gets a time instead of a condition.
2. Say where home is, and what must be true before a cycle starts
Home is the state the machine waits in and returns to after a fault. For the example: clamp back, press up, all outputs off. The start conditions are what must be true before the cycle may begin: the machine is at home, the safety relay is healthy, air pressure is present, and a part is in the nest.
Also say what happens at power-up. If the press may be down when the power returns, the machine must not start a cycle from there: it needs a homing move, or an operator action, first.
3. Write the steps: action, wait, time limit, and what happens after
One row per step. The four columns after the step number are the whole method: what the machine switches, what it waits for, the longest that wait may last, and what it does if the wait runs out.
| Step | Action | Wait for | Max time | If the time runs out |
|---|---|---|---|---|
| 0 | Wait at home, all outputs off | Part present and start pressed | No limit | — |
| 1 | Clamp valve on | Clamp forward switch on | 2 s | Alarm “Clamp did not go forward”, clamp off, stop |
| 2 | Press down coil on | Press down switch on | 3 s | Alarm “Press did not reach down”, press up, clamp off, stop |
| 3 | Hold the press down | 1.0 s has passed | — | — |
| 4 | Press up coil on | Press up switch on | 3 s | Alarm “Press did not return”, stop with the clamp held |
| 5 | Clamp valve off | Clamp back switch on | 2 s | Alarm “Clamp did not release”, stop |
| 6 | Green lamp on, add 1 to the OK count | Part removed | No limit | — |
- Every wait on a sensor has a time limit. A program that waits for ever on a switch that has failed is the commonest machine hang there is.
- Each time-out names its alarm. “Clamp did not go forward” tells the operator where to look. “Cycle fault” does not.
- Each time-out says where the machine ends up. Step 4 stops with the clamp held, because releasing a part under a press that has not returned is worse than stopping.
- Waits with no limit are deliberate. Steps 0 and 6 wait for the operator, so they have none, and the table says so.
4. Add the modes
| Automatic | The cycle repeats while parts keep arriving. |
|---|---|
| One cycle per start | One part, then wait for the start button again. The example works this way. |
| Manual | A button for each output, for setting up. Say which moves must be refused: in the example, clamp back while the press is down. |
| Step by step | The sequence advances one step per button press, for proving a new machine. |
5. List the safety devices
Emergency stop, safety relay, guard switches, light curtain, two-hand start, low air pressure. The emergency stop and the guards must work in hardware, through a safety relay, whether or not the PLC is running. The program reads their state so that it stops the sequence cleanly and shows the reason.
Say what the machine should do when each one trips, and check that the hardware can do it. In the example the press valve is double-solenoid, so it stays where it was last sent: switching a PLC output off does not stop the press. Stopping it on an open guard has to come from the safety circuit and the air supply.
6. Say what else the machine should keep
- An alarm list with the likely cause of each alarm.
- Counters: OK parts, rejected parts, parts this shift.
- Settings the operator may change, each with a default and an allowed range: the press hold time, 0.5 to 5.0 s.
- Recipes, if the machine takes more than one part variant.
- Data to be logged, and where it should go.
Mistakes that make a program late
- “Then the cylinder comes back.” Which cylinder, which switch proves it, how long may it take?
- No fault behaviour. A sequence that describes only the good cycle is half a sequence. Most of a program is what happens when something does not arrive.
- Nothing about power-up. The machine will lose power in the middle of a cycle one day. Say where it should go afterwards.
- Unnamed sensors. “Sensor 3” means something only to the person who wired it. Name them by what they detect.
- Writing the logic instead of the behaviour. “Use a timer and a latch” hides what you want. “Hold the press down for one second” says it.
Send it, and get the program back
A sequence written this way is everything a programmer needs. Put yours into the free PLC program form: the form asks for the same things in the same order. We write the program for your CODESYS, Delta, Siemens or Omron controller and email it within 3 days, free, with the electrical schematic in EPLAN or AutoCAD Electrical if you want one. Operator screens are separate, quoted work: HMI programming.
Still planning the machine itself? How to specify a special purpose machine covers the brief a machine builder needs before there is a sequence at all.
Send it as it is. If something is unclear we ask first, and the 3 days run from your answer.
Questions about writing a sequence
What is a sequence of operations?
A written description of what a machine does, step by step: what it switches on in each step, what it waits for before moving to the next one, how long that may take, and what happens if it takes longer. It is the document a PLC program is written from.
How detailed does it have to be?
One row per step is enough: the action, the condition that ends the step, a maximum time and what to do when the time runs out. A paragraph in your own words works too, as long as every wait has a limit.
Do I need to know the PLC addresses?
No. Give the address if you know it. What matters is what is connected: the sensor or valve, PNP or NPN, normally open or closed, single or double solenoid. The addresses can be assigned when the program is written.
Should I describe how the program should work?
No. Describe what the machine does and what it waits for. Timers, step registers and interlocks are the programmer's job, and a sequence that prescribes them usually hides what the machine is actually meant to do.
What about safety?
List the safety devices: emergency stop, safety relay, guard switches, light curtain, two-hand start. The emergency stop and guards must work in hardware. The program reads their state and stops the sequence; it is not the safety function.
Have a job that a machine should be doing?
Send the part and the target output. You get a concept, a sequence and a budget range back — free, and with no obligation to build it with us.