- •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 B: - Operands in CoDeSys
Appendix B: Operands in CoDeSys
In CoDeSys Constants, variables, addresses and possibly function calls can appear as operands.
10.10 Constants
BOOL Constants
BOOL constants are the logical values TRUE and FALSE.
TIME Constants
TIME constants can be declared in CoDeSys. These are generally used to operate the timer in the standard library. A TIME constant is always made up of an initial "t" or "T" (or "time" or "TIME" spelled out) and a number sign "#".
This is followed by the actual time declaration which can include days (identified by "d"), hours (identified by "h"), minutes (identified by "m"), seconds (identified by "s") and milliseconds (identified by "ms"). Please note that the time entries must be given in this order according to length (d before h before m before s before m before ms) but you are not required to include all time increments.
Examples of correct TIME constants in a ST assignment:
TIME1 := T#14ms; |
|
|
TIME1 := T#100S12ms; |
(*The highest component may be allowed to exceed its limit*) |
|
TIME1 := t#12h34m15s; |
|
|
the following would be incorrect: |
||
TIME1 := t#5m68s; |
(*limit exceeded in a lower component*) |
|
TIME1 := 15ms; |
(*T# is missing*) |
|
TIME1 := t#4ms13d; |
(*Incorrect order of entries*) |
|
DATE Constants
These constants can be used to enter dates. A DATE constant is declared beginning with a "d", "D", "DATE" or "date" followed by "#". You can then enter any date with format Year-Month-Day.
Examples:
DATE#1996-05-06 d#1972-03-29
(see also Chapter 10.14 Data types, Time Data Types)
TIME_OF_DAY Constants
Use this type of constant to store times of the day. A TIME_OF_DAY declaration begins with "tod#", "TOD#", "TIME_OF_DAY#" or "time_of_day#" followed by a time with the format: Hour:Minute:Second. You can enter seconds as real numbers or you can enter fractions of a second.
Examples:
TIME_OF_DAY#15:36:30.123 tod#00:00:00
(see also Chapter 10.14 Data types, Time Data Types)
CoDeSys V2.3 |
10-25 |
Appendix B: - Operands in CoDeSys
DATE_AND_TIME Constants
Date constants and the time of day can also be combined to form so-called DATE_AND_TIME constants. DATE_AND_TIME constants begin with "dt#", "DT#", "DATE_AND_TIME#" or "date_and_time#". Place a hyphen after the date followed by the time.
Examples:
DATE_AND_TIME#1996-05-06-15:36:30 dt#1972-03-29-00:00:00
(see also Chapter 10.14 Data types, Time Data Types)
Number Constants
Number values can appear as binary numbers, octal numbers, decimal numbers and hexadecimal numbers. If an integer value is not a decimal number, you must write its base followed by the number sign (#) in front of the integer constant. The values for the numbers 10-15 in hexadecimal numbers will be represented as always by the letters A-F.
You may include the underscore character within the number.
Examples: |
|
14 |
(decimal number) |
2#1001_0011 |
(dual number) |
8#67 |
(octal number) |
16#A |
(hexadecimal number) |
These number values can be from the variable types BYTE, WORD, DWORD, SINT, USINT, INT, UINT, DINT, UDINT, REAL or LREAL.
Implicit conversions from "larger" to "smaller" variable types are not permitted. This means that a DINT variable cannot simply be used as an INT variable. You must use the type conversion.
REAL/LREAL Constants
REAL and LREAL constants can be given as decimal fractions and represented exponentially. Use the standard American format with the decimal point to do this.
Example:
7.4 instead of 7,4
1.64e+009 instead of 1,64e+009
STRING Constants
A string is a sequence of characters. STRING constants are preceded and followed by single quotation marks. You may also enter blank spaces and special characters (umlauts for instance). They will be treated just like all other characters.
In character sequences, the combination of the dollar sign ($) followed by two hexadecimal numbers is interpreted as a hexadecimal representation of the eight bit character code. In addition, the combination of two characters that begin with the dollar sign are interpreted as shown below when they appear in a character sequence:
$$ |
Dollar signs |
$' |
Single quotation mark |
$L or $l |
Line feed |
$N or $n |
New line |
$P or $p |
Page feed |
10-26 |
CoDeSys V2.3 |
Appendix B: - Operands in CoDeSys
$R or $r |
Line break |
$T or $t |
Tab |
Examples:
'w1Wüß?'
' Abby and Craig ' ':-)'
Typed Literals
Basically, in using IEC constants, the smallest possible data type will be used. If another data type must be used, this can be achieved with the help of typed literals without the necessity of explicitly declaring the constants. For this, the constant will be provided with a prefix which determines the type.
This is written as follows: <Type>#<Literal>
<Type> specifies the desired data type; possible entries are: BOOL, SINT, USINT, BYTE, INT, UINT, WORD, DINT, UDINT, DWORD, REAL, LREAL. The type must be written in uppercase letters.
<Literal> specifies the constant. The data entered must fit within the data type specified under <Type>.
Example:
var1:=DINT#34;
If the constant can not be converted to the target type without data loss, an error message is issued: Typed literals can be used wherever normal constants can be used.
10.11 Variables
Variables can be declared either locally in the declaration part of a POU or in a global variable list.
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 however 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.
The variable identifier may not contain any blank spaces or special characters, may not be declared more than once and cannot be the same as any of the keywords. Capitalization is not recognized which means that VAR1, Var1, and var1 are all the same variable. The underscore character is recognized in identifiers (e.g., "A_BCD" and "AB_CD" are considered two different identifiers). An identifier may not have more than one underscore character in a row. The length of the identifier, as well as the meaningful part of it, are unlimited.
Variables can be used anywhere the declared type allows for them. You can access available variables through the Input Assistant.
System Flags
System flags are implicitly declared variables that are different on each specific PLC. To find out which system flags are available in your system, use the command 'Insert' 'Operand' An Input Assistant dialog box pops up, select the category System Variable.
Accessing variables for arrays, structures and POUs.
Two-dimensional array components can be accessed using the following syntax:
<Fieldname>[Index1, Index2]
Structure variables can be accessed using the following syntax:
<Structurename>.<Variablenname>
CoDeSys V2.3 |
10-27 |
Appendix B: - Operands in CoDeSys
Function block and program variables can be accessed using the following syntax:
<Functionblockname>.<Variablename>
Addressing bits in variables
In integer variables individual bits can be accessed. For this, the index of the bit to be addressed is appended to the variable, separated by a dot. The bit-index can be given by any constant. Indexing is 0-based.
Example:
a : INT; b : BOOL;
...
a.2 := b;
The third bit of the variable a will be set to the value of the variable b.
If the index is greater than the bit width of the variable, the following error message is issued: Index '<n>' outside the valid range for variable '<var>'!
Bit addressing is possible with the following variable types: SINT, INT, DINT, USINT, UINT, UDINT, BYTE, WORD, DWORD.
If the variable type does not allow it, the following error message is issued: "Invalid data type '<type>' for direct indexing"
A bit access must not be assigned to a VAR_IN_OUT variable!
Bitaccess via a global constant:
If you have declared a global constant, which defines the bit-index, you can use this constant for a bitaccess.
Please regard: The project option 'Replace constants' (category Build) must be activated !
See in the following examples for such a bitaccess on a variable resp. a structure variable.:
Declaration in global variables list for both examples:
Variable enable defines which bit should be accessed:
VAR_CONSTANT GLOBAL enable:int:=2;
END_VAR
Example 1, Bitaccess on an integer variable:
Declaration in POU:
VAR xxx:int; END_VAR
Bitaccess:
xxx.enable:=true; -> the second bit in variable xxx will be set TRUE
Example 2, Bitaccess on an integer structure component:
Declaration of structure stru1:
TYPE stru1 : STRUCT bvar:BOOL; rvar:REAL; wvar:WORD;
{bitaccess enable 42 'Start drive'}
10-28 |
CoDeSys V2.3 |
