Auto mode logic is best written as a step sequence (state machine): one integer Step holds the current state, each step has clear actions, and each transition has one condition. For the conveyor: 10 Ready → Start → 20 Wait part → entry sensor → 30 Conveying (motor on, jam timer) → exit sensor → 40 At exit (motor off) → part removed → 50 Count → 20. Stop, mode change or any alarm sends the sequence to 0.
- One step active at a time: an integer Step is easiest to read and debug
- Actions depend only on the step; transitions only on conditions
- Every moving step has a watchdog timer that raises an alarm
- Stop, mode change and alarms always lead to a defined step
Sequence logic written as a tangle of seal-in rungs works until someone needs to change it. A step chain makes the machine's behaviour readable: look at the step number, and you know exactly what the machine is waiting for.
Step 1: Design the Step Table
| Step | Name | Action (outputs) | Transition | Next |
|---|---|---|---|---|
| 0 | Idle | All off | Auto mode AND no alarm | 10 |
| 10 | Ready | Amber lamp, start lamp flash | Start pressed | 20 |
| 20 | Wait part | Motor off | DI_Entry_Sensor | 30 |
| 30 | Conveying | Cmd_Motor_Run, T_Jam running | DI_Exit_Sensor | 40 |
| 40 | At exit | Motor off | NOT DI_Exit_Sensor (part removed) | 50 |
| 50 | Count | C_Parts +1 | Always (one scan) | 20 (or 10 if batch done) |
| any | Abort | All off | Stop, manual, any alarm, T_Jam.Q | 0 |
Step 2: Run the Sequence in the Simulator
Auto sequence simulator
Switch Auto on and press Start. Toggle the entry sensor ON (part arrives), then the exit sensor ON, then OFF (part removed). Leave the exit sensor off while conveying to see the 8 s jam alarm.
Green contact = passing power. Orange moving wire = rung is true and the output is energised.
Step 3: Write It in Ladder (and ST for Comparison)
In ladder, compare the Step integer with EQ blocks to create step bits (Step_30 := Step = 30), write one transition network per step that MOVEs the next step number, and one action network per output. The same logic in ST is compact enough to read in one screen:
IF NOT Sts_Auto_Mode OR Any_Alarm OR NOT DI_Stop_PB THEN
Step := 0;
END_IF;
CASE Step OF
0: IF Sts_Auto_Mode AND NOT Any_Alarm THEN Step := 10; END_IF;
10: IF DI_Start_PB THEN Step := 20; END_IF;
20: IF DI_Entry_Sensor THEN Step := 30; END_IF;
30: IF DI_Exit_Sensor THEN Step := 40; END_IF;
40: IF NOT DI_Exit_Sensor THEN Step := 50; END_IF;
50: C_Parts_CV := C_Parts_CV + 1;
IF C_Parts_CV >= Par_Batch_Size THEN Step := 10; ELSE Step := 20; END_IF;
END_CASE;
T_Jam(IN := Step = 30, PT := T#8s);
IF T_Jam.Q THEN Alm_Jam := TRUE; END_IF;
Cmd_Auto_Run := Step = 30;Step 4: Test the Auto Sequence
| ID | Check | How to check | Pass criterion | Result |
|---|---|---|---|---|
| Auto sequence tests | ||||
| AS-01 | Normal cycle | Run 3 parts | Steps 10-20-30-40-50-20, count = 3 | |
| AS-02 | Stop mid-cycle | Press Stop in step 30 | Motor off, step 0 | |
| AS-03 | Jam | Block exit sensor | Alm_Jam after 8 s, step 0 | |
| AS-04 | Mode change | Switch to manual in step 30 | Step 0, motor off | |
| AS-05 | Restart | Reset, auto, Start | Sequence restarts from step 20 | |
Practice Exercise
Add step 35 “Slow down”: when a second sensor before the exit sees the part, reduce speed (ACS580 constant speed 2 in Lab 20). Update the step table first, then the code.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| Sequence skips steps | Several transitions in one scan | Use an integer step and ELSIF/one transition per step |
| Sequence stuck | Transition condition never TRUE | Monitor Step and the condition online |
| Count jumps by many | Step 50 held more than one scan | Leave step 50 in the same scan |
| Motor runs in step 40 | Output also written elsewhere | Actions only in Motor_Logic via Cmd_ bits |
Frequently asked questions
How do I program a sequence in PLC ladder logic?
Use an integer step variable. Create a network per transition that moves the next step number when its condition is TRUE, and drive outputs from step comparisons.
Why use an integer step instead of seal-in bits?
Only one step can be active, the current state is visible as one number and adding steps does not change existing rungs.
What is a watchdog timer in a sequence?
A timer that runs while a step waits for something. If the time is exceeded, it raises an alarm such as a jam instead of waiting forever.
Should I use SFC for sequences in Automation Builder?
SFC is supported and suits large sequences. Integer steps in LD or ST are easier for beginners and maintenance teams to follow.