Block Reference
All available function blocks with examples
Block Reference
This page lists every function block you can use in your PLC programs — both in the visual FBD editor and in Structured Text code.
Logic Blocks
Use these to combine TRUE/FALSE signals.
| Block | What it does | Example use |
|---|---|---|
| AND | TRUE only when ALL inputs are TRUE | Both sensors must be active |
| OR | TRUE when ANY input is TRUE | Either button starts the motor |
| NOT | Flips TRUE to FALSE and vice versa | Invert a sensor signal |
| XOR | TRUE when inputs are DIFFERENT | Toggle behavior |
[IMAGE: FBD editor showing AND block with two sensor inputs connected to a motor output]
Example in ST:
MotorRun := Sensor1 AND Sensor2; // Both must be active
AlarmActive := Fault1 OR Fault2; // Either fault triggers alarm
DoorClosed := NOT DoorOpen; // Invert signalTimers
Add delays to your logic. Essential for real automation — almost every program uses at least one timer.
TON — On-Delay Timer
Waits before turning on. Use when you need a delay after a condition becomes true.
Common uses: Debounce a sensor, delay a conveyor start, wait before extending a cylinder.
StartDelay(IN := StartButton, PT := T#2s);
IF StartDelay.Q THEN
ConveyorSpeed := 500.0; // Starts 2 seconds after button press
END_IFTOF — Off-Delay Timer
Stays on for a while after the input turns off. Use when something should keep running briefly.
Common uses: Keep a conveyor running after the last box passes, hold a valve open.
RunOnTimer(IN := BoxDetected, PT := T#5s);
ConveyorRun := RunOnTimer.Q; // Keeps running 5s after last boxTP — Pulse Timer
Turns on for an exact duration, then turns off. Use for timed actions.
Common uses: Extend a cylinder for a fixed time, flash a warning light, trigger a sort pulse.
PushPulse(IN := SortSignal, PT := T#500ms);
PusherExtend := PushPulse.Q; // Pushes for exactly 500ms[IMAGE: Trace view showing TON, TOF, and TP timing diagrams side by side]
Counters
Count events — how many boxes passed, how many cycles completed.
CTU — Count Up
Counts rising edges. Outputs TRUE when the count reaches the target.
BoxCounter(CU := SensorPulse, PV := 50, RESET := ResetButton);
IF BoxCounter.Q THEN
// 50 boxes counted — trigger action
BatchComplete := TRUE;
END_IFCTD — Count Down
Starts at a value and counts down to zero.
CTUD — Up/Down Counter
Counts both up and down. Useful for tracking inventory (items in minus items out).
[IMAGE: FBD editor showing a CTU counter connected to a sensor input and a comparison block]
Edge Detection
Detect the exact moment a signal changes — not that it IS true, but that it just BECAME true.
R_TRIG — Rising Edge
Pulses TRUE for one scan when the input goes from FALSE to TRUE.
Use when: You want to count button presses (not hold), trigger an action once per detection.
ButtonEdge(CLK := StartButton);
IF ButtonEdge.Q THEN
// Runs exactly once per button press
ToggleMotor := NOT ToggleMotor;
END_IFF_TRIG — Falling Edge
Pulses TRUE for one scan when the input goes from TRUE to FALSE.
Use when: You want to detect when a sensor clears (box left the zone).
Latches
Remember a state until explicitly changed. Like a light switch — stays on until you turn it off.
| Block | Behavior |
|---|---|
| SR | Set wins if both set and reset are active at the same time |
| RS | Reset wins if both are active at the same time |
MotorLatch(S := StartButton, R := StopButton OR Fault);
MotorRun := MotorLatch.Q; // Stays on until stop or faultMath Blocks
Do calculations with numbers.
| Block | Operation | Example |
|---|---|---|
| ADD | A + B | Total weight |
| SUB | A - B | Difference |
| MUL | A × B | Scale a value |
| DIV | A ÷ B | Average calculation |
| ABS | Remove negative sign | Distance regardless of direction |
| LIMIT | Clamp between min and max | Keep speed in safe range |
| MIN / MAX | Smaller / larger of two values | Safety limits |
// Clamp conveyor speed between 0 and 1000 mm/s
SafeSpeed := LIMIT(0.0, RequestedSpeed, 1000.0);Comparison Blocks
Compare two values — result is TRUE or FALSE.
| Block | Meaning | Example |
|---|---|---|
| EQ | Equal to | Temperature EQ 100.0 |
| NE | Not equal to | State NE 0 |
| GT | Greater than | Speed GT 500.0 |
| GE | Greater or equal | Count GE 10 |
| LT | Less than | Position LT 0.0 |
| LE | Less or equal | Pressure LE MaxPressure |
Selection Blocks
Choose between values based on a condition.
SEL — Binary Select
Pick one of two values based on a TRUE/FALSE condition:
// Run at 500 if in fast mode, 200 if in slow mode
Speed := SEL(FastMode, 200.0, 500.0);MUX — Multi Select
Pick from multiple values using an index number:
// Select speed based on gear (0, 1, 2, 3)
Speed := MUX(GearNumber, 0.0, 100.0, 300.0, 500.0);