Programming in IEC 61131-3 languages

Opening and creating the POU, creating variables

If you have created the project with the project template for an empty project for your controller (Creating a new project), a Program Organization Unit (POU) with the name Main is created automatically in the COMPONENTS area under Programming (x), Local (x), Programs (x).

Opening a POU

To open a POU, proceed as follows:

  • In the COMPONENTS area, open the Programming (x), Local (x), Programs (x) section.
  • Double-click on the desired POU, for example Moving_Light_Prog.

The editor group for the selected POU opens. You are prompted to select the programming language for the first worksheet of the POU.

61131-Programmierung_Programmiersprache_waehlen_fuer_Arbeitsblatt_1.png
  • Click on the desired programming language.

Creating a new POU

To create a new POU, proceed as follows:

  • In the COMPONENTS area, open the Programming (x), Local (x), Programs (x) section.
  • Right-click Programs (x).
  • In the context menu, select Add Program.
Kontextmenue_Programm_hinzufuegen.png

The newly created POU is inserted in the Programming (x), Local (x), Programs (x) section in the COMPONENTS area.

  • Right-click to open the context menu for the newly created POU.
  • Select Rename.
  • Enter a unique and meaningful name. The name must not contain any spaces.
  • Press the Enter key to apply the entry.
  • Double-click on the desired POU to open the editor group for the POU.

You are prompted to select the programming language for the first worksheet of the POU.

  • Click on the desired programming language.

The editor group for the POU opens. You can now create the necessary variables.

Creating variables

  • Select the Variables editor.
  • Create the variables that you need for the selected POU.
Variablen_fuer_eine_POE_anlegen.png

Once you have created all of the necessary variables, create the program for the selected POU, see Creating a program.

Creating a program

To create a program, proceed as follows:

  • Select the program editor.

By default, the program editor is referred to as Code. You can change the designation of the program editor as desired.

  • Create the program.
Beispielprogramm_Lauflicht_in_FBD.png

Adding worksheets

The program for a POU can consist of several worksheets and different programming lan­guages. For each required programming language, add a corresponding worksheet (code worksheet) to the POU. Each worksheet is inserted in the POU editor group as an additional Code editor.
To add additional worksheets to a POU, proceed as follows:

  • Select a worksheet in the program editor.
  • Click on the arrow on the right next to the designation of the program editor.
  • From the drop-down list that opens, select the desired code worksheet.
Code-Arbeitsblatt_hinzufuegen.png

Creating functions and function blocks

Creating a function or function block

To create your own functions and function blocks, proceed as follows:

  • In the COMPONENTS area, open the Programming (x), Local (x), Functions & Function Blocks (x) section.
  • Right-click Functions & Function Blocks (x).
  • In the context menu, select the appropriate entry for the new function or function block to be created.
Kontextmenue_Fkt_oder_Fkt-Baustein_hinzufuegen.png

The newly created function or function block is inserted in the Programming (x), Local (x), Functions & Function Blocks (x) section in the COMPONENTS area.

  • Right-click to open the context menu for the newly created function or function block.
  • Select Rename.
  • Enter a unique and meaningful name, Moving_Light in the example.

The name must not contain any spaces.

  • Press the Enter key to apply the entry.
Neu_angelegter_Funktionsbaustein.png

Once you have created a new function or function block, you must program the logic for the function or function block. To do this, first select the programming language for the first worksheet.

Selecting the programming language for the first worksheet

  • In the COMPONENTS area, open the Programming (x), Local (x), Functions & Function Blocks (x) section.
  • Double-click on the function or function block.

The editor group for the function or function block opens. You are prompted to select the programming language for the first worksheet of the function or function block.

Erstes_Code-Arbeitsblatt_fuer_neuen_Funktionsbaustein.png
  • Click on the desired programming language.

Creating variables

Once you have chosen the programming language, create the required variables. To do this, proceed as follows:

  • Select the Variables editor.
  • Create the variables that you need to program the function or function block.
Variablen_fuer_einen_Funktionsbaustein_anlegen.png

Once you have created all of the required variables, program the logic for the function or function block.

Programming logic

  • Select the Code editor.
  • Create the program.
Logik_eines_Funktionsbausteins_programmieren.png

Adding worksheets

The program can consist of several worksheets and different programming languages. For each required programming language, add a corresponding worksheet (code worksheet) to the function or function block. Each worksheet is inserted in the editor group for the function or function block as another Code editor.
To add additional worksheets to a function or function block, proceed as follows:

  • Select a worksheet in the program editor.
  • Click on the arrow on the right next to the designation of the program editor.
  • From the drop-down list that opens, select the desired code worksheet.

 

 

 


• Published/reviewed: 2024-12-10  ☃  Revision 075 •