
- •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

Global Variables, Variable Configuration, Document Frame
Resources tab in CoDeSys
6.2Global Variables, Variable Configuration, Document Frame
Objects in 'Global Variables'
In the Object Organizer, you will find three objects in the Resources register card in the Global Variables folder (default names of the objects in parentheses).
•Global Variables List (Global Variables)
•Variables Configuration (Variable Configuration)
All variables defined in these objects are recognized throughout the project.
If the global variables folder is not opened (plus sign in front of the folder), you can open it with a double-click<Enter> in the line.
Select the corresponding object. The 'Object Open' command opens a window with the previously defined global variables. The editor for this works the same way as the declaration editor.
Several Variables Lists
Global variables, global network variables (VAR_GLOBAL), global network variables (VAR_GLOBAL, target specific) and variable configurations (VAR_CONFIG) must be defined in separate objects.
If you have declared a large number of global variables, and you would like to structure your global variables list better, then you can create further variables lists.
In the Object Organizer, select the Global Variables folder or one of the existing objects with global variables. Then execute the 'Project' 'Object Add' command. Give the object that appears in the dialog box a corresponding name. With this name an additional object will be created with the key word VAR_GLOBAL. If you prefer an object a variable configuration, change the corresponding key word to VAR_CONFIG.
6.2.1Global Variables...
What are Global Variables
„Normal" variables, constants or remanent variables that are known throughout the project can be declared as global variables, but also network variables that are also used for data exchange with other network subscribers.
6-2 |
CoDeSys V2.3 |

6 - The Resources
Please regard: In a project you can define a local variable which has the same name like a global variable. In this case within a POU the locally defined variable will be used.
It is not allowed to name two global variables identically. For example you will get a compiler error,if you have defined a variable "var1" in the PLC Configuration as well as in a global variables list.
Network variables
Note: The use of network variables must be supported by the target system and must be activated in the target settings (category Network functionality).
By an automatic data exchange (compare this to the non-automatic data exchange via the Parameter Manager) it is possible to update the value of a network variable on several controller systems within a CoDeSys compatible controller network. This requires no controller-specific functions but the network subscribers must use identical declaration lists and matching transfer configurations for network variables in their projects. In order to make this possible it is recommended that the declaration not be entered manually in each controller application, but loaded from a separate file when creating the list. (see 'Create a global variables list').
Create a Global Variable List
To create a Global Variable List, open the register 'Resources' in the Object Organizer and select the entry 'Global Variables' or select an already existing list. Then choose the command 'Project' 'Object' 'Add' to open the dialog Global variable list.
This dialog can also be opened by the command 'Project' 'Object' 'Properties' which is available if an existing Global Variable List is marked in the object organizer. It shows the configuration of this list..
Dialog to create a new Global Variable List
CoDeSys V2.3 |
6-3 |

Global Variables, Variable Configuration, Document Frame
Name of the global variable list: Insert a list name. Link to file:
Filename: If you have an export file (*.exp) or a DCF file, which contains the desired variables, you can set up a link to this file. To do this, insert the path of the file in the field Filename resp. press the button Browse to get the standard dialog 'Select text file'. DCF files are converted to ICE syntax when they are read in.
Activate option Import before compile, if you wish that the variable list will be read from the external file before each compilation of the project. Activate the option Export before compile, if you want the variable list to be written to the external file before each compilation of the project.
If you close the 'Global variable list' dialog with OK, the new object is created. Global variables lists
can be recognized in the Object Organizer by the symbol. With the command 'Project' 'Object' 'Properties' you can re-open the 'Global variable list' configuration dialog for the entry marked in the Object Organizer.
Configuration of network variables:
If the option 'Support network variables' is activated in the target settings, then the button <Add network> is available. Pressing this button the dialog gets extended and looks like shown in the picture. If the option is not activated, the button is not available.
Connection <n> (<Network type>): In the lower part of the dialog you can create configuration sets for up to four network connections, each on a separate tab. A configuration set defines the parameters of the data exchange for the particular variables list within the network. In order for the exchange in the network to work as intended, the same variable list must be compatibly configured to match in the other network subscribers.
If no configuration is yet present, you will get in the case of a UDP network a single tabulator sheet with the inscription 'Connection 1 (UDP)'. Each time the 'Add network' button is pressed again, you get up to four more sheets inscribed with serial numbers after „Connection".
Network type: Choose the desired type from the list. The list is defined by the target system entries. For example, „CAN" as an abbreviation for a CAN network, or „UDP" for a UDP transmission system, might be selectable.
Settings: This button opens the dialog Settings for <networktype> with the following configuration parameters:
UDP:
Use standard If this button is pressed, Port 1202 will be defined for the data exchange with the other network participants. The Broadcast/Multicastaddress will be set to "255 . 255 . 255 . 255" , which means, that the data exchange will be done with all participants in the network.
Port: Enter here a desired port number to overwrite the standard setting (see above, Use standard). Make sure that the other nodes in the network define the same port! If you have more than one UDP connection defined in the project then the port number will be automatically modified in all configuration sets according to the input you make here.
Broadcast/Multicast address: Enter here an address resp. the address range of a subnetwork, if you want to overwrite the standard setting (e.g. "197 . 200 . 100 . 255", if you want to communicate with all nodes with IP-addresses 197 . 200 . 100 . x).
Regard for Win32 systems, that the Broadcast/Multicast addresses must match the subnet mask of the TCP/IP configuration of the PC !
6-4 |
CoDeSys V2.3 |

6 - The Resources
Dialog 'Settings for UDP
CAN:
Controller Index: Index of the CAN Controller, by which the variables should be transferred.
The following options can be activated or deactivated in configuring the transmission behaviour of the variables:
Pack variables: The variables are assembled for transfer into packets (telegrams) whose size depends on the network. If the option is deactivated, a packet is set up for each variable.
Variable telegram number: Identification number of the first packet, in which the variables will be sent. (default = 1). Further packets will be numbered in ascendant order.
Include Checksum: A checksum will be added to each packet which is sent. The checksum will be checked by the receiver to make sure that the variable definitions of sender and receiver are identical. A packet with a non-matching checksum will not be accepted and – if this is configured ('Use acknowledge transfer', see below) – will be acknowledged negatively.
Use acknowledged transfer: Each message will be acknowledged by the receiver. As soon as the sender does not get at least one acknowledgement within a cycle, an error message will be produced.
Read: The variables in the list are read; if the option is deactivated, further variables sent over the net will be ignored.
Request at Bootup: If the local node is a "reading" node (Option 'Read' activated), then as soon as it gets re-booted the actual variable values will be requested from all writing nodes and will be sent by those, independently of any other transmit conditions (time, event), which normally trigger the communication. Precondition: In the configuration of the writing nodes the option 'Answer Bootup requests' must be activated ! (see below).
Write: The variables are written; the following options apply:
Answer Bootup requests: If the local node is a "writing" node (Option 'Write' activated), then each request of a reading node which is sent by it at bootup (Option Request on Bootup, see above), will be answered. That means that the actual variable values will be transmitted even if none of the other defined transmission triggers (time or event) would force this at this moment.
Transmit each cycle: Variables are written within the intervals specified after Interval. (time notation e.g. T#70ms).
Transmit on change: Variables are written only when their values change; an entry after Minimum can, however, set a minimum time lapse between transfers.
Transmit on event: The variables of the list will be written as soon as the variable inserted at Variable gets TRUE.
Global Network variables lists are marked by the symbol in the Object Organizer.
Note: If a network global variable is used on one or more tasks, the following applies to the time component of the transfer: When each task is called it is tested to determine which parameters apply to the transfer of the variable value (configuration in the 'Global variables list' dialog). The variable value will be transferred or not, depending on whether the specified time interval has passed. At each transfer the time interval counter for this variable is reset to zero.
Sending is always undertaken from the run-time system of the controller affected. Thus no controlspecific functions have to be provided for the data exchange.
CoDeSys V2.3 |
6-5 |

Global Variables, Variable Configuration, Document Frame
Editing Global Variable and Network Variable Lists
The editor for global variables works similar to the declaration editor. But note that you cannot edit in this editor an list, which is an image of an linked external variable list ! External variable lists only can be edited externally and they will be read at each opening and compiling of the project.
Syntax:
VAR_GLOBAL
(* Variables declarations *)
END_VAR
Network variables only can be used, if allowed by the target system. They are also defined in this syntax.
Example of a network variables list which was created by linking of an export file *.exp and which got the name NETWORKVARIABLES_UDP:
Example of a network variables list, which has been created by loading an export file *.exp and which was named Network_Vars_UDP:
Editing Remanent Global Variables Lists
If they are supported by the runtime system, remanent variables may be processed. There are two types of remanent global variables (see also Chapter 5.2.1, Remanent Variables !):
Retain variables remain unchanged after an uncontrolled shutdown of the runtime system (off/on) or an 'Online' 'Reset' in CoDeSys. Persistent variables remain unchanged only after a download.
Persistent variables are not automatically also Retain variables !
Remanent variables are additionally assigned the keyword RETAIN or PERSISTENT or both. See chapter 5.2.1, Remanent Variables, for further information.
Network variables are also defined in this syntax. Syntax:
VAR_GLOBAL RETAIN
(* Variables declarations *)
END_VAR
VAR_GLOBAL PERSISTENT
(* Variables declarations *)
END_VAR
Network variables (target specific) are also defined using this syntax.
Global Constants
Global constants additionally get the keyword CONSTANT.
6-6 |
CoDeSys V2.3 |