Standard Library
Standard Library
Functions and function blocks that every IEC 61131-3 implementation must ship.
Functions
Pure functions — no instance, called directly.
- Type-conversion —
<SRC>_TO_<DST>,TRUNC, BCD codecs. - Arithmetic —
ABS,SQRT,LN/LOG/EXP, trig + inverse trig. - Comparison functions —
GT,GE,EQ,LE,LT,NE(the function-form of the comparison operators; useful for variadic chained checks). - Selection —
SEL,MUX,MIN,MAX,LIMIT. - String —
LEN,LEFT/RIGHT/MID,CONCAT,INSERT,DELETE,REPLACE,FIND. - Bit —
SHL,SHR,ROL,ROR. Includes the matiec emit-bug warning forSHL(BYTE#1, …).
Constants — not IEC core
IEC 61131-3 specifies the math functions but no constants. PI, E and
friends are vendor extensions, and the vendors disagree on naming +
scope. ForgeIEC offers an opt-in forgeiec_math library — but the
portable approach is to declare what you need in a
VAR_GLOBAL CONSTANT block in your project.
- Mathematical constants —
PI,E,SQRT2,GOLDEN_RATIO, … the cross-vendor table + how to declare them portably. - How to use constants and math — practical recipes
(degrees↔radians, polar↔cartesian, dB-scaling, accumulator drift,
domain validation before
SQRT/LN).
Function blocks
Stateful — declare an instance, then call the instance.