Skip to content

ST Examples

Every channel in IO Mapping is already exposed as a global variable through its DefaultMapping name — IN0IN6, OUT0OUT5, AN0AN2, LED and TEMPERATURE are usable directly in any POU without declaring or mapping them.

PROGRAM PLC_PRG
VAR
blinker : TON;
END_VAR
blinker(IN := NOT blinker.Q, PT := T#500ms);
IF blinker.Q THEN
LED := NOT LED;
END_IF

Mirror each digital input onto the corresponding output:

PROGRAM PLC_PRG
OUT0 := IN0;
OUT1 := IN1;
OUT2 := IN2;
OUT3 := IN3;
OUT4 := IN4;
OUT5 := IN5;

Turn on OUT0 when AN0 (raw 0–65535) goes past a threshold:

PROGRAM PLC_PRG
OUT0 := AN0 > 40000;
PROGRAM PLC_PRG
OUT5 := TEMPERATURE > 70.0; // drive an alarm output past 70 °C