This example is intended for illustrative purposes — how one can use the IEC standard in LTPS programming. ST (Structured Text) language allows implementing the simplest logic of a variable operation. To interact with the device, we use the TPS-driver which allows to manage the device variables (analog and GPIO). Let’s create an application that can switch red and green LEDs by the button click on TPS.
First, we need to create the ST program. Set important properties:
VAR greenLight, redLight : BOOL; buttonPressed : BOOL; button : BOOL; END_VAR
After creating the variables, you must select GPIO variables names and their direction.
IF button = FALSE THEN buttonPressed := TRUE; ELSIF button AND buttonPressed THEN IF greenLight = FALSE THEN greenLight := TRUE; redLight := FALSE; ELSE greenLight := FALSE; redLight := TRUE; END_IF buttonPressed := FALSE; END_IF