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

Appendix A: - IEC Operators and additional norm extending functions
10.6Address Operators...
Attention: After an Online Change there might be changes concerning the data on certain addresses. Please regard this in case of using pointers on addresses.
ADR
Address Function not prescribed by the standard IEC61131-3.
ADR returns the address of its argument in a DWORD. This address can be sent to manufacturing functions to be treated as a pointer or it can be assigned to a pointer within the project.
dwVar:=ADR(bVAR);
Example in IL:
LD bVar ADR
ST dwVar man_fun1
BITADR
Adress function, not prescribed by the standard IEC61131-3.
BITADR returns the bit offset within the segment in a DWORD. Regard that the offset value depends on whether the option byte addressing in the target settings is activated or not.
VAR
var1 AT %IX2.3:BOOL; bitoffset: DWORD;
END_VAR
Example in ST:
bitoffset:=BITADR(var1); (* Result if byte addressing=TRUE: 19, if byte addressing=FALSE: 35 *)
Example in IL:
LD Var1
BITADR
ST Var2
Content Operator
A pointer can be dereferenced by adding the content operator "^" after the pointer identifier.
Example in ST: pt:POINTER TO INT; var_int1:INT; var_int2:INT;
pt := ADR(var_int1); var_int2:=pt^;
CoDeSys V2.3 |
10-13 |

Appendix A: - IEC Operators and additional norm extending functions
10.7Calling Operators...
CAL
Calling a function block or a program
Use CAL in IL to call up a function block instance. The variables that will serve as the input variables are placed in parentheses right after the name of the function block instance.
Example:
Calling up the instance Inst from a function block where input variables Par1 and Par2 are 0 and TRUE respectively.
CAL INST(PAR1 := 0, PAR2 := TRUE)
10.8Type Conversions...
Its is forbidden to implicitly convert from a "larger" type to a "smaller" type (for example from INT to BYTE or from DINT to WORD). Special type conversions are required if one wants to do this. One can basically convert from any elementary type to any other elementary type.
Syntax:
<elem.Typ1>_TO_<elem.Typ2>
Please regard that at ...TO_STRING conversions the string is generated left-justified. If it is defined to short, it will be cut from the right side.
BOOL_TO Conversions
Conversion from type BOOL to any other type:
For number types the result is 1, when the operand is TRUE, and 0, when the operand is FALSE. For the STRING type the result is ‚TRUE' or ‚FALSE'.
Examples in AWL: |
|
LD TRUE |
(*Result is 1 *) |
BOOL_TO_INT |
|
ST i |
|
LD TRUE |
(*Result is 'TRUE' *) |
BOOL_TO_STRING |
|
ST str |
|
LD TRUE |
(*Result is T#1ms *) |
BOOL_TO_TIME |
|
ST t |
|
LD TRUE |
(*Result is TOD#00:00:00.001 *) |
BOOL_TO_TOD |
|
ST |
|
LD FALSE |
(*Result is D#1970-01-01 *) |
BOOL_TO_DATE |
|
ST dat |
|
LD TRUE |
(*Result is DT#1970-01-01-00:00:01 *) |
BOOL_TO_DT |
|
ST dandt |
|
10-14 |
CoDeSys V2.3 |

Appendix A: - IEC Operators and additional norm extending functions
Examples in ST: |
|
i:=BOOL_TO_INT(TRUE); |
(* Result is 1 *) |
str:=BOOL_TO_STRING(TRUE); |
(* Result is "TRUE" *) |
t:=BOOL_TO_TIME(TRUE); |
(* Result is T#1ms *) |
tof:=BOOL_TO_TOD(TRUE); |
(* Result is TOD#00:00:00.001 *) |
dat:=BOOL_TO_DATE(FALSE); |
(* Result is D#1970 *) |
dandt:=BOOL_TO_DT(TRUE); |
(* Result is |
|
DT#1970-01-01-00:00:01 *) |
Examples in FUP: |
|
|
(*Result is 1 *) |
|
(*Result is 'TRUE' *) |
|
(*Result is T#1ms *) |
|
(*Result is TOD#00:00:00.001 *) |
|
(*Result is D#1970-01-01 *) |
|
(*Result is |
|
DT#1970-01-01-00:00:01 *) |
TO_BOOL Conversions
Conversion from another variable type to BOOL:
The result is TRUE when the operand is not equal to 0. The result is FALSE when the operand is equal to 0.
The result is true for STRING type variables when the operand is "TRUE", otherwise the result is FALSE.
Examples in AWL: |
|
LD 213 |
(*Result is TRUE *) |
BYTE_TO_BOOL |
|
ST b |
|
LD 0 |
(*Result is FALSE *) |
INT_TO_BOOL |
|
ST b |
|
LD T#5ms |
(*Result is TRUE *) |
TIME_TO_BOOL |
|
ST b |
|
LD 'TRUE' |
(*Result is TRUE *) |
STRING_TO_BOOL |
|
ST b |
|
CoDeSys V2.3 |
10-15 |

Appendix A: - IEC Operators and additional norm extending functions
Examples in FUP:
|
(*Result is TRUE *) |
|
(*Result is FALSE *) |
|
(*Result is TRUE *) |
|
(*Result is TRUE *) |
Examples in St: |
|
b := BYTE_TO_BOOL(2#11010101); |
(* Result is TRUE *) |
b := INT_TO_BOOL(0); |
(* Result is FALSE *) |
b := TIME_TO_BOOL(T#5ms); |
(* Result is TRUE *) |
b := STRING_TO_BOOL('TRUE'); |
(* Result is TRUE *) |
Conversion between Integral Number Types
Conversion from an integral number type to another number type:
When you perform a type conversion from a larger to a smaller type, you risk losing some information. If the number you are converting exceeds the range limit, the first bytes for the number will be ignored.
Example in ST:
si := INT_TO_SINT(4223); (* Result is 127 *)
If you save the integer 4223 (16#107f represented hexadecimally) as a SINT variable, it will appear as 127 (16#7f represented hexadecimally).
Example in IL:
LD 2
INT_TO_REAL
MUL
Example in FBD:
REAL_TO-/ LREAL_TO Conversions
Converting from the variable type REAL or LREAL to a different type:
The value will be rounded up or down to the nearest whole number and converted into the new variable type. Exceptions to this are the variable types STRING, BOOL, REAL and LREAL.
Please regard at a conversion to type STRING that the total number of digits is limited to 16. If the (L)REAL-number has more digits, then the sixteenth will be rounded. If the length of the STRING is defined to short, it will be cut beginning from the right end.
When you perform a type conversion from a larger to a smaller type, you risk losing some information.
Example in ST:
i := REAL_TO_INT(1.5); (* Result is 2 *)
10-16 |
CoDeSys V2.3 |

Appendix A: - IEC Operators and additional norm extending functions
j := REAL_TO_INT(1.4); (* Result is 1 *)
i := REAL_TO_INT(-1.5); (* Result is -2 *) j := REAL_TO_INT(-1.4); (* Result is -1 *)
Example in IL:
LD 2.7
REAL_TO_INT
GE %MW8
Example in FBD:
TIME_TO/TIME_OF_DAY Conversions
Converting from the variable type TIME or TIME_OF_DAY to a different type:
The time will be stored internally in a DWORD in milliseconds (beginning with 12:00 A.M. for the TIME_OF_DAY variable). This value will then be converted.
When you perform a type conversion from a larger to a smaller type, you risk losing some information For the STRING type variable, the result is a time constant.
Examples in IL: |
|
|
LD T#12ms |
(*Result is 'T#12ms' *) |
|
TIME_TO_STRING |
|
|
ST str |
|
|
LD T#300000ms |
(*Result is 300000 *) |
|
TIME_TO_DWORD |
|
|
ST dw |
|
|
LD TOD#00:00:00.012 |
(*Result is 12 *) |
|
TOD_TO_SINT |
|
|
ST si |
|
|
Examples in ST: |
|
|
str :=TIME_TO_STRING(T#12ms); |
|
(* Result is T#12ms *) |
dw:=TIME_TO_DWORD(T#5m); |
|
(* Result is 300000 *) |
si:=TOD_TO_SINT(TOD#00:00:00.012); |
(* Result is 12 *) |
Examples in FBD:
DATE_TO/DT_TO Conversions
Converting from the variable type DATE or DATE_AND_TIME to a different type:
The date will be stored internally in a DWORD in seconds since Jan. 1, 1970. This value will then be converted.
CoDeSys V2.3 |
10-17 |

Appendix A: - IEC Operators and additional norm extending functions
When you perform a type conversion from a larger to a smaller type, you risk losing some information For STRING type variables, the result is the date constant.
Examples in IL: |
|
|
LD D#1970-01-01 |
(* Result is FALSE *) |
|
DATE_TO_BOOL |
|
|
ST b |
|
|
LD D#1970-01-15 |
(* Result is 29952 *) |
|
DATE_TO_INT |
|
|
ST i |
|
|
LD DT#1970-01-15-05:05:05 |
(* Result is 129 *) |
|
DT_TO_BYTE |
|
|
ST byt |
|
|
LD DT#1998-02-13-14:20 |
(* Result is 'DT#1998-02-13-14:20' *) |
|
DT_TO STRING |
|
|
ST str |
|
|
Examples in ST: |
|
|
b :=DATE_TO_BOOL(D#1970-01-01); |
(* Result is FALSE *) |
|
i :=DATE_TO_INT(D#1970-01-15); |
(* Result is 29952 *) |
|
byt :=DT_TO_BYTE(DT#1970-01-15-05:05:05); |
(* Result is 129 *) |
|
str:=DT_TO_STRING(DT#1998-02-13-14:20); |
(* Result is |
|
|
|
'DT#1998-02-13-14:20' *) |
Examples in FBD:
STRING_TO Conversions
Converting from the variable type STRING to a different type:
The operand from the STRING type variable must contain a value that is valid in the target variable type, otherwise the result will be 0.
Examples in IL: |
|
LD 'TRUE' |
(* Result is TRUE *) |
STRING_TO_BOOL |
|
ST b |
|
LD 'abc34' |
(* Result is 0 *) |
STRING_TO_WORD |
|
ST w |
|
10-18 |
CoDeSys V2.3 |