
- •1 A Brief Introduction to CoDeSys
- •1.1 What is CoDeSys
- •1.2 Overview of CoDeSys Functions...
- •1.3 Overview on the user documentation for CoDeSys
- •2 What is What in CoDeSys
- •2.1 Project Components...
- •2.2 Languages...
- •2.2.1 Instruction List (IL)...
- •2.2.2 Structured Text (ST)...
- •2.2.3 Sequential Function Chart (SFC)...
- •2.2.4 Function Block Diagram (FBD)...
- •2.2.5 The Continuous Function Chart Editor (CFC)...
- •2.2.6 Ladder Diagram (LD)...
- •2.3 Debugging, Online Functions...
- •2.4 The Standard...
- •3 We Write a Little Program
- •3.1 Controlling a Traffic Signal Unit...
- •3.2 Visualizing a Traffic Signal Unit...
- •4 The Individual Components
- •4.1 The Main Window...
- •4.3 Managing Projects...
- •4.4 Managing Objects in a Project...
- •4.5 General Editing Functions...
- •4.8 Help when you need it...
- •5 Editors in CoDeSys
- •5.1 This is for all Editors...
- •5.2 Declaration Editor...
- •5.2.1 Working in the Declaration Editor
- •5.2.3 Pragma instructions in the Declaration Editor
- •5.3 The Text Editors...
- •5.3.1 Working in text editors
- •5.3.2 The Instruction List Editor...
- •5.3.3 The Editor for Structured Text...
- •5.4 The Graphic Editors...
- •5.4.1 Working in graphic editors
- •5.4.2 The Function Block Diagram Editor...
- •5.4.3 The Ladder Editor...
- •5.4.4 The Sequential Function Chart Editor...
- •5.4.5 The Continuous Function Chart Editor (CFC)...
- •6 The Resources
- •6.1 Overview of the Resources
- •6.2 Global Variables, Variable Configuration, Document Frame
- •6.2.1 Global Variables...
- •6.2.2 Variable Configuration...
- •6.2.3 Document Frame...
- •6.3 Alarm Configuration
- •6.3.1 Overview
- •6.3.2 General information on alarms, Terms
- •6.3.3 Alarm classes
- •6.3.4 Alarm groups
- •6.3.5 Alarm saving
- •6.3.6 'Extras' Menu: Settings
- •6.4 Library Manager...
- •6.6 PLC Configuration...
- •6.6.1 Overview
- •6.6.2 Working in the PLC Configuration...
- •6.6.3 General Settings in the PLC Configuration
- •6.6.4 Custom specific parameter dialog
- •6.6.5 Configuration of an I/O Module...
- •6.6.6 Configuration of a Channel
- •6.6.7 Configuration of Profibus Modules...
- •6.6.8 Configuration of CAN modules...
- •6.6.9 Configuration of a CanDevice (CANopen Slave)
- •6.6.10 PLC Configuration in Online Mode
- •6.6.11 Hardware scan/State/Diagnosis information from the PLC
- •6.7 Task Configuration...
- •6.7.1 Working in the Task Configuration
- •6.7.2 System Events
- •6.7.3 Taskconfiguration in Online Mode
- •6.8 Watch and Receipt Manager...
- •6.8.1 Overview
- •6.8.2 Watch and Receipt Manager in the Offline Mode
- •6.8.3 Watch and Receipt Manager in the Online Mode
- •6.9 The Sampling Trace
- •6.9.1 Overview and Configuration
- •6.9.2 Display of the Sampling Trace
- •6.9.3 'Extras' 'Save Trace'
- •6.9.4 'Extras' 'External Trace Configurations'
- •6.10 Workspace
- •6.11 Parameter Manager ..
- •6.11.1 Overview, Activating
- •6.11.2 The Parameter Manager Editor, Overview
- •6.11.3 Parameter List Types and Attributes
- •6.11.4 Managing parameter lists
- •6.11.5 Editing parameter lists
- •6.11.6 Parameter Manager in Online Mode
- •6.11.7 Export / Import of parameter lists
- •6.12 Target Settings
- •6.13 The PLC-Browser
- •6.14 Tools
- •6.14.1 Properties of available Tool Shortcuts (Object Properties)
- •6.14.2 Managing Tool Shortcuts
- •6.14.3 Frequently asked questions on Tools
- •7.1 What is ENI
- •7.2 Preconditions for Working with an ENI project data base
- •7.3 Working with the ENI project data base in CoDeSys
- •7.4 Object categories concerning the project data base
- •8 DDE Interface
- •8.1 DDE interface of the CoDeSys programming system...
- •8.2 DDE communcation with the GatewayDDE Server...
- •9 The License Management in CoDeSys
- •9.1 The License Manager
- •9.1.1 Creating a licensed library in CoDeSys
- •10 APPENDIX
- •Appendix A: IEC Operators and additional norm extending functions
- •Arithmetic Operators...
- •Bitstring Operators...
- •Selection Operators
- •Comparison Operators...
- •Address Operators...
- •Calling Operators...
- •Type Conversions...
- •Numeric Operators...
- •Appendix B: Operands in CoDeSys
- •Constants
- •Variables
- •Addresses
- •Functions
- •Appendix C: Data types in CoDeSys
- •Standard data types
- •Defined data types
- •Appendix D: The CoDeSys Libaries
- •The Standard.lib library
- •String functions...
- •Bistable Function Blocks...
- •Trigger...
- •Counter...
- •Timer...
- •The Util.lib library
- •BCD Conversion
- •Bit-/Byte Functions
- •Mathematic Auxiliary Functions
- •Controllers
- •Signal Generators...
- •Function Manipulators...
- •Analog Value Processing...
- •The AnalyzationNew.lib library
- •The CoDeSys System Libraries
- •Appendix E: Operators and Library Modules Overview
- •Appendix F: Command Line-/Command File
- •Command Line Commands
- •Command File (cmdfile) Commands
- •Appendix G: Siemens Import
- •Import from a SEQ Symbol File
- •Import from a S5 Project File
- •Converting S5 to IEC 61131-3
- •Appendix H: Target Settings in Detail
- •Settings in Category Target Platform
- •Appendix I: Use of Keyboard
- •Appendix J: Compiler Errors and Warnings
- •Warnings
- •Errors

Declaration Editor...
When a variable is open, all of its components are listed after it. A minus sign appears in front of the variable. If you double-click again or press <Enter>, the variable will be closed, and the plus sign will reappear.
Pressing <Enter> or double-clicking on a single-element variable will open the dialog box to write a variable. Here it is possible to change the present value of the variable. In the case of Boolean variables, no dialog box appears; these variables are toggled.
The new value is displayed after the variable, in pointed brackets and in turquoise color, and remains unchanged. If the 'Online' 'Write values' command is given, then all variables are placed in the selected list and are once again displayed in black.
If the 'Online' 'Force values' command is given, then all variables will be set to the selected values, until the 'Release force' command is given. In this event, the color of the force value changes to red
5.2.3Pragma instructions in the Declaration Editor
The pragma instruction is used to affect the properties of a variable concerning the compilation resp. precompilation process. It can be used in with supplementary text in a program line of the declaration editor or in its own line.
The pragma instruction is enclosed in curly brackets, upperand lower-case are ignored: { <Instruction text> }
If the compiler cannot meaningfully interpret the instruction text, the entire pragma is handled as a comment and read over. A warning is issued: „Ignore compiler directive ‚<Instruction text>’!"
Depending on the type and contents of pragma, the pragma either operates on the line in which it is located or on all subsequent lines until it is ended by an appropriate pragma, or the same pragma is executed with different parameters, or the end of the file is reached. By file we mean here: declaration part, implementation portion, global variable list, type declaration.
The opening bracket may immediately follow a variable name. Opening and closing brackets must be located on the same line.
The following pragmas are currently available in CoDeSys: Pragma {flag} for Initialization, Monitoring, Creation of symbols Pragma {bitaccess...} for the Bitaccess
Pragma {parameter..}, {template...}, {instance...} for creating for Parameter Manager entries
Pragma instructions for Initialization, Monitoring, Creation of symbols, Bitaccess Pragma {flag [<flags>] [off|on]}
<flags> can be a combination of the following flags:
noinit: |
The variable will not be initialized. |
nowatch: |
The variable can not be monitored |
noread: |
The variable is exported to the symbol file without read |
|
permission |
nowrite: |
The variable is exported to the symbol file without write |
|
permission |
5-10 |
CoDeSys V2.3 |
5 - Editors in CoDeSys
noread, |
The variable will not get exported to the symbol file |
nowrite: |
|
With the „on" modifier, the pragma operates on all subsequent variable declarations until it is ended by the pragma {flag off}, or until overwritten by another {flag <flags> on} pragma.
Without the „on" or „off" modifier, the pragma operates only on the current variable declaration (that is the declaration that is closed by the next semicolon).
Examples for use of pragma {flag}:
Initialization and monitoring of variables:
The variable a will not be initialized and will not be monitored. The variable b will not be initialized:
VAR
a : INT {flag noinit, nowatch}; b : INT {flag noinit };
END_VAR
VAR
{flag noinit, nowatch on} a : INT;
{flag noinit on} b : INT;
{flag off}
END_VAR
Neither variable will be initialized:
{flag noinit on}
VAR
a : INT; b : INT;
END_VAR {flag off}
VAR
{flag noinit on} a : INT;
b : INT;
{flag off} END_VAR
Getting variables to the symbol file:
The flags „noread" and „nowrite" are used, in a POU that has read and/or write permission, to provide selected variables with restricted access rights. The default for the variable is the same as the setting for the POU in which the variable is declared. If a variable has neither read nor write permission, it will not be exported into the symbol file.
Examples:
If the POU has read and write permission, then with the following pragmas variable a can only be exported with write permission, while variable b can not be exported at all:
VAR
a : INT {flag noread};
b : INT {flag noread, nowrite}; END_VAR
VAR
{flag noread on} a : INT;
{flag noread, nowrite on} b : INT;
{flag off}
END_VAR
Neither variable a nor b will be exported to the symbol file:
CoDeSys V2.3 |
5-11 |

Declaration Editor...
{ flag noread, nowrite on }
VAR
a : INT; b : INT;
END_VAR
{flag off}
VAR
{ flag noread, nowrite on} a : INT;
b : INT;
{flag off}
END_VAR
The pragma operates additively on all subsequent variable declarations.
Example: (all POUs in use will be exported with read and write permission) a : afb;
...
FUNCTION_BLOCK afB
VAR
b : bfb {flag nowrite}; c : INT;
END_VAR
...
FUNCTION_BLOCK bfB VAR
d : INT {flag noread}; e : INT {flag nowrite};
END_VAR
„a.b.d": Will not be exported
„a.b.e": Will be exported only with read permission „a.c": Will be exported with read and write permission.
Pragma {bitaccess...} for the Bitaccess
This pragma can be used to get a correct display of a variable, which is doing a bitaccess with the help of a global constant, in the input assistant, in the intellisense function and at monitoring in the declaration window. Further on it will effect that, when this variable is monitored in the declaration window of the particular POU, the used global constants are shown below the respective structure variable.
Please regard: The project option 'Replace constants' (category Build) must be activated !
The pragma must be inserted in the declaration of the structure in a separate line. The line is not terminated by a semicolon.
Syntax:
{bitaccess <Global Constant> <Bitnumber> '<comment>'}
<Global Constant>: Name of the global constant, which must be defined in a global variables list. <Bitnumber>: Value of the global constant, as defined in the global variables list.
See for an example in Chapter Appendix B: Operands in CoDeSys, Addressing bits in variables.
Pragma instructions for Parameter Manager entries
Pragma instructions can be inserted in variable declarations in order to create entries for these variables in parameter lists which are handled in the Parameter Manager. It depends on the target system, whether the Parameter Manager is available in the CoDeSys programming system. This means it must be activated in the target settings, category Networkfunctionality..
5-12 |
CoDeSys V2.3 |

5 - Editors in CoDeSys
The syntax:
•The pragma instruction is enclosed in curly brackets, upperand lower-case are ignored: { <Instruction text> }. If it is included in "normal" variable declarations, it must be set before the terminating semicolon of the declaration.
•Pragmas, which are used in the VAR_CONFIG interface, are set each in a single line and are not terminated with a semicolon !
•The key definitions are written separated by space characters, all together enclosed in square brackets.
•<name>: Name of the parameter list in the Parameter Manager. If the list does not yet exist, it will be created.
•<key>: Name of the attribute, i.e. column title in the parameter list; e.g. "Name", "Value", "Accesslevel" etc.; It depends on the definition of the parameter list type, which keys can be defined in the pragma.
•<value>: Value of the attribute which is defined by <key>. If <value> contains empty spaces it must be enclosed in double quotation marks, e.g. ...accessright="read only"...
Please note: The pragma instructions will be effective as soon as the focus is changed, that means as soon as a precompile is done e.g. via leaving the editor window. Erroneous inputs will not be messaged until the project is compiled.
The following entries can be generated:
1. Entries in parameter lists of type 'Variables'
(a)from the declaration part of programs and global variables lists:
For a variable defined in a PROGRAMor VAR_GLOBAL declaration an entry in a parameter list of type 'Variables' can be created, if it is declared like described in the following: (If the parameter list does not yet exist, it will be created automatically)
Syntax: {parameter list=<name> [ <key>=<value> <key>=<value> ...further keys ] }
Example: Variable bvar is declared in a program. It should be entered in the parameter list parlist1 type 'Variables') with symbolic name bvar1, value 102, index 16#1200 and subindex 16#2l.
VAR
bvar:INT{parameter list=parlist1 [name=bvar1 value=102 index=16#1200 subindex=16#1 ] };
END_VAR
(b)via a declaration in the VAR_CONFIG Interface:
There is the possibility to create an entry for a variable in a parameter list of type 'Variables' by placing a pragma in a VAR_CONFIG window (independent of variable configurations, which also are done in the VAR_CONFIG interface): (If the parameter list does not yet exist, it will be created automatically)
Syntax: {parameter list=<name> path=<path> [ <key>=<value> <key>=<value> ...further keys ] } <path> Path of the variable, for which the entry should be generated, e.g. "PLC_PRG.act1.var_x"
Example: For variable var_x an entry is created in parameter list "varlist1", symbolic name is xvar".
VAR_CONFIG
{parameter list=varlist1 path=PLC_PRG.act1.var_x [ name=xvar ] }
END_VAR
CoDeSys V2.3 |
5-13 |

Declaration Editor...
2. Entries in parameter lists of type 'Template' via function blocks and structures
Pragmas in variable declarations in function blocks and structures can be used to create entries in parameter lists of type 'Template'. (If the template does not yet exist, it will be created automatically.)
Syntax: {template list=<name> [ <key>=<value> <key>=<value> ...further keys ] }
Example: Variable strvar, which is an element of structure "stru1", should be entered in a parameter list "templ1" of type 'Template'; symbolic name (member) of the entry is "struvar1, the access level is "low" :
TYPE stru :
STRUCT
ivar:INT;
strvar:STRING{template list=vorl1 [member=struvar1 accesslevel=low] };
END_STRUCT
END_TYPE
3. Entries in parameter lists of type 'Instance' (for arrays, function blockor structure variables)
(a)via declarations in programs or global variable lists
At the declaration of arrays, function blockor structure variables in a program or in a global variables list directly an parameter list of type 'Instance' can be created:
Syntax: {instance list=<name> template=<template> baseindex=<index> basesubindex=<subindex> [ <key>=<value> <key>=<value> ...further keys ] }
Attention: Do not define a value for the key "Member"; this column will be filled automatically by using the array index values.
Examples:
Example1:
An array variable "arr_1" is declared as described in the following in order to get entries in a parameter list "arrinst" of type 'Instance'; in this list all array components will get a symbolic name "xname" (could be edited afterwards in the parameter manager) and the subindex will be counted up by 1 for each entry, starting with 0.
arr_1: ARRAY [1..8] OF INT{instance list=arrinst template=ARRAY baseindex=16#0 basesubindex=16#0 [name=xname ] };
Example1, Entries for an array in an instance list
5-14 |
CoDeSys V2.3 |

5 - Editors in CoDeSys
Example2:
A structure variable of type "stru1" (contains variables a,b,c) is declared as described in the following in order to get entries in a parameter list of type 'Instance' which is basing on the template "strulist_temp"; the list will get entries for the components a,b,c, no symbolic names are assigned, the access level is set to "high" and each index value defined by the template will be increased by 2. Make sure that the template defined in the pragma is available in the Parameter Manager:
struvar:stru1{instance list=strulist template=strulist_templ baseindex=16#2 basesubindex=16#0 [accesslevel=high] };
Example2, Entries for structure variable in Template
(b)via declarations in the VAR_CONFIG interface
For variables which can be instanced, you can directly create entries in an parameter list of type 'Instance' by a pragma in a VAR_CONFIG window (independent of variable configuration definitions which are also done in this interface). (If the template does not yet exist, it will be created automatically).
Make sure that the Template defined in the pragma is already available in the Parameter Manager..
Syntax: {instance list=<name> path=<path> template=<template> baseindex=<index> basesubindex=<subindex>[ <key>=<value> <key>=<value> ...further keys ] }
<path>: The instance path of the variable;e.g. "PLC_PRG.fb1inst", whereby fb1inst is an instance of function block fb1.
Example: The following entry in a VAR_CONFIG window will create entries for all variables of function block "fb1" in an instance list "varinst1" basing on the template "fb1_templ" (which must be already available). For each entry the index offset, which is predefined by the template, will be increased by 2 (baseindex), the subindex offset will not be modified (basesubindex). Each entry gets a symbolic name "fb1var", which you can edit afterwards in the Parameter Manager.
VAR_CONFIG
CoDeSys V2.3 |
5-15 |