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.
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
| FB | Name | Behavior | Siemens S5 Equivalent |
|---|---|---|---|
| TP | Pulse Timer | Generates a fixed-duration pulse on rising edge of IN | SI (Zeit als Impuls) |
| TON | On-Delay Timer | Output Q = TRUE after preset time PT, while IN = TRUE | SD (Einschaltverzögerung) |
| TOF | Off-Delay Timer | Output Q stays TRUE for PT time after IN goes FALSE | SA (Ausschaltverzögerung) |
Common interface:
| Parameter | Direction | Type | Description |
|---|---|---|---|
| IN | Input | BOOL | Timer start condition |
| PT | Input | TIME | Preset time (e.g., T#5s) |
| Q | Output | BOOL | Timer output |
| ET | Output | TIME | Elapsed 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
| FB | Name | Behavior | Siemens S5 Equivalent |
|---|---|---|---|
| CTU | Count Up | Increments on rising edge of CU. Q = TRUE when CV ≥ PV | ZV (Zähler vorwärts) |
| CTD | Count Down | Decrements on rising edge of CD. Q = TRUE when CV ≤ 0 | ZR (Zähler rückwärts) |
| CTUD | Count Up/Down | Bidirectional. QU when CV ≥ PV, QD when CV ≤ 0 | ZV + 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
| FB | Name | Behavior | Siemens S5/S7 Equivalent |
|---|---|---|---|
| R_TRIG | Rising Edge | Q = TRUE for one scan when CLK goes FALSE→TRUE | FP (Flanke positiv) |
| F_TRIG | Falling Edge | Q = TRUE for one scan when CLK goes TRUE→FALSE | FN (Flanke negativ) |
Interface:
| Parameter | Direction | Type |
|---|---|---|
| CLK | Input | BOOL |
| Q | Output | BOOL (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
| FB | Name | Behavior | Description |
|---|---|---|---|
| SR | Set-dominant | S1 has priority over R | If both S1 and R are TRUE, Q = TRUE |
| RS | Reset-dominant | R1 has priority over S | If 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 Block | S7-300/400 | S7-1200 | S7-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
S5 Timer Conversion: KT Values to IEC Timers
Complete guide to converting Siemens S5 KT timer values to S7 IEC timers (TON, TOF, TP). Includes BCD format explanation, conversion table with 20+ examples, and behavior differences between S5 and IEC timers.
12 min read
migration-guideMigrating S5 Counter Programs (Z/ZV/ZR) to S7
How to migrate S5 counter programs to S7. Covers ZV (count up), ZR (count down), BCD format differences, S7 equivalents (S_CU, S_CD, CTU, CTD, CTUD), and common pitfalls.
10 min read
migration-guideConverting Ladder Logic to Structured Text: Why and How
When and how to convert PLC ladder logic (LD/KOP/LAD) to Structured Text (ST/SCL). Covers the benefits, conversion patterns, what to keep in ladder, and practical examples.
8 min read
Analyze your PLC code with AI
PLCcheck Pro explains, documents, optimizes, and migrates PLC code — automatically.
Try PLCcheck Pro →Not affiliated with Siemens AG. S5, S7, STEP 5, STEP 7, and TIA Portal are trademarks of Siemens AG.