Standard function blocks
Standard function blocks
The Function Blocks defined in IEC 61131-3 second annex (normative) — every implementation, including matiec, must provide them. They split into four families:
Bistables
State elements with S / R set / reset inputs. Behaviour
depends on which input has priority.
SR— Set-dominant bistable.S1(set) wins overR.RS— Reset-dominant bistable.R1(reset) wins overS.
Edge detectors
One-shot pulse on a BOOL transition.
Counters
Hold an INT count, advanced by edges on the count input.
Timers
Measure elapsed time in TIME units.
Common patterns
Every standard FB follows the same use pattern:
- Declare an instance variable in the calling POU’s
VARsection:myInstance : <FB_TYPE>;. - Call the instance every cycle (or conditionally),
passing the inputs as named parameters:
myInstance(IN := x, PT := T#100ms);. - Read the outputs through the instance:
IF myInstance.Q THEN ... END_IF;.
The full pattern with declaration is documented at Function and FB calls > FB instances vs. function calls.