In the world of industrial automation, time is the fourth dimension of logic. A Programmable Logic Controller (PLC) does not just react to "what" is happening (inputs), but also to when it happens and for how long. The Siemens S7-1200 PLC utilizes the IEC 61131-3 standard for timers, providing a robust, predictable, and highly accurate method for controlling temporal events.
This manual explores
the four fundamental IEC timers TON (On-Delay), TOF (Off-Delay), TP
(Pulse), and TONR (Accumulator) through the lens of a practical
four-motor control system.
2. Theoretical
Foundation: How Timers Work in S7-1200
Unlike old legacy
timers that relied on limited hardware registers, IEC timers in the S7-1200 are
"Function Blocks" (FBs). When you call an IEC timer in TIA Portal,
the system creates a Data Block (DB) to store the timer’s status,
including its start time, elapsed time, and current state.
IEC
Timer Block
- IN (Input): The digital signal that triggers the
timer.
- PT (Preset Time): The target duration. In TIA Portal, this
is written in the format T#10s, T#5m20s, or T#100ms.
- Q (Output): The resulting logic state that controls
your hardware (e.g., a Motor).
- ET (Elapsed Time): A dynamic value showing exactly how much
time has passed since the timer started.
- R (Reset): (Specific to TONR) The signal used to
clear the stored time value.
The
Four Essential Timers
I. TON: The
On-Delay Timer ("The Delay Starter")
The TON timer
is the most common instruction in automation. Its primary purpose is to wait
for a specific condition to remain "True" for a set period before
acting.
Industrial
Application: Imagine a
conveyor belt. When a sensor detects a box (Input), we don't want to trigger a
reject arm immediately. We wait 2 seconds (TON) to ensure the box is perfectly cantered.
Logic Behaviour:
- When IN transitions from 0 to 1, the timer
starts counting.
- If IN stays at 1 until ET reaches PT, the
output Q turns ON.
- If IN drops to 0 at any point, ET
immediately resets to 0, and Q turns OFF.
The
Off-Delay Timer
The TOF timer
is the inverse of the TON. It is used to keep an output active for a period after
the input signal has disappeared.
Industrial
Application: Consider a
cooling fan for a high-temperature oven. When the oven is turned OFF (Input
goes to 0), we want the fan (Output) to continue running for 5 minutes (TOF) to
prevent heat damage.
Logic Behaviour:
- When IN is 1, Q is immediately 1.
- When IN transitions from 1 to 0, the timer
starts counting.
- Q remains 1 until ET reaches PT.
- Once the time expires, Q turns OFF.
The
Pulse Timer
The TP timer
generates an output for a fixed duration, regardless of how long the input
signal lasts. It is a "Fire and Forget" instruction.
Industrial
Application: Think of an
automatic lubrication system. When a machine starts (Input pulse), a pump
(Output) needs to run for exactly 10 seconds (TP) to oil the gears. It doesn't
matter if the machine start signal was a short tap or a long hold; the oiling
time is fixed.
Logic Behaviour:
- A 0 to 1 transition at IN triggers the
timer.
- Q turns ON immediately.
- Q stays ON for exactly the duration of PT.
- Even if IN changes back to 0 or pulses
again during the count, the timer ignores it until the pulse is finished.
TONR:
The Time Accumulator
The TONR is a
specialized version of the TON. While a standard TON resets if the input is
lost, the TONR retains the elapsed time.
Industrial
Application: Maintenance
tracking. A motor needs servicing after 100 hours of total runtime. The TONR
accumulates time only when the motor is running. If the motor stops for a
break, the timer pauses. When the motor restarts, it continues from the last
second.
Logic
Behaviour:
- When IN is 1, the timer counts.
- When IN is 0, the timer pauses but keeps
the ET value.
- When IN is 1 again, it continues counting
from the paused value.
- Q turns ON once the accumulated time
reaches PT.
- The timer only resets to 0 when the
R (Reset) input is activated.
Problem Solution:
The Four-Motor Control System
To demonstrate these
timers in a real-world scenario, we will implement a program for a factory
floor with four distinct motor behaviours.
Hardware
Address Mapping
|
Component |
PLC Address |
Timer Type |
Goal |
|
Switch 1 |
I0.0 |
TON |
Start Motor 1 after a 10s delay. |
|
Switch 2 |
I0.1 |
TOF |
Stop Motor 2 10s after the switch is turned
OFF. |
|
Switch 3 |
I0.2 |
TP |
Run Motor 3 for exactly 10s upon a tap. |
|
Switch 4 |
I0.3 |
TONR |
Accumulate 10s of runtime for Motor 4. |
|
Reset Button |
I0.4 |
— |
Reset the Accumulator (Motor 4). |
|
Motor 1 |
Q0.0 |
— |
Output 1 |
|
Motor 2 |
Q0.1 |
— |
Output 2 |
|
Motor 3 |
Q0.2 |
— |
Output 3 |
|
Motor 4 |
Q0.3 |
— |
Output 4 |
Network
Logic Description
Network 1: Safety
Delay (Motor 1)
In this network, we
use the TON instruction. When the operator flips Switch 1 (I0.0),
a siren might sound, but the motor does not move. After exactly 10 seconds,
the TON instruction evaluates that the condition has been met and sets Q0.0
to High. This ensures that the motor only starts if the switch is held or
locked in the ON position.
Network 2:
Cool-Down Logic (Motor 2)
Here, the TOF
instruction is used. As soon as Switch 2 (I0.1) is turned ON, Motor 2
(Q0.1) starts spinning. When the operator finishes their work and turns the
switch OFF, the TOF starts its 10-second countdown. This keeps the motor
running (perhaps for ventilation) before finally shutting down automatically.
Network 3:
Precision Pulse (Motor 3)
In this network, we
use the TP instruction. This is perfect for a "Start"
push-button. When Switch 3 (I0.2) is pressed, Motor 3 (Q0.2)
triggers. Even if the operator releases the button or gets distracted and
presses it again, the motor will run for exactly 10 seconds—no more, no less.
Network 4: Runtime
Accumulation (Motor 4)
Using the TONR,
we track the total time Switch 4 (I0.3) has been active. If the operator
runs the motor for 4 seconds, then stops for lunch, and then runs it for 6 more
seconds, the timer hits the 10-second mark. Motor 4 (Q0.3) then
activates. This motor will stay ON forever until the Reset (I0.4) signal
is received, clearing the memory of the timer.
Runtime
Test Cases & Validation
To ensure the program
is working correctly in TIA Portal, engineers must perform "Runtime
Testing." Below are the expected results:
|
Test Sequence |
Input State |
Timer State |
Output State |
Result |
|
1 |
I0.0 = 1 |
TON counting |
Q0.0 = 0 |
Motor 1 waiting... |
|
2 |
I0.0 = 1 (after 10s) |
TON Done |
Q0.0 = 1 |
Motor 1 Starts |
|
3 |
I0.1 = 0 (was 1) |
TOF counting |
Q0.1 = 1 |
Motor 2 still running... |
|
4 |
I0.1 = 0 (after 10s) |
TOF Done |
Q0.1 = 0 |
Motor 2 Stops |
|
5 |
I0.2 = 1 (pulse) |
TP counting |
Q0.2 = 1 |
Motor 3 runs for 10s |
|
6 |
I0.3 = 1 (intermittent) |
TONR adding |
Q0.3 = 0 |
Motor 4 accumulating... |
|
7 |
I0.4 = 1 |
TONR Reset |
Q0.3 = 0 |
Time cleared to 0s |
Best Practices for TIA Portal Timers
Data Block Management: Every IEC timer requires a DB. In large programs, use "multi-instance" DBs to keep your project tree organized rather than having hundreds of individual Timer DB
Scan Cycle Awareness: PLCs execute code from top to bottom. If a timer finishes in the middle of a scan, the outputs further down the program will react immediately, while outputs above it will wait for the next scan.
Memory Retention: If the PLC loses power, standard timers usually reset. If you need a timer to remember its value after a power failure, ensure the Timer DB is marked as "Retentive.
Avoid Using 'Global' Timers for Local Logic: Always try to keep your timers local to the Function Block they are serving to prevent "crosstalk" or logic errors where two different parts of the program try to use the same timer.
The implementation of
IEC timers in the S7-1200 PLC is a foundational skill for any automation
engineer. By mastering the differences between ON-delay, OFF-delay, Pulse, and
Accumulator logic, you can design systems that are not only functional but also
safe and energy-efficient. Whether it is delaying a motor start for safety or
ensuring a cooling fan runs after a stop, timers provide the precision required
for modern industrial excellence.
No comments:
Post a Comment