
- •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 E: - Operators and Library Modules Overview
Appendix E: Operators and Library Modules Overview
The table shown below shows an overview on the operators, which are available in CoDeSys resp. in the libraries Standard.lib and Util.lib. You find there the notation for ST and IL. For IL also the supported modificators are listed.
Take note that for the 'IL operator' column: Only the line in which the operator is used will be displayed. A prerequisite is that the (first) required operand have been successfully loaded in the preceding line (e.g. LD in).
The 'Mod. IL' column shows the possible modifiers in IL:
C The command is only executed if the result of the preceding expression is TRUE.
Nfor JMPC, CALC, RETC: The command is only executed if the result of the preceding expression is FALSE.
N otherwise: negation of the operand (not of the accumulator)
( Operator enclosed in brackets: only after the closing bracket is reached will the operation preceding the brackets be carried out.
Please obtain a detailed description of usage from the appropriate Appendices concerning IEC operators integrated into CoDeSys resp. the libraries.
10.20 Operators in CoDeSys:
in ST |
in AWL |
Mod. Description |
|
|
|
AWL |
|
' |
|
|
String delimiters (e.g. 'string1') |
.. |
|
|
Size of Array range (e.g. ARRAY[0..3] OF |
[ ] |
|
|
INT) |
: |
|
|
Delimiter between Operand and Type in a |
|
|
|
declaration (e.g. var1 : INT;) |
; |
|
|
Termination of instruction (e.g. a:=var1;) |
^ |
|
|
Dereferenced Pointer (e.g. pointer1^) |
|
LD var1 |
N |
Load value of var1 in buffer |
:= |
ST var1 |
N |
Store actual result to var1 |
|
S boolvar |
|
Set boolean operand boolvar exactly then to |
|
|
|
TRUE, when the actual result is TRUE |
|
R boolvar |
|
Set boolean operand boolvar exactly then to |
|
|
|
FALSE, when the actual result is TRUE |
|
JMP label |
CN |
Jump to label |
<Program name> |
CAL prog1 |
CN |
Call program prog1 |
<Instance name> |
CAL inst1 |
CN |
Call function block instance inst1 |
<Fctname>(vx, vy,..) |
<Fctname> vx, vy |
CN |
Call function fctname and transmit variables |
|
|
|
vx, vy |
CoDeSys V2.3 |
10-61 |

|
Appendix E: - Operators and Library Modules Overview |
||
in ST |
in AWL |
Mod. Description |
|
|
|
AWL |
|
|
( |
|
The value following the bracket is handled as |
|
|
|
operand, the operation before the bracket is |
|
|
|
not executed before the expression in the |
|
|
|
brackets. |
|
) |
|
Now execute the operation which has been |
|
|
|
set back |
AND |
AND |
N,( |
Bitwise AND |
OR |
OR |
N,( |
Bitwise OR |
XOR |
XOR |
N,( |
Bitwise exclusive OR |
NOT |
NOT |
|
Bitweise NOT |
+ |
ADD |
( |
Addition |
- |
SUB |
( |
Subtraction |
* |
MUL |
( |
Multiplication |
/ |
DIV |
( |
Division |
> |
GT |
( |
Greater than |
>= |
GE |
( |
Greater or equal |
= |
EQ |
( |
Equal |
<> |
NE |
( |
Not equal |
<= |
LE |
( |
Less or equal |
< |
LT |
( |
Less than |
MOD(in) |
MOD |
|
Modulo Division |
INDEXOF(in) |
INDEXOF |
|
Internal index of POU in1; [INT] |
SIZEOF(in) |
SIZEOF |
|
Number of bytes required for the given data |
|
|
|
type of in |
SHL(K,in) |
SHL |
|
Bitwise left-shift of operator in by K |
SHR(K,in) |
SHR |
|
Bitwise right-shift of operator in by K |
ROL(K,in) |
ROL |
|
Bitwise rotation to the left of operator in by K |
ROR(K,in) |
ROR |
|
Bitwise rotation to the right of operator in by |
|
|
|
K |
SEL(G,in0,in1) |
SEL |
|
Binary selection between 2 operands in0 (G |
|
|
|
is FALSE) and in1 (G is TRUE) |
MAX(in0,in1) |
MAX |
|
Returns the greater of 2 values |
MIN(in0,in1) |
MIN |
|
Returns the lesser of 2 values in0 and in1 |
LIMIT(MIN,in,Max) |
LIMIT |
|
Limits the value range (in is set back to MIN |
|
|
|
or MAX in case of exceeding the range) |
10-62 |
CoDeSys V2.3 |
Appendix E: - Operators and Library Modules Overview
in ST |
in AWL |
Mod. Description |
|
|
AWL |
MUX(K,in0,...in_n) |
MUX |
Selectsi the Kth value out of a group of |
|
|
values (in0 to In_n) |
ADR(in) |
ADR |
Address of the operand in [DWORD] |
BOOL_TO_<type>(in) |
BOOL_TO_<type> |
Type conversion of the boolean operand |
<type>_TO_BOOL(in) |
<type>_TO_BOOL |
Type conversion to BOOL |
INT_TO_<type>(in) |
INT_TO_<type> |
Type conversion of an INT Operand to |
|
|
anotner elementary type |
REAL_TO_<type>(in) |
REAL_TO_<type> |
Type conversion of an REAL operand to |
|
|
anotner elementary type |
LREAL_TO_<type>(in) |
LREAL_TO_<type> |
Type conversion of a LREAL operand to |
|
|
anotner elementary type |
TIME_TO_<type>(in) |
TIME_TO_<type> |
Type conversion of a TIME operand to |
|
|
anotner elementary type |
TOD_TO_<type>(in) |
TOD_TO__<type> |
Type conversion of a TOD operand to |
|
|
anotner elementary type |
DATE_TO_<type>(in) |
DATE_TO_<type> |
Type conversion of a DATE operand to |
|
|
anotner elementary type |
DT_TO_<type>(in) |
DT_TO_<type> |
Type conversion of a DT operand to anotner |
|
|
elementary type |
STRING_TO_<type>(in) |
STRING_TO_<type> |
Type conversion of a string operand des |
|
|
Operanden to anotner elementary type, in |
|
|
must contain valid value of desired type |
TRUNC(in) |
TRUNC |
Conversion from REAL to INT |
ABS(in) |
ABS |
Absolut value of operand in |
SQRT(in) |
SQRT |
Square root of operand in |
LN(in) |
LN |
Natural logarithm of operand in |
LOG(in) |
LOG |
Logarithm of operand in, base 10 |
EXP(in) |
EXP |
Exponential function of operand in |
SIN(in) |
SIN |
Sine of operand in |
COS(in) |
COS |
Cosine of operand in |
TAN(in) |
TAN |
Tangent of operand in |
ASIN(in) |
ASIN |
Arc sine of operand in |
ACOS(in) |
ACOS |
Arc cosine of operand in |
ATAN(in) |
ATAN |
Arc tangent of operand in |
EXPT(in,expt) |
EXPT expt |
Exponentation of operand in with expt |
CoDeSys V2.3 |
10-63 |

Appendix E: - Operators and Library Modules Overview
10.21 Elements of the Standard.lib:
in ST |
in AWL |
Description |
LEN(in) |
LEN |
String length of operand in |
LEFT(str,size) |
LEFT |
Left inital string of given size of string str |
RIGHT(str,size) |
RIGHT |
Right initial string of given size of string str |
MID(str,size) |
MID |
Partial string of str of given size |
CONCAT('str1','str2') |
CONCAT 'str2' |
Concatenation of two subsequent strings |
INSERT('str1','str2',pos) |
INSERT 'str2',p |
Insert string str1 in String str2 at position pos |
DELETE('str1',len,pos) |
DELETE len,pos |
Delete partial string (length len), start at position pos of |
|
|
str1 |
REPLACE('str1','str2',len,pos) |
REPLACE |
Replace partial string of lenght len by str2, start at |
|
'str2',len,pos |
position pos of str1 |
FIND('str1','str2') |
FIND 'str2' |
Search for partial string str2 in str1 |
SR |
SR |
Bistable FB is set dominant |
RS |
RS |
Bistable FB is set back |
SEMA |
SEMA |
FB: Software Semaphor (interruptable) |
R_TRIG |
R_TRIG |
FB: rising edge is detected |
F_TRIG |
F_TRIG |
FB: falling edge is detected |
CTU |
CTU |
FB: Counts upv |
CTD |
CTD |
FB: Counts down |
CTUD |
CTUD |
FB: Counts up and down |
TP |
TP |
FB: trigger |
TON |
TON |
FB: Einschaltverzögerung |
TOF |
TOF |
FB: Ausschaltverzögerung |
RTC |
RTC |
FB: Laufzeit-Uhr |
10.22 Elements of the Util.lib:
BCD_TO_INT |
Conversion of a Byte: BCD to INT format |
INT_TO_BCD |
Converstion of a Byte: INT to BCD format |
EXTRACT(in,n) |
The n-th bit of DWORD in is returned in BOOl |
PACK |
Up to 8 bits are packed into a byte |
PUTBIT |
A bit of a DWORD is set to a certain value |
UNPACK |
A Byte is returned as single bits |
10-64 |
CoDeSys V2.3 |
|
Appendix E: - Operators and Library Modules Overview |
DERIVATIVE |
Local derivation |
INTEGRAL |
Integral |
STATISTICS_INT |
Min.,Max, Average values in INT format |
STATISTICS_REAL |
Min.,Max, Average in REAL format |
VARIANCE |
Variance |
PD |
PD controller |
PID |
PID controller |
BLINK |
Pulsating signal |
GEN |
Periodic functions |
CHARCURVE |
linear functions |
RAMP_INT |
Limiting ascendance of descendance of the function beeing fed (INT) |
RAMP_REAL |
Limiting ascendance of descendance of the function beeing fed (REAL) |
HYSTERESIS |
Hysteresis |
LIMITALARM |
Watches whether input value exceeds limits of a defined range |
CoDeSys V2.3 |
10-65 |

Appendix E: - Operators and Library Modules Overview
10-66 |
CoDeSys V2.3 |