PLCcheck

IEC 61131-3 Standard Function Blocks: Quick Reference

Quick reference of IEC 61131-3 standard function blocks: timers (TP, TON, TOF), counters (CTU, CTD, CTUD), edge detection (R_TRIG, F_TRIG), bistable (SR, RS). With Siemens S5/S7 equivalents.

·6 min read
IEC 61131-3function blocksTPTONTOFCTUCTDR_TRIGF_TRIGSRRStimercounter

IEC 61131-3 Standard Function Blocks: Quick Reference

IEC 61131-3 defines a set of standard function blocks that every compliant PLC must support. These are the building blocks of automation programs — timers, counters, edge detectors, and bistable elements.

Timers

FBNameBehaviorSiemens S5 Equivalent
TPPulse TimerGenerates a fixed-duration pulse on rising edge of INSI (Zeit als Impuls)
TONOn-Delay TimerOutput Q = TRUE after preset time PT, while IN = TRUESD (Einschaltverzögerung)
TOFOff-Delay TimerOutput Q stays TRUE for PT time after IN goes FALSESA (Ausschaltverzögerung)

Common interface:

ParameterDirectionTypeDescription
INInputBOOLTimer start condition
PTInputTIMEPreset time (e.g., T#5s)
QOutputBOOLTimer output
ETOutputTIMEElapsed time

Note: TONR (Accumulating On-Delay Timer) is available on S7-1500 only. It is not part of the original IEC standard but is a Siemens extension.

For detailed timer syntax and examples, see our SCL Timer Reference.

Counters

FBNameBehaviorSiemens S5 Equivalent
CTUCount UpIncrements on rising edge of CU. Q = TRUE when CV ≥ PVZV (Zähler vorwärts)
CTDCount DownDecrements on rising edge of CD. Q = TRUE when CV ≤ 0ZR (Zähler rückwärts)
CTUDCount Up/DownBidirectional. QU when CV ≥ PV, QD when CV ≤ 0ZV + ZR combined

Critical migration note: S5 counter output (U Z n) tests CV > 0. IEC CTU output Q tests CV ≥ PV. These are fundamentally different conditions.

For detailed counter syntax and BCD/INT conversion, see our SCL Counter Reference and Counter Format Reference.

Edge Detection

FBNameBehaviorSiemens S5/S7 Equivalent
R_TRIGRising EdgeQ = TRUE for one scan when CLK goes FALSE→TRUEFP (Flanke positiv)
F_TRIGFalling EdgeQ = TRUE for one scan when CLK goes TRUE→FALSEFN (Flanke negativ)

Interface:

ParameterDirectionType
CLKInputBOOL
QOutputBOOL (TRUE for one scan cycle)

SCL Example:

VAR
    risingEdge : R_TRIG;
END_VAR

risingEdge(CLK := "StartButton");
IF risingEdge.Q THEN
    // Execute once on button press
    "PartsCounter" := "PartsCounter" + 1;
END_IF;

Bistable Elements

FBNameBehaviorDescription
SRSet-dominantS1 has priority over RIf both S1 and R are TRUE, Q = TRUE
RSReset-dominantR1 has priority over SIf both S and R1 are TRUE, Q = FALSE

When to use: SR for safety applications where the "set" condition must dominate. RS for general applications where "reset" (stop) should take priority over "start."

Availability Summary

Function BlockS7-300/400S7-1200S7-1500
TP, TON, TOF
TONR
CTU, CTD, CTUD
R_TRIG, F_TRIG
SR, RS

Convert Legacy Function Blocks to IEC

PLCcheck Pro identifies S5 legacy timer/counter calls (SI, SE, SD, SS, SA, ZV, ZR) and maps them to the correct IEC equivalents with parameter translation.

Upload code for function block conversion →

Part of the IEC 61131-3 Reference. Maintained by PLCcheck.ai. Not affiliated with Siemens AG or IEC.

Related Articles

Analyze your PLC code with AI

PLCcheck Pro explains, documents, optimizes, and migrates PLC code — automatically.

Try PLCcheck Pro →
← Back to Blog

Not affiliated with Siemens AG. S5, S7, STEP 5, STEP 7, and TIA Portal are trademarks of Siemens AG.