ST Examples
nXPico W shares its I/O with nXPico. 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”PROGRAM PLC_PRGOUT0 := IN0;OUT1 := IN1;OUT2 := IN2;OUT3 := IN3;OUT4 := IN4;OUT5 := IN5;Dimming an output
Section titled “Dimming an output”The six outputs can be driven as PWM at runtime — see IO Mapping › PWM outputs.
PROGRAM PLC_PRGVAR ramp : UINT;END_VAR
PWM_ENABLE := 2#0000_0100; // OUT2 (GP8) becomes a PWM output
ramp := ramp + 256; // wraps on its own at 65535PWM2 := ramp; // slow fadeThe carrier frequency is not set from ST: it is a device parameter (9200 for OUT0/OUT1, 9201 for OUT2/OUT3, 9202 for OUT4/OUT5), so you set it in the device editor and it applies when the application starts. The duty stays 0…65535 whatever frequency you pick.
The onboard LED cannot be dimmed on this board — it hangs off the CYW43 and is not a GPIO.
Analog threshold
Section titled “Analog threshold”The comparison is made directly on the raw count. To send the value over the network, once WiFi is up (see WiFi Configuration), use the library — for example by publishing it over MQTT: OPC UA, Modbus TCP and WebVisu are not available on this board.
PROGRAM PLC_PRGOUT0 := AN0 > 2048; // AN0 is a raw 12-bit count, 0...4095See nXPico ST Examples for the temperature-alarm example — it applies identically here.