Creating Programs
The “PLC_PRG” main program is created automatically. You can create additional programs.
- Right-click the corresponding application and select POU in the context menu.
- In the dialog assign a name and select the type and the implementation language per IEC 61131-3.
- 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.
- To assign a program to the task, click the created task and add a [Program call].
- A “Program call” dialog is opened.
- 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]. - The program name is entered in the “Program call” dialog.
- To add the program call, click the [Add] button.
- To open and edit the added program double-click the program in the Project Structure.
- Depending on the implementation language you have selected under point 2, the corresponding programming editor is displayed.
- Write your program according to IEC 61131-3.
- 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:
- Workspace > “Programming” Workspace
- “Programming” Workspace > Task Configuration
- Panels > Program Structure