====== Simatic S7 SCL reference: Timers ====== Back to reference overview: [[de:s7:scl_reference|Simatic S7 SCL reference with examples]] ===== IEC timers ===== {{anchor:iec_timers}} IEC timers (TP, TON, TOF) should definitely be called embedded from the FBs, the description of which can be found here: [[de:s7:tia_knowhow#call_fb|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"): |< 100% 65% 35% >| |{{:de:s7:fb_call_4.png|}}|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.| |{{:de:s7:fb_call_5.png|}}|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.| ===== TON: Generate on-delay ===== {{anchor:ton}} 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: [[de:s7:scl_reference#timers|Timer operations]] {{ :de:s7:ton_iec.png |TON: Generate on-delay}} |< 100% 15% 15% 15%>| |[[de:s7:tia_knowhow#fb|_FB_]] **TON (**| | | | | |**IN:** [[de:s7:tia_datatypes#bool|BOOL]] **,**|input|**Start signal:** The function monitors the positive edge of this binary signal. The timer start, if signal is "TRUE".| | |**PT:** [[de:s7:tia_datatypes#time|TIME]] **,** |input|**Delay time:** The delay time, example: t#12s| | |**Q:** [[de:s7:tia_datatypes#bool|BOOL]] **,**|output|**Result:** When the time is up, the result will be "TRUE".| | |**ET:** [[de:s7:tia_datatypes#time|TIME]] |output|**Elapsed time**| |**);**|||| ==== TON Examples ==== === CALL TON === {{:de:s7:ton_example.png|TON Examples}} === TON second impuls === The example program below can be downloaded here: {{ :de:s7:test_ton.scl |test_ton.scl}}. \\ \\ Here is a description of how to import the downloaded program to the TIA Portal: [[de:s7:tia_knowhow#import|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 ===== {{anchor:tof}} 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: [[de:s7:scl_reference#timers|Timer operations]] {{ :de:s7:tof_iec.png |TON: Generate off-delay}} |< 100% 15% 15% 15%>| |[[de:s7:tia_knowhow#fb|_FB_]] **TOF (**| | | | | |**IN:** [[de:s7:tia_datatypes#bool|BOOL]] **,**|input|**Start signal:** The function monitors the positive edge of this binary signal. The timer start, if signal is "TRUE".| | |**PT:** [[de:s7:tia_datatypes#time|TIME]] **,** |input|**Delay time:** The delay time, example: t#12s| | |**Q:** [[de:s7:tia_datatypes#bool|BOOL]] **,**|output|**Result:** When the time is up, the result will be "TRUE".| | |**ET:** [[de:s7:tia_datatypes#time|TIME]] |output|**Elapsed time**| |**);**|||| === TOF Examples === {{:de:s7:tof_example.png|TOF Examples}} ===== TP: Generate pulse ===== {{anchor:tp}} 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: [[de:s7:scl_reference#timers|Timer operations]] {{ :de:s7:tp_iec.png |TP: Generate pulse}} |< 100% 15% 15% 15%>| |[[de:s7:tia_knowhow#fb|_FB_]] **TP (**| | | | | |**IN:** [[de:s7:tia_datatypes#bool|BOOL]] **,**|input|**Start signal:** The function monitors the positive edge of this binary signal. The timer start, if signal is first time "TRUE".| | |**PT:** [[de:s7:tia_datatypes#time|TIME]] **,** |input|**Extending time:** example: t#12s| | |**Q:** [[de:s7:tia_datatypes#bool|BOOL]] **,**|output|**Result:** "Q" will be TRUE for the duration of the signal extension.| | |**ET:** [[de:s7:tia_datatypes#time|TIME]] |output|**Elapsed time**| |**);**|||| ===== TONR: Time accumulator ===== {{anchor:tonr}} 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: [[de:s7:scl_reference#timers|Timer operations]] {{ :de:s7:tonr_iec.png |TONR: Time accumulator}} |< 100% 15% 15% 15%>| |[[de:s7:tia_knowhow#fb|_FB_]] **TONR (**| | | | | |**IN:** [[de:s7:tia_datatypes#bool|BOOL]] **,**|input|**Start signal:** The function monitors the positive edge of this binary signal. The timer running, if signal is "TRUE".| | |**R:** [[de:s7:tia_datatypes#bool|BOOL]] **,**|input|**Reset signal:** The timer function can be reset with the reset input "R" to set null the amount of time collected.| | |**PT:** [[de:s7:tia_datatypes#time|TIME]] **,** |input|**Extending time:** example: t#12s| | |**Q:** [[de:s7:tia_datatypes#bool|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:** [[de:s7:tia_datatypes#time|TIME]] |output|**Elapsed / collected time**| |**);**|||| ==== End of site ==== ~~NOCACHE~~ Post views: {{counter|total}} {{page>de:s7:foot}}