* These are Tibbo BASIC/C-programmable devices and their function depends on the loaded app.
We offer many ready-to-use apps, among them a serial-over-IP (SoI) app and Modbus Gateway app.
LED Control with Button

LED Control with Button

About the Application

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.

What you need


Onboard Software


First, we need to create the ST program. Set important properties:

  1. Type - Program
  2. Task - true
  3. Device Context - tps (pre-created)
  4. Execution Type - Cycle.

Next Step

Create the local variables. Write this code in the variable area.

The variables source code:

    greenLight, redLight : BOOL;
    buttonPressed : BOOL;
    button : BOOL;

After creating the variables, you must select GPIO variables names and their direction.

Final Step

Implementation program logic.

The program source code:

IF button = FALSE THEN
    buttonPressed := TRUE;
ELSIF button AND buttonPressed  THEN
   IF greenLight = FALSE THEN
      greenLight := TRUE;
      redLight := FALSE;
      greenLight := FALSE;
      redLight := TRUE;       
   buttonPressed := FALSE;  

From now on,

you can run the program from the context menu and control LEDs on your Linux TPS.

LED Control with Button