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.

BlockWhat it doesExample use
ANDTRUE only when ALL inputs are TRUEBoth sensors must be active
ORTRUE when ANY input is TRUEEither button starts the motor
NOTFlips TRUE to FALSE and vice versaInvert a sensor signal
XORTRUE when inputs are DIFFERENTToggle 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 signal

Timers

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_IF

TOF — 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 box

TP — 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_IF

CTD — 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_IF

F_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.

BlockBehavior
SRSet wins if both set and reset are active at the same time
RSReset wins if both are active at the same time
MotorLatch(S := StartButton, R := StopButton OR Fault);
MotorRun := MotorLatch.Q;  // Stays on until stop or fault

Math Blocks

Do calculations with numbers.

BlockOperationExample
ADDA + BTotal weight
SUBA - BDifference
MULA × BScale a value
DIVA ÷ BAverage calculation
ABSRemove negative signDistance regardless of direction
LIMITClamp between min and maxKeep speed in safe range
MIN / MAXSmaller / larger of two valuesSafety 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.

BlockMeaningExample
EQEqual toTemperature EQ 100.0
NENot equal toState NE 0
GTGreater thanSpeed GT 500.0
GEGreater or equalCount GE 10
LTLess thanPosition LT 0.0
LELess or equalPressure 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);

On this page