Target behavior
Extend the rod with a button, hold it at the extended end for 3 seconds, then retract it automatically
What you will learn
Let's continue learning ladder logic with the air cylinder model!
This time, reproduce a motion where pressing the Piston button extends the rod, holds it extended for 3 seconds, and then retracts it.
For this ladder, you need a new instruction: the timer instruction (TMR).
Here is how to use the TMR instruction.
When using TMR, specify a timer device T and a preset time (in units of 100 ms).
In the example below, when N.O. contact X3 turns ON, T1 starts counting.
When X3 has been ON for 3 seconds, T1 turns ON and the Y3 coil turns ON. T1 stays ON while X3 is ON, and its contact opens when X3 turns OFF.
If X3 turns OFF before 3 seconds, the T1 count is reset, and when X3 turns ON again it starts counting from 0.
Now let's write the ladder using TMR!
Based on this approach, try writing the ladder yourself first.
In the simulator, you can create the wiring and ladder and actually run the 3D equipment model.
| Device | Comment |
|---|---|
| Inputs | |
X0 | Auto switch (extended) |
X1 | Auto switch (retracted) |
X2 | Piston button |
| Outputs | |
Y0 | Cylinder solenoid valve |
| Timers | |
T0 | Dwell time at extended end |
The row numbers in the figures match the row numbers in the simulator's ladder window.
On the rising edge (LDP) of X2 (Piston button), SET Y0 (solenoid valve) only when the rod is at the retracted end X1.
LDP is used here so that if the button is held down, the rod does not extend again right after retracting.
Y0 is ON and X0 (extended end) is ON, T0 counts. The preset 30 is in units of 100 ms, so it is 3 seconds.T0 turns ON, RES Y0 to retract the rod.When Y0 turns OFF, the condition on row 004 is no longer met and T0 automatically returns to 0. On the next cycle it counts 3 seconds from 0 again.
The sample wiring and ladder data can be downloaded fromGitHuband loaded with "Load wiring" and "Load ladder" in the simulator.
Key points
T0) is ON from when the count reaches the preset until the input turns OFF.