Simatic S7 SCL reference: Timers
Back to reference overview: Simatic S7 SCL reference with examples
IEC timers
IEC timers (TP, TON, TOF) should definitely be called embedded from the FBs, the description of which can be found here: Call FBs
In the case of embedding, the functions must be called from the „static” block of the calling FB (just type „TON” for the „data type”):
TON: Generate on-delay
The TON „switch-on delay” function. It monitors the positive edge of the binary signal at the „IN” input. If the signal persists for a specified „PT” time, it outputs „Q”. The timer is most commonly used to delay signals, for example: - in the case of a field signal, we want to make sure that not only one interference signal is received - in case of level signals we want to get a certain signal (many level signals „wobble”)
See: Timer operations
_FB_ TON ( | |||
IN: BOOL , | input | Start signal: The function monitors the positive edge of this binary signal. The timer start, if signal is „TRUE”. | |
PT: TIME , | input | Delay time: The delay time, example: t#12s | |
Q: BOOL , | output | Result: When the time is up, the result will be „TRUE”. | |
ET: TIME | output | Elapsed time | |
); |
TON Examples
CALL TON
TON second impuls
The example program below can be downloaded here: test_ton.scl.
Here is a description of how to import the downloaded program to the TIA Portal: Import source code to the TIA portal.
// author OB121 / Sandor Vamos // ob121.com; 2022.04.13. // TON example: sec impuls // // More information: // https://www.ob121.com/doku.php?id=de:s7:scl_reference_timers // // FB "static" variables: // secTakt: TON_TIME // q, secChange: BOOL // secCount: INT // FB "temp" variables: // tempInt: INT // tempBool: BOOL // TON, as sec impuls generator #secTakt(IN:=NOT(#q), PT:=t#1s); // For example, the "Q" parameter can be called // directly when calling "secTakt", // OR it can be referred to as: #q := #secTakt.Q; // when the time has elapsed, the block will be called: // - secChange changes its status every second // - secCount increases every second, in the range 0..9 IF #q THEN #secChange := NOT (#secChange); #secCount := #secCount + 1; IF #secCount > 9 THEN #secCount := 0; END_IF; END_IF; // monitor #tempInt := #secCount; #tempBool := #secChange;
TOF: Generate off-delay
The TOF „switch-off delay” function. It monitors the positive edge of the binary signal at the „IN” input. If the signal persists for a specified „PT” time, it outputs „Q”. The timer is most commonly used to delay signals, for example: - in the case of a field signal, we want to make sure that not only one interference signal is received - in case of level signals we want to get a certain signal (many level signals „wobble”)
See: Timer operations
_FB_ TOF ( | |||
IN: BOOL , | input | Start signal: The function monitors the positive edge of this binary signal. The timer start, if signal is „TRUE”. | |
PT: TIME , | input | Delay time: The delay time, example: t#12s | |
Q: BOOL , | output | Result: When the time is up, the result will be „TRUE”. | |
ET: TIME | output | Elapsed time | |
); |
TOF Examples
TP: Generate pulse
The TP „pulse generator” function. It monitors the positive edge of the binary signal at the „IN” input, and generates pulses in effect equal „PT” length from this. It is commonly used to extend very short-lived signals because, for example, the cycle time of a WinCC HMI is typically 1 sec. If the signals are „extended” for 2 seconds, the HMI can also process them.
See: Timer operations
_FB_ TP ( | |||
IN: BOOL , | input | Start signal: The function monitors the positive edge of this binary signal. The timer start, if signal is first time „TRUE”. | |
PT: TIME , | input | Extending time: example: t#12s | |
Q: BOOL , | output | Result: „Q” will be TRUE for the duration of the signal extension. | |
ET: TIME | output | Elapsed time | |
); |
TONR: Time accumulator
The TONR „time accumulator” function. It practically collects the times, and if the input signal „IN” has already existed for the right amount of time, it indicates a result „Q”. The timer function can be reset with the reset input „R” to set null the amount of time collected.
See: Timer operations
_FB_ TONR ( | |||
IN: BOOL , | input | Start signal: The function monitors the positive edge of this binary signal. The timer running, if signal is „TRUE”. | |
R: BOOL , | input | Reset signal: The timer function can be reset with the reset input „R” to set null the amount of time collected. | |
PT: TIME , | input | Extending time: example: t#12s | |
Q: BOOL , | output | Result: After collecting the „PT” amount of time, the „Q” output will be „TRUE”. The function can then be restarted with the „R” input. | |
ET: TIME | output | Elapsed / collected time | |
); |
End of site
Post views: 898