ST Examples
Every channel in IO Mapping is already exposed as a global variable through its DefaultMapping name — IN0–IN6, OUT0–OUT5, AN0–AN2, LED and TEMPERATURE are usable directly in any POU without declaring or mapping them.
Blink the onboard LED
Section titled “Blink the onboard LED”PROGRAM PLC_PRGVAR blinker : TON;END_VAR
blinker(IN := NOT blinker.Q, PT := T#500ms);IF blinker.Q THEN LED := NOT LED;END_IFDigital pass-through
Section titled “Digital pass-through”Mirror each digital input onto the corresponding output:
PROGRAM PLC_PRGOUT0 := IN0;OUT1 := IN1;OUT2 := IN2;OUT3 := IN3;OUT4 := IN4;OUT5 := IN5;Analog threshold
Section titled “Analog threshold”Turn on OUT0 when AN0 (raw 0–65535) goes past a threshold:
PROGRAM PLC_PRGOUT0 := AN0 > 40000;Temperature alarm
Section titled “Temperature alarm”PROGRAM PLC_PRGOUT5 := TEMPERATURE > 70.0; // drive an alarm output past 70 °C