Skip to content

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.

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
PROGRAM PLC_PRG
OUT0 := IN0;
OUT1 := IN1;
OUT2 := IN2;
OUT3 := IN3;
OUT4 := IN4;
OUT5 := IN5;

The six outputs can be driven as PWM at runtime — see IO Mapping › PWM outputs.

PROGRAM PLC_PRG
VAR
ramp : UINT;
END_VAR
PWM_ENABLE := 2#0000_0100; // OUT2 (GP8) becomes a PWM output
ramp := ramp + 256; // wraps on its own at 65535
PWM2 := ramp; // slow fade

The 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.

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_PRG
OUT0 := AN0 > 2048; // AN0 is a raw 12-bit count, 0...4095

See nXPico ST Examples for the temperature-alarm example — it applies identically here.