Creating Programs

The “PLC_PRG” main program is created automatically. You can create additional programs.

  1. Right-click the corresponding application and select POU in the context menu.
  2. In the dialog assign a name and select the type and the implementation language per IEC 61131-3.
  3. Creating a Program
  4. The programs are automatically assigned to a task. If the task was deleted, you can create this again by right-clicking the application and selecting [Task Configuration] in the context menu.
  5. To assign a program to the task, click the created task and add a [Program call].
  6. Adding a Program Call
  7. A “Program call” dialog is opened.
  8. In the “POU to Call” field, enter the program name.
    Alternatively, use the Input Assistant by clicking the […] button, select the program in the new window and confirm with [OK].
  9. Entering the Program Name via the Input Assistant
  10. The program name is entered in the “Program call” dialog.
  11. To add the program call, click the [Add] button.
  12. To open and edit the added program double-click the program in the Project Structure.
  13. Depending on the implementation language you have selected under point 2, the corresponding programming editor is displayed.
  14. Programming Editor (in this example: Structured Text (ST))
  15. Write your program according to IEC 61131-3.
  16. Tip for declaring variables: If you enter a variable while programming that has not yet been declared, it is underlined with a red wavy line. In the default setting, click the variable and a light bulb button takes you to the variable declaration. To change this behavior and to open the variable declaration with [Enter], change the following setting:
    1. Open the “Options” page of the Backstage view.
    2. Click the [CODESYS Options] button.
    3. Under “Intelligent coding”, select the options “Automatically declare unknown variables” and “Activate in ST editor”.

For additional information see: