Skip to content

Block library

ProtoCode includes more than 150 standard blocks. They are in the Library tab of each editor’s right panel and can also be called from ST.

  • FB (function block): has memory and needs an instance (e.g. T1 : TON). Its outputs are read as T1.Q.
  • Function: needs no instance. In Ladder and FBD it gets EN (enable) and ENO (enable out) pins.
  • Stateful function: like a function (no instance to declare) but it keeps internal state between scans.

The LD column tells whether a block is available in Ladder. All blocks are available in FBD and ST.

Block Inputs Outputs Description
TON IN, PT : TIME Q, ET : TIME On delay: Q turns on once IN has been on for PT.
TOF IN, PT : TIME Q, ET : TIME Off delay: Q stays on for PT after IN drops.
TP IN, PT : TIME Q, ET : TIME Pulse of length PT on the rising edge of IN.
Block Inputs Output Description
RTON IN, R, PT : TIME Q Accumulates time while IN is on, even if interrupted; R resets it.
TONR IN, R, PT : TIME Q On-delay timer with memory (accumulating).
RTOFF IN, R, PT : TIME Q Retentive off delay.
Block Inputs Outputs Description
CTU CU, R, PV : INT Q, CV : INT Up counter: Q when CV ≥ PV.
CTD CD, LD, PV : INT Q, CV : INT Down counter: LD loads PV; Q when CV ≤ 0.
CTUD CU, CD, R, LD, PV : INT Q, CV : INT Up/down counter.
Block Inputs Output Description
R_TRIG CLK Q One-scan pulse on the rising edge of CLK.
F_TRIG CLK Q One-scan pulse on the falling edge of CLK.
SR S1, R Q Set-dominant bistable.
RS S, R1 Q Reset-dominant bistable.
Block Pins LD Description
AND, OR, XOR, NOT IN… → OUT — Basic FBD gates (in Ladder use contacts in series/parallel).
NAND, NOR, XNOR IN0, IN1 → OUT — Negated gates.
EQ_B, NEQ_B IN0, IN1 → OUT — Boolean equality / inequality.
BUF IN → OUT — Copies a Boolean signal.
MOVE IN → OUT ✓ Copies a value.
SEL G, IN0, IN1 → OUT ✓ IN0 if G = FALSE, IN1 if G = TRUE.
MUX K : INT, IN0, IN1 → OUT ✓ Picks input number K.
Block Pins Description
ADD, SUB, MUL, DIV, MOD IN0, IN1 → OUT Add, subtract, multiply, divide, remainder.
MIN, MAX IN0, IN1 → OUT Minimum and maximum.
ABS, ROUND, FLOOR, CEIL, TRUNC IN → OUT Absolute value and rounding.
LIMIT MN, IN, MX → OUT Clamps IN between MN and MX.
SIN, COS, TAN, ASIN, ACOS, ATAN IN → OUT Trigonometry (radians).
ATAN2 Y, X → OUT Arc tangent of Y/X with quadrant.
SQRT, EXP, LN, LOG10 IN → OUT Square root, exponential and logarithms.
POW, EXPT IN, EXP → OUT Power.
Block Pins Description
GT, GE, LT, LE, EQ, NEQ IN0, IN1 → OUT : BOOL >, ≥, <, ≤, =, ≠
Block Pins Description
SCALE IN, InMin, InMax, OutMin, OutMax → OUT Linear conversion between two ranges (e.g. ADC counts to °C).
NORMALIZE IN, MN, MX → OUT Maps IN to the 0…1 range.
DEADBAND IN, Center, Band → OUT Dead band around Center.
Block Pins Description
ADD_TIME, SUB_TIME IN0, IN1 : TIME → OUT : TIME Add and subtract times.
MUL_TIME, DIV_TIME IN : TIME, K : REAL → OUT : TIME Multiply or divide a time by a factor.

Signal processing and control (stateful function)

Section titled “Signal processing and control (stateful function)”
Block Pins Description
FILTER_LP IN, Tau → OUT First-order low-pass filter.
FILTER_HP IN, Tau → OUT High-pass filter.
INTEGRATOR IN, R → OUT Integrates IN over time; R resets.
DERIVATIVE IN → OUT Derivative of IN.
SLEW IN, Rate → OUT Rate-of-change limiter (ramp).
HYST IN, High, Low → OUT : BOOL Comparator with hysteresis.
MEDIAN3, MEDIAN5 IN → OUT Median of the last 3 or 5 samples.
PID SP, PV, Kp, Ki, Kd, OutMin, OutMax → OUT PID controller with clamped output. Run it in a periodic task.
Block Pins Description
ALM_LATCH Trigger, R → Q Alarm latched until acknowledged with R.
ALM_DELAY_ON Cond, Delay : TIME → Q Alarm raised if Cond lasts longer than Delay.
ALM_DELAY_OFF Cond, Delay : TIME → Q Alarm held for Delay after Cond clears.
EVENT_COUNTER Event, R → CV : INT Counts Event edges.
Category Blocks
16-bit bitwise AND_W, OR_W, XOR_W, NOT_W, MASK_W, SHL_W, SHR_W, ROL_W, ROR_W, BIT_SET, BIT_RESET, BIT_TOGGLE, BIT_TEST
32-bit bitwise AND_DW, OR_DW, XOR_DW, NOT_DW, SHL_DW, SHR_DW, ROL_DW, ROR_DW
Shift SHL, SHR, ROL, ROR (IN, N)
Packing MERGE_BYTES, MERGE_WORDS, LOW_BYTE, HIGH_BYTE, LOW_WORD, HIGH_WORD
Conversions <SOURCE>_TO_<TARGET> between BOOL, INT, DINT, WORD, DWORD, REAL and TIME (e.g. INT_TO_REAL, REAL_TO_INT, TIME_TO_DINT)
System CYCLE_TIME (scan time in ms), NOW_MS, TICK_MS, RANDOM, RANDOM_RANGE (MN, MX)

The functions and function blocks you create in the project also appear in the library and are used just like the standard ones. See Functions and function blocks.