de:s7:scl_reference_timers

Simatic S7 SCL reference: Timers

Back to reference overview: Simatic S7 SCL reference with examples

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”):

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”. FBs must be called in the program in much the same way, of course the DB call must be omitted.
The image shows the data of the embedded FBs in the IDB of the calling FB. The great advantage of this method is that the program is easy to import / export / copy, as you only need one FB definition.

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

TON: Generate on-delay

_FB_ TON (
IN: BOOL ,inputStart signal: The function monitors the positive edge of this binary signal. The timer start, if signal is „TRUE”.
PT: TIME , inputDelay time: The delay time, example: t#12s
Q: BOOL ,outputResult: When the time is up, the result will be „TRUE”.
ET: TIME outputElapsed time
);

CALL TON

TON Examples

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;

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

TON: Generate off-delay

_FB_ TOF (
IN: BOOL ,inputStart signal: The function monitors the positive edge of this binary signal. The timer start, if signal is „TRUE”.
PT: TIME , inputDelay time: The delay time, example: t#12s
Q: BOOL ,outputResult: When the time is up, the result will be „TRUE”.
ET: TIME outputElapsed time
);

TOF Examples

TOF Examples

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

TP: Generate pulse

_FB_ TP (
IN: BOOL ,inputStart signal: The function monitors the positive edge of this binary signal. The timer start, if signal is first time „TRUE”.
PT: TIME , inputExtending time: example: t#12s
Q: BOOL ,outputResult: „Q” will be TRUE for the duration of the signal extension.
ET: TIME outputElapsed time
);

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

TONR: Time accumulator

_FB_ TONR (
IN: BOOL ,inputStart signal: The function monitors the positive edge of this binary signal. The timer running, if signal is „TRUE”.
R: BOOL ,inputReset signal: The timer function can be reset with the reset input „R” to set null the amount of time collected.
PT: TIME , inputExtending time: example: t#12s
Q: BOOL ,outputResult: 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 outputElapsed / collected time
);

Post views: 898

Donate

2022/04/21 15:01

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /home/www/ob121.com/lib/plugins/authplain/auth.php on line 436