Codesys 3.5 Manual
Jun 06, 2018 Step by step instructions on creating a simple menu & user levels which restrict access. Free auto clicker online. This feature is in 3S Codesys 3.5 & WAGO e!COCKPIT.
Nvidia 7800 gt. Of all the manufacturers of SSD for the mass market, Intel maybe has not best reputation, still quite high. Top products will lose most ofall, but also drives of the entry level, in particular 330-series, will be much more accessible toconsumers.Below are stated all prices and possible devaluation. Old price is indicated in parentheses.Intel SSD 320 300 GB (OEM). Reducing of prices on popular drives series SSD320, SSD 330 and SSD 520 is expected in August this year. Using this, the Corporation of Santa Clara sets high prices of their SSDs, not fearing for the sales.However, as suggested by experts, the pressure from competitors will still force Intel companyto go for price concessions for customers.
- A Brief Introduction to CoDeSys CoDeSys V2.3 1-1 1 A Brief Introduction to CoDeSys 1.1 What is CoDeSys CoDeSys is a complete development environment for your PLC. (CoDeSys stands for Controlled Developement System). CoDeSys puts a simple approach to the powerful IEC language at the disposal of the PLC programmer.
- The CODESYS Device Directory is a comprehensive listing of intelligent hardware devices programmable with the IEC 61131-3 automation software CODESYS. It currently contains more than 500 devices such as PLCs, drives or motion controllers from renowned manufacturers.
- 1.5.1 CODESYS- Market standard for PLC programming according to IEC 61131-3 CODESYS (Controller Development System) is a PLC programming software with which you can cotrol, embedded and PC based equipment to the international standard IEC 61131-3. It consists of the programming system CODESYS and the runtime system CODESYS Control.
- Overview of CoDeSys Functions. 1-2 CoDeSys V2.3 You can use the flow control to check which program lines have been run. A Log records operations, user actions and internal processes during an online session in a chronological order. If activated in the target settings the Sampling Trace allows you to trace and display the actual course of variables over an extended period of time.
Codesys 3.5 Manual Online
PLC Programming with CoDeSys 2.3
Copyright 1994, 1997, 1999, 2001,2002, 2003 by 3S - Smart Software Solutions GmbH All rights reserved.
We have gone to great lengths to ensure this documentation is correct and complete. However, since it is not possible to produce an absolutely error-free text, please feel free to send us your hints and suggestions for improving it.
Trademark Intel is a registered trademark and 80286, 80386, 80486, Pentium are trademarks of Intel Corporation. Microsoft, MS and MS-DOS are registered trademarks, Windows is a trademark of Microsoft Corporation.
Publisher 3S - Smart Software Solutions GmbH Memminger Straße 151 D-87439 Kempten Tel. +49 831 5 40 31 - 0 Fax +49 831 5 40 31 – 50
Last update 20.08.2003 Version 2.0
Content 1 A Brief Introduction to CoDeSys 1.1 1.2 1.3
What is CoDeSys .................................................1-1 Overview of CoDeSys Functions.. ...................................1-1 Overview on the user documentation for CoDeSys.......................1-3
2 What is What in CoDeSys 2.1 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.3 2.4
4-1
The Main Window.................................................4-1 Project Options...................................................4-3 Managing Projects................................................4-15 'Project 'Data Base Link'............................................4-34 Managing Objects in a Project.. .....................................4-41 General Editing Functions..........................................4-48 General Online Functions.. .........................................4-52 Window set up...................................................4-62 Help when you need it.. ............................................4-62
5 Editors in CoDeSys 5.1 5.2 5.3 5.3.1 5.3.2 5.4 5.4.1 5.4.2 5.4.3 5.4.4
3-1
Controlling a Traffic Signal Unit......................................3-1 Visualizing a Traffic Signal Unit......................................3-12
4 The Individual Components 4.1 4.2 4.3 4.3.1 4.4 4.5 4.6 4.7 4.8
2-1
Project Components...............................................2-1 Languages.. .....................................................2-8 Instruction List (IL).. ...............................................2-8 Structured Text (ST)...............................................2-10 Sequential Function Chart (SFC).....................................2-16 Function Block Diagram (FBD).. .....................................2-20 The Continuous Function Chart Editor (CFC).. .........................2-21 Ladder Diagram (LD)..............................................2-21 Debugging, Online Functions........................................2-23 The Standard.. ...................................................2-25
3 We Write a Little Program 3.1 3.2
1-1
5-1
This is for all Editors.. .............................................5-1 Declaration Editor.. ...............................................5-2 The Text Editors.. ................................................5-12 The Instruction List Editor.. .........................................5-16 The Editor for Structured Text.......................................5-17 The Graphic Editors.. .............................................5-17 The Function Block Diagram Editor.. .................................5-19 The Ladder Editor.................................................5-24 The Sequential Function Chart Editor.................................5-29 The Continuous Function Chart Editor (CFC).. .........................5-36
Table Of Contents
6 The Resources 6.1 6.2 6.2.1 6.2.2 6.2.3 6.3 6.4 6.5 6.5.1 6.5.2 6.5.3 6.5.4 6.5.5 6.5.6 6.5.7 6.5.8 6.5.9 6.6 6.6.1 6.7 6.8 6.9 6.9.1 6.9.2 6.9.3 6.10 6.10.1 6.11 6.11.1 6.11.2 6.11.3 6.11.4 6.11.5 6.11.6 6.12 6.12.1 6.12.2 6.12.3 6.12.4 6.13 6.13.1 6.13.2 6.13.3 6.13.4 6.13.5 6.13.6 7 ENI
Overview of the Resources......................................... 6-1 Global Variables, Variable Configuration, Document Frame............... 6-2 Global Variables.................................................. 6-2 Variable Configuration.. ........................................... 6-6 Document Frame.. ............................................... 6-7 Library Manager.. ................................................ 6-8 Log.. .......................................................... 6-10 PLC Configuration................................................ 6-12 Working in the PLC Configuration.. .................................. 6-13 General Settings in the PLC Configuration ............................. 6-14 Custom specific parameter dialog .................................... 6-14 Configuration of an I/O Module...................................... 6-15 Configuration of a Channel......................................... 6-18 Configuration of Profibus Modules ................................... 6-18 Configuration of CAN modules ...................................... 6-26 Configuration of a CanDevice (CANopen Slave) ........................ 6-30 PLC Configuration in Online Mode ................................... 6-33 Target Settings ................................................... 6-33 Dialog Target Settings ............................................. 6-34 Task Configuration.. .............................................. 6-35 Watch and Receipt Manager.. ...................................... 6-40 Sampling Trace.................................................. 6-43 Create a Sampling Trace........................................... 6-43 'Extras' 'Save trace values' ......................................... 6-47 'Extras' 'External Trace Configurations'................................ 6-48 Target Settings ................................................... 6-49 Dialog Target Settings ............................................. 6-50 Parameter Manager ............................................... 6-50 Activating the Parameter Manager ................................... 6-51 Der Parameter Manager Editor.. .................................... 6-52 Parameter List Types and Attributes .................................. 6-52 Editing parameter lists ............................................. 6-54 Export / Import of parameter lists .................................... 6-56 Parameter Manager in Online Mode .................................. 6-56 PLC Browser.................................................... 6-57 General remarks concerning PLC Browser operation .................... 6-57 Command entry in the PLC Browser.................................. 6-58 Use of macros during the command entry in PLC-Browser................ 6-59 Further PLC Browser options ....................................... 6-60 Tools........................................................... 6-60 Creating new Tool Shortcuts ........................................ 6-61 Properties of available Tool Shortcuts (Object Properties)................. 6-62 Deleting connections.............................................. 6-65 Executing Tool Shortcuts ........................................... 6-65 Saving Tool Shortcuts............................................. 6-65 Frequently asked questions on Tools ................................. 6-65 7-1
7.1.1 7.1.2 7.1.3 7.1.4
ii
6-1
What is ENI ..................................................... 7-1 Preconditions for Working with an ENI project data base.................. 7-1 Working with the ENI project data base in CoDeSys ..................... 7-2 Object categories concerning the project data base...................... 7-2
CoDeSys V2.3
8 The License Manager 8.1.1
Creating a licensed library in CoDeSys ................................8-1
9 DDE Communication with CoDeSys 9.1 9.2
10.1 10.2 10.3 10.4 10.5 10.6 10.7 10.8 10.9 Appendix B: 10.10 10.11 10.12 10.13 Appendix C: 10.14 10.15 Appendix D: 10.16 10.16.1 10.16.2 10.16.3 10.16.4 10.16.5 10.17 10.17.1 10.17.2 10.17.3 10.17.4 10.17.5 10.17.6 10.17.7 10.18 10.19
9-1
DDE interface of the CoDeSys programming system.. ...................9-1 DDE communcation with the GatewayDDE Server.......................9-2
10 APPENDIX Appendix A:
8-1
10-1 IEC Operators and additional norm extending functions
10-1
Arithmetic Operators.. .............................................10-1 Bitstring Operators.. ..............................................10-4 Bit-Shift Operators................................................10-6 Selection Operators...............................................10-9 Comparison Operators.............................................10-11 Address Operators.. ..............................................10-13 Calling Operators.................................................10-14 Type Conversions.................................................10-15 Numeric Operators................................................10-19 Operands in CoDeSys
10-25
Constants.......................................................10-25 Variables ........................................................10-27 Addresses.......................................................10-28 Functions .......................................................10-29 Data types in CoDeSys
10-31
Standard data types ...............................................10-31 Defined data types................................................10-33 CoDeSys Libraries
10-39
The Standard.lib library............................................10-39 String functions...................................................10-39 Bistable Function Blocks.. ..........................................10-43 Trigger.. ........................................................10-44 Counter.. .......................................................10-46 Timer...........................................................10-48 The Util.lib library.................................................10-51 BCD Conversion..................................................10-51 Bit-/Byte Functions ................................................10-52 Mathematic Auxiliary Functions ......................................10-53 Controllers ......................................................10-54 Signal Generators.. ...............................................10-55 Function Manipulators.. ............................................10-56 Analog Value Processing.. .........................................10-58 AnalyzationNew.lib library ..........................................10-59 The CoDeSys System Libraries ......................................10-60
Appendix E:
Operators and Library Modules Overview
10-61
Appendix F:
Command Line-/Command File
10-67
10.20
Command Line Commands .........................................10-67
Table Of Contents
10.21
Command File (cmdfile) Commands.................................. 10-67
Appendix G:
Siemens Import
10-75
Appendix H:
Target Settings Dialogs in Detail
10-81
10.21.1 10.21.2 10.21.3 10.21.4 Appendix I: 10.22 10.23 Appendix J: 10.24 10.25 11 Index
iv
Settings in Category Target Platform ................................. 10-82 Target Settings in Category General .................................. 10-90 Target Settings in Category Networkfunctionality ........................ 10-91 Target Settings in Category Visualisation .............................. 10-92 Use of Keyboard
10-93
Use of Keyboard ................................................. 10-93 Key Combinations ................................................ 10-93 Compiler Errors and Warnings
10-99
Warnings ....................................................... 10-99 Errors.......................................................... 10-102 I
CoDeSys V2.3
A Brief Introduction to CoDeSys
1
A Brief Introduction to CoDeSys
1.1
What is CoDeSys CoDeSys is a complete development environment for your PLC. (CoDeSys stands for Controlled Developement System). CoDeSys puts a simple approach to the powerful IEC language at the disposal of the PLC programmer. Use of the editors and debugging functions is based upon the proven development program environments of advanced programming languages (such as Visual C++).
1.2
Overview of CoDeSys Functions..
How is a project structured? A project is put into a file named after the project. The first POU (Program Organization Unit) created in a new project will automatically be named PLC_PRG. The process begins here (in compliance with the main function in a C program), and other POUs can be accessed from the same point (programs, function blocks and functions). Once you have defined a Task Configuration, it is no longer necessary to create a program named PLC_PRG. You will find more about this in chapter 6.7, Task Configuration. There are different kinds of objects in a project: POUs, data types, display elements (visualizations) and resources. The Object Organizer contains a list of all the objects in your project. How do I set up my project? First you should configure your PLC in order to check the accuracy of the addresses used in the project. Then you can create the POUs needed to solve your problem. Now you can program the POUs you need in the desired languages. Once the programming is complete, you can compile the project and remove errors should there be any. How can I test my project? Once all errors have been removed, activate the simulation, log in to the simulated PLC and 'load' your project in the PLC. Now you are in Online mode. Now open the window with your PLC Configuration and test your project for correct sequence. To do this, enter input variables manually and observe whether outputs are as expected. You can also observe the value sequence of the local variables in the POUs. In the Watch and Receipt Manager you can configure data records whose values you wish to examine. Debugging In case of a programming error you can set breakpoints. If the process stops at such a breakpoint, you can examine the values of all project variables at this point in time. By working through sequentially (single step) you can check the logical correctness of your program. Additional Online Functions Further debugging functions: You can set program variables and inputs and outputs at certain values.
CoDeSys V2.3
1-1
Overview of CoDeSys Functions..
You can use the flow control to check which program lines have been run. A Log records operations, user actions and internal processes during an online session in a chronological order. If activated in the target settings the Sampling Trace allows you to trace and display the actual course of variables over an extended period of time. Also a target specific function is the PLC Browser which can serve to request certain information from the PLC. Once the project has been set up and tested, it can be loaded down to the hardware and tested as well. The same online functions as you used with the simulation will be available. Additional CoDeSys Features The entire project can be documented or exported to a text file at any time. For communication purposes CoDeSys has a symbolic interface and a DDE interface. A Gateway Server plus OPC Server and DDE Server are components of the CoDeSys-standard installation packet. Using the appropriate target settings, which can be loaded with the aid of a target file (Target Support Package) allows to load the same CoDeSys project to various target systems. Network global variables and a Parameter Manager might be available, if activated by the current target settings, for data exchange within a network of controllers. ENI: The E ' ngineering Interface' can be used to access any desired source code management program via the ENI Server, which is running as an independent process. CoDeSys POUs and compile files can be filed in that data base and are by that accessible also by other clients of the ENI Server. This allows multi user operation during the work on a CoDeSys project, it provides a common data pool for different tools besides CoDeSys and it makes possible a version management. Tools: This functionality also is target dependent and allows to start target-specific executable files in a CoDeSys project. Besides that files can be defined, which should be loaded to the controller. Connections to external tools can be pre-defined in the target file or/and inserted in the project Resource tree. A CoDeSys visualization can be processed target specifically to be available as Web-Visualization and/or Target-Visualization. This allows to run and view the visualization via Internet or on a PLCmonitor. SoftMotion: Diese Funktionalität ist eine Art Basis-Werkzeugkasten zum Realisieren von Bewegungen – von einfachen Einachs- über Kurvenscheiben- bis hin zu komplexen Bewegungen in mehreren Dimensionen unter der Entwicklungsumgebung von CoDeSys. Die gesamte Programmlogik wird im SPS-Programm behandelt und nur die reine Bewegungsinformation in Bibliotheksbausteinen abgearbeitet. SoftMotion erfordert eine eigene Lizenz und muss vom Zielsystem unterstützt werden. (Siehe separate Anwenderdokumentation)
1-2
CoDeSys V2.3
A Brief Introduction to CoDeSys
1.3
Overview on the user documentation for CoDeSys
Module
Docu Contents
Name of File
CoDeSys Programming System
on hand manual and online help via help menu in the programming system
Manual_V23_D.pdf First Steps with CoDeSys V23.pdf
First steps with the CoDeSys Programming system (sample) Gateway Server
Concept, installation and User Interface; Online Help for the User Interface via Gateway menu (can be opened by a mouseclick on the gateway symbol in the system tray)
Gateway Manual.pdf
OPC Server
OPC-Server V2.0, Installation and Use
OPC_20_How_to_use_E.pdf
CoDeSys Visualization
Manual for the CoDeSys Visualization incl. CoDeSys HMI, Target- and Web-Visualization
CoDeSys_Visu_E.pdf
SoftMotion
How to use, description SoftMotion library modules
SoftMotion_Manual_V23_E.pdf
Bibliotheken
Standard.lib and Util.lib are described in the on hand manual.
of
the
main
.pdf UserManual_V23_E.pdf
For each of the CoDeSys System Libraries there is a document .pdf SoftMotion librariers: documentation. ENI Server
see
SoftMotion-
Installation and configuration of the ENI Servers concerning the source control of a CoDeSys project in an external data base.
EniServerQuickstart_E.pdf UserManual_V23_E.pdf
Configuration of ENI in CoDeSys: see the on hand manual. ENI Admin, ENI Control and ENI Explorer: see the referring online help.
CoDeSys V2.3
1-3
What is What in CoDeSys
2
What is What in CoDeSys
2.1
Project Components..
Project A project contains all of the objects in a PLC program. A project is saved in a file named after the project. The following objects are included in a project: POUs (Program Organization Units), data types, visualizations, resources, and libraries. POU (Program Organization Unit) Functions, function blocks, and programs are POUs which can be supplemented by actions. Each POU consists of a declaration part and a body. The body is written in one of the IEC programming languages which include IL, ST, SFC, FBD, LD or CFC. CoDeSys supports all IEC standard POUs. If you want to use these POUs in your project, you must include the library standard.lib in your project. POUs can call up other POUs. However, recursions are not allowed. Function A function is a POU, which yields exactly one data element (which can consist of several elements, such as fields or structures) when it is processed, and whose call in textual languages can occur as an operator in expressions. When declaring a function do not forget that the function must receive a type. This means, after the function name, you must enter a colon followed by a type. A correct function declaration can look like this example: FUNCTION Fct: INT
In addition, a result must be assigned to the function. That means that function name is used as an output variable. A function declaration begins with the keyword FUNCTION. In IL a function call only can be positioned within actions of a step or within a transition. In ST a function call can be used as operand in an expression. Example in IL of a function that takes three input variables and returns the product of the first two divided by the third: Example of a function in IL
CoDeSys V2.3
2-1
Project Components..
The call of a function in ST can appear as an operand in expressions. Functions do not have any internal conditions. That means that calling up a function with the same argument (input parameters) always produces the same value (output). Examples for calling up a function in IL: LD 7 Fct 2,4 ST Result in ST: Result := Fct(7, 2, 4); in FBD:
Functions do not keep internal stati. That means that each time you call a function by passing the same arguments (input parameters), it will return the same value (output). For that functions may not contain global variables and addresses. Attention: If a local variable is declared as RETAIN in a function, this is without any effect ! The variable will not be written to the Retain area ! If you define a function in your project with the name CheckBounds, you can use it to check range overflows in your project! The name of the function is defined and may have only this identifier. For further description please see chapter 10.1, Arithmetic Operators, DIV. If you define functions in your project with the names CheckDivByte, CheckDivWord, CheckDivDWord and CheckDivReal, you can use them to check the value of the divisor if you use the operator DIV, for example to avoid a division by 0. If you define functions with the names CheckRangeSigned and CheckRangeUnsigned, then range exceeding of variables declared with subrange types (see Data types) can be intercepted. All these check function names are reserved for the described usage. For further description please see Defined Datatypes, Array.
In SFC a function call can only take place within a step or a transition. Function Block A function block is a POU which provides one or more values during the procedure. As opposed to a function, a function block provides no return value. A function block declaration begins with the keyword FUNCTION_BLOCK. Reproductions or instances (copies) of a function block can be created.
2-2
CoDeSys V2.3
What is What in CoDeSys
Example of a function block in IL
Example in IL of a function block with two input variables and two output variables. One output is the product of the two inputs, the other a comparison for equality: Function Block Instances Reproductions or instances (copies) of a function block can be created. Each instance possesses its own identifier (the Instance name), and a data structure which contains its inputs, outputs, and internal variables. Instances are declared locally or globally as variables, whereas the name of the function block is indicated as the type of an identifier. Example of an instance with the name INSTANCE of the FUB function block: INSTANCE: FUB; Function blocks are always called through the instances described above. Only the input and output parameters can be accessed from outside of an function block instance, not its internal variables. Example for accessing an input variable The function block FB has an input variable in1 of the type INT. PROGRAM prog VAR inst1:fb; END_VAR LD 17 ST inst1.in1 CAL inst1 END_PROGRAM
The declaration parts of function blocks and programs can contain instance declarations. Instance declarations are not permitted in functions. Access to a function block instance is limited to the POU in which it was declared unless it was declared globally. The instance name of a function block instance can be used as the input for a function or a function block. Note:
CoDeSys V2.3
All values are retained after processing a function block until the next it is processed. Therefore, function block calls with the same arguments do not always return the same output values! If there at least one of the function block variables is a retain variable, the total instance is stored in the retain area.
2-3
Project Components..
Calling a function block The input and output variables of a function block can be accessed from another POU by setting up an instance of the function block and specifying the desired variable using the following syntax: . If you would like to set the input parameters when you open the function block, you can do this in the text languages IL and ST by assigning values to the parameters after the instance name of the function block in parentheses (this assignment takes place using ':=' just as with the initialization of variables at the declaration position). Please regard, that the InOutVariables (VAR_IN_OUT) of a function block are handed over as pointers. For this reason in a call of a function block no constants can be assigned to VAR_IN_OUTs and there is no read or write access from outside to them. VAR inst:fubo; var:int; END_VAR var1:=2; inst(instout1:=var1^);
not allowed in this case: inst(instout1:=2); or inst.inout1:=2; Examples for calling function block FUB:
The multiplication result is saved in the variable ERG, and the result of the comparison is saved in QUAD. An instance of FUB with the name INSTANCE is declared. This is how the instance of a function block is called in IL:
This is how the instance of a function block is called in ST(the declaration part the same as with IL)
2-4
CoDeSys V2.3
What is What in CoDeSys
This is how the instance of a function block is called in FBD(the declaration part the same as with IL)
In SFC function block calls can only take place in steps. Program A program is a POU which returns several values during operation. Programs are recognized globally throughout the project. All values are retained from the last time the program was run until the next. Example of a program
Programs can be called. A program call in a function is not allowed. There are also no instances of programs. If a POU calls a program, and if thereby values of the program are changed, then these changes are retained the next time the program is called, even if the program has been called from within another POU. This is different from calling a function block. There only the values in the given instance of a function block are changed. These changes therefore play a role only when the same instance is called. A program declaration begins with the keyword PROGRAM and ends with END_PROGRAM. Examples for program calls: In IL: CAL PRGExample LD PRGexample.PAR ST ERG In ST: PRGExample; Erg := PRGexample.PAR;
CoDeSys V2.3
2-5
Project Components..
In FBD :
Example for a possible call sequence for PLC_PRG : LD 0 ST PRGexample.PAR (*Default setting for PAR is 0*) CAL IL call (*ERG in IL call results in 1*) CAL ST call (*ERG in ST call results in 2*) CAL FBD call (*ERG in FBD call results in 3*) If the variable PAR from the program PRGexample is initialized by a main program with 0, and then one after the other programs are called with above named program calls, then the ERG result in the programs will have the values 1, 2, and 3. If one exchanges the sequence of the calls, then the values of the given result parameters also change in a corresponding fashion.
PLC_PRG The PLC_PRG is a special predefined POU. Each project must contain this special program. This POU is called exactly once per control cycle. The first time the 'Project' 'Object Add' command is used after a new project has been created, the default entry in the POU dialog box will be a POU named PLC_PRG of the program type. You should not change this default setting! If tasks have been defined, then the project may not contain any PLC_PRG, since in this case the procedure sequence depends upon the task assignment. Attention: Do not delete or rename the POU PLC_PRG (assuming you are not using a Task Configuration)! PLC_PRG is generally the main program in a single task program.
Action Actions can be defined and assigned to function blocks and programmes ('Project' 'Add action'). The action represents a further implementation which can be entirely created in another language as the 'normal' implementation. Each action is given a name. An action works with the data from the function block or programme which it belongs to. The action uses the same input/output variables and local variables as the 'normal' implementation uses. Example for an action of a function block
In the example given, calling up the function block Counter increases or decreases the output variable 'out', depending on the value of the input variable 'in'. Calling up the action Reset of the function block sets the output variable to zero. The same variable 'out' is written in both cases.
2-6
CoDeSys V2.3
What is What in CoDeSys
Calling an action: An action is called up with . or . Regard the notation in FBD (see example below) ! If it is required to call up the action within its own block, one just uses the name of the action in the text editors and in the graphic form the function block call up without instance information. Examples for calls of the above described action from another POU: Declaration for all examples: PROGRAM PLC_PRG VAR Inst : Counter; END_VAR Call of action 'Reset' in another POU, which is programmed in IL: CAL Inst.Reset(In := FALSE) LD Inst.out ST ERG Call of action 'Reset' in another POU, which is programmed in ST: Inst.Reset(In := FALSE); Erg := Inst.out; Call of action 'Reset' in another POU, which is programmed in FBD:
Notes: Actions play an important role in blocks in sequential function charts, see Sequential Function Chart . The IEC standard does not recognise actions other than actions of the sequential function chart.
Resources You need the resources for configuring and organizing your project and for tracing variable values: •
Global Variables which can be used throughout the project or network
•
Library manager for adding libraries to the project
•
Log for recording the actions during an online session
•
PLC Configuration for configuring your hardware
•
Task Configuration for guiding your program through tasks
•
Watch and Receipt Manager for displaying variable values and setting default variable values
•
Target system settings for selection and if necessary final configuration of the target system
Depending on the target system and on the target settings made in CoDeSys the following resources also might be available in your project: •
Sampling Trace for graphic display of variable values
•
Parameter Manager for data exchange with other controllers in a network
•
PLC-Browser as controller monitor
•
Tools – availability depending on target – for calling external tool programs from within CoDeSys
Libraries You can include in your project a series of libraries whose POUs, data types, and global variables you can use just like user-defined variables. The libraries standard.lib and util.lib are standard parts of the program and are always at your disposal.
CoDeSys V2.3
2-7
Languages..
See 'Library Manager'. Data types Along with the standard data types the user can define his own data types. Structures, enumeration types and references can be created. See 'Data Types'. Visualization CoDeSys provides visualizations so that you can display your project variables. You can plot geometric elements off-line with the help of the visualization. In Online mode, these can then change their form/color/text output in response to specified variable values. A visualization can be used as a pure operating interface for a PLC with CoDeSys HMI or as a WebVisualization or Target-Visualization running via Internet resp. directly on the PLC. See the document 'The CoDeSys Visualization'.
2.2
Languages.. CoDeSys supports all languages described by the standard IEC-61131: Textual Languages: Instruction List (IL) Structured Text (ST) Grafic Languages: Sequential Function Chart (SFC) Function Block Diagram (FBD) The Continuous Function Chart Editor (CFC) Ladder Diagram (LD)
2.2.1
Instruction List (IL).. An instruction list (IL) consists of a series of instructions. Each instruction begins in a new line and contains an operator and, depending on the type of operation, one or more operands separated by commas. In front of an instruction there can be an identification mark (label) followed by a colon (:). A comment must be the last element in a line. Empty lines can be inserted between instructions. Example: LD
17
ST
lint
GE
5
JMPC
next
LD
idword
EQ
istruct.sdword
STN
test
(* comment *)
next:
2-8
CoDeSys V2.3
What is What in CoDeSys
Modifiers and operators in IL In the IL language the following operators and modifiers can be used. Modifiers: •C
with JMP, CAL, RET:
The instruction is only then executed if the result of the preceding expression is TRUE.
•N
with JMPC, CALC, RETC:
The instruction is only then executed if the result of the preceding expression is FALSE.
•N
otherwise:
Negation of the operand (not of the accumulator)
Below you find a table of all operators in IL with their possible modifiers and the relevant meaning: Operator Modifiers Meaning LD
N
Make current result equal to the operand
ST
N
Save current result at the position of the operand
S
Then put the Boolean operand exactly at TRUE if the current result is TRUE
R
Then put the Boolean operand exactly at FALSE if the current result is TRUE
AND
N,(
Bitwise AND
OR
N,(
Bitwise OR
XOR
N,(
Bitwise exclusive OR
ADD
(
Addition
SUB
(
Subtraction
MUL
(
Multiplication
DIV
(
Division
GT
(
>
GE
(
>=
EQ
(
=
NE
(
LE
(
the components of structure struct1 will be offered:
Declaration Editor.. The declaration editor is used to declare variables of POUs and global variables, for data type declarations, and in the Watch and Receipt Manager. It gives access to the usual Windows functions, and even those of the IntelliMouse can be used if the corresponding driver is installed. In Overwrite mode, 'OV' is shown in black on the status bar; switching between Overwrite and Insert modes can be accomplished with the key. The declaration of variables is supported by syntax coloring. The most important commands are found in the context menu (right mouse button or +).
Declaration Part All variables to be used only in this POU are declared in the declaration part of the POU. These can include: input variables, output variables, input/output variables, local variables, retain variables, and constants. The declaration syntax is based on the IEC61131-3 standard. An example of a correct declaration of variables in CoDeSys-Editor:
5-2
CoDeSys V2.3
5 - Editors in CoDeSys
Input Variable Between the key words VAR_INPUT and END_VAR, all variables are declared that serve as input variables for a POU. That means that at the call position, the value of the variables can be given along with a call. Example: VAR_INPUT in1:INT (* 1. Inputvariable*) END_VAR
Output Variable Between the key words VAR_OUTPUT and END_VAR, all variables are declared that serve as output variables of a POU. That means that these values are carried back to the POU making the call. There they can be answered and used further. Example: VAR_OUTPUT out1:INT; (* 1. Outputvariable*) END_VAR
Input and Output Variables Between the key words VAR_IN_OUT and END_VAR, all variables are declared that serve as input and output variables for a POU. Attention: With this variable, the value of the transferred variable is changed ('transferred as a pointer', Call-byReference). That means that the input value for such variables cannot be a constant. For this reason, even the VAR_IN_OUT variables of a function block can not be read or written directly from outside via .
Example: VAR_IN_OUT inout1:INT; (* 1. Inputoutputvariable *) END_VAR
CoDeSys V2.3
5-3
Declaration Editor..
Local Variables Between the keywords VAR and END_VAR, all of the local variables of a POU are declared. These have no external connection; in other words, they can not be written from the outside. Example: VAR loc1:INT; (* 1. Local Variable*) END_VAR
Remanent variables Remanent variables can retain their value throughout the usual program run period. These include Retain variables and Persistent variables. •
Retain variables are identified by the keyword RETAIN. These variables maintain their value even after an uncontrolled shutdown of the controller as well as after a normal switch off and on of the controller (resp. at the command 'Online' 'Reset. When the program is run again, the stored values will be processed further. A concrete example would be an piece-counter in a production line, that recommences counting after a power failure. All other variables are newly initialized, either with their initialized values or with the standard initializations. Contrary to Persistent variables Retain Variables are reinitialized at a new download of the program.
•
Persistent variables are identified by the keyword PERSISTENT. Unlike Retain variables, these variables retain their value after a re-Download resp. at the command 'Online' 'Reset Original' or 'Online' 'Reset (cold)'), but not at switching off and on of the controller (i.e. not at the command 'Online' 'Reset'), because they are not saved in the 'retain area'. If also persistent variables should maintain their values after a uncontrolled shutdown of the controller, then they have to be declared additionally as VAR RETAIN variables. A concrete example of 'persistent Retain-Variables' would be a operations timer that recommences timing after a power failure.
Example: VAR RETAIN rem1:INT; (* 1. Retain variable*) END_VAR Attention:
• • •
If a local variable is declared as VAR RETAIN, then exactly that variable will be saved in the retain area (like a global retain variable) If a local variable in a function block is declared as VAR RETAIN, then the complete instance of the function block will be saved in the retain area (all data of the POU), whereby only the declared retain variable will be handled as a retain. If a local variable in a function is declared as VAR RETAIN, then this will be without any effect. The variable will not be saved in the retain area ! If a local variable is declared as PERSISTENT in a function, then this will be without any effect also !
Constants, Typed Literals Constants are identified by the key word CONSTANT. They can be declared locally or globally. Syntax: VAR CONSTANT : := ; END_VAR Example: VAR CONSTANT
5-4
CoDeSys V2.3
5 - Editors in CoDeSys
con1:INT:=12; (* 1. Constant*) END_VAR
See Appendix B: 'Operands in CoDeSys' for a listing of possible constants. See there also regarding the possibility of using typed constants (Typed Literals). External variables Global variables which are to be imported into the POU are designated with the keyword EXTERNAL. They also appear in the Watch window of the declaration part in Online mode. If the VAR_EXTERNAL declaration does not match the global declaration in every respect, the following error message appears: 'Declaration of ' does not match global declaration!' If the global variable does not exist, the following error message appears: 'Unkown global variable: '!' Example: VAR EXTERNAL var_ext1:INT:=12; (* 1st external variable *) END_VAR
Keywords Keywords are to be written in uppercase letters in all editors. Keywords may not be used as variables. Examples for keywords: VAR, VAR_CONSTANT, IF, NOT, INT. Variables declaration A variables declaration has the following syntax: {AT }: {:=}; The parts in the braces {} are optional. Regarding the identifier, that is the name of a variable, it should be noted that it may not contain spaces or umlaut characters, it may not be declared in duplicate and may not be identical to any keyword. Upper/lowercase writing of variables is ignored, in other words VAR1, Var1 and var1 are not different variables. Underlines in identifiers are meaningful, e.g. A_BCD and AB_CD are interpreted as different identifiers. Multiple consecutive underlines at the beginning of an identifier or within a identifier are not allowed. The length of the identifier, as well as the meaningful part of it, are unlimited. All declarations of variables and data type elements can include initialization. They are brought about by the ':=' operator. For variables of elementary types, these initializations are constants. The defaultinitialization is 0 for all declarations. Example: var1:INT:=12; (* Integer variable with initial value of 12*) If you wish to link a variable directly to a definite address, then you must declare the variable with the keyword AT. For faster input of the declarations, use the shortcut mode. In function blocks you can also specify variables with incomplete address statements. In order for such a variable to be used in a local instance, there must be an entry for it in the variable configuration. Pay attention to the possibility of an automatic declaration AT Declaration If you wish to link a variable directly to a definite address, then you must declare the variable with the keyword AT. The advantage of such a procedure is that you can assign a meaningful name to an
CoDeSys V2.3
5-5
Declaration Editor..
address, and that any necessary changes of an incoming or outgoing signal will only have to be made in one place (e.g., in the declaration). Notice that variables requiring an input cannot be accessed by writing. A further restriction is that AT declarations can only be made for local and global variables, and not for input- and output variables from POUs. Examples: counter_heat7 AT %QX0.0: BOOL; lightcabinetimpulse AT %IX7.2: BOOL; download AT %MX2.2: BOOL; Note:
If boolean variables are assigned to a Byte, Word or DWORD address, they occupy one byte with TRUE or FALSE, not just the first bit after the offset!
'Insert' 'Declaration keywords' You can use this command to open a list of all the keywords that can be used in the declaration part of a POU. After a keyword has been chosen and the choice has been confirmed, the word will be inserted at the present cursor position. You also receive the list, when you open the Input Assistant () and choose the Declarations category. 'Insert' 'Type' With this command you will receive a selection of the possible types for a declaration of variables. You also receive the list when you access the Input Assistant (). The types are divided into these categories: •
Standard types BOOL, BYTE, etc.
•
Defined types Structures, enumeration types, etc.
•
Standard function blocks for instance declarations
•
Defined function blocks for instance declarations
CoDeSys supports all standard types of IEC1131-3: Syntax Coloring In all editors you receive visual support in the implementation and declaration of variables. Errors are avoided, or discovered more quickly, because the text is displayed in color. A comment left unclosed, thus annotating instructions, will be noticed immediately; keywords will not be accidentally misspelled, etc. The following color highlighting will be used: Blue
Keywords
Green
Comments in the text editors
Pink
Special constants (e.g. TRUE/FALSE, T#3s, %IX0.0)
Red
Input error (for example, invalid time constant, keyword, written in lower case,..)
Black
Variables, constants, assignment operators, ..
Shortcut Mode The declaration editor for CoDeSys allows you to use the shortcut mode. This mode is activated when you end a line with The following shortcuts are supported:
5-6
CoDeSys V2.3
5 - Editors in CoDeSys
•
All identifiers up to the last identifier of a line will become declaration variable identifiers
•
The type of declaration is determined by the last identifier of the line. In this context, the following will apply: B or BOOL
gives the result
BOOL
I or INT
gives the result
INT
R or REAL
gives the result
REAL
S or string
gives the result
STRING
•
If no type has been established through these rules, then the type is BOOL and the last identifier will not be used as a type (Example 1.).
•
Every constant, depending on the type of declaration, will turn into an initialization or a string (Examples 2. and 3.).
•
An address (as in %MD12) is extended around the ATATDeclaration>Proc.. attribute(Example 4.).
•
A text after a semicolon (;) becomes a comment (Example 4.).
•
All other characters in the line are ignored (e.g., the exclamation point in Example 5.). Examples: Shortcut
Declaration
A
A: BOOL;
ABI2
A, B: INT := 2;
ST S 2; A string
ST:STRING(2); (* A string *)
X %MD12 R 5 Real X AT %MD12: REAL := 5.0;(* Real Number *) Number B!
B: BOOL;
Autodeclaration If the Autodeclaration option has been chosen in the Editor category of the Options dialog box , then a dialog box will appear in all editors after the input of a variable that has not yet been declared. With the help of this dialog box, the variable can now be declared. Dialog Box for Declaration of Variables
With the help of the Class combobox, select whether you are dealing with a local variable (VAR), input variable( (VAR_INPUT), output variable (VAR_OUTPUT), input/output variable (VAR_INOUT), or a global variable (VAR_GLOBAL). With the CONSTANT, RETAIN, PERSISTENT options, you can define whether you are dealing with a constant or a retain variable
CoDeSys V2.3
5-7
Declaration Editor..
The variable name you entered in the editor has been entered in the Name field, BOOL has been placed in the Type field. The from all possible data types.
button opens the Input Assistant dialog which allows you to select
If ARRAY is chosen as the variable type, the dialog for entering array boundaries appears. Dialog for determining array boundaries during automatic declaration
.
For each of the three possible dimensions (Dim.), array boundaries can be entered under Start and End by clicking with the mouse on the corresponding field to open an editing space. The array data type is entered in the Type field. In doing this, the dialog.
button can be used to call up an input assistant
Upon leaving the array boundaries dialog via the OK button, variable declarations in IEC format are set up based on the entries in the Type field in the dialog. Example: ARRAY [1.5, 1.3] OF INT In the field Initial value, you may enter the initial value of the variable being declared. If this is an array or a valid structure, you can open a special initialization dialog via the input assistant dialog for other variable types.
button or , or open the
In the initialization dialog for an array you are presented a list of array elements; a mouse click on the space following „:='opens an editing field for entering the initial value of an element. In the initialization dialog for a structure, individual components are displayed in a tree structure. The type and default initial value appear in brackets after the variable name; each is followed by „:='. A mouse click on the field following „:=' opens an editing field in which you can enter the desired initial value. If the component is an array, then the display of individual fields in the array can be expanded by a mouse click on the plus sign before the array name and the fields can be edited with initial values. After leaving the initialization dialog with OK, the initialization of the array or the structure appears in the field Initial value of the declaration dialog in IEC format. Example: x:=5,field:=2,3,struct2:=(a:=2,b:=3) In the Address field, you can bind the variable being declared to an IEC address (AT declaration). If applicable, enter a Comment. The comment can be formatted with line breaks by using the key combination + . By pressing OK, the declaration dialog is closed and the variable is entered in the corresponding declaration editor in accordance to the IEC syntax. Note:
The dialog box for variable declaration you also get by the command 'Edit' 'Declare Variable' . If the cursor is resting on a variable in Online mode, the Autodeclare window can be opened with with the current variable-related settings displayed.
Line Numbers in the Declaration Editor In offline mode, a simple click on a special line number will mark the entire text line.
5-8
CoDeSys V2.3
5 - Editors in CoDeSys
In the online mode, a single click on a specific line number will open up or close the variable in this line, in case a structural variable is involved. Declarations as tables If the Declarations as table option is activated in the Options dialog box in the category, the declaration editor looks like a table. As in a card-index box, you can select the register cards of the respective variable types and edit the variables. For each variable you are given the following entry fields. Name:
Input the identifier of the variable.
Address:
If necessary, input the address of the variable (AT declaration)
Type:
Input the type of the variable. (Input the function block when instantiating a function block)
Initial:
Enter a possible initialization of the variable (corresponding to the ':= ' assignment operator).
Comment: Enter a comment here. Both of the display types of the declaration editor can be changed without causing any problems. In the online mode, there are no differences for the display. In order to edit a new variable, select the 'Insert' 'New Declaration' command. Declaration Editor as a Table
'Insert' 'New Declaration' With this command you bring a new variable into the declaration table of the declaration editor. If the present cursor position is located in an field of the table, then the new variable will be pasted in the preceding line; otherwise, the new variable is pasted at the end of the table. Moreover, you can paste a new declaration at the end of the table by using the right arrow key or the tab key in the last field of the table. You will receive a variable that has 'Name' located in the Name field, and 'Bool' located in the Type field, as its default setting. You should change these values to the desired values. Name and type are all that is necessary for a complete declaration of variables. Pragma instructiion The pragma instruction is used to affect the properties of a variable concerning the compilation 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, upper- and lower-case are ignored: { } If the compiler cannot meaningfully interpret the instruction text, the entire pragma is handled as a comment and read over. A warning is issued, however: „Ignore compiler directive ‚’!'
CoDeSys V2.3
5-9
Declaration Editor..
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 pragma may currently be used: {flag [] [off on]} 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
noread, nowrite:
The variable will not get exported to the symbol file
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 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:
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
The flags „n oread' 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:
5-10
CoDeSys V2.3
5 - Editors in CoDeSys
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: { 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. Declaration Editors in Online Mode In online mode , the declaration editor changes into a monitor window. In each line there is a variable followed by the equal sign (=) and the value of the variable. If the variable at this point is undefined, three question marks (???) will appear. For function blocks, values are displayed only for open instances (command: 'Project' 'Open instance'). In front of every multi-element variable there is a plus sign. By pressing or after doubleclicking on such a variable, the variable is opened up. In the example, the traffic signal structure would be opened up.
CoDeSys V2.3
5-11
The Text Editors..
When a variable is open, all of its components are listed after it. A minus sign appears in front of the variable. If you doubleclick again or press , the variable will be closed, and the plus sign will reappear. Pressing or doubleclicking 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.3
The Text Editors.. The text editors used for the implementation portion (the Instruction List editor and the Structured Text editor) of CoDeSys provide the usual Windows text editor functions. The implementation in the text editors is supported by syntax coloring. In Overwrite mode the status bar shows a black OV. You can switch between Overwrite mode and Insert mode by key
The most important commands are found in the context menu (right mouse button or +). The text editors use the following menu commands in special ways:
5-12
CoDeSys V2.3
5 - Editors in CoDeSys
'Insert' 'Operators'in text editors With this command all of the operators available in the current language are displayed in a dialog box. If one of the operators is selected and the list is closed with OK, then the highlighted operator will be inserted at the present cursor position. (This is managed here just as it is in the Input Assistant). 'Insert' 'Operand'in text editors With this command all variables in a dialog box are displayed. You can select whether you would like to display a list of the global, the local, or the system variables. If one of the operands is chosen, and the dialog box is closed with OK, then the highlighted operand will be inserted at the present cursor position. (This is managed here just as it is in the Input Assistant). 'Insert' 'Function' in text editors With this command all functions will be displayed in a dialog box. You can choose whether to have a list displaying user-defined or standard functions. If one of the functions is selected and the dialog box is closed with OK, then the highlighted function will be inserted at the current cursor position. (The management will proceed, as in the input selection.) If the With arguments option was selected in the dialog box, then the necessary input and output variables will also be inserted. 'Insert' 'Function Block' in text editors With this command all function blocks are displayed in a dialog box. You can choose whether to have a list displaying user-defined or standard function blocks. If one of the function blocks is selected and the dialog box is closed with OK, then the highlighted function block will be inserted at the current cursor position. (This is managed here just as it is in the Input Assistant). If the With arguments option was selected in the dialog box, then the necessary input variables of the function block will also be inserted. Calling POUs with output parameters in text editors The output parameters of a called POU can be directly assigned upon being called in the text languages IL and ST. Example: Output parameter out1 of afbinst is assigned variable a. IL: CAL afbinst(in1:=1, out1=>a) ST: afbinst(in1:=1, out1=>a); The text editors in Online mode The online functions in the editors are set breakpoint and single step processing (steps). Together with the monitoring, the user thus has the debugging capability of a modern Windows standard language debugger. In Online mode, the text editor window is vertically divided in halves. On the left side of the window you will then find the normal program text; on the right side you will see a display of the variables whose values were changed in the respective lines. The display is the same as in the declaration part. That means that when the PLC is running, the present values of the respective variables will be displayed. The following should be noted when monitoring expressions or Bit-addressed variables: in the case of expressions, the value of the entire expression is always displayed. Example: a AND b is displayed in blue or with „:=TRUE' if both a and b are TRUE. For Bit-addressed variables, the bit value that is addressed is always monitored (e.g. a.3 is displayed in blue or with „:=TRUE, if a has the value 4).
CoDeSys V2.3
5-13
The Text Editors..
If you place the mouse pointer briefly above a variable, then the type, the address and the comment about the variable will be displayed in a Tooltip. 'Extras' 'Monitoring Options' With this command you can configure your monitoring window. In the text editors, the window is divided into two halves during monitoring. The program is located in the left half. In the right half, all variables that are located in the corresponding program line are monitored. You can specify the Monitor Window Width and which Distance two variables should have in a line. An distance declaration of 1 corresponds, in this case, to a line height in the selected font. Monitoring Options Dialog Box
Breakpoint Positions in Text Editor Since in CoDeSys several IL lines are internally combined into a single C-code line, breakpoints can not be set in every line. Breakpoint positions include all positions in a program at which values of variables can change or where the program flow branches off. (Exception: function calls. If necessary, a breakpoint in the function must be set here.) At the positions lying inbetween, a breakpoint would not even make sense, since nothing has been able to change in the data since the preceding breakpoint position. This results in the following breakpoint positions in the IL: •
At the start of the POU
•
At every LD, LDN (or, in case a LD is located at a label, then at the label)
•
At every JMP, JMPC, JMPCN
•
At every label
•
At every CAL, CALC, CALCN
•
At every RET, RETC, RETCN
•
At the end of the POU
•
Structured Text accommodates the following breakpoint positions:
•
At every assignment
•
At every RETURN and EXIT instruction
•
in lines where conditions are being evaluated (WHILE, IF, REPEAT)
•
At the end of the POU
Breakpoint positions are marked by the display of the line number field in the color which is set in the project options.
5-14
CoDeSys V2.3
5 - Editors in CoDeSys
IL Editor with Possible Breakpoint Positions (darker number fields)
How do you set a breakpoint? In order to set a breakpoint, click the line number field of the line where you want to set a breakpoint. If the selected field is a breakpoint position, then the color of the line numbers field will change from dark gray to light blue, and the breakpoint will be activated in the PLC. Deleting Breakpoints Correspondingly, in order to delete a breakpoint, click on the line number field of the line with the breakpoint to be deleted. Setting and deleting of breakpoints can also be selected via the menu ('Online' 'Toggle Breakpoint'), via the function key , or via the symbol in the tool bar. What happens at a breakpoint? If a breakpoint is reached in the PLC, then the screen will display the break with the corresponding line. The line number field of the line where the PLC is positioned will appear in red. The user program is stopped in the PLC. If the program is at a breakpoint, then the processing can be resumed with 'Online' 'Run'. In addition, with 'Online' 'Step over' or 'Step in' you can cause the program to run to the next breakpoint position. If the instruction where you are located is a CAL command, or, if there is a function call in the lines up to the next breakpoint position, then you can use 'Step over' to bypass the function call. With 'Step in', you will branch to the open POU Line Number of the Text Editor The line numbers of the text editor give the number of each text line of an implementation of a POU. In Off-line text line.
mode,
a
simple
click
on
a
special
line
number
will
mark
the
entire
In Online mode, the background color of the line number indicates the breakpoint status of every line. The standard settings for the colors are • dark gray: This line is a possible position for a breakpoint. • light blue: a breakpoint has been set in this line. • red: The program has reached this point. In Online mode, simply clicking the mouse will change the breakpoint status of this line.
CoDeSys V2.3
5-15
The Text Editors..
5.3.1
The Instruction List Editor.. This is how a POU written in the IL looks under the corresponding CoDeSys editor:
All editors for POUs consist of a declaration part and a body. These are separated by a screen divider. The Instruction List editor is a text editor with the usual capabilities of Windows text editors. The most important commands are found in the context menu (right mouse button or +).Multiline POU calls are also possible: Example: CAL CTU_inst( CU:=%IX10, PV:=( LD A ADD 5 ) )
For information concerning the language, see Chapter 2.2.1, Instruction List (IL). IL in Online mode With the 'Online' 'Flow control' command, an additional field in which the accumulator contents is displayed is inserted in the IL editor on the left side of every line. For further information concerning the IL editor in Online mode, see 'The Text Editors in Online Mode'.
5-16
CoDeSys V2.3
5 - Editors in CoDeSys
5.3.2
The Editor for Structured Text.. This is how a POU written in ST appears under the corresponding CoDeSys editor:
All editors for POUs consist of a declaration part and a body. These are separated by a screen divider. The editor for Structured Text is a text editor with the usual capabilities of Windows text editors. The most important commands are found in the context menu (right mouse button or +). For information about the language, see Chapter 2.2.2, 'Structured Text (ST).
5.4
The Graphic Editors.. The editors of the graphically oriented languages, sequential function chart SFC, ladder diagram LD and function block diagram FBD and of free graphic function block diagrams have many points in common. In the following paragraphs these features will be summarized; the specific descriptions of LD, FBD an CFC, as well as the Sequential Function Chart language SFC follow in separate sections. The implementation in the graphics editors is supported by syntax coloring.
Zoom Objects such as POUs, actions, transitions etc. in the languages SFC, LD, FBD, CFC and in visualizations can be enlarged or reduced in size with a zoom function. All elements of the window contents of the implementation part are affected; the declaration part remains unchanged. In standard form, every object is displayed with the zoom level 100%. The zoom level that is set is saved as an object property in the project. The printing of project documentation always occurs at the 100% display level! The zoom level can be set through a selection list in the toolbar. Values between 25% and 400% can be selected; individual values between 10% and 500% can be entered manually. The selection of a zoom level is only available if the cursor rests on an object created in a graphical language or a visualization object.
CoDeSys V2.3
5-17
The Graphic Editors..
Even with the object zoomed, cursor positions in the editors can be further selected and even reached with the arrow keys. Text size is governed by the zoom factor and the font size that is set. The execution of all editor menu features (e.g. inserting a box) as a function of cursor position is available at all zoom levels, taking the same into account. In Online mode, each object is displayed according to the zoom level that has been set; Online functionality is available without restriction. When the IntelliMouse is used, an object can be enlarged/reduced by pressing the key and at the same time turning the wheel forward or backwards. Network In the LD and FBD editors, the program is arranged in a list of networks. Each network is designated on the left side by a serial network number and has a structure consisting of either a logical or an arithmetic expression, a program, function or function block call, and a jump or a return instruction. Label Each network has a label that can optionally be left empty. This label is edited by clicking the first line of the network, directly next to the network number. Now you can enter a label, followed by a colon. Network Comments, Networks with Linebreaks, 'Extras' 'Options' Every network can be supplied with a multi-lined comment. In the dialog 'Function Block and Ladder Diagram Options', which can be opened by executing the command 'Extras' 'Options', you can do the settings concerning comments and linebreaks: In the maximum comment size field you can enter the maximum number of lines to be made available for a network comment (The default value here is 4.) In the field minimum comment size you can enter the number of lines that generally should be reserved for . If, for example, the number 2 is entered, then, at the start of each network there will be two empty lines after the label line. The default value here is 0, which has the advantage of allowing more networks to fit in the screen area. If the minimal comment size is greater than 0, then in order to enter a comment you simply click in the comment line and then enter the comment. Otherwise you first must select the network to which a comment is to be entered, and use 'Insert' 'Comment' to insert a comment line. In contrast to the program text, comments are displayed in grey. In the Ladder editor you can also assign an individual comment to each contact or coil. For this activate the option Comments per Contact and insert in the edit field Lines for variable comment the number of lines which should be reserved and displayed for the comment. If this setting is done, a comment field will be displayed in the editor above each contact and coil where you can insert text. If the option Comments per Contact is activated, then in the Ladder editor also the number of lines (Lines for variable text :) can be defined which should be used for the variable name of the contact resp. coil. This is used to display even long names completely by breaking them into several lines. In the Ladder editor it is possible to force linebreaks in the networks as soon as the network length would exceed the given window size and some of the elements would not be visible. For this activate the option Networks with Linebreaks. 'Insert' 'Network (after)' or 'Insert' 'Network (before)' Shortcut: + (Network after) In order to insert a new network in the FBD or the LD editor, select the 'Insert' 'Network (after)' or the 'Insert' 'Network (before)' command, depending on whether you want to insert the new network before or after the present network. The present network can be changed by clicking the network number. You will recognize it in the dotted rectangle under the number. With the and a mouse click you can select from the entire area of networks, from the present one to the one clicked. The network editors in the online mode In the FBD and the LD editors you can only set breakpoints for networks. The network number field of a network for which a breakpoint has been set, is displayed in blue. The processing then stops in front
5-18
CoDeSys V2.3
5 - Editors in CoDeSys
of the network, where the breakpoint is located. In this case, the network number field is displayed in red. With single step processing (steps), you can jump from network to network. All values are monitored upon entering and exiting network POUs (Program Organization Units). The following should be noted when monitoring expressions or Bit-addressed variables: In expressions, e.g. a AND b, used as transition condition or function block input, the value of the whole expression is always displayed (a AND b is shown in blue or as :=TRUE, if a and b are TRUE). For Bit-addressed variables, the bit value that is addressed is always monitored (e.g. a.3 is displayed in blue or with „:=TRUE, if a has the value 4) The flow control is run with the 'Online' 'Flow control' command. Using the flow control, you can view the present values that are being carried in the networks over the connecting lines. If the connecting lines do not carry Boolean values, then the value will be displayed in a specially inserted field. The monitor fields for variables that are not used (e.g. in the function SEL) are displayed in a shade of grey. If the lines carry Boolean values, then they will be shaded blue, in the event that they carry TRUE. Therefore, you can accompany the flow of information while the PLC is running. If you place the mouse pointer briefly above a variable, then the type, the address and the comment about the variable will be displayed in a Tooltip.
5.4.1
The Function Block Diagram Editor.. This is how a POU written in the FBD under the corresponding CoDeSys editor looks:
The Function Block Diagram editor is a graphic editor. It works with a list of networks, in which every network contains a structure that displays, respectively, a logical or an arithmetical expression, the calling up of a function block, a function, a program, a jump, or a return instruction.The most important commands are found in the context menu (right mouse button or +). Regard the possibility to switch the display of a FUP-POU between FUP- and KOP editor, in offline mode as well as in online mode. Cursor positions in FBD Every text is a possible cursor position. The selected text is on a blue background and can now be changed.
CoDeSys V2.3
5-19
The Graphic Editors..
You can also recognize the present cursor position by a dotted rectangle. The following is a list of all possible cursor positions with an example: 1) Every text field (possible cursor positions framed in black):
2) Every input:
3) Every operator, function, or function block:
4) Outputs, if an assignment or a jump comes afterward:
5) The lined cross above an assignment, a jump, or a return instruction:
6) Behind the outermost object on the right of every network ('last cursor position,' the same cursor position that was used to select a network):
7) The lined cross directly in front of an assignment:
How to set the cursor in FBD The cursor can be set at a certain position by clicking the mouse, or with the help of the keyboard. Using the arrow keys, you can jump to the nearest cursor position in the selected direction at any time. All cursor positions, including the text fields, can be accessed this way. If the last cursor position is selected, then the or arrow keys can be used to select the last cursor position of the previous or subsequent network. An empty network contains only three question marks '???'. By clicking behind these, the last cursor position is selected. 'Insert' 'Assign' in FBD Symbol:
Shortcut: +
This command inserts an assignment.
5-20
CoDeSys V2.3
5 - Editors in CoDeSys
Depending on the selected position (see 'Cursor positions in FBD'), insertion takes place directly in front of the selected input (Cursor Position 2), directly after the selected output (Cursor Position 4) or at the end of the network (Cursor Position 6). For an inserted assignment, a selection can be made accompanying the entered text '???', and the assignment can be replaced by the variable that is to be assigned. For this you can also use the Input Assistant. In order to insert an additional assignment to an existing assignment, use the 'Insert' 'Output' command. 'Insert' 'Jump' in FBD Symbol:
Shortcut: +
This command inserts a jump. Depending on the selected position (see 'Cursor positions in FBD'), insertion takes place directly in front of the selected input (Cursor Position 2), directly after the selected output (Cursor Position 4) or at the end of the network (Cursor Position 6). For an inserted jump, a selection can be made accompanying the entered text '???', and the jump can be replaced by the label to which it is to be assigned. 'Insert' 'Return' in FBD Symbol:
Shortcut: +
This command inserts a RETURN instruction. Depending on the selected position (see 'Cursor positions in FBD'), insertion takes place directly in front of the selected input (Cursor Position 2),directly after the selected output (Cursor Position 4), directly before the selected line cross (Cursor Position 5), or at the end of the network (Cursor Position 6) 'Insert' 'Box' in FBD Symbol:
Shortcut: +
With this command, operators, functions, function blocks and programs can be inserted. First of all, it is always inserted an 'AND' operator. This can be converted by Selection and Overwrite of the type text („AND') into every other operator, into every function, into every function block and every program. You can select the desired POU by using Input Assistant (). If the new selected block has another minimum number of inputs, these will be attached. If the new block has a smaller highest number of inputs, the last inputs will be deleted. In functions and function blocks, the formal names of the in- and outputs are displayed. In function blocks there exists an editable instance field above the box. If another function block that is not known is called by changing the type text, an operator box with two inputs and the given type is displayed. If the instance field is selected, Input Assistant can be obtained via with the categories for variable selection. The newest POU is inserted at the selected position: •
If an input is selected (Cursor Position 2), then the POU is inserted in front of this input. The first input of this POU is linked to the branch on the left of the selected input. The output of the new POU is linked to the selected input.
•
If an output is selected (Cursor Position 4), then the POU is inserted after this output. The first input of the POU is connected with the selected output. The output of the new POU is linked to the branch with which the selected output was linked.
•
If a POU, a function, or a function block is selected (Cursor Position 3), then the old element will be replaced by the new POU.
CoDeSys V2.3
5-21
The Graphic Editors..
•
As far as possible, the branches will be connected the same way as they were before the replacement. If the old element had more inputs than the new one, then the unattachable branches will be deleted. The same holds true for the outputs.
•
If a jump or a return is selected, then the POU will be inserted before this jump or return. The first input of the POU is connected with the branch to the left of the selected element. The output of the POU is linked to the branch to the right of the selected element.
•
If the last cursor position of a network is selected (Cursor Position 6), then the POU will be inserted following the last element. The first input of the POU is linked to the branch to the left of the selected position.
All POU inputs that could not be linked will receive the text '???'. This text must be clicked and changed into the desired constant or variable. If there is a branch to the right of an inserted POU, then the branch will be assigned to the first POU output. Otherwise the outputs remain unassigned. 'Insert' 'Input' Symbol:
Shortcut: +
This command inserts an operator input. With many operators, the number of inputs may vary. (For example, ADD can have 2 or more inputs.) In order to extend such an operator by an input, you need to select the input in front of which you wish to insert an additional input (Cursor Position 1); or you must select the operator itself (Cursor Position 3), if a lowest input is to be inserted (see 'Cursor positions in FBD'). The inserted input is allocated with the text '???'. This text must be clicked and changed into the desired constant or variable. For this you can also use the Input Assistant. 'Insert' 'Output' Symbol: This command inserts an additional assignment into an existing assignment. This capability serves the placement of so-called assignment combs; i.e., the assignment of the value presently located at the line to several variables. If you select the lined cross above an assignment (Cursor Position 5) (see 'Cursor positions in FBD') or the output directly in front of it (Cursor Position 4), then there will be another assignment inserted after the ones already there. If the line cross directly in front of an assignment is selected (Cursor Position 4), then another assignment will be inserted in front of this one. The inserted output is allocated with the text '???'. This text must be clicked and changed into the desired variable. For this you can also use the Input Assistant. 'Extras' 'Negate Symbol:
Shortcut: +
With this command you can negate the inputs, outputs, jumps, or RETURN instructions. The symbol for the negation is a small circle at a connection. If an input is selected (Cursor Position 2) (see 'Cursor positions in FBD'), then this input will be negated. If an output is selected (Cursor Position 4), then this output will be negated. If a jump or a return is marked, then the input of this jump or return will be negated. A negation can be canceled through renewed negation.
5-22
CoDeSys V2.3
5 - Editors in CoDeSys
'Extras' 'Set/Reset' Symbol: With this command you can define outputs as Set or Reset Outputs. A grid with Set Output is displayed with [S], and a grid with Reset Output is displayed with [R]. Set/Reset Outputs in FBD
An Output Set is set to TRUE, if the grid belonging to it returns TRUE. The output now maintains this value, even if the grid jumps back to FALSE. An Output Reset is set to FALSE, if the grid belonging to it returns FALSE. The output maintains its value, even if the grid jumps back to FALSE. With multiple executions of the command, the output will alternate between set, reset, and normal output. 'Extras' 'View' Using this command for a POU created in the FBD-Editor you can choose, whether it should be displayed in the LD- (ladder logic) or in the FBD-Editor (Function block diagram). This is possible in offline as as well as in online mode. Open instance This command corresponds to the 'Project' 'Open instance' command. It is available in the context menu () or in the 'Extras' menu, if the cursor is positioned on the name of a function block in a text editor or if the function block box is selected in a graphic editor. Cutting, Copying, Pasting, and Deleting in FBD The commands used to 'Cut', 'Copy', 'Paste', and 'Delete' are found under the 'Edit' menu item. If a line cross is selected(Cursor Position 5) (see 'Cursor positions in FBD'), then the assignments, jumps, or RETURNS located below the crossed line will be cut, deleted, or copied. If a POU is selected (Cursor Position 3), then the selected object itself, will be cut, deleted, or copied, along with all of the branches dependent on the inputs, with the exception of the first (highest position) branch. Otherwise, the entire branch located in front of the cursor position will be cut, deleted, or copied. After copying or cutting, the deleted or copied part is located on the clipboard and can now be pasted, as desired. In order to do so, you must first select the pasting point. Valid pasting points include inputs and outputs. If a POU has been loaded onto the clipboard (As a reminder: in this case all connected branches except the first are located together on the clipboard), the first input is connected with the branch before the pasting point. Otherwise, the entire branch located in front of the pasting point will be replaced by the contents of the clipboard. In each case, the last element pasted is connected to the branch located in front of the pasting point.
CoDeSys V2.3
5-23
The Graphic Editors..
Note:
The following problem is solved by cutting and pasting: A new operator is inserted in the middle of a network. The branch located on the right of the operator is now connected with the first input, but should be connected with the second input. You can now select the first input and perform the command 'Edit' 'Cut'. Following this, you can select the second input and perform the command 'Edit' 'Paste'. This way, the branch is dependent on the second input.
The Function Block Diagram in the Online Mode In the Function Block Diagram, breakpoints can only be set to networks. If a breakpoint has been set to a network, then the network numbers field will be displayed in blue. The processing then stops in front of the network where the breakpoint is located. In this case, the network numbers field will become red. Using stepping (single step), you can jump from network to network. The current value is displayed for each variable. Exception: If the input to a function block is an expression, only the first variable in the expression is monitored. Doubleclicking on a variable opens the dialog box for writing 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 will turn red and will remain 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. The flow control is started with the 'Online' 'Flow control' command Using the flow control, you can view the present values that are being carried in the networks over the connecting lines. If the connecting lines do not carry Boolean values, then the value will be displayed in a specially inserted field. If the lines carry Boolean values, then they will be shaded blue in the event that they carry TRUE. By this means, you can accompany the fl ow of information while the PLC is running. If you place the mouse pointer briefly above a variable, then the type, the address and the comment about the variable will be displayed in a Tooltip.
5.4.2
The Ladder Editor.. This is how a POU written in the LD appears in the CoDeSys editor:
5-24
CoDeSys V2.3
5 - Editors in CoDeSys
All editors for POUs consist of a declaration part and a body. These are separated by a screen divider. The LD editor is a graphic editor. The most important commands are found in the context menu (right mouse button or +). For information about the elements, see Chapter 2.2.6, Ladder Diagram (LD). Cursor Positions in the LD Editors The following locations can be cursor positions, in which the function block and program accessing can be handled as contacts. POUs with EN inputs and other POUs connected to them are treated the same way as in the Function Block Diagram. Information about editing this network part can be found in the chapteron the FBD Editor. 1. Every text field (possible cursor positions framed in black)
2. Every Contact or Function Block
3. Every Coil
4. The Connecting Line between the Contacts and the Coils.
The Ladder Diagram uses the following menu commands in a special way: Move elements in the LD-Editor An element can be moved to a different position within a LD POU by 'drag&drop'. In order to do this select the desired element (contact, coil, function block) and drag it - keeping the mouse key pressed - away from the current position. Thereupon all possible postions within all networks of the POU, to which the element might be moved, will be indicated by grey-filled rectangles. Move the element to one of these positions and let off the mouse key: the element will be inserted at the new position.
CoDeSys V2.3
5-25
The Graphic Editors..
'Insert' 'Contact' in LD Symbol:
Shortcut: +
Use this command in the LD editor in order to insert a contact in front of the marked location in the network. If the marked position is a coil or the connecting line between the contacts and the coils, then the new contact will be connected serially to the previous contact connection. The contact is preset with the text '???'. You can click on this text and change it to the desired variable or the desired constant. For this you can also use the Input Assistant. You can activate the options Comments per Contact and Lines for variable comment in the dialog 'Function Block and Ladder Diagram Options' ('Extras' 'Options') to reserve a certain number of lines for the variable name. This might be useful, if long variable names are used, to keep the network short. Also regard the option Networks with linebreaks, which you also can activate in the Ladder Diagram Options. Example for the options dialog and the resulting display in a FBD or Ladder network:
'Insert' 'Parallel Contact' Symbol:
Shortcut: +
Use this command in the LD editor to insert a contact parallel to the marked position in the network. If the marked position is a coil or the connection between the contacts and the coils, then the new contact will be connected in parallel to the entire previous contact connection.
5-26
CoDeSys V2.3
5 - Editors in CoDeSys
The contact is preset with the text '???'. You can click on this text and change it to the desired variable or the desired constant. For this you can also use the Input Assistant. It is possible to display the variable name with linebreaks. Also a separate comment can be inserted for the contact. For a description see 'Insert' 'Contact' . 'Insert' 'Function Block' in LD Shortcut: + Use this command in order to insert an operator, a function block, a function or a program as a POU. For this, the connection between the contacts and the coils, or a coil, must be marked. The new POU at first has the designation AND. If you wish, you can change this designation to another one. For this you can also use the Input Assistant. Both standard and self-defined POUs are available. The first input to the POU is placed on the input connection, the first output on the output connection; thus these variables must definitely be of type BOOL. All other in- and outputs of the POU are filled with the text „???'. These prior entries can be changed into other constants, variables or addresses. For this you can also use the Input Assistant. 'Insert' 'Coil' in LD Symbol:
Shortcut: +
You can use this command in the LD editor to insert a coil in parallel to the previous coils. If the marked position is a connection between the contacts and the coils, then the new coil will be inserted as the last. If the marked position is a coil, then the new coil will be inserted directly above it. The coil is given the text '???' as a default setting. You can click on this text and change it to the desired variable. For this you can also use the Input Assistant. It is possible to display the variable name with linebreaks. Also a separate comment can be inserted for the coil. For a description see 'Insert' 'Contact' POUs with EN Inputs If you want to use your LD network as a PLC for calling up other POUs , then you must merge a POU with an EN input. Such a POU is connected in parallel to the coils. Beyond such a POU you can develop the network further, as in the Function Block Diagram. You can find the commands for insertion at an EN POU under the menu item 'Insert' 'Insert at Blocks'. An operator, a function block, a program or a function with EN input performs the same way as the corresponding POU in the Function Block Diagram, except that its execution is controlled on the EN input. This input is annexed at the connecting line between coils and contacts. If this connection carries the information 'On', then the POU will be evaluated. If a POU has been created once already with EN input, then this POU can be used to create a network. This means that data from usual operators, functions, and function blocks can flow in an EN POU and an EN POU can carry data to such usual POUs. If, therefore, you want to program a network in the LD editor, as in FBD, you only need first to insert an EN operator in a new network. Subsequently, from this POU, you can continue to construct from your network, as in the FBD editor. A network thus formed will perform like the corresponding network in FBD. 'Insert' 'Box with EN in LD' Use this command to insert a function block, an operator, a function or a program with EN input into a LD network. The marked position must be the connection between the contacts and the coils (Cursor Position 4) or a coil (Cursor Position 3). The new POU is inserted in parallel to the coils and underneath them; it contains initially the designation 'AND'. If you wish, you can change this designation to another one. For this you can also use the Input Assistant.
CoDeSys V2.3
5-27
The Graphic Editors..
'Insert' 'Insert at Blocks in LD With this command you can insert additional elements into a POU that has already been inserted (also a POU with EN input). The commands below this menu item can be executed at the same cursor positions as the corresponding commands in the Function Block Diagram. With Input you can add a new input to the POU. With Output you can add a new output to the POU. With POU, you insert a new POU. The procedure is similar to that described under 'Insert' 'POU'. With Assign you can insert an assignment to a variable. At first, this is shown by three question marks „???', which you edit and replac e with the desired variable. Input assistance is available for this purpose. 'Insert' 'Jump' in LD With this command you can insert a parallel jump in the selected LD editor, in parallel, at the end of the previous coils. If the incoming line delivers the value 'On', then the jump will be executed to the indicated label. The marked position must be the connection between the contacts and the coilsor a coil. The jump is present with the text '???'. You can click on this text and make a change in the desired label. 'Insert' 'Return' in LD In the LD editor, you can use this command to insert a Return instruction in parallel at the end of the previous coils. If the incoming line delivers the value 'On,' then the processing of the POU in this network is broken off. The marked position must be the connection between the contacts and the coilsor a coil. 'Extras' 'Paste after' in LD Use this command in the LD editor to paste the contents of the clipboard as serial contact below the marked position. This command is only possible if the contents of the clipboard and the marked position are networks comprised of contacts. 'Extras' 'Paste below'in LD Shortcut: + Use this command in the LD editor to insert the contents of the clipboard as parallel contact below the marked position. This command is only possible if the contents of the clipboard and the marked position are networks comprised of contacts. 'Extras' 'Paste above' in LD Use this command in the LD editor to insert the contents of the clipboard as parallel contact above the marked position. This command is only possible if the contents of the clipboard and the marked position are networks comprised of contacts. 'Extras' 'Negate' in LD Symbol:
Shortcut: +
Use this command to negate a contact, a coil, a jump or return instruction, or an input or output of EN POUs at the present cursor position . Between the parentheses of the coil or between the straight lines of the contact, a slash will appear ((/) or / ). If there are jumps, returns, or inputs or outputs of EN POUs, a small circle will appear at the connection, just as in the FBD editor.
5-28
CoDeSys V2.3
5 - Editors in CoDeSys
The coil now writes the negated value of the input connection in the respective Boolean variable. Right at this moment, a negated contact switches the status of the input to the output, if the respective Boolean variable carries the value FALSE. If a jump or a return is marked, then the input of this jump or return will be negated. A negation can be canceled through renewed negation. 'Extras' 'Set/Reset' in LD If you execute this command on a coil, then you will receive a Set Coil. Such a coil never overwrites the value TRUE in the respective Boolean variable. This means that once you have set the value of this variable to TRUE, it will always remain at TRUE. A Set Coil is designated with an 'S' in the coil symbol. If you execute this command once again, then you will be given a Reset coil. Such a coil never overwrites the value FALSE in the respective Boolean variable. This means that once you have set the value of this variable to FALSE, it will always remain at FALSE. A Reset Coil is designated with an 'R' in the coil symbol. If you execute this command repeatedly, the coil will alternate between set, reset and normal coil. The Ladder Diagram in the Online Mode In Online mode, the contacts and coils in the Ladder Diagram that are in the 'On' state are colored blue. Likewise, all lines over which the 'On' is carried are also colored blue. At the inputs and outputs of function blocks, the values of the corresponding variables are indicated. Breakpoints can only be set on networks; by using stepping, you can jump from network to network. If you place the mouse pointer briefly above a variable, then the type, the address and the comment about the variable will be displayed in a Tooltip.
5.4.3
The Sequential Function Chart Editor.. This is how a POU written in the SFC appears in the CoDeSys editor:
CoDeSys V2.3
5-29
The Graphic Editors..
All editors for POUs consist of a declaration part and a body. These are separated by a screen divider. The Sequential Function Chart editor is a graphic editor. The most important commands are found in the context menu (right mouse button or ). Tooltips show in Offline as well as in Online mode and in the zoomed state the full names or expressions of steps, transitions, jumps, jump labels, qualifiers or associated actions. For information about the Sequential Function Chart see Chapter 2.2.3, 'Sequential Function Chart'. The editor for the Sequential Function Chart must agree with the particulars of the SFC. In reference to these, the following menu items will be of service. Marking Blocks in the SFC A marked block is a bunch of SFC elements that are enclosed in a dotted rectangle. You can select an element (a step, a transition, or a jump) by pointing the mouse on this element and pressing the left mouse button, or you can use the arrow keys. In order to mark a group of several elements, press for a block already marked, and select the element in the lower left or right corner of the group. The resulting selection is the smallest cohesive group of elements that includes both of these elements. Please regard, that a step can only be deleted together with the preceeding or the succeeding transition ! 'Insert' 'Step Transition (before)' Symbol:
Shortcut: +
This command inserts a step in the SFC editor followed by a transition in front of the marked block. 'Insert' 'Step Transition (after)' Symbol:
Shortcut: +
This command inserts a step in the SFC editor followed by a transition after the first transition in the marked block. Delete Step and Transition A step can only be deleted together with the preceeding or the succeeding transition. For this purpose put a selection frame around step and transition and choose command 'Edit' 'Delete' or press the
Shortcut: +
This command inserts an alternative branch in the SFC editor as a right branch of the marked block. For this the marked block must both begin and end with a transition. The new branch is then made up of one transition. 'Insert' 'Alternative Branch (left)' Symbol: This command inserts an alternative branch in the SFC editor as the left branch of the marked block. For this the marked block must both begin and end with a transition. The new branch is then made up of one transition.
5-30
CoDeSys V2.3
5 - Editors in CoDeSys
'Insert' 'Parallel Branch (right)' Symbol:
Shortcut: +
This command inserts a parallel branch in the SFC editor as the right branch of the marked block. For this the marked block must both begin and end with a step. The new branch is then made up of one step. To allow jumps to the parallel branches that have been created, these must be provided with a jump label. 'Insert' 'Parallel Branch (left)' Symbol: 'This command inserts a parallel branch in the SFC editor as the left branch of the marked block. For this the marked block must both begin and end with a step. The new branch is then made up of one step. To allow jumps to the parallel branches that have been created, these must be provided with a jump label (see 'Extras' 'Add label to parallel branch'). 'Insert' 'Jump' 'This command inserts a jump in the SFC editor at the end of the branch, to which the marked block belongs. For this the branch must be an alternative branch. The inserted text string 'Step' in the inserted jump can then be selected and replaced by the step name or the jump label of a parallel branch to be jumped to. 'Insert' 'Transition-Jump' Symbol: This command inserts a transition in the SFC editor, followed by a jump at the end of the selected branch. For this the branch must be a parallel branch. The inserted text string 'Step' in the inserted jump can then be selected and replaced by the step name or the jump label of a parallel branch to be jumped to. 'Insert' 'Add Entry-Action' With this command you can add an entry action to a step. An entry-action is only executed once, right after the step has become active. The entry-action can be implemented in a language of your choice. A step with an entry -action is designated by an 'E' in the bottom left corner. 'Insert' 'Add Exit-Action' With this command you can add an exit-action to a step. An exit-action is only executed once, before the step is deactivated. The exit-action can be implemented in a language of your choice. A step with an exit-action is designated by an 'X' in the lower right corner. 'Extras' 'Paste Parallel Branch (right)' This command pastes the contents of the clipboard as a right parallel branch of the marked block. For this the marked block must both begin and end with a step. The contents of the clipboard must, likewise, be an SFC block that both begins and ends with a step. 'Extras' 'Add label to parallel branch' In order to provide a newly inserted parallel branch with a jump label, the transition occurring before the parallel branching must be marked and the command 'Add label to parallel branch' must be executed. At that point, the parallel branch will be given a standard name consisting of „Parallel' and an appended serial number, which can be edited according to the rules for identifier names. In the following example, 'Parallel' was replaced by 'Par_1_2' and the jump to the transition 'End' was steered to this jump label.
CoDeSys V2.3
5-31
The Graphic Editors..
Delete a label A jump label can be deleted by deleting the label name. 'Extras' 'Paste after' This command pastes the SFC block on the clipboard after the first step or the first transition of the marked block. (Normal copying pastes it in front of the marked block.) This will now be executed, if the resulting SFC structure is correct, according to the language norms. 'Extras' 'Zoom Action/Transition' Shortcut: + The action of the first step of the marked block or the transition body of the first transition of the market block is loaded into the editor in the respective language, in which it has been written. If the action or the transition body is empty, then the language must be selected, in which it has been written. 'Extras' 'Clear Action/Transition' With this command you can delete the actions of the first step of the marked block or of the transitions body of the first transition. If, during a step, you implement either only the action, the entry-action, or the exit-action, then the same will be deleted by the command. Otherwise a dialog box appears, and you can select which action or actions are to be deleted. If the cursor is located in the action of an IEC step, then only this association will be deleted. If an IEC step with an associated action is selected, then this association will be deleted. During an IEC step with several actions, a selection dialog box will appear. 'Extras' 'Step Attributes' With this command you can open a dialog box in which you can edit the attributes for the marked step. Dialog Box for Editing Step Attributes You can take advantage of three different entries in the step attribute dialog box. Under Minimum Time, you enter the minimum length of time that the processing of this step should take. Under the Maximum Time, you enter the maximum length of time that the processing of this step should take. Note that the entries are of the TIME type, so you use a TIME constant (i.e. T#3s) or a variable of the TIME type. Under Comment you can insert a comment to the step. In the 'Sequential function chart options' dialog which you open under 'Extras' 'Options', you can then enter whether comments or the time
5-32
CoDeSys V2.3
5 - Editors in CoDeSys
setting is displayed for the steps in the SFC editor. On the right, next to the step, either the comment or the time setting will appear. If the maximum time is exceeded, SFC flags are set which the user can query.
The example shows a step whose execution should last at least two, and at the most, ten seconds. In Online mode, there is, in addition to these two times, a display of how long the step has already been active. 'Extras' 'Time Overview' With this command you can open a window in which you can edit the time settings of your SFC steps: Time Boundaries Overview for a SFC POU
In the time boundaries overview, all steps of your SFC POU are displayed. If you have entered a time boundary for a step, then the time boundary is displayed to the right of the step (first, the lower limit, then the upper limit). You can also edit the time boundaries. To do so, click on the desired step in the overview. The name of the step is then shown below in the window. Go to the Minimum Time or Maximum Time field, and enter the desired time boundary there. If you close the window with OK, then all of the changes will be stored. In the example, steps 2 and 6 have a time boundary. Shift1 lasts at least two, and at most, ten seconds. Shift2 lasts at least seven, and at most, eight seconds. 'Extras' 'Options' With this command you open a dialog box in which you can set different options for your SFC POU.
CoDeSys V2.3
5-33
The Graphic Editors..
Dialog Box for Sequential Function Chart Options
In the SFC Options dialog box you can undertake five entries. Under Step Height, you can enter how many lines high an SFC step can be in your SFC editor. 4 is the standard setting here. Under Step Width, you can enter how many columns wide a step should be. 6 is the standard setting here. You can also preset the Display at Step. With this, you have three possibilities: You can either have Nothing displayed, or the Comment, or the Time Limits. The last two are shown the way you entered them in 'Extras' 'Step Attributes'. 'Extras' 'Associate Action' With this command actions and Boolean variables can be associated with IEC steps. To the right of, and next to the IEC step, an additional divided box is attached, for the association of an action. It is preset in the left field with the qualifier 'N' and the name 'Action.' Both presets can be changed. For this you can use the Input Assistant. Maximum nine actions can be assigned to an IEC step. New actions for IEC steps are created in the Object Organizer for an SFC POU with the 'Project' 'Add Action' command. 'Extras' 'Use IEC-Steps' Symbol: If this command is activated (denoted by a check in front of the menu item and a printed symbol in the Tool bar), then IEC steps will be inserted instead of the simplified steps upon insertion of step transitions and parallel branches. If this option is switched on, the Init step is set as an IEC step when you create a new SFC POU. This settings are saved in the file 'CoDeSys.ini' and are restored when CoDeSys gets started again. Sequential Function Chart in Online Mode With the Sequential Function Chart editor in Online mode, the currently active steps will be displayed in blue. If you have set it under 'Extras' 'Options', then the time management is depicted next to the steps. Under the lower and upper bounds that you have set, a third time indicator will appear from which you can read how long the step has already been active.
In the picture above the step depicted has already been active 8 seconds and 410 milliseconds. The step must, however, be active for at least 7 minutes before the step will be left. With 'Online' 'Toggle Breakpoint' a breakpoint can be set on a step, or in an action at the locations allowed by the language in use. Processing then stops prior to execution of this step or before the location of the action in the program. Steps or program locations where a breakpoint is set are marked in light blue. If several steps are active in a parallel branch, then the active step whose action will be processed next is displayed in red.
5-34
CoDeSys V2.3
5 - Editors in CoDeSys
If IEC steps have been used, then all active actions in Online mode will be displayed in blue. With the command 'Online' 'Step over' it is stepped always to the next step which action is executed. If the current location is: •
a step in the linear processing of a POU or a step in the rightmost parallel branch of a POU, execution returns from the SFC POU to the caller. If the POU is the main program, the next cycle begins.
•
a step in a parallel branch other than the rightmost, execution jumps to the active step in the next parallel branch.
•
the last breakpoint location within a 3S action, execution jumps to the caller of the SFC.
•
the last breakpoint location within an IEC action, execution jumps to the caller of the SFC.
•
the last breakpoint position within an input action or output action, execution jumps to the next active step.
With 'Online' 'Step in' even actions can be stepped into. If an input, output or IEC action is to be jumped into, a breakpoint must be set there. Within the actions, all the debugging functionality of the corresponding editor is available to the user. If you rest the mouse cursor for a short time on a variable in the declaration editor, the type, the address and the comment of the variable will be displayed in a tooltip Sequential Function Chart with an Active Step (Shift1) and a Breakpoint (Step10) Please regard: If you rename a step and perform an Online Change while this step is active, the program will be stopped in undefined status !
Processing order of elements in a sequence: 1. First, all Action Control Block flags in the IEC actions that are used in this sequence are reset (not, however, the flags of IEC actions that are called within actions). 2. All steps are tested in the order which they assume in the sequence (top to bottom and left to right) to determine whether the requirement for execution of the output action is provided, and this is executed if that is the case. 3. All steps are tested in the order which they assume in the sequence to determine whether the requirement for the input action is provided, and this is executed if that is the case. 4. For all steps , the following is done in the order which they assume in the sequence: - If applicable, the elapsed time is copied into the corresponding step variable. - If applicable, any timeout is tested and the SFC error flags are serviced as required. - For non-IEC steps, the corresponding action is now executed. 5. IEC actions that are used in the sequence are executed in alphabetical order. This is done in two passes through the list of actions. In the first pass, all the IEC actions that are deactivated in the current cycle are executed. In the second pass, all the IEC actions that are active in the current cycle are executed. 6. Transitions are evaluated: If the step in the current cycle was active and the following transition returns TRUE (and if applicable the minimum active time has already elapsed), then the following step is activated.
The following must be noted concerning implementation of actions: It can come about that an action is carried out several times in one cycle because it is associated with multiple sequences. (For example, an SFC could have two IEC actions A and B, which are both implemented in SFC, and which both call IEC action C; then in IEC actions A and B can both be active in the same cycle and furthermore in both actions IEC action C can be active; then C would be called twice). If the same IEC action is used simultaneously in different levels of an SFC, this could lead to undesired effects due to the processing sequence described above. For this reason, an error message is issued in this case. It can possibly arise during processing of projects created with older versions of CoDeSys. Note:
CoDeSys V2.3
In monitoring expressions (e.g. A AND B) in transitions, only the „Total value' of the transition is displayed.
5-35
The Graphic Editors..
5.4.4
The Continuous Function Chart Editor (CFC).. It looks like a block which has been produced using the continuous function chart editor (CFC):
No snap grid is used for the continuous function chart editor so the elements can be placed anywhere. Elements of the sequential processing list include boxes, input, output, jump, label, return and comments. The inputs and outputs of these elements can be connected by dragging a connection with the mouse. The connecting line will be drawn automatically. The shortest possible connection line is drawn taking into account existing connections. The connecting lines are automatically adjusted when the elements are moved. If the case arises where a connecting line cannot be drawn simply because of lack of space, a red line will be shown between the input and the associated output instead. This line will be converted into a connecting line just as soon as space is available. One advantage of the continuous function chart as opposed to the usual function block diagram editor FBD is the fact that feedback paths can be inserted directly. The most important commands can be found in the context menu Cursor positions in the CFC Each text is a possible cursor position. The selected text is shaded in blue and can be modified. In all other cases the current cursor position is shown by a rectangle made up of points. The following is a list of all possible cursor positions with examples: 1. Trunks of the elements box, input, output, jump, label, return and comments.
5-36
CoDeSys V2.3
5 - Editors in CoDeSys
2. Text fields for the elements box, input, output, jump, label, return and comments as well as text fields for connection marker
3. Inputs for the elements box, input, output, jump and return
4. Outputs for the elements box and input:
'Insert' 'Box' in the CFC Symbol:
Shortcut: +
This command can be used to paste in operators, functions, function blocks and programs First of all, it is always inserted an 'AND' operator. This can be converted by Selection and Overwrite of the text into every other operator, into every function, into every function block and every program. The input assistance serves to select the desired block from the list of supported blocks. If the new block has another minimum number of inputs, these will be attached. If the new block has a smaller highest number of inputs, the last inputs will be deleted. 'Insert' 'Input' in CFC Symbol:
Shortcut: +
This command is used to insert an input. The text offered '???' can be selected and replaced by a variable or constant. The input assistance can also be used here. 'Insert' 'Output'in CFC Symbol:
Shortcut: +
This command is used to insert an output. The text offered '???' can be selected and replaced by a variable. The input assistance can also be used here. The value which is associated with the input of the output is allocated to this variable.
CoDeSys V2.3
5-37
The Graphic Editors..
'Insert' 'Jump'in CFC Symbol:
Shortcut: +
This command is used to insert a jump. The text offered '???' can be selected and replaced by the jump label to which the program should jump. The jump label is inserted using the command 'Insert 'Label'. 'Insert' 'Label' in CFC Symbol:
Shortcut: +
This command is used to insert a label. The text offered '???' can be selected and replaced by the jump label. In Online mode a RETURN label for marking the end of POU is automatically inserted. The jump is inserted using the command 'Insert 'Jump'. 'Insert' 'Return' in CFC Symbol:
Shortcut: +
This command is used to insert a RETURN command. Note that in Online mode a jump label with the name RETURN is automatically inserted in the first column and after the last element in the editor; in stepping, it is automatically jumped to before execution leaves the POU. 'Insert' 'Comment' in CFC Symbol:
Shortcut: +
This command is used to insert a comment. You obtain a new line within the comment with + . 'Insert' 'Input of box' in CFC Shortcut: + This command is used to insert an input at a box. The number of inputs is variable for many operators (e.g. ADD can have two or more inputs). To increase the number of inputs for such an operator by one, the box itself must be selected Insert' 'In-Pin' in CFC, 'Insert' 'Out-Pin' Symbol: These commands are available as soon as a macro is opened for editing. They are used for inserting in- or out-pins as in- and outputs of the macro. They differ from the normal in- and outputs of POUs by the way they are displayed and in that they have no position index. 'Extras' 'Negate' in CFC Symbol:
Shortcut: +
This command is used to negate inputs, outputs, jumps or RETURN commands. The symbol for the negation is a small cross on the connection. The input of the element block, output, jump or return is negated when it is selected. The output of the element block or input is negated when it is selected (Cursor position 4). A negation can be deleted by negating again.
5-38
CoDeSys V2.3
5 - Editors in CoDeSys
'Extras' 'Set/Reset' in CFC Symbol:
Shortcut: +
This command can only be used for selected inputs of the element output . The symbol for Set is S and for Reset is R.
VarOut1 is set to TRUE, if VarIn1 delivers TRUE. VarOut1 retains this value, even when VarIn1 springs back to FALSE. VarOut2 is set to FALSE, if VarIn2 delivers TRUE. VarOut2 retains this value, even when VarIn2 springs back to FALSE. Multiple activation of this command causes the output to change between Set, Reset and the normal condition. 'Extras' 'EN/ENO' in CFC Symbol:
Shortcut: +
This command is used to give a selected block (Cursor position 3) an additional Boolean enable input EN (Enable In) and a Boolean output ENO (Enable Out).
ADD is only executed in this example when the Boolean variable 'Bedingung' (condition) is TRUE. VarOut is also set to TRUE after ADD has been executed. ADD will not be executed when the variable 'Bedingung' (condition) is FALSE and VarOut retains its value FALSE. The example below shows how the value ENO can be used for further blocks:
x should initialised to 1 and y initialised to 0. The numbers in the right corner of the block indicate the order in which the commands are executed.
CoDeSys V2.3
5-39
The Graphic Editors..
x will be increased by one until it reaches the value 10. This causes the output of the block LT(0) to deliver the value FALSE and SUB(3) and ADD(5) will be executed. x is set back to the value 1 and y is increased by 1. LT(0) is executed again as long as x is smaller than 10. y thus count the number of times x passes though the value range 1 to 10. 'Extras' 'Properties..' in CFC Constant input parameters (VAR_INPUT CONSTANT) from functions and function blocks are not shown directly in the continuous function chart editor. These can be shown and their value can be changed when one selects the trunk of the block in question and then selects the command ‚Extras' ‚Properties' or simply double clicks on the trunk. The „Edit parameters' dialog opens: Properties dialog
The values of the constant input parameter (VAR_INPUT CONSTANT) can be changed. Here it is necessary to mark the parameter value in the column Value. Another mouse click or pressing on the space bar allows this to be edited. Confirmation of the change to the value is made by pressing the key or pressing rejects the changes. The button OK stores all of the changes which were made. Selecting elements in CFC One clicks on the trunk of the element to select it. To mark more elements one presses the key and clicks in the elements required, one after the other, or one drags the mouse with the left hand mousekey depressed over the elements to be marked. The command 'Extras' 'Select all' marks all elements at once. Moving elements in CFC One or more selected elements can be moved with the arrow keys as one is pressing on the key. Another possibility is to move elements using a depressed left mousekey. These elements are placed by releasing the left mousekey in as far as they do not cover other elements or exceed the foreseen size of the editor. The marked element jumps back to its initial position in such cases and a warning tone sounds. Copying elementsin CFC One or more selected elements can be copied with the command 'Edit' 'Copy' and inserted with the command 'Edit' 'Paste'. Changing connections A connection between the output of an element E1 and the input of an element E2 can easily be changed into a connection between the output of element E1 and the input of element E3. The mouse is clicked on the input of E2, the left mousekey is kept depressed, the mouse cursor is moved to the input of E3 and then released.
5-40
CoDeSys V2.3
5 - Editors in CoDeSys
'Extras' 'Connection marker' Connections can also be represented by a connector (connection marker) instead of a connecting line. Here the output and the associated input have a connector added to them which is given a unique name. Where a connection already exists between the two elements which should now be represented by connectors, the output of the connecting line is marked and the menu point ‚Extras' ‚Connection marker' is selected. The following diagram shows a connection before and after the selection of this menu point.
A unique name is given as standard by the program which begins with M, but which can be changed The connector name is stored as an output parameter, but can be edited both at the input and at the output. It is important to know that the connector name is associated with a property of the output of a connection and is stored with it. 1. Edit the connector at the output: If the text in the connector is replaced, the new connector name is adopted by all associated connectors at the inputs. One cannot, however, select a name which already belongs to another connection marker since the uniqueness of the connector name would be violated. 2. Edit the connector at the input: If the text in a connector is replaced, it will also be replaced in the corresponding connection marker on the other POU. Connections in connector representations can be converted to normal connections in that one marks the output of the connections (Cursor position 4) and again selects the menu point 'Extras' 'Connection marker'. Insert inputs/outputs 'on the fly' If exactly one input or output pin of an element is selected, then the corresponding input- or outputelement can be directly inserted and its editor field filled with a string by entering the string at the keyboard. Order of execution The elements block, output, jump, return and label each possess a number indicating the order in which they are executed. In this sequential order the individual elements are evaluated at run time. When pasting in an element the number is automatically given according to the topological sequence (from left to right and from above to below). The new element receives the number of its topological successor if the sequence has already been changed and all higher numbers are increased by one. The number of an element remains constant when it is moved. The sequence influences the result and must be changed in certain cases. If the sequence is displayed, the corresponding sequential execution number is shown in the upper right hand corner of the element. 'Extras' 'Order' 'Show Order' This command switches the display of the order of execution on and off. The default setting is to show it (recognised by a tick (ü) in front of the menu point). The relevant order of execution number appears in the upper right hand corner for the elements block, output, jump, return and label.
CoDeSys V2.3
5-41
The Graphic Editors..
'Extras' 'Order' 'Order topologically' Elements are ordered in a topological sequence when the execution takes place from left to right and from above to below, that is the number increases from left to right and from above to below for topologically arranged elements. The connections are not relevant, only the location of the elements is important. All selected elements are topologically arranged when the command 'Extras' 'Order' 'Order topologically' is executed. All elements in the selection are taken out of the sequential processing list by this process. The elements are then entered into the remaining sequential processing list individually from bottom right through to upper left. Each marked element is entered into the sequential processing list before its topological successor, i.e. it is inserted before the element that in a topological sequencing would be executed after it, when all elements in the editor were sequenced according to a topological sequencing system. This will be clarified by an example.
The elements with numbers 1, 2 and 3 are selected. If the command 'Order topologically' is selected the elements are first taken out of the sequential processing list. Var3, the jump and the AND-operator are then inserted again one after the other. Var3 is placed before the label and receives the number 2. The jump is then ordered and receives the number 4 at first but this then becomes 5 after the AND is inserted. The new order of execution which arises is:
When a newly generated block is introduced it will be placed by default in front of its topological successor in the sequential processing list. 'Extras' 'Order' 'One up' With this command all selected elements with the exception of the element which is at the beginning of the sequential processing list are moved one place forwards in the sequential processing list.
5-42
CoDeSys V2.3
5 - Editors in CoDeSys
'Extras' 'Order' 'One down' With this command all selected elements with the exception of the element which is at the end of the sequential processing list are moved one place backwards in the sequential processing list. 'Extras' 'Order' 'Order first' With this command all selected elements will be moved to the front of the sequential processing list whereby the order within the group of selected elements is maintained. The order within the group of unselected elements also remains the same. 'Extras' 'Order' 'Order last' With this command all selected elements will be moved to the end of the sequential processing list whereby the order within the group of selected elements is maintained. The order within the group of unselected elements also remains the same. 'Extras' 'Order' 'Order everything according to data flow' This command effects all elements. The order of execution is determined by the data flow of the elements and not by their position. The diagram below shows elements which have been ordered topographically. Sequence before the ordering according to data flow
The following arrangement exists after selecting the command:
CoDeSys V2.3
5-43
The Graphic Editors..
Sequence after the ordering according to data flow
When this command is selected the first thing to happen is that the elements are ordered topographically. A new sequential processing list is then created. Based on the known values of the inputs, the computer calculates which of the as yet not numbered elements can be processed next. In the above 'network' the block AND, for example, could be processed immediately since the values at its inputs (1 and 2) are known. Block SUB can only then be processed since the result from ADD must be known first, etc. Feedback paths are inserted last. The advantage of the data flow sequencing is that an output box which is connected to the output of a block comes immediately after it in the data flow sequencing system which by topological ordering would not always be the case. The topological ordering can deliver another result in some cases than ordering by data flow, a point which one can recognise from the above example. 'Extras' 'Create macro' Symbol: With this command, several POUs that are selected at the same time can be assembled into a block, which can be named as a macro. Macros only can be reproduced by Copy/Paste, whereby each copy becomes a separate macro whose name can be chosen independently. Macros are thus not references. All connections that are cut by the creation of a macro generate in- or out-pins on the macro. Connections to inputs generate an in-pin. The default name appears next to the pin in the form In. For connections to outputs, Out appears. Affected connections which had connection markers prior to the creation of the macro, retain the connection marker on the PIN of the macro. At first, a macro has the default name 'MACRO'. This can be changed in the Name field of the macro use. If the macro is edited, the name of the macro will be displayed in the title bar of the editor window appended to the POU name.
5-44
CoDeSys V2.3
5 - Editors in CoDeSys
Example: Selection
Macro:
In the editor:
'Extras' 'Jump into Macro' Symbol: By this command, or by double clicking on the body of the macro, the macro is opened for editing in the editor window of the associated POU. The name of the macro is displayed appended to the POU name in the title bar. The pin boxes generated for the in- and outputs of the macro during creation can be handled like normal POU in- and outputs. They can also be moved, deleted, added, etc. They differ only in how they are displayed and have no position index. For adding you can use the buttons
(input) resp.
(output), which are available in the menu bar. Pin boxes have rounded corners. The text in the pin-box matches the name of the pin in the macro display. The order of the pins in the macro box follows the order of execution of the elements of the macro. A lower order index before a higher one, higher pin before lower. The processing order within the macro is closed, in other words the macro is processed as a block, at the position of the macro in the primary POU. Commands for manipulating the order of execution therefore operate only within the macro.
CoDeSys V2.3
5-45
The Graphic Editors..
'Extras' 'Expand macro' With this command, the selected macro is re-expanded and the elements contained in it are inserted in the POU at the macro's location. The connections to the pins of the macro are again displayed as connections to the in- or outputs of the elements. If the expansion of the macro can not occur at the location of the macro box for lack of space, the macro is displaced to the right and down until enough space is available. Note:
If the project is saved under project version number 2.1, the macros will likewise all be expanded. All macros will also be expanded before conversion into other languages.
'Extras' 'One macro level back', 'Extras' 'All macro levels back' Symbols: These commands are also available in the toolbar, as soon as a macro is opened for editing. If macros are nested within one another, it is possible to switch to the next higher or to the highest display level. Feedback paths in CFC Feedback paths can only be displayed directly in the continuous function chart editor and not in the usual function block diagram editor. Here it should be observed that the output of a block always carries an internal intermediate variable. The data type of the intermediate variable results, for operators, from the largest data type of the inputs. The data type of a constant is obtained from the smallest possible data type, that is the constant '1' adopts the data type SINT. If now an addition with feedback and the constant '1' is executed, the first input gives the data type SINT and the second is undefined because of the feedback. Thus the intermediate variable is also of the type SINT. The value of the intermediate variable is only then allocated to the output variable. The diagram below shows an addition with feedback and an addition with a variable. The variables x and y should be of the type INT here.
There are differences between the two additions: The variable y can be initialised with a value which is not equal to zero but this is not the case for intermediate variable for the left addition. The intermediate variable for the left addition has the data type SINT while that on the right has the th data type INT. The variables x and y have different values after the 129 call up. The variable x, although it is of the type INT, contains the value 127 because the intermediate variable has gone into overflow. The variable y contains the value 129, on the other hand. CFC in Online mode Monitoring: The values for inputs and outputs are displayed within the input or output boxes. Constants are not monitored. For non-boolean variables, the boxes are expanded to accommodated the values displayed. For boolean connections, the variable name as well as the connection are displayed in blue if the value is TRUE, otherwise they remain black. Internal boolean connections are also displayed Online in blue in the TRUE state, otherwise black. The value of internal non-boolean connections is displayed in a small box with rounded corners on the output pin of the connection.
5-46
CoDeSys V2.3
5 - Editors in CoDeSys
PINs in macros are monitored like in- or output boxes.
Non-boolean connections with connection markers display their value within the connection marker. For boolean connections, the lines as well as the marker names are displayed in blue if the line is carrying the value TRUE, otherwise black. Flow control: When flow control is switched on, the connections that have been traversed are marked with the color selected in the project options. Breakpoints: Breakpoint s can be set on all elements that also have a processing sequence order index. The processing of the program will be halted prior to execution of the respective element, that is for POUs and outputs before the assignment of inputs, for jump labels before execution of the element with the next index. The processing sequence index of the element is used as the breakpoint position in the Breakpoint dialog. The setting of breakpoints on a selected element is accomplished with the F9 key or via the menu item 'Breakpoint on/off' in the 'Online' or 'Extras' menu or in the editor's context menu. If a breakpoint is set on an element, then this will be erased and reversed the next time the command 'Breakpoint on/off' is executed. In addition, the breakpoint on an element can be toggled by double-clicking on it. Breakpoints are displayed in the colors entered in the project options. RETURN label: In Online mode, a jump label with the name „RETURN' is automatically generated in the first column and after the last element in the editor. This label marks the end of the POU and is jumped to when stepping just before execution leaves the POU. No RETURN marks are inserted in macros. Stepping: When using 'Step over' the element with the next-higher order index will always be jumped to. If the current element is a macro or a POU, then its implement branches when 'Step in' is in effect. If a 'Step over' is executed from there, the element whose order index follows that of the macro is jumped to. Zoom to POU Shortcut: + With this command a selected POU is loaded into its editor. The command is available in the context menu () or in the 'Extras' menu, if the cursor is positioned on the name of a POU in a text editor or if the POU box is selected in a graphic editor. If you are dealing with a POU from a library, then the library manager is called up, and the corresponding POU is displayed.
CoDeSys V2.3
5-47
6 - The Resources
6
The Resources
6.1
Overview of the Resources In the Resources register card of the Object Organizer, there are objects for configuring and organizing your project and for keeping track of the values of the variables: •
Global Variables that can be utilized in the entire project; the global variables of the project as well as the libraries.
•
Library Manager for handling all libraries which are included to the project
•
Log for recording the activities during the online sessions
•
PLC Configuration for configuring your hardware
•
Watch and Receipt Manager for indicating and presetting variable values
•
Task Configuration for controlling your program control via tasks
•
Target settings for selecting the hardware platform (target) and if available for customizing target specific parameters
Depending on the target settings the following resources also might be available: •
Parameter Manager for managing variables, which are also accessible for other participants in the network. This functionality will only be available if defined in the corresponding target settings.
•
PLC Browser for monitoring of information from the PLC
•
Sampling Trace for graphic logging of variable values
•
Tools for linking external tools, which then can be started in CoDeSys. This functionality will only be available if defined in the corresponding target settings.
•
The SoftMotion functionality (license needed): CNC program list (CNC Editor) and CAMs (CAMEditor) (see the separate documentation on SoftMotion).
•
Additionally there might be created and loaded a Docuframe file which offers a set of comments for the project variables (e.g. in a certain language), which will be printed when documenting the project with 'Project' 'Document'.
Resources tab in CoDeSys
CoDeSys V2.3
6-1
Global Variables, Variable Configuration, Document Frame
6.2
Global Variables, Variable Configuration, Document Frame
Objects in 'Gobal 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 up (plus sign in front of the folder), you can open it with a doubleclick 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.1
Global 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. 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:
he use of network variables must be supported by the target system and must be activated in the
target settings (category networkfunctionality). 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').
6-2
CoDeSys V2.3
6 - The Resources
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
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. Network global variables lists can be recognized in the Object Organizer by the symbol
CoDeSys V2.3
. With the command
6-3
Global Variables, Variable Configuration, Document Frame
'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 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 (): In the lower part of the dialog you can create configuration sets for up to four network connections, each on an 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 ' with the following configuration parameters: Use standard If this button is pressed, Port 1202 will be defined for the data exchange with the other network particiapnts. 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). Dialog 'Settings for UDP
The following options can be activated or deactivated in configuring the transmission behavior 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 ascendent 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 identic. A packet with a non-matching chechsum will not be accepted and – if this is configured ('Use acknowledge transfer', see below) – will be acknowledged negatively.
6-4
CoDeSys V2.3
6 - The Resources
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: Answ er 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 Note:
in the Object Organizer.
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 tim e 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. 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:
CoDeSys V2.3
6-5
Global Variables, Variable Configuration, Document Frame
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: Retain variables remain unchanged after an uncontrolled shutdown of the runtime system (off/on) or an 'Online' 'Reset' in CoDeSys. Persistent variables remain unchanged after a controlled shutdown of the runtime system (stop, start) or an 'Online' 'Cold reset' or a download. Persistent variables are not automatically also Retain variables ! Remanent variables are additionally assigned the keyword RETAIN or PERSISTENT. 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. Syntax: VAR_GLOBAL CONSTANT (* Variables declarations *) END_VAR
6.2.2
Variable Configuration.. In function blocks it is possible to specify addresses for inputs and outputs that are not completely defined, if you put the variable definitions between the key words VAR and END_VAR. Addresses not completely defined are identified with an asterisk. Example: FUNCTION_BLOCK locio
6-6
CoDeSys V2.3
6 - The Resources
VAR loci AT %I*: BOOL := TRUE; loco AT %Q*: BOOL; END_VAR Here two local I/O-variables are defined, a local-In (%I*) and a local-Out (%Q*). If you want to configure local I/Os for variables configuration in the Object Organizer in the Resources register card, the object Variable_Configuration will generally be available. The object then can be renamed and other objects can be created for the variables configuration. The editor for variables configuration works like the declaration editor. Variables for local I/O-configurations must be located between the key words VAR_CONFIG and END_VAR. The name of such a variable consists of a complete instance path through which the individual POUs and instance names are separated from one another by periods. The declaration must contain an address whose class (input/output) corresponds to that of the incompletely specified address (%I*, %Q*) in the function block. Also the data type must agree with the declaration in the function block. Configuration variables, whose instance path is invalid because the instance does not exist, are also denoted as errors. On the other hand, an error is also reported if no configuration exists for an instance variable. In order to receive a list of all necessary configuration variables, the 'All Instance Paths' menu item in the 'Insert' menu can be used. Example for a Variable Configuration Assume that the following definition for a function block is given in a program: PROGRAM PLC_PRG VAR Hugo: locio; Otto: locio; END_VAR Then a corrected variable configuration would look this way: VAR_CONFIG PLC_PRG. Hugo.loci AT %IX1.0 : BOOL; PLC_PRG. Hugo.loco AT %QX0.0 : BOOL; PLC_PRG. Otto.loci AT %IX1.0 : BOOL; PLC_PRG.Otto.loco AT %QX0.3 : BOOL; END_VAR
See also: ‚Insert' 'All Instance Paths' 'Insert' 'All Instance Paths' With this command a VAR_CONFIG - END_VAR-block is generated that contains all of the instance paths available in the project. Declarations already on hand do not need to be reinserted in order to contain addresses already in existence. This menu item can be found in the window for configuration of variables if the project is compiled ('Project' 'Rebuild All').
6.2.3
Document Frame.. If a project is to receive multiple documentations, perhaps with German and English comments, or if you want to document several similar projects that use the same variable names, then you can save yourself a lot of work by creating a docuframe with the 'Extras' 'Make Docuframe File' command. The created file can be loaded into a desired text editor and can be edited. The file begins with the DOCUFILE line. Then a listing of the project variables follows in an arrangement that assigns three lines to each variable: a VAR line that shows when a new variable comes; next, a line with the name of the variable; and, finally, an empty line. You can now replace this line by using a comment to the
CoDeSys V2.3
6-7
Library Manager..
variable. You can simply delete any variables that you are unable to document. If you want, you can create several document frames for your project. Windows Editor with Document Frame In order to use a document frame, give the 'Extras' 'Link Docu File' command. Now if you document the entire project, or print parts of your project, then in the program text, there will be an insertion of the comment produced in the docuframe into all of the variables. This comment only appears in the printout! 'Extras' 'Make Docuframe File' Use this command to create a document frame. The command is at your disposal, whenever you select an object from the global variables. A dialog box will open for saving files under a new name. In the field for the name file, the *.txt extension has already been entered. Select a desired name. Now a text file has been created in which all the variables of your project are listed. 'Extras' 'Link Docu File' With this command you can select a document frame. The dialog box for opening files is opened. Choose the desired document frame and press OK. Now if you document the entire project, or print parts of your project, then in the program text there will be an insertion of the comment produced in the docuframe into all of the variables. This comment only appears in the printout! To create a document frame, use the 'Extras' 'Make Docuframe File' command.
6.3
Library Manager.. The library manager shows all libraries that are connected with the current project. The POUs, data types, and global variables of the libraries can be used the same way as user-defined POUs, data types, and global variables. The library manager is opened with the 'Window' 'Library Manager' command. Information concerning included libraries is stored with the project and can be viewed in the dialog 'Informations about external library'. To open this dialog select the corresponding library name in the library manager and execute the command 'Extras' 'Properties'. Library Manager
6-8
CoDeSys V2.3
6 - The Resources
Using the Library Manager The window of the library manager is divided into three or four areas by screen dividers. The libraries attached to the project are listed in the upper left area. In the area below that, depending on which register card has been selected, there is a listing of the POUs , Data types, Visualizations or Global variables of the library selected in the upper area. Folders are opened and closed by doubleclicking the line or pressing . There is a plus sign in front of closed folders, and a minus sign in front of opened folders. If a POU is selected by clicking the mouse or selecting with the arrow keys then the declaration of the POU will appear in the upper right area of the library manager; and in the lower right is the graphic display in the form of a black box with inputs and outputs. With data types and global variables, the declaration is displayed in the right area of the library manager. Standard Library The library with 'standard.lib' is always available. It contains all the functions and function blocks which are required from the IEC61131-3 as standard POUs for an IEC programming system. The difference between a standard function and an operator is that the operator is implicitly recognized by the programming system, while the standard POUs must be tied to the project (standard.lib). The code for these POUs exists as a C-library and is a component of CoDeSys. User-defined Libraries If a project is to be compiled in its entity and without errors, then it can be saved in a library with the 'Save as' command in the 'File' menu. The project itself will remain unchanged. An additional file will be generated, which has the default extension '.lib'. This library afterwards can be used and accessed like e.g. the standard library. For the purpose to have available the POUs of a project in other projects, save the project as an Internal Library *.lib. This library afterwards can be inserted in other projects using the library manager. If you have implemented POUs in other programming languages, e.g. C, and want to get them into a library, then save the project using data type External Library *.lib). You will get the library file but additonally a file with the extension '*.h'. This file is structured like a C header file and contains the declarations of all POUs, data types and global variables, which are available with the library. If an external library is used in a project, then in simulation mode that implementation of the POUs will be executed, which was written with CoDeSys; but on the target the C-written implementation will be processed. If you want to add licensing information to a library, then press button Edit license info.. and insert the appropriate settings in the dialog 'Edit Licensing Informationen'. See the corresponding description at 'File' 'Save as..' resp. at License Management in CoDeSys. 'Insert' 'Additional Library' With this command you can attach an additional library to your project. When the command is executed, the dialog box for opening a file appears. Choose the desired library with the '*.lib' extension and close the dialog with OK. The library is now listed in the library manager and you can use the objects in the library as user-defined objects. As soon as you include a library for which a license is needed and no valid license is found, you may get a message that the library is only available in demo mode or that the library is not licensed for the currently set target. You can ignore this message at that time or start appropriate actions concerning the license. An invalid license will produce an error during compile ('Project' 'Build'). In this case a doubleclick on the error message resp. will open the dialog 'License information' where you can start the appropriate actions. (See separate documentation on the 'License Manager'.
CoDeSys V2.3
6-9
Log..
Remove Library With the 'Edit' 'Delete' command you can remove a library from a project and from the library manager. 'Extras' 'Properties' This command will open the dialog 'Informations about internal (resp. external) library'. For internal libraries you will find there all data, which have been inserted in the Project Info (where applicable including the license information) when the library had been created in CoDeSys. For external libraries the library name and library path will be displayed.
6.4
Log.. The log stores in chronological order actions that occur during an Online session. For this purpose a binary log file (*.log) is set up. Afterward, the user can store excerpts from the appropriate project log in an external log. The log window can be opened in either Offline or Online mode and can thus serve as a direct monitor online.
'Window' 'Log' To open, select the menu item 'Window' 'Log' or select entry 'Log' in the Resources tab. Log window
In the log window, the filename of the currently displayed log appears after Log:. If this is the log of the current project, the word '(Internal)' will be displayed. Registered entries are displayed in the log window. The newest entry always appears at the bottom.
6-10
CoDeSys V2.3
6 - The Resources
Only actions belonging to categories that have been activated in the 'Filter' field of the menu 'Project' 'Options' 'Log' will be displayed. Available information concerning the currently selected entry is displayed below the log window: Category: The category to which the particular log entry belongs. The following four categories are possible: •
User action: The user has carried out an Online action (typically from the Online menu).
•
Internal action: An internal action has been executed in the Online layer (e.g. Delete Buffers or Init debugging).
•
Status change: The status of the runtime system has changed (e.g. from Running to Break, if a breakpoint is reached).
•
Exception: An exception has occurred, e.g. a communication error.
Description: The type of action. User actions have the same names as their corresponding menu commands; all other actions are in English and have the same name as the corresponding OnlineXXX() function. Info: This field contains a description of an error that may have occurred during an action. The field is empty if no error has occurred. System time: The system time at which the action began, to the nearest second. Relative time: The time measured from the beginning of the Online session, to the nearest millisecond. Duration: Duration of the action in milliseconds. Menu Log When the log window has the input focus, the menu option Log appears in the menu bar instead of the items 'Extras' and 'Options'. The menu includes the following items: Load… An external log file *.log can be loaded and displayed using the standard file open dialog. The log that is present in the project will not be overwritten by the command. If the log window is closed and later opened again, or a new Online session is started then the version that is loaded will again be replaced by the project log. Save… This menu item can only be selected if the project log is currently displayed. It allows an excerpt of the project log to be stored in an external file. For that, the following dialog will be displayed, in which the Online sessions to be stored can be selected:
After successful selection, the standard dialog for storing a file opens ('Save Log'). Display Project Log This command can only be selected if an external log is currently displayed. It switches the display back to the project log.
CoDeSys V2.3
6-11
PLC Configuration
Storing the project log Regardless of whether or not the log is stored in an external file (see above), the project log is automatically stored in a binary file entitled .log. If a different path is not explicitly given in the 'Project' 'Options' 'Log' dialog, the file is stored in the same directory as that in which the project is stored. The maximum number of Online sessions to be stored can be entered in the 'Project' 'Options' 'Log' dialog. If this number is exceeded during recording, the oldest session is deleted to make room for the newest one.
6.5
PLC Configuration The PLC Configuration is found as an object in the register card Resources in the Object Organizer. With the PLC Configuration editor, you must describe the hardware the opened project is established for. For the program implementation, the number and position of the inputs and outputs is especially important. With this description, CoDeSys verifies whether the IEC addresses used in the program also actually exist in the hardware. The base of working in the configuration editor is/are the configuration files (*.cfg; see below Note concerning version compatibility') and the device files (.e.g. *.gsd, *.eds). These are stored in the directory which is defined in the target file (see Target Settings) and are read when the project is opened in CoDeSys. The configuration file describes a basic configuration, which is mapped in the configuration editor, and it defines to which extent the user can customize this configuration in the editor. Attention: As soon as the underlying configuration file (*.cfg) has been modified, you have to redo the configuration in CoDeSys! Note concerning version compatibility: In CoDeSys V2.2 a new format was implemented for the PLC Configuration. From that version on the basic configuration files have to use the extension *.cfg. In contrast the configuration editor in former CoDeSys versions needed configuration files with an extension *.con. But: In the target file you can determine that the 'old' configurator should be used furtheron, even when an old project is opened in V2.2 or higher. This avoids the necessarity to create new configuration files, the *.con-files can be used furtheron. If this option is not set in the target file, then you can convert the old PLC Configuration, which is stored in the project, to the new format, if (!) an appropriate new *.cfg-file has been provided. See more details in 'Extras' 'Convert'.
The CoDeSys configuration editor allows to configure I/O modules as well as CAN and profibus modules. After the final customization by the user a binary image of the configuration is sent to the PLC: Example PLC Configuration with a CPU Module and a CAN Module
6-12
CoDeSys V2.3
6 - The Resources
The PLC Configuration is displayed in the editor in tree structure and can be edited using menu commands and dialogs. The configuration contains input and/or output elements and also management elements which themselves also have subelements (for example, a CAN-bus or a digital input card with 8 inputs). For inputs and outputs, symbolic names can be assigned. The IEC-address where this input or output can be accessed is then located behind the symbolic name.
6.5.1
Working in the PLC Configuration.. The configuration editor is divided up in two parts. In the left window the configuration tree is displayed. Structure and components of the tree result primarily (Standardconfiguration) from the definitions found in the configuration file, but can be modified by the additional adaptation which is done by the user in the CoDeSys PLC Configurator. In the right window the currently available dialog is shown. On top of the configuration tree there is the entry of the 'root' module, marked with the symbol and a name, which has been defined in the configuration file. Below you find hierarchically idented the other elements of the configuration: Modules of different types (CAN, Profibus, I/O), channels or bit channels.Selecting of elements •
For selecting elements, click the mouse on the corresponding element, or, using the arrow keys, move the dotted rectangle onto the desired element.
•
Elements that begin with a plus sign are organization elements and contain subelements. To open an element, select the element and doubleclick the plus sign or press . You can close opened elements (minus sign in front of the element) the same way.
Insert elements, 'Insert' 'Insert element', 'Insert' 'Append subelement' Depending on the definitions in the configuration file(s) and on the available device files, which have been read when the project was opened, a basic composition of elements is automatically positioned in the configuration tree. If one of those elements is selected, further elements may be added if this is allowed by the definitions in the configuration file and if the needed device files are available: •
'Insert' 'Insert element': An element can be selected and inserted before the element which is currently marked in the configuration tree.
•
'Insert' 'Append subelement': An element can be selected and inserted as subelement of the element which is currently marked in the configuration tree. It will be inserted at the last position.
The most important commands are found in the context menu (right mouse button or +). Replacing/switching Elements, 'Extras' 'Replace element' Depending on the definition in the configuration file, the currently selected element may be get replaced by an other one. The same way it may be possible to switch channels, which are set up in a way that they can be used as input or as output elements. Use the command 'Extras' 'Replace element' Symbolic names Symbolic names for modules and channels can be defined in the configuration file. In this case they will be shown in the configuration editor before the 'AT' of the IEC address of the respective element. In the configuration file also is defined whether the symbolic name can be edited or inserted in the configuration editor. To enter a symbolic name, select the desired module or channel in the configuration tree and open a text field by a mouseclick on the 'AT' before the IEC address. In the same manner you can edit an existing symbolic name after a doubleclick on the name. Please regard that allocating a symbolic name corresponds with a valid variable declaration ! Recalculation of Module addresses, 'Extras' 'Compute addresses' If the option 'Calculate addresses' is activated in the dialog 'Settings' of the PLC configuration editor , then the command 'Extras' 'Compute addresses' will start to recalculate the addresses of the modules.
CoDeSys V2.3
6-13
PLC Configuration
All modules starting with the one, which is currently selected in the configuration tree, will be regarded. Return to standard configuration, 'Extras' 'Standardconfiguration' The command 'Extras' 'Standardconfiguration' can be used to restore the original PLC configuration, which is defined by the configuration file and saved in the project. Converting of old PLC configurations, 'Extras' 'Convert' This command is available in the menu 'Extras' if you open a project containing a PLC configuration, which was created with an older CoDeSys version than V2.2. If all needed configuration files are available, the command 'Convert' will transfer the existing configuration into the format of the actual PLC configuration. A dialog will open which asks 'Convert the configuration to the new format ? Attention: Undo is not possible !' You can select Yes or No. If you close the dialog with Yes, the configuration editor will be closed also. Reopen it and you will see the configuration in the new format. Be aware that after having converted the old format cannot get restored anymore !
6.5.2
General Settings in the PLC Configuration Select the entry 'PLC configuration' ('root' module) at top of the configuration tree. Thereupon the dialog 'Settings' is shown in the right part of the window: Calculate addresses: Each newly inserted module automatically is allocated with an address, which results from the address of the module inserted before plus the size of this address. If a module is removed from the configuration, the addresses of the following modules are adjusted automatically. When the command 'Extras' 'Compute addresses' is executed, all addresses starting at the selected node (module) will be recalculated. Check for overlapping addresses: At compilation the project will be checked for overlapping addresses and a corresponding message will be displayed. Dialog for the general Settings of the PLC configuration
The global mode of addressing (flat addresses / addresses depending on Id) in the PLC configuration is defined in the configuration file.
6.5.3
Custom specific parameter dialog The parametrizing possibilities of the configurator can be expanded by the use of an applicationspecific DLL, that is an individual dialog. This 'Hook'-DLL must be in that directory which contains the configuration file and then can be linked by an entry in the configuration file.to a module or channel. If done so, for the concerned modules the standard dialog 'Modulparameter' will be replaced by a dialog defined in the DLL.
6-14
CoDeSys V2.3
6 - The Resources
Example of an application-specific parameter dialog (Custom Parameters)
6.5.4
Configuration of an I/O Module..
Base parameters of an I/O Module Base parameter s Dialog for an I/O Module
If an I/O module is selected in the configuration tree, the dialog 'Base parameters' is displayed with the following entries:
CoDeSys V2.3
6-15
PLC Configuration
Modul id: The Modul-ID is a unique identifier of the module within the entire configuration. It is defined by the configuraiton file and it is not editable in the configuration editor. Node number: The Nodenumber is defined by an entry in the configuration file or – if there is no entry – by the position of the module in the configuration structure. Input address, Output address, Diagnostic address: Addresses for Input - and Output respectively for the storage of diagnosis data. These addresses refer to the module. It depends on the general settings , which addresses are already predefined, which address mode is valid and whether the addresses can be still edited here. The diagnosis in the PLC configuration: A marker address must be given at the Diagnostic address of the module. For normal I/O modules it depends on the special hardware configuration how the diagnosis will be handled. For bus systems like CAN or Profibus DP the diagnosis works like described in the following: From the given diagnosis address onwards there will be stored various information concerning the structure GetBusState which is part of a corresponding library delivered by the manufacturer. All bus modules get a request to fill the diagnosis structure in a cyclic sequence each time when an IEC task has written or read process data to/from the modules. As soon as at least one module in the bus system produces an error, the specific diagnosis information can be read using the function block DiagGetState which is also part of the above mentioned library. This function is only available for bus masters, which have been configured within the CoDeSys PLC configuration ! See in the following the input and output parameters of the function block DiagGetState. Define an instance of this function block in your CoDeSys project to read the diagnosis information for a specific bus module: Input variables of DiagGetState: ENABLE: BOOL;
At a rising edge of ENABLE the function block starts working
DRIVERNAME:POINTER TO STRING;
Name of the driver (address of the name) to which the diagnosis request should be sent. If here is entered a 0, the diagnosis request will be forwarded to all present drivers.
DEVICENUMBER:INT;
Identification of the bus which is managed by the driver. E.g.: the Hilscher driver can handle up to 5 cards (busses). The index is 0based.
BUSMEMBERID:DWORD ;
Unique bus-/driver specific identification of the busmodule entifizierung des Busteilnehmers. (E.g.: for a CANopen-card this is the NodeID, for a PB-DP card this is the station address of the participant etc. )
Output variables of DiagGetState READY:BOOL ;
TRUE: the work on the diagnosis request has been terminated
STATE:INT;
If READY = TRUE then STATE gets one of the following values which define the actual state of the function block: -1: invalid input parameter (NDSTATE_INVALID_INPUTPARAM:INT;) 0: function block does not work (NDSTATE_NOTENABLED: INT;) 1: function block is just reading the diagnosis info (NDSTATE_GETDIAG_INFO:INT;) 2: diagnosis info is now available (NDSTATE_DIAGINFO_AVAILABLE:INT;) 3: no diagnosis info is available (NDSTATE_DIAGINFO_NOTAVAILABLE:INT;)
6-16
CoDeSys V2.3
6 - The Resources
EXTENDEDINFO:ARRAY[0.129] Up to 100 Bytes manufacturer specific diagnosis data of the bus. OF BYTE; For each bus participant 1 byte is reserved in which the 0 – 2 are used as described in the following: Bit 0: Bus module exists in PLC configuration. Bit 1: Bus module is available in bus system. Bit 2: Bus module reports error. Modul parameters / Custom Parameters of an I/O Module Modulparameter Dialog
In this dialog the parameters which are given by the device file are shown. Only the column 'value' is editable. Index: The Index is a consecutive digit (i), which numbers through all the way the parameters of the module. Name: Name of the parameter Value : Value of the parameter, editable Initially the default is displayed. Values can be set directly or by means of symbolic names. If the entries in the configuration file are not set to 'Read Only', they can be edited. To do that click on the edit field respectively select on of the entries in a scoll list. If the value is a file name, you can open the dialog 'Oben file' by a doubleclick and browse for another file there. Default: Default value of the parameters Min.: minimum value of the parameter (only if no symbolic names are used) Max.: maximum value of the parameter (only if no symbolic names are used) A tooltip may give additional information on the currently marked parameter. Instead of the Modulparameter dialog there might be a customer specific dialog. This is due to the fact, that such a dialog is linked by an entry (Hook-DLL) at the module definition in the configuration file.
CoDeSys V2.3
6-17
PLC Configuration
6.5.5
Configuration of a Channel
Base parameters of a channel Basisparameter dialog for a channel
Channel-Id: Globally unique identifier of the channel Class: Defines whether the channel is used als input (I), output (Q), or as input and output (I&Q), or whether it is switchable (I Q). If the channel is switchable, this can be done by the command 'Extras' 'Replace element'. Size: Size of the channel [Byte] Default identifier: Symbolic name of the channel The name of the channel is defined in the configuration file. Only if it is allowed by the definition of the father module, the name of the channel can be edited in the configuration tree. Comment: Additional information on the channel In the edit field a comment can be inserted or modified. Address: This edit field only will be available if it was activated by an entry in the configuration file. Insert the desired address for the channel. Channel parameters Corresponding to the Moduleparameter dialog the Channelparameter dialog is used to display and modify the parameters of a channel: Index, Name, Wert, Default, Min., Max. This dialog also can be replaced by a customer specific dialog 'Custom Parameters' ersetzt sein. Bitchannels Bitchannels are automatically inserted, when CreateBitChannels=TRUE in the configuration file.
a
channel
is
defined
with
an
entry
The Basisparameter dialog of bitchannels just contains the field Comment.
6.5.6
Configuration of Profibus Modules CoDeSys supports a hardware configuration corresponding to the profibus DP standard. In the profibus system you find master and slave modules. Each slave is provided with a parameter set by ist master and supplies data on request of the master. A PROFIBUS DP system consists of one or several masters and their slaves. First the modules must be configured so that a data exchange over the bus is possible. At the initialization of the bus system each master parameterizes the slaves which are assigned to it by the configuration. In a running bus system the master sends and/or requests data to/from the slaves.
6-18
CoDeSys V2.3
6 - The Resources
The configuration of the master and slave modules in CoDeSys is based on the gsd files attached to them by the hardware manufacturer. For this purpose all gsd files which are stored in the configuration files directory will be considered. The modules described by a gsd file can be inserted in the configuration tree and their parameters can be edited there. Below a master there can be inserted on or several slaves. If a DP master is selected in the configuration tree, the following dialogs will be available in the right part of the configuration: Basisparameter, DP Parameter, Busparameter, Modulparameter. If a DP slave is selected, which is inserted below a DP master, the following dialogs will be available: Basisparameter, DP Parameter, Input/Output, Userparameter, Groups, Modulparameter. If a DP slave is inserted on the level of a master, the following dialogs are available for configuration: Basisparameter, DP Parameter, Input/Output, Modulparameter. Base parameters of the DP master The Basisparameter dialog of a DP master matches that of the other modules: Module ID, Node number, Input, Output and Diagnostic addresses (see 'Base parameters of an I/O Module') Modul parameters of the DP master The Modulparameter dialog of a DP master matches that of the other modules: The parameters assigned to the master in additon to the DP and bus parameters in the configuration file are displayed here and the values can be edited in the standard case (see Chapter 6.5.4, 'Modulparameters of an I/O Module' ). DP parameters of the DP master This dialog shows the following parameters extracted from the device file of the DP master: DP Parameter dialog for DP master
Info
Manufacturer, GSD Revision, ID (identification number), HW Release and SW Release (hard- and software version), GSD-Filename
Module name The settings can be edited at this position. Addresses
Station address: The allowable range extends from 0 to 126. Each device newly inserted on a bus line is automatically provided the next higher address. (note: Address 126 is the default DP slave address). Manual entry is possible; addresses are tested for duplication. Highest station address: The highest stationaddress (HSA) assigned on the bus is displayed. Here, a lower address can also be entered in order to narrow the GAP range (that is, the address range within which the search for newly-active devices is carried out).
CoDeSys V2.3
6-19
PLC Configuration
The GSD file pertaining to a device can be opened and examined using the GSD File button. The Groups button leads to the 'Group properties' dialog. The Group properties pertain to the slaves assigned to the master. Up to eight groups can be set up. For each group, enter whether it is to operate in Freeze mode and/or Sync mode. By assigning slaves (see 'Properties of the DP slave' 'Group assignment') to va rious groups, data exchange from the master can be synchronized via a global control command. With a Freeze command, a master instructs a slave or a group to „freeze' inputs in their instantaneous state and to transfer these data in the following data exchange. With a Sync command, the slaves are instructed to synchronously switch to output at the next Synch command all data received from the master following the first command. To switch the Freeze and Sync options for a group on/off, please click with the left mouse button on the appropriate location in the table to place or remove an „X' next to the desired option, or use the right mouse button to activate or deactivate the option via a context menu. In addition, you can edit the group name here. DP parametesr of the DP master / Group Properties
Bus parameters of the DP master The Bus parameters describe the timing of the communication. If the option Optimize is activated, then the parameter values will be calculated automatically depending on the Baudrate set by the user and the settings given by the GSD files. Attention: : The automatically calculated values are just approximated values ! Busparameter of the DP master
6-20
CoDeSys V2.3
6 - The Resources
All parameters can also be edited manually. Baud rate
The entries already present in the GSD file are available for selection, but only a transmission rate supported by all slaves can be entered.
Optimize
If the option is activated, the entries made in the 'Bus parameters' dialog will be optimized with respect to the specifications in the GSD files; it is only possible to edit the values if the option is deactivated. Important : The values calculated automatically are only rough approximate values.
Slot Time
Maximum time during which the master waits, after sending a request message, for the receipt of the first character of the slave's reply message
Min.Station Delay
min. TSDR (in tbit): minimum reaction time after which a station on the bus may reply (min. 11 tBit)
Max.Station Delay
max. TSDR (in tbit): maximum time span within which a slave must reply.
Quiet Time
TQUI (in tbit): idle period which must be taken into account during conversion of NRZ (Non Return to Zero) signals to other codings (switchover time for repeater)
Target Rotation Time
TTR (in tbit): token cycle time setting; projected time interval in which a master should receive the token. Result of the sum of the token stop times of all masters on the bus.
Gap Update Factor
GAP update factor G: number of bus cycles after which the master's GAP (address range from its own bus address to the address of the next active station) is searched for an additional, newly inserted active station.
Max. Retry Limit
maximum number of repeated request attempts by the master when it has not received a valid response from the slave
Min. Slave Interval
Time between two bus cycles in which the slave can process a request from the master (time basis 100µs). The value entered here must be checked against the respective specifications in the slave's GSD file.
Poll Timeout
Maximum time after which the master's reply by a master-master communication must be retrieved by the requester (Class 2 DP master) (time basis 1 ms).
Data Control Time
Time in which the master reports its status to the slaves assigned to it. At the same time, the master monitors whether at least one data exchange each has taken place with the slaves within this period, and updates the Data_Transfer_List.
Watchdog Time
Time value for the access monitoring (watchdog). Setting is currently not supported (fixed-set to 400 ms)
Base parameters of a DP slaves The Basisparameter dialog of a DP -Slaves corresponds to that of other modules: Modul-Id, Nodenumber, Input-, Output- and Diagnosisaddress
CoDeSys V2.3
6-21
PLC Configuration
Basisparameter dialog for a DP slave
DP parameters of a DP slave This dialog shows the following parameters extracted from the device file of the DP slave: DP Parameter dialog for a DP slave
Info
Manufacturer, GSD Revision, HW Release and SW Release (hard- and software version), GSD-Filename, Slavetype
Standardparameter
Identnumber: Unique identnumber assigned by the PNO for this device type. Allows unambiguous reference between a DP slave and the corresponding GSD file. TSDR (Tbit*): Time Station Delay Responder: Reaction time, the earliest time after which the slave is permitted to respond to the master. (min. 11 TBit) * TBit: Time unit for transfer of a bit on the PROFIBUS; Reciprocal value of the transimission rate; z.B. 1 TBit at 12MBaud=1/12.000.000 Bit/sek=83ns Lock/Unlock: Slave is locked or released to other masters:
6-22
CoDeSys V2.3
6 - The Resources
0: 1: 2: 3:
min.TSDR and slave-specific parameters may be overwritten Slave released to other masters, Slave locked to other masters, all parameters are accepted; Slave released to other masters
Identification
Station address (see 'Properties of the DP masters'), Station name (matches device name, editable)
Activation
Slave is active/inactive in current configuration. If activation is not selected, configuration data will still be transferred to the coupler on Download, but not data exchange occurs over the bus.
Watchdog
If Watchdog Control is set active, the entered Watchdog time applies (access monitoring, basis 10 ms). If the slave has not been accessed by the master within this time, it is reset to its initialization state.
You can inspect the corresponding GSD file via the GSD-File button. In-/outputs of a DP slave Dialog for configuring the in-/outputs of a DP slave
As the maximum data lengths specified in the GSD file (Max. length of input data, Max. length of output data, Max. length of in-/output data) and the maximum number of modules (Max. number of modules) must be respected, this information is displayed in both module lists. The left block displays the maximum possible values for the device, the right the values resulting from summing the values selected in the configuration. If the maximum values are exceeded, an error message is issued. The dialog lists in the left window all the in- and output modules available in the slave's GSD file, while the right window contains the configuration currently selected for this device as it relates to in- and outputs. If this is a modular slave (a device that can be equipped with various I/O modules), the selection proceeds as follows: In the left-hand list, the desired in- or output module is selected by mouse-click and copied into the right window using the Select >> button. Incorrect entries can be corrected by selecting the undesired module in the right window and pressing the Delete button. This kind of selection is not possible for non-modular slaves. These directly enforce a closed display of their in- and outputs in the right window. Undesired modules can then by removed by selecting and using Delete.
CoDeSys V2.3
6-23
PLC Configuration
The Properties button leads to the 'Module properties' dialog for the in- or output module currently selected in the left or the right list. It shows the Name, the Config (module description coding according to PROFIBUS standard) and the in- and output lengths of the module in bytes. If the module description in the GSD file contains specific parameters in addition to the standard set, these are listed here with their values and range of values. If the Symbolic names option is activated, the symbolic names are then used. Module properties dialog for in-/outputs of a DP slave
User parameters of a DP slave User parameter dialog for a DP slave
Here, various extended parameters of a DP slave, defined in the GSD file, are listed. The Parameters column shows the name of the parameter. The parameter values entered in Value column can be altered by double-click or via the right mouse button. In addition, the Value range is specified. If symbolic names are also specified for the parameters in the GSD file, the Symbolic names option can be activated, so that the values can be displayed with these names. For information, the Length of user parameters is also given above the table.
6-24
CoDeSys V2.3
6 - The Resources
Group assignment of a DP slave Dialog for group assignment of a DP slave
This dialog is used for assigning the slave to one or more of the eight possible groups. The universally applicable group properties (Sync. Mode and/or Freeze Mode), on the other hand, are defined during configuration of the master's properties (see 'Properties of the DP master, Group properties'). This dialog can also be reached via the Global Group Properties button. The group(s) to which the slave is assigned are marked with a plus sign. The assignment to or removal from a group is accomplished by selecting the group name in the Group Membership column and pressing 'Add slave to group' or 'Remove slave from group' with the right mouse button, or by clicking again with the mouse to the left of the group name. A slave device can only be assigned to those groups whose properties it supports. The concerned properties of each slave (Sync. Mode / Freeze Mode ) are displayed above the table. The modes supported by the device are checked. Module parameters of a DP slave The module parameters dialog of a DP slave matches that of the other modules (see Chapter 6.5.4). The parameters assigned to the slave in addition to the DP and user parameters in the configuration file are displayed here, and the values can be edited in the standard case. Properties of a DP slave in slave operation of the Profibus If a Profibus runs in slave mode, the slave device is inserted in the master level of the configuration tree. The configuration can be done in the following dialogs (for a description see the chapters above): •
Basisparameter
•
DP Parameter
•
Modulparameter
•
Input/Output
CoDeSys V2.3
6-25
PLC Configuration
6.5.7
Configuration of CAN modules CoDeSys supports a hardware configuration according to CANopen Draft Standard 301. The configuration looks like that described for the hardware dependant configuration. All EDS (Electronic Data Sheet) respectively DCF (Device Configuration File) files which are stored in the subdirectory PLCCONF of the library when CoDeSys is started, can be integrated, edited and displayed in the configuration. In the EDS file the configuration options of a CAN module are described. If you add a module, which is described in a DCF file, only the IEC addresses can be modified, for the module has already been configured completely in a CAN configurator.
Base parameters of a CAN Master For information on Modul-Id, Eingabe-/Ausgabeadressen, Diagnosis address see Chapter 6.5.4', Base parameters of an I/O module'. CAN Parameters of a CAN Master CAN Parameter Dialog for a CAN-Master
The properties for transmission on the CAN bus can be set directly after the insertion of the module or can be called up with the command ’Extras’ ‘Properties’ . Using the selection option, set the required Baud rate which the transmission should take place at. One differentiates between synchronous and asynchronous transmission modes (see PDO properties) for PDO’s (Process Data Object). The synchronisation message is sent with a unique number Sync.COB-Id (Communication Object Identifier) in the interval in microseconds which is given by the Communication Cycle Period. The synchronous PDO’s are transmitted directly after the synchronisation message in the time window (Sync.Window Length in microseconds). No synchronisation message will be sent if the fields Comm. Cycle Period and Sync. Window Length contain 0. activate: Only if this option is activated synchronization messages will be transmitted between master and slaves.
NodeID: serves to identify the CAN module uniquely and corresponds to the set number on the module itself which is between 1 and 127. The Id must be entered as a decimal number. ( Do not mix up with the 'Node number' !)
6-26
CoDeSys V2.3
6 - The Resources
The CAN bus will automatically initialised and started when downloading is occurring and when the controller system starts up if the option Automatic start is activated. The CAN bus must be started up in the project if this option is not active. If the option Support DSP301,V3.01 and DSP306 is activated, then modular CAN Slaves as well as some additional extensions concerning the standards DSP301 V3.01 and DSP306 will be supported. In this case e.g the stroke of the Heartbeat will be adjustable (Heartbeat Master [ms]:). Working with Heartbeats is an alternative guarding mechanism: In contrast to the Nodeguarding functionality it can be executed by Master- and Slave-Modules. Usually the master will be configured to send heartbeats to the slaves. Module Parameters of a CAN-Master The modul parameters dialog of a CAN master is the same as that for the other modules (see Chapter 6.5.4). The parameters which have been additionally assigned to the master in the configuration file, are displayed here and as a default the values can be edited. CAN Parameters of a CAN Module CAN Parameter -Dialog for a CAN Module
The CAN parameters of a CAN module, which is not acting as master (global watching of the bus), are different to those of a CAN master. Section General: The Node-Id serves to identify the CAN module uniquely and corresponds to the set number on the module itself which is between 1 and 127. The Id must be entered as a decimal number. If DCF write is activated, a DCF file will be created after inserting an EDS file in the defined directory for the compiled files whose name is made up of the name of the EDS file and the Node Id which is tacked on the end. If the option Create all SDO's is activated, then for all objects SDO's will be created (not only for those that have been modified). If the option Reset node is activated, then the slave will be reset before downloading the configuration. Section Nodeguard Settings: (alternatively to guarding by the Heartbeat mechanism) If the option Nodeguarding is activated, a message will be sent to the module according to the interval set by Guard Time in milliseconds. If the module does not then send a message with the
CoDeSys V2.3
6-27
PLC Configuration
given Guard COB-ID (Communication Object Identifier), it will receive the status 'timeout'. As soon as the number of attempts (Life Time Factor) has been reached, the module will receive the status 'not OK'. The status of the module will be stored at the diagnosis address. No monitoring of the module will occur if the variables Guard Time and Life Time Factor are not defined (0). Section Heartbeat Settings: (alternatively to Nodeguarding) If the option Activate Heartbeat Producer is activated, the module will send heartbeats according to the interval defined in Heartbeat Producer Time: given in m s. If the option Activate Heartbeat Consumer is activated, then the module will listen to heartbeats which are sent by the master. As soon as no more heartbeats are received, the module will switch off the I/Os. Section Emergency Telegram: A module sends an emergency message, with a unique COB-Id., when there is an internal error. These messages, which vary from module to module, are stored in the diagnosis address. The entries 'FileInfo' and 'DeviceInfo' of the EDS or DCF file from the corresponding module manufacturer are hidden behind the Info button. Base parameters of a CAN module For information on Modul-Id, Input/Output adresses, Diagnosis address see Chapter 6.5.4, 'Base parameters of an I/O module'. IEC addresses by which the PDO’s (Process Data Object) in the project can be addressed are entered for output and input addresses, whereby the direction (input or output) is defined from view of the module. A marker address must be given at the diagnosis address of the CAN module. It works like described for the CAN master. CAN Modules Selection for Modular Slaves In the left column (Available modules) you find all modules which are available for the slave. Mark the desired modules and by using the buttons Add and Remove create a selection in the right column (Selected Modules). The PDO- and SDO selection will be updated automatically. PDO mapping of a CAN module The tabs Receive PDO mapping and Send PDO mapping in the configuration dialog for a CAN module allow the 'mapping' of the module, which is described in the EDS file, to be changed. All of the 'mappable' objects in the EDS file are located on the left side and can be added in the right side to the PDO's (Process Data Object) ('>>' button) or removed again (Remove button). The StandardDataTypes can be inserted to create empty spaces in the PDO.
6-28
CoDeSys V2.3
6 - The Resources
Configuration of a CAN module, PDO-Mapping
The button Insert Element can be used to create further PDO's and to add appropriate objects to them. The allocation of inputs or outputs to the IEC addresses can be achieved over the inserted PDO's. The setting which have been made in the controller system configuration will become visible when one leaves the dialog. The individual objects can be afforded symbolic names there. The standard set properties of the PDO's can be edited using Properties. PDO Properties dialog
Each PDO message requires a unique COB-Id (Communication Object Identifier). The field appears in grey and cannot be edited if an option is not be supported by the module or if the value cannot be changed. The Inhibit Time is the minimum time between two messages from this PDO. This is to prevent PDO's which are sent when the value is changed from being sent too often. The CMS Priority Group cannot be changed and describes the relative importance of the PDOs during the CAN transmission. Values from 0 to 7 are displayed, whereby 0 is the highest. Transmission Type offers you a selection of possible transmission modes for this module: acyclic - synchronous: the PDO will be transmitted synchronously but not periodically.
CoDeSys V2.3
6-29
PLC Configuration
cyclic – synchronous: the PDO will be transmitted synchronously, whereby the Number of Sync's gives the number of synchronisation messages, which lie between two transmissions of this PDO. synchronous – RTR only: the PDO will be updated after each synchronisation message but not sent. It is only sent when there is an explicit request to do so (Remote Transmission Request) asynchronous – RTR only: the PDO will only be updated and transmitted when there is an explicit request to do so (Remote Transmission Request) asynchronous – device profile specific and asynchronous - manufacturer specific: the PDO will only be transmitted when specific events occur.
Number of Syncs: If cyclic transmission has been set, enter here the number of synchronisation messages (see 'Com. Cycle period' in the CAN parameter dialog) which should be sent between two transmissions of the PDO. Event-Time: If an corresponding transmission type is set, enter here in milliseconds (ms) the interval between two transmissions. Service Data Objects Here you find a list of all objects in the EDS or DCF file which are in the area of the Index 0x2000 to 0x9FFF and which are marked as writable. Dialog for configuration of the Service Data Objects (SDO)
The properties Index, Name, Value, Type and Default are displayed for every object. The value can be changed. Mark the value and press the . After making the change confirm the new value with or reject it with the key. The set values are transmitted in the form of SDO's (Service Data Object) to the CAN modules at the initialisation of the CAN bus. Note: All incompatible data types between CANopen and IEC-61131 will be replaced in CoDeSys by the next larger IEC-61131 data type.
6.5.8
Configuration of a CanDevice (CANopen Slave) A PLC which is programmable with CoDeSys can be used as a CANopen Slave (CANopen-Node, called 'CanDevice' in the following) in a CAN network. For this purpose the PLC can be configured in the CoDeSys PLC Configurator and the configuration can be saved in an EDS-file. This EDS-file (device file) later can be used in any CANopen Master configuration. Preconditions for creating a CanDevice in the CoDeSys PLC Configurator: 1. The libraries
6-30
•
3S_CanDrv.lib
•
3S_CanOpenManager.lib
•
3S_CanOpenDevice.lib
CoDeSys V2.3
6 - The Resources
must be included in the CoDeSys project. They are needed for running the PLC as an CANopen device. 2. In the configuration file (*.cfg) on which the configuration is basing, an appropriate entry for a CanDevice must be inserted. Only then in the PLC Configuration Editor a subelement 'CanDevice' can be appended and parameterized in the three configuration dialogs which will be described in the following: •
Base settings
•
CAN settings
•
Default PDO mapping
Base settings of a CanDevice Dialog Base settings
Bus identifier: currently not used. Name of updatetask: Name of the task, in which the CanDevice is called. A selection list will provide all tasks which are available in the project. EDS file generation: Activate this option if you want to generate a device file (EDS file) from the current configuration settings in order to be able to use the CanDevice later in any master configuration. Enter a path and name for the file in the field Name of EDS file. Optionally a manually created template file can be defined (Template for EDS file), which will be supplemented with the settings done in the configuration dialogs. For example you could create a text file containing certain EDS file entries, save it as 'EDS_template.txt' and enter the path of this template in the current dialog. If you then generate an EDS file 'device_xy.eds' from the current project, the entries resulting from the project will be merged with those of the template and will be saved in 'device_xy.eds'. (Do not use the extension '.eds' for the template file !) If entries are created by the current project which are already defined by the template, the template definitions will not be overwritten. For entering the file pathes you can use the standard dialog for browsing for a file which can be opened by using the button Browse..
CoDeSys V2.3
6-31
PLC Configuration
CAN settings of a CanDevice Dialog CAN settings
Here you can set the Node id and the Baudrate. The node id is a node number which is used by the master for addressing the device in a CANopen network. A configuration of Nodeguard- and Emergency Telegram functionality is possible. Please see the corresponding descriptions for the configuration of CAN modules and masters. Heartbeat is currently not supported. Default PDO mapping of a CanDevice In this dialog the entries of the local Parameter Manager can be assigned to PDOs, which will be sent/received by the CanDevice. The PDOs then will be available for the PDO mapping in any master configuration where the CanDevice is integrated. In the Parameter Manager lists the parameter entries are linked to project variables via index/subindex. Please regard: Subindex 0 of an index, which implicits more than one subindex, will be used implicitely for storing the number of subindices. For this reason do not use subindex 0 in the Parameter Manager. Also regard that the parameters of a particular index must be entered in ascending order (subindices 1,2,3..) in the Parameter Manager.
List of mapable objects: Choose from the selection list the variables' parameter list, for whose entries the CanDevice should generate PDOs. According to the chosen parameter list the Objects will appear in the left window. In the right window you create the desired PDO configuration (PDO's). Via the buttons Insert receive PDO resp. Insert send PDO there you can insert 'Receive PDOs' and 'Send PDOs' below the corresponding list organizing elements. In order to assign an object of the left window to one of these send or receive PDOs, mark the object in the left window and also the PDO in the right window and then press >>. Thereupon the object will be inserted below the PDO in the right window.
6-32
CoDeSys V2.3
6 - The Resources
Dialog Default PDO mapping
The Properties of the PDO can be defined in a dialog which is also used for the PDO configuration of other CAN modules. By using button Delete the PDO currently marked in the right window will be removed from the configuration.
6.5.9
PLC Configuration in Online Mode In online mode the PLC configuration displays the stati of the inputs and outputs of the PLC. If a boolean input or output has the value TRUE, the little box at the beginning of the entry line in the configuration tree will get blue, non-boolean values will be added at the end of the entry line (e.g. '=12'). The boolean inputs can be toggled by mouseclicks. At other inputs a mouseclick on the beginning of the line opens a dialog, where the value can be modified. The modified value will be set in the PLC as soon as the dialog is closed with OK.
6.6
Target Settings The 'Target Settings' is an object of the 'Resources'. Here you define, which target shall be used for the project and how it will be configured. If a new project is started with 'Project' 'New', a dialog will open where the target, that means a predefined configuration for a target, has to be set. The list of available targets depends on which Target Support Packages (TSP) are installed on the computer. These describe platform specific basic configurations and also define, to which extent the configuration can be modified by the user in the CoDeSys Target settings dialogs. Please regard: If no TSP is available, only the setting 'None' will be offered in the target system selection box. This will switch to simulation mode automatically and no configuration settings will be possible.
CoDeSys V2.3
6-33
Target Settings
Target-Support-Package A Target Support Package (TSP) must be installed before starting by the aid of the installation program InstallTarget which might be part of the CoDeSys-Setup. A Target Support Package (TSP) contains all the files and configuration information necessary to control a standard platform with a program created in CoDeSys. What has to be configured: codegenerator, memory layout, PLC functionality, I/O modules. In addition libraries, gateway drivers, ini-files for error messaging and PLC browser have to be linked. The central component of a TSP is one or more Target files. A Target file directs to the files which are in addition necessary to configure the target. It is possible that several target files share these additional files. The default extension for a Target file is *.trg, the format is binary. Additive definitions are attached to the entries in the target file which determine whether the user can see and edit the settings in the CoDeSys dialogs. During installation of a TSP the target file for each target is put to a separate directory and the path is registered. The associated files are copied to the computer according to the information of a Info file *.tnf . The name of the target directory is the same as the targets name. It is recommended to store the target specific files in a directory which is named with the manufacturers name. The files which get installed with a TSP are read when CoDeSys is started. The target settings which are done in the CoDeSys dialogs will be saved with the project. Please note: If you use a new target file or if you have changed the existing one, CoDeSys has to be restarted to read the updated version.
6.6.1
Dialog Target Settings The dialog Target Settings will open automatically, when a new project is created. It also can be opened by selecting the menu item 'Target Settings' in the register 'Resources' in the Object Organizer. Choose one of the target configurations offered at Configuration. If no Target Support Package has been installed, only 'None' can be selected, which means working in simulation mode. If you choose one of the installed configurations it depends on the entries in the target files, which possibilities are left to customize this configuration in the CoDeSys dialogs. If you choose a target configuration, for which there exists no valid licence on the computer, CoDeSys asks you to choose another target. If a configuration is selected, which is provided with the entry 'HideSettings' in the corresponding target file, you only can see the name of the configuration. Otherwise there are five dialogs available to modify the given configuration: 5. Target Platform 6. Memory Layout 7. General 8. Networkfunctionality 9. Visualization Attention !: Please be aware, that each modification of the predefined target configuration can cause severe changes in performance and behaviour of the target !
Press if you want to reset the target settings to the standard configuration given by the target file.
6-34
CoDeSys V2.3
6 - The Resources
6.7
Task Configuration.. In addition to declaring the special PLC_PRG program, you can also control the processing of your project using the task management. A Task is a time unit in the processing of an IEC program. It is defined by a name, a priority and by a type determining which condition will trigger the start of the task. This condition can be defined by a time (cyclic, freewheeling) or by an internal or external event which will trigger the task; e.g. the rising edge of a global project variable or an interrupt event of the controller. For each task you can specify a series of programs that will be started by the task. If the task is executed in the present cycle, then these programs will be processed for the length of one cycle. The combination of priority and condition will determine in which chronological order the tasks will be executed. For each task you can configure a watch dog (time control) can be configured. In the Online Mode the task processing can be monitored in a diagram. Additionally there is the possibility to link System events (e.g. Start, Stop, Reset) directly with the execution of a project POU.
The Task Configuration is found as an object in the Resources tab the Object Organizer. The Task editor is opened in a bipartited window. For an example of the Task Configuration Window see the picture on the following page. In the left part of the window the tasks are represented in a configuration tree. At the topmost position you will always find the entry 'Taskconfiguration'. Below there are the entry 'System events' and the entries for the particular tasks, represented by the task name. Below each task entry the assigned program calls are inserted. Each line is preceeded by an icon. In the right part of the window a dialog will be displayed which belongs to the currently marked entry in the configuration tree. Here you can configure the tasks (Task properties), program calls (Program call) resp. define the linking of system events (System events). It depends on the target which options are available in the configuration dialogs. They are defined by a description file which is referenced in the target file. If the standard descriptions are extended by customer specific definitions, then those will be displayed in an additional tab 'Parameter' in the right part of the window. Note:
Please do not use the same string function (see standard.lib) in several tasks, because this may cause program faults by overwriting.
Working in the Task Configuration •
The most important commands you find in the context menu (right mouse button).
•
At the heading of the Task Configuration are the words 'Task Configuration.' If a plus sign is located before the words, then the sequence list is closed. By doubleclicking on the list or pressing , you can open the list. A minus sign now appears. By doubleclicking once more, you can close the list again. For every task, there is a list of program call-ups attached. Likewise, you can open and close this list the same way.
•
With the 'Insert' 'Insert Task' command, you can insert a task.
•
With the 'Insert' 'Append Task' command, you can insert a task at the end of the configuration tree.
•
With the 'Insert' 'Insert Program Call', a program call will be assigned to the task which is actually selected in the configuration tree.
•
Furtheron for each entry in the configuration tree an appropriate configuration dialog will appear in the right part of the window. There options can be activated/deactivated resp. inputs to editor fields can be made. Depending on which entry is selected in the configuration tree, there will be the dialog for defining the 'Taskattributes' (see 'Insert Task'), the dialog for defining a 'Program Call' (see 'Insert Program Call' einfügen') or the table of S ' ystem events. The settings made in the dialogs will be taken over to the configuration tree as soon as the focus is set to the tree again.
CoDeSys V2.3
6-35
Task Configuration..
•
A task name or program name can also get edited in the configuration tree. For this perform a mouseclick on the name or select the entry and press the button to open an edit frame.
•
You can use the arrow keys to select the previous or next entry in the configuration tree.
•
By clicking on the task or program name, or by pressing the , you can set an edit control box around the name. Then you can change the designation directly in the task editor.
'Insert' 'Insert Task' or 'Insert' 'Append Task' With this command you can insert a new task into the Task Configuration. The entries each consist of a symbol and the task name. If a task or the entry 'System events' is selected, then the 'Insert Task' command will be at your disposal. The new task will be inserted after the selected one. If the entry 'Task Configuration' is selected, then the 'Append Task' is available, and the new task will be appended to the end of the existing list. The dialog box will open for you to set the task attributes. Dialog Box for Setting Task Attributes
Insert the desired attributes: Name: a name for the task; with this name the task is represented in the configuration tree; the name can be edited there after a mouseclick on the entry or after pressing the key when the entry is selected. Priority (0-31): (a number between 0 and 31; 0 is the highest priority, 31 is the lowest), Type: cyclic ( ) : The task will be processed cyclic according to the time definition given in the field 'Interval' (see below). freewheeling ( ) : The task will be processed as soon as the program is started and at the end of one run will be automatically restart ed in a continuous loop. There is no cycle time defined. triggered by event ( ): The task will be started as soon as the variable, which is defined in the Event field gets a rising edge. triggered by external event ( ): The task will be started as soon as the system event, which is defined in the Event field, occurs. It depends on the target, which events will be supported and offered in the selection list.
6-36
CoDeSys V2.3
6 - The Resources
Properties: Interval (for Type 'cyclic' or 'freewheeling'): the period of time, after which the task should be restarted. If you enter a number, then you can choose the desired unit in the selection box behind the edit field: milliseconds [ms] or microseconds [µs]. Inputs in [ms]-format will be shown in the TIME format (e.g. 't#200ms') as soon as the window gets repainted; but you also can directly enter the value in TIME format. Inputs in [ms] will always be displayed as a pure number (e.g. '300'). Single (for Type 'triggered by event' or 'triggered by external event'): a global variable which will trigger the start of the task as soon as a rising edge is detected. Use button .. or the input assistant to get a list of all available global variables. If there is no entry in both of these fields, then the task interval will depend on which runtime system is used (see runtime documentation); e.g. in this case for CoDeSys SP NT V2.2 and higher an interval of 10 ms will be used). Watchdog Activate watchdog When this option is activated ( ) then the task will be terminated in error status as soon as the processing takes longer than defined in the 'Time' field (see below). Time (e.g.: t#200ms): Watchdog time; after the expiration of this term the watchdog will be activated unless the task has not been terminated already. Sensitivity: Number of overruns of the watchdog time, which are accepted without generating an error. 'Insert' 'Insert Program Call' or 'Insert' 'Append Program Call' With these commands you will open the dialog box for entering a program call to a task in the Task Configuration. Each entry in the task configuration tree consists of a symbol ( name.
) and the program
With 'Insert Program Call', the new program call is inserted before the selected program call, and with 'Append Program Call' the program call is appended to the end of the existing list or program calls. Dialog box for Program Call Entry
In the field 'program call' specify a valid program name out of your project or open the Input Assistant with the Select button to select a valid program name. The program name later also can be modified in the configuration tree. For this select the entry and press the key or just perform a mouseclick to open an editor field. If the selected program requires input variables, then enter these in their usual form and of the declared type (for example, prg(invar:=17)). The processing of the program calls later in online mode will be done according to their order (top down) in the task editor. Please regard: Do not use the same string function in several tasks (see Standard Library Elements), because in this case values might be overstroke during processing of the tasks.
System Events Instead of a 'task' also a 'system event' can be used to call a POU of your project. The available system events are target specific (definition in target file). The list of the standard events of the target
CoDeSys V2.3
6-37
Task Configuration..
may be extended by customer specific events. Possible events are for instance: Stop, Start, Online Change. The assignment of system events to POUs is also done in the Task configuration editor. Use the dialog 'Events', which will be opened as soon as the entry ' System-events' is selected in the task configuration tree: Table for Assigning POUs to System Events
Each event is represented in a line: Name and Description are displayed as defined in the target file, in the column called POU you can enter the name of the project POU which should be called and processed as soon as the event occurs. For this use the input assistant () or enter manually the name of an already existing POU (e.g. 'PLC_PRG' or 'PRG.ACT1'), or insert a name for a not yet existing POU. In order to get this POU created in the project, press button Create POU. Hereupon the POU will be inserted in the Object Organizer. The input and output parameters which are required by the event will automatically be defined in the declaration part of the POU. Below the assignment table the currently selected event is displayed in a picture, showing the required parameters. If you actually want the POU to be called by the event, activate the entry in the assignment table ( ). Activating/deactivating is done by a mouseclick on the control box. Which task is being processed? For the execution, the following rules apply: •
That task is executed, whose condition has been met; i.e., if its specified time has expired, or after its condition (event) variable exhibits a rising edge.
•
If several tasks have a valid requirement, then the task with the highest priority will be executed.
•
If several tasks have valid conditions and equivalent priorities, then the task that has had the longest waiting time will be executed first.
•
The processing of the program calls will be done according to their order (top down) in the task editor.
Taskconfiguration in Online Mode In online mode the status and number of passed through cycles of each task will be displayed in the configuration tree. The time flow is monitored in a diagram. Precondition: the libraries SysTaskInfo.lib and SysTime.lib must be included in the project to provide functions for the internal evaluation of the
6-38
CoDeSys V2.3
6 - The Resources
task times. The libraries will be included automatically as soon as a target is set which supports the task monitoring. Display of task status in the configuration tree: In online mode the current status of a task will be displayed in brackets at the end of the task entry line in the configuration tree, also the number of already passed through process cycles. This update interval is the same as usual for the monitoring of PLC values. The possible stati: Idle
has not been started since last update; especially used for event tasks
Running
has been started at least once since last update
Stop
stopped
Stop on BP
stopped, because breakpoint in task is reached
Stop on Error
Error, e.g. division by zero, page fault etc.
Stop Watchdog
cycle time has been exceeded
The task entry will be displayed red coloured in case of status 'Stop on Error' or 'Stop Watchdog' .
Display of the time flow of the tasks If the entry 'Taskconfiguration' is selected in the configuration tree, the utilization of the tasks will be displayed in bar charts in the right part of the window: Display of the Task Execution in Online Mode
For each task a bar chart is displayed. The length of the bar represents the length of a cycle period. Below the bar as well as by appropriate marks on the bar the following measurement values are illustrated: Min:
minimum measured runtime in µs
Akt:
last measured runtime in µs
Max:
maximum measured runtime in µs
Cycle:
total length of a cycle in µs
Jitter:
maximum measured jitter in µs
The button Reset can be used to set back the values of Min., Max. and Jitter to 0.
CoDeSys V2.3
6-39
Watch and Receipt Manager..
The scaling of the chart (microseconds per Pixel) can be adjusted by the aid of a selection list at Scaling [µs/Pixel].
Additional online functions in the context menu resp. in the 'Extras' menu: Task Configuration'Extras' 'Set Debug Task' For targets with preemptive multitasking this command is available to define a debugging task in Online mode in the Task Configuration. The text [DEBUG] will appear after the set task. The debugging capabilities then will apply only to this task. In other words, the program only stops at a breakpoint if the program is gone through by the set task. Task Configuration t'Extras' 'Enable / disable task' With this command the task which is currently marked in the task configuration can be disabled or reenabled. A disabled task will not be regarded during processing of the program. In the configuration tree it will be indicated by a greyed entry. 'Extras' 'Callstack' If the program is stopped at a breakpoint during debugging, then this command can be used to show the callstack of the corresponding POU. For this purpose the debug task must be selected in the task configuration tree of. The window 'Callstack of task ' will open. There you get the name of the POU and the breakpoint position (e.g. 'prog_x (2)' for line 2 of POU prog_x) . Below the complete call stack is shown in backward order. If you press button 'Go To', the focus will jump to that position in the POU which is currently marked in the callstack.
6.8
Watch and Receipt Manager.. With the help of the Watch and Receipt Manager you can view the values of selected variables. The Watch and Receipt Manager also makes it possible to preset the variables with definite values and transfer them as a group to the PLC ('Write Receipt'). In the same way, current PLC values can be read into and stored in the Watch and Receipt Manager ('Read Receipt'). These functions are helpful, for example, for setting and entering of control parameters. All watch lists created ('Insert' 'New Watch List') are indicated in the left column of the Watch and Receipt Manager. These lists can be selected with a mouse click or an arrow key. In the right area of the Watch and Receipt Manager the variables applicable at any given time are indicated. In order to work with the Watch and Receipt Manager, open the object for the Manager in the Resources register card in the Object Organizer.
Watch and Receipt
Watch and Receipt Manager in the Offline Mode In Offline Mode, you can create several watch lists in the Watch and Receipt Manager using the 'Insert' 'New Watch List'. For inputting the variables to be watched, you can call up a list of all variables with the Input Assistant, or you can enter the variables with the keyboard, according to the following notation: . With global variables, the POU Name is left out. You begin with a point. The variable name can, once again, contain multiple levels. Addresses can be entered directly. Example of a multiple-level variable: PLC_PRG.Instance1.Instance2.Structure.Componentname Example of a global variable: .global1.component1
6-40
CoDeSys V2.3
6 - The Resources
Watch and Receipt Manager in the Offline Mode
The variables in the watch list can be preset with constant values. That means that in Online mode you can use the 'Extras' 'Write Receipt' command to write these values into the variables. To do to do must use := to assign the constant value of the variable: Example: PLC_PRG.TIMER:=50 In the example, the PLC_PRG.COUNTER variable is preset with the value 6 'Insert' 'New Watch List' With this command in offline mode a new watch list can be inserted into the Watch and Receipt Manager. Enter the desired name for the watch list in the dialog box that appears. 'Extras' 'Rename Watch List' With this command you can change the name of a watch list in the Watch and Receipt Manager. In the dialog box that appears, enter the new name of the watch list. 'Extras' 'Save Watch List' With this command you can save a watch list. The dialog box for saving a file is opened. The file name is preset with the name of the watch list and is given the extension '*.wtc'. The saved watch list can be loaded again with 'Extras' 'Load Watch List'. 'Extras' 'Load Watch List' With this command you can reload a saved watch list. The dialog box is opened for opening a file. Select the desired file with the '*.wtc' extension. In the dialog box that appears, you can give the watch list a new name. The file name is preset without an extension. With 'Extras' 'Save Watch List', you can save a watch list. Watch and Receipt Manager in the Online Mode In Online mode, the values of the entered variables are indicated. Structured values (arrays, structures, or instances of function blocks) are marked by a plus sign in front of the identifier. By clicking the plus sign with the mouse or by pressing , the variable is opened up or closed.If a function block variable is marked in the watch list, the associated context menu is expanded to include the two menu items 'Zoom' and 'Open instance'. In order to input new variables, you can turn off the display by using the 'Extras' 'Active Monitoring' command. After the variables have been entered, you can use the same command again to activate the display of the values.
CoDeSys V2.3
6-41
Watch and Receipt Manager..
Watch and Receipt Manager in the Online Mode
In the Offline Mode you can preset variables with constant values (through inputting := after the variable). In the Online Mode, these values can now be written into the variables, using the 'Extras' 'Write Receipt' command. With the 'Extras' 'Read Receipt' command you can replace the presetting of the variable with the present value of the variable. Note:
Only those values the watch list are loaded which was selected in the Watch and Receipt Manager!
'Extra' 'Monitoring Active' With this command at the Watch and Receipt Manager in the Online mode the display is turned on or off. If the display is active, a check (ü) will appear in front of the menu item. In order to enter new variables or to preset a value (see Offline Mode), the display must be turned off through the command. After the variables have been entered, you can use the same command again to activate the display of the values. 'Extras' 'Write Receipt' With this command in the Online Mode of the Watch and Receipt Manager you can write the preset values (see Offline Mode) into the variables. Note:
Only those values of the watch list are loaded which was selected in the Watch and Receipt Manager!
'Extras' 'Read Receipt' With the command, in the Online Mode of the Watch and Receipt Manager, you can replace the presetting of the variables (see Offline Mode) with the present value of the variables. Example: PLC_PRG.Counter [:= ] = Note:
Only the values of that watch list are loaded which was selected in the Watch and Receipt Manager!
Force values In the Watch and Receipt Manager you can also 'Force values' and 'Write values'. If you click on the respective variable value, then a dialog box opens, in which you can enter the new value of the variable. Changed variables appear in red in the Watch and Receipt Manager.
6-42
CoDeSys V2.3
6 - The Resources
6.9
Sampling Trace
6.9.1
Create a Sampling Trace Sampling Trace will be available as an object in the CoDeSys resources, if it is activated in the target settings (category 'General').It can be used to trace the progression of values for variables is traced over a certain time. These values are written in a ring buffer (trace buffer). If the memory is full, then the 'oldest' values from the start of the memory will be overwritten. As a maximum, 20 variables can be traced at the same time. A maximum of 500 values can be traced per variable. Since the size of the trace buffer in the PLC has a fixed value, in the event of very many or very wide variables (DWORD), fewer than 500 values can be traced. Example: if 10 WORD variables are traced and if the memory in the PLC is 5000 bytes long, then, for every variable, 250 values can be traced. In order to be able to perform a trace, open the object for a Sampling Trace in the Resources register card in the Object Organizer. Create resp. load an appropriate trace configuration and define the variables to be traced. (See 'Extras' 'Trace Configuration' and 'Selection of the Variables to be Displayed'). After you have created the configuration and have started the trace in the PLC ('Start Trace'), then the values of the variables will be traced. With 'Read Trace', the final traced values will be read out and displayed graphically as curves. A Trace (variable values and configuration) can be saved and reloaded in project format (*.trc) or in XML format (*.mon). Just the configuration can be stored and reloaded via a *.tcf-file. Various traces can be available in a project for getting displayed. They are listed in a selection list ('Trace') in the upper right corner of the trace window. You can select one of those to be the currently used trace configuration. Please regard: If a task configuration is used for controlling the program, the trace functionality refers to the debug task.
'Extras' 'Trace Configuration' With this command you will be given the dialog box for entering the variables to be traced, as well as diverse trace parameters for the Sampling Trace. The dialog can also be opened by a double click in the grey area of the dialog Sampling Trace. First define a name for the trace configuration (Trace Name). This name will be added to the selection list 'Trace' in the upper right corner of the Trace window, as soon as you have confirmed and closed the configuration dialog with OK. Optionally enter a comment. The list of the Variables to be traced is initially empty. In order to append a variable the variable must be entered in the field under the list. Following this, you can use the Add button or the to append the variable to the list. You can also use the Input Assistant. The use of enumeration variables is possible. A variable is deleted from the list when you select the variable and then press the Delete button.
CoDeSys V2.3
6-43
Sampling Trace
Dialog Box for Trace Configuration
A Boolean or analogue variable can be entered into the field Trigger Variable. The input assistance can also be used here. The trigger variable describes the termination condition of the trace. In Trigger Level you enter the level of an analogue trigger variable at which the trigger event occurs. When Trigger edge positive is selected the trigger event occurs after an ascending edge of the Boolean trigger variable or when an analogue variable has passed through the trigger level from below to above. Negative causes triggering after a descending edge or when an analogue variable went from above to below. Both causes triggering for both descending and ascending edges or by a positive or negative pass, whereas none does not initiate a triggering event at all. Trigger Position is used to set the percentage of the measured value which will be recorded before the trigger event occurs. If, for example, you enter 25 here then 25 % of the measured values are shown before the triggering event and 75% afterwards and then the trace is terminated. The field Sample Rate is used set the time period between two recordings in milliseconds. The default value '0' means one scanning procedure per cycle. Select the mode for recalling the recorded values: With Single the Number of the defined samples are displayed one time. With Continuous the reading of the recording of the defined number of measured values is initiated anew each time. If, for example, you enter the number '35' the first display contains the first measured values 1 to 35 and the recording of the next 35 measured values (36-70) will then be automatically read, etc. Manual selection is used to read the trace recordings specifically with 'Extras' 'Read trace'.
6-44
CoDeSys V2.3
6 - The Resources
The recall mode functions independently of whether a trigger variable is set or not. If no trigger variable is set the trace buffer will be filled with the defined number of measured values and the buffer contents will be read and displayed on recall. The button Save is used to store the trace configuration which has been created in a file. The standard window 'File save as' is opened for this purpose. Stored trace configurations can be retrieved using the button Load. The standard window 'File open' is opened for this purpose. Note: Please note that Save and Load in the configuration dialog only relates to the configuration, not to the values of a trace recording (in contrast to the menu commands 'Extras' 'Save trace' and 'Extras' 'Load trace').
If the field Trigger Variable is empty, the trace recording will run endlessly and can be stopped by 'Extras' 'Stop Trace'. Selection of the Variables to be Displayed The comboboxes to the right, next to the window for displaying curves trace variables defined in the trace configuration. If a variable is selected from the list, then after the trace buffer has been read the variable will be displayed in the corresponding color (Var 0 green, etc.). Variables can also be selected if curves are already displayed. A maximum of up to eight variables can be observed simultaneously in the trace window. 'Extra' 'Start Trace' Symbol: With this command the trace configuration is transferred to the PLC and the trace sampling is started in the PLC. 'Extra' 'Read Trace' Symbol: With this command the present trace buffer is read from the PLC, and the values of the selected variables are displayed. 'Extra' 'Auto Read' With this command the present trace buffer is read automatically from the PLC, and the values are continuously displayed. If the trace buffer is automatically read, then a check (ü) is located before the menu item. 'Extra' 'Stop Trace' Symbol: This command stops the Sampling Trace in the PLC.
CoDeSys V2.3
6-45
Sampling Trace
Display of the Sampling Trace Sampling Trace of Differ ent Variables
If a trace buffer is loaded, then the values of all variables to be displayed will be read out and displayed. If no scan frequency has been set, then the X axis will be inscribed with the continuous number of the traced value. The status indicator of the trace window (first line) indicates whether the trace buffer is full and when the trace is completed. If a value for the scan frequency was specified, then the x axis will specify the time of the traced value. The time is assigned to the 'oldest' traced value. In the example, e.g., the values for the last 25 seconds are indicated. The Y axis is inscribed with values in the appropriate data type. The scaling is laid out in a way that allows the lowest and the highest value to fit in the viewing area. In the example, Var 0 has taken on the lowest value of 6, and the highest value of 100: hence the setting of the scale at the left edge. If the trigger requirement is met, then a vertical dotted line is displayed at the interface between the values before and after the appearance of the trigger requirement. A memory that has been read will be preserved until you change the project or leave the system. 'Extras' 'Cursor Mode' The easiest way to set a cursor in the monitoring area is to click there with the left mouse button. A cursor appears and can be moved by the mouse. At the top of the monitoring window the current xposition of the cursor is displayed. In the fields next to 'Var 0', 'Var 1', .., 'Var n' the value of the respective variable is shown. Another way is the command 'Extras' 'Cursor mode'. With this command two vertical lines will appear in the Sampling Trace. First they are laying one on the other. One of the lines can be moved to the right or to the left by the arrow keys. By pressing + or + the speed of the movement can be increased by factor 10. If additionally the key is pressed, the second line can be moved, showing the difference to the first one. 'Extras' 'Multi Channel' With this command you can alternate between single-channel and multi-channel display of the Sampling Trace. In the event of a multi-channel display, there is a check (ü) in front of the menu item. The multi-channel display has been preset. Here the display window is divided into as many as eight display curves. For each curve the maximum and the minimum value are displayed at the edge. In a single-channel display, all curves are displayed with the same scaling factor and are superimposed. This can be useful when displaying curve abnormalities.
6-46
CoDeSys V2.3
6 - The Resources
'Extras' 'Show grid' With this command you can switch on and off the grid in the graphic window. When the grid is switched on, a check (ü) will appear next to the menu item. 'Extras' 'Y Scaling' With this command you can change the preset Y scaling of a curve in the trace display. By doubleclicking on a curve you will also be given the dialog box 'Y-scaling'. As long as option Automatic is activated, the default scaling will be used, which depends on the type of the used variable. In case of enumeration variables the enumeration values will be displayed at the scale. In order to change the scaling, deactivate option 'Automatic' and enter the number of the respective curve (Channel) and the new maximum (maximum y scale) and the new minimum value (minimum y scale) on the y axis. The channel and the former value are preset. Dialog Box for Setting the Y Scale
'Extras' 'Stretch' Symbol: With this command you can stretch (zoom) the values of the Sampling Trace that are shown. The beginning position is set with the horizontal picture adjustment bar. With repeated stretches that follow one-after-another, the trace section displayed in the window will increasingly shrink in size. This command is the counterpart to 'Extras' 'Compress'. 'Extras' 'Compress' Symbol: With this command the values shown for the Sampling Trace are compressed; i.e., after this command you can view the progression of the trace variables within a larger time frame. A multiple execution of the command is possible. This command is the counterpart to 'Extras' 'Stretch'.
6.9.2
'Extras' 'Save trace values' Use the commands of this menu to save traces (configuration + values) to files resp. to reload them from files to the project. Besids that a trace can be saved in a file in ASCII-format. Note: Regard the alternative way of storing and reloading traces by using the commands of menu 'Extras' 'External Trace Configurations ' (XML format, *.mon-Datei) !
'Save Values' With this command you can save a Sampling Trace (values + configuration data). The dialog box for saving a file is opened. The file name receives the extension '*.trc'.
CoDeSys V2.3
6-47
Sampling Trace
Be aware, that here you save the traced values as well as the trace configuration, whereas Save trace in the configuration dialog only concerns the configuration data. The saved Sampling Trace can be loaded again with 'Extras' 'Load Trace'. 'Load Values' With this command a saved Sampling Trace (traced values + configuration data) can be reloaded. The dialog box for opening a file is opened. Select the desired file with the '*.trc' extension. With 'Extras' 'Save Values' you can save a Sampling Trace. 'Trace in ASCII-File' With this command you can save a Sampling Trace in an ASCII-file. The dialog box for saving a file is opened. The file name receives the extension '*.txt'. The values are deposited in the file according to the following scheme: CODESYS Trace D:CODESYSPROJECTS TRAFFICSIGNAL.PRO Cycle PLC_PRG.COUNTER PLC_PRG.LIGHT1 021 121 221 ... If no frequency scan was set in the trace configuration, then the cycle is located in the first column; that means one value per cycle has been recorded at any given time. In the other respects, the entry here is for the point in time in ms at which the values of the variables have been saved since the Sampling Trace has been run. In the subsequent columns, the corresponding values of the trace variables are saved. At any given time the values are separated from one another by a blank space. The appertaining variable names are displayed next to one another in the third line, according to the sequence (PLC_PRG.COUNTER, PLC_PRG.LIGHT1).
6.9.3
'Extras' 'External Trace Configurations' Use the commands of this menu to save or reload traces (configuration + trace values) in files resp. from files, to load a trace from the controller to the project or to set a certain trace as that which should be used in the project. Note: Regard the alternative way of storing and reloading traces by using the commands of menu 'Extras' 'Save Trace' (Projektformat, *.trc-Datei, ASCII) !
'Save to file' With this command a trace (configuration + values) can be saved in a file in XML format. For this purpose the standard dialog for saving a file opens. Automatically the file extension *.mon will be used. A *.mon-file can be reloaded to a project with command 'Load from file'. 'Load from file' With this command a trace (configuration + values), which is available in a file in XML format (*.mon, can be loaded into the project. The dialog for opening a file will open and you can browse for files with extension *.mon. The loaded trace will be displayed and added to the selection list in field 'Trace in the configuration dialog. If you want to set it as currently used project trace configuration, use command 'Set as project configuration'.
6-48
CoDeSys V2.3
6 - The Resources
A *.mon-file can be created by using command 'Save to file'. Note: Regard the alternative way of saving a trace by using the commands of menu values '.
'Extras' 'Save trace
'Load from controller' With this command the trace (configuration + values) which is currently used on the controller can be loaded to the CoDeSys project. It will be displayed in the trace window and can be set as active project trace configuration. 'Set as project configuration' With this command the trace configuration which is currently selected in the list of available traces (field 'Trace' in the trace window) can be set as active configuration within the project. The selection list besides the currently used (top position) offers all traces which have been loaded to the project by command 'Load from file' from *.mon-files (e.g. for the purpose of viewing).
6.10
Target Settings The 'Target Settings' is an object of the 'Resources'. Here you define, which target shall be used for the project and how it will be configured. If a new project is started with 'Project' 'New', a dialog will open where the target, that means a predefined configuration for a target, has to be set. The list of available targets depends on which Target Support Packages (TSP) are installed on the computer. These describe platform specific basic configurations and also define, to which extent the configuration can be modified by the user in the CoDeSys Target settings dialogs. Please regard: If no TSP is available, only the setting 'None' will be offered in the target system selection box. This will switch to simulation mode automatically and no configuration settings will be possible.
Target-Support-Package A Target Support Package (TSP) must be installed before starting by the aid of the installation program InstallTarget which might be part of the CoDeSys-Setup. A Target Support Package (TSP) contains all the files and configuration information necessary to control a standard platform with a program created in CoDeSys. What has to be configured: codegenerator, memory layout, PLC functionality, I/O modules. In addition libraries, gateway drivers, ini-files for error messaging and PLC browser have to be linked. The central component of a TSP is one or more Target files. A Target file directs to the files which are in addition necessary to configure the target. It is possible that several target files share these additional files. The default extension for a Target file is *.trg, the format is binary. Additive definitions are attached to the entries in the target file which determine whether the user can see and edit the settings in the CoDeSys dialogs. During installation of a TSP the target file for each target is put to a separate directory and the path is registered. The associated files are copied to the computer according to the information of a Info file *.tnf . The name of the target directory is the same as the targets name. It is recommended to store the target specific files in a directory which is named with the manufacturers name. The files which get installed with a TSP are read when CoDeSys is started. The target settings which are done in the CoDeSys dialogs will be saved with the project. Please Note: If you use a new target file or if you have changed the existing one, CoDeSys has to be restarted to read the updated version.
CoDeSys V2.3
6-49
Parameter Manager
6.10.1
Dialog Target Settings The dialog Target Settings will open automatically, when a new project is created. It also can be opened by selecting the menu item 'Target Settings' in the register 'Resources' in the Object Organizer. Choose one of the target configurations offered at Configuration. If no Target Support Package has been installed, only 'None' can be selected, which means working in simulation mode. If you choose one of the installed configurations it depends on the entries in the target files, which possibilities are left to customize this configuration in the CoDeSys dialogs. If you choose a target configuration, for which there exists no valid licence on the computer, CoDeSys asks you to choose another target. If a configuration is selected, which is provided with the entry 'HideSettings' in the corresponding target file, you only can see the name of the configuration. Otherwise there are five dialogs available to modify the given configuration: 1. Target Platform 2. Memory Layout 3. General 4. Networkfunctionality 5. Visualization Attention !: Please be aware, that each modification of the predefined target configuration can cause severe changes in performance and behaviour of the target !
Press if you want to reset the target settings to the standard configuration given by the target file.
6.11
Parameter Manager TheParameter Manager is a a target specific component component of the CoDeSys programming system and must be activated in the target settings. (siehe Kap. ???). The Parameter Manager can be used to make variables of a CoDeSys IEC-program, constant parameters or specific system parameters accessible to all CoDeSys compatible systems in a network for the purpose of data exchange, typically via fieldbus. For this purpose in the editor you can create parameter lists and load down to and up from the runtime system. What are Parameters ?: In this context parameters are: •
process variables of the CoDeSys IEC project
•
process independent parameters
•
specific system parameters, predefined by the target system
•
functionblock instances or structure variables, arrays
Each parameter is identified by a certain set of attributes like e.g.'default value', 'access rights', and especially by an unique access key ('Index', 'SubIndex', 'Name'), which can be addressed for reading or writing data from/to the parameter list. This data exchange can be done via communication services and it is not necessary to know any addresses of variables or to provide any extra functions. So the use of the Parameter Manager functionality it is an alternative to using Network Variables. What are Parameter Lists?: Parameter lists are used for organizing the parameters and can be saved with the project and loaded to the local target system which is controlled by the corresponding IEC-program. For each type of parameters there is a corresponding type of parameter list.
6-50
CoDeSys V2.3
6 - The Resources
Each parameter entry is represented by a line in the parameter list. Each column of the list is representing one of the parameter attributes. In addition to a certain set of standard attributes also manufacturer specific attributes might be used for the description of a parameter in the Parameter Manager. It depends on the definitions in a target specific description file which attributes (columns) will be visible and editable in the Parameter Manager and in which way they will be arranged in a parameter list. If the description file is missing, the complete standard set of attributes will be displayed, each showing the default value. Besides lists for project variables and project constants the Parameter Manager also can handle lists for system parameters. Those are parameters which are fixly defined by the target system. Furtheron you can create lists for functionblock instances or structure variables which base on user-defined templates also created in the Parameter Manager. Due to the fact that the data are stored independently of the IEC-program, a parameter list for example can be used for saving 'recipes', which are preserved even if the program is replaced by another version. Furtheron a running PLC can be 'feeded' with different recipes without the need of a re-download the program. Application example: Two or more parameter lists can be generated which have identical indexing, the objects of which, however, have different values. As required, the desired set of values can be loaded into the controller by loading the corresponding list. This way it is not necessary to 'touch' the control program itself. Note: It is depending on the target system, whether the parameter manager will be regarded at the creation of a boot project.
6.11.1
Activating the Parameter Manager In the Resources tab in CoDeSys open the Target Settings, category Networkfunctionality:
Activate option Support parameter manager and insert the desired Index- and Subindex ranges, which should be valid for the entries in the parameter lists of type 'Parameter' (constants) and 'Variables' (project variables).
CoDeSys V2.3
6-51
Parameter Manager
6.11.2
Der Parameter Manager Editor..
Overview In the Resources tab choose the object 'Parameter-Manager'. An editor window will open, where you can create, edit and store parameter lists and in online mode also can load them to the target system and monitor the current parameter values. Note:
In order to have available the Parameter Manager functionality in a CoDeSys project, the option ' Support Parameter Manager' in the Target Settings must be activated and appropriate index ranges must be defined there !
Parameter Manager Editor in CoDeSys
The editor window is bipartited. The left part is used for navigation, it shows a list of all parameter lists currently loaded to the Parameter Manager. The right part cont ains a table editor, the columns titled with the names of the attributes. In the navigation window you insert, delete, rearrange or rename parameter lists of different types (Variables, Constant Parameters, Template, Instance, System Parameters). In the table editor you fill the lists with parameter entries. Each list type will show a special selection of attribute columns which can be edited or just are visible. Either this is defined by a target specific description file or the default settings will be taken. In online mode you can load the lists, you have created before, to the currently connected target system. You also can use the Parameter Manager functions to access them there for the purpose of data exchange with other systems (write values, upload). Furtheron in the Parameter Manager window you can monitor the current values of the parameters. If currently no online connection is established, the parameter lists just can be created locally and saved with the project.
6.11.3
Parameter List Types and Attributes The Parameter Manager can handle the following parameter list types: Variables: The entries in parameter lists of this type represent processing variables of the project. Parameters: The entries in parameter lists of this type represent parameters whose values are not attached by the process. System Parameters: The entries in parameter lists of this type represent special constant parameters which are not attached by the process and which are determined by the target system. System Parameter lists cannot be deleted or renamed. Template: A template does not contain parameter entries which can be directly accessed for the purpose of data exchange. In fact the entries provide a 'basic attribute configuration' for the components of a functionblock or a structure. Thus a template can be used in parameters lists of type 'Instance'.
6-52
CoDeSys V2.3
6 - The Resources
Instance: The entries in parameter lists of this type represent parameter entries for variables which are of type of the a functionblock or structure, that means which are instances or structure variables. For an easy entering of the parameters a template can be used, which has also been created in the Parameter Manager before. Each list type will be displayed in the Parameter Manager Editor according to the attributes defined by a description file in XML format. If such a file is missing, default settings will be used. Instances and Templates An Instance' parameter list .. .. handles parameter entries, which represent a functionblock, a structure variable or an array. Instance lists for a functionblock or a structure are each based on a template which is also to be defined in the Parameter Manager for the respective functionblock resp. structure. Instance lists for arrays cannot use a template made in the Parameter Manager, but directly refer to the array which is used in the project. A 'Template' parameter list .. .. does not contain parameters which are directly accessed for the purpose of data exchange. In fact it defines index and subindex offsets and certain attributes for parameter entries which represent the components of a functionblock or a structure. The template then can be used in a 'Instance' parameter list (see above), thus providing an easy way to create parameter entries for project variables which are instances of a functionblock or a structure. Creating a Template parameter list: In the edit field next to Base POU enter the name of the functionblock or structure for which a parameter template should be created. Using the input assistant you can browse the available POUs of the project. Press Apply to enter the components of the chosen POU in the parameter list editor. Now edit the attribute fields and close the list to make it available for use in an 'Instance' list. The command Insert missing entries in the context menu or in the 'Extras' menu will cause an update of the entries according to the current version of the Base POU. This might be necessary after having deleted some lines or after having changed the Base-POU. Creating an Instance parameter list: Edit a Template from the selction list below the table. This list offers all templates currently available for functionblocks or structures in the Parameter Manager plus the option ARRAY, which you select, if you want to refer directly to an array used in your project. Press Apply to insert the predefined components to the parameter list table. In the edit field Base variable enter exactly that project variable (must be of type of the functionblock or the structure or the array which is described by the chosen template), for the components of which you want to create parameter entries. Enter a Base index and Base subindex for the instance. The indices and subindices of the particular components then will be calculated automatically by adding the index resp. subindex values which are defined in the template for each component. They will be filled automatically to the res pective attribute fields. The command Insert missing entries in the context menu or in the 'Extras' menu will cause an update of the entries according to the current version of the used template. That might be useful after having deleted entries or after the template has been modified.
Example: Create a functionblock fubo with input- or output variables: a,b,c. In PLC_PRG define the following FBinstances: inst1_fubo:fubo; inst2_fubo:fubo. Now open the Parameter Manager in order to create parameter lists for the variables inst1_fubo.a, inst1_fubo.b, inst1_fubo.c and inst2_fubo.a, inst2_fubo.b, inst2_fubo. Insert a parameter list which is of type 'Template' and name it 'fubo_template'. Define the Base-POU: 'fubo'. Press Apply and define some attributes for the components a,b,c: te. Inter alia enter the Index offsets: for a: 16#1, for b: 16#2, for c: 16#3. Also the SubIndex offsets, e.g. a: 16#2, b: 16#3, c: 16#4.
CoDeSys V2.3
6-53
Parameter Manager
Now close the template and insert a parameter list which is of type 'Instance'. Choose template 'fubo_template'. Insert the Base variable 'inst1_fubo'. Define a Base index of e.g. 16#2300 and a Base subindex of 30 (you must regard the ranges defined in the target settings in tab Networkfunctionality !). Now press Apply to get displayed the indices which are calculated for the componentes a, b, c by the addition of base offsets and template defined offsets: Indices: 16#2301, 16#2302, 16#2303; SubIndices:16#23, 16#33, 16#43.
6.11.4
Editing parameter lists
Insert list Shortcut: Ins To insert a new parameter list in the Parameter Manage use the command 'Insert list..', resp. 'Insert new list' in the 'Insert' or context menu. The commands are available when the focus is in the empty navigation window resp. on an already existing entry in the navigation tree. The dialog 'Insert list' opens: Dialog 'Insert list'
Insert a Name for the new parameter list (must be unique within the list type) and choose one of the following list types: Variables
Entries for process variables
Parameters
Entries for constant parameters, whose values remain unattached by the process
Template
Template of attribut setting for the components of a functionblock or a structure
Instance
Entries for variables of type of a functionbolck or a structure, basing on the corresponding template (see above)
System parameters
Entries for parameters whose values are not attached by the process and which are defined by the target system
After confirming the settings and closing the dialog with OK the new parameter list will appear as an entry in the navigation window, the list type beeing indicated by the icon. In the table editor the appropriate attributes will be displayed as column titles. Selection and order of the columns are
6-54
CoDeSys V2.3
6 - The Resources
defined by a target specific description file, otherwise the default settings are used. Now you can edit the table, by entering a line for each desired parameter (see chapter 6.11.4, Editing parameter lists). Rename List The parameter list, which is currently marked in the navigation window, can be renamed by using the command 'Rename list' which is available in the 'Extras' menu or in the context menu. An edit field will open, which you also get when doing a double-click with the mouse on the list name. Cut / Copy /Paste list Shortcut: + , + , + , The command 'Cut' (Edit menu) resp. 'Cut list' (context menu) moves the currently marked list from the navigation window to a temporary buffer, so that you can reinsert it by the 'Paste' command at any other position in the navigation tree. Before re-inserting mark that list, above which you want to insert. The command 'Copy' resp. 'Copy list' also uses the temporary buffer, but the original navigation tree entry will be kept, and a copy will be added by 'Paste'. Delete list Shortcut:
Which columns (attributes) are displayed: The currently marked parameter list (navigation window) will be displayed in the table window as defined by a target specifc description file resp. according to the default settings. This means that the attributes' values of each particular parameter will be displayed in a separate line according to the list-type-specific order and selection of columns. You can fade out and fade in columns by deactivating/activating them in the context menu when the cursor is pointing to any field of the list column title bar. For modifying the column move the dividers between the column title fields or use one of the commands available in the context menu when the cursor is placed on a column title field: Command Standard column width will set a standard width for all columns which makes them all visible in the window. Maximize width will change the width of the currently focussed column so that each entry will be fully displayed. Commands for editing a parameter list entry: The following commands for editing a parameter list are available in the context menu resp. in the menus 'Insert' or 'Extras': Inserting /Deleting lines: Insert line resp. New line
A new entry (line) will be inserted before that one where the cursor is currently placed.
Line after resp. New line after Shortcut:
A new entry (line) will be inserted after that one where the cursor is currently placed. .
Delete line
The line, where the cursor is currently placed, will be deleted.
Cut, copy, paste line
These commands can be used to move (cut/paste) or to copy (copy/paste) the selected line.
Editing attribute values: If a new line for a parameter entry is inserted, the attribute fields will be automatically filled with default values. See chapter 6.11.3, 'Parameter List Types and Attributes' for the possible
CoDeSys V2.3
6-55
Parameter Manager
attributes. To enter or edit an attribute value, click on the corresponding field. An edit field will be opened, if the attribute is editable. The input assistant () will be available in fields where a component of the CoDeSys project should be entered. Press to close the entry. Using the arrow keys you can jump to another field. In order to toggle the input format between 'decimal' and hexadecimal' use the command F ' ormat Dec/Hex' in the 'Extras' menu. Options: Below the table in the editor window there can be activated the following options (availability depending on list type): Download with program: At a login the list will be downloaded automatically to the controller. Synchronous actions: currently without function The sequence of entries within a parameter list can be sorted concerning an attribute (column) in ascending or descending order of the attribute values. This works in offline and in online mode. Perform a mouse-click on the field which contains the column title of the desired attribute. Thus the table lines will be re-sorted and in the column title field of the attribute am arrow symbol will be displayed, showing the current sorting (pointing upwards = ascending sort sequence, pointing downwards = descending sort sequence).
6.11.5
Export / Import of parameter lists
'Extras' 'Export' The command 'Export' of the 'Extras' menu can be used to export the lists of the Parameter Manager to a XML-file. This file for example might be imported to another project by using the import function in the CoDeSys Parameter Manager. 'Extras' 'Import' The command 'Import' of the 'Extras' menu can be used to import a XML-file which describes parameter lists. This file for example might be created by using the export function in the CoDeSys Parameter Manager.
6.11.6
Parameter Manager in Online Mode
List transfer between Editor and Controlling Unit In online mode the parameter lists, which have been created in the editor, can be downloaded to resp. uploaded from the runtime system. Furtheron you can write single parameter values to the runtime system. Please regard: At login automatically a download of all parameter lists will be done for which the option 'Load with project' is activated ! The current value of each parameter is monitored in an additional column which is displayed in the parameter manager in online mode :
The following commands are available in the 'Extras' menu for handling the list transfer between editor and controller: Delete list
6-56
The list currently marked in the navigation window will be deleted from the
CoDeSys V2.3
6 - The Resources
PLC runtime system. Write list
This command will open the dialog 'Copy objects' where you can select from the available lists those you want to download to the runtime system. The download will be done as soon as you confirm with OK.
Read list
All lists of type 'Parameters' will be read from the runtime system and loaded into the Parameter Manager.
Write values
All values defined in column 'Value' will be written to the parameter list in the runtime system. To write single values, perform a double-click on the respective field in the column to get the dialog 'Write value', as known from the function 'Online' 'Write values'.
Write default The values defined in column 'Default' will be written to the parameter list in values the runtime system. Take values
over The current values will be read from the runtime system and be uploaded to column 'Value'.
The command Format Dec/Hex is also available to toggles the input format between 'decimal' and hexadecimal' .
6.12
PLC Browser The PLC-browser is a text-based control monitor (terminal). Commands for the request of specific information from the controller are entered in an entry line and sent as string to the controller. The returned response string is displayed in a result window of the browser. This functionality serves diagnostic- and debugging purposes. The commands available for the set target -system are made up of the CoDeSys standard set plus a possible extension set of the controller manufacturer. They are managed in an ini file and implemented accordingly in the runtime system.
6.12.1
General remarks concerning PLC Browser operation Select the entry PLC-Browser in the Resources tab-control. It will be available there if it is activated in the current target settings (category networkfunctionality). The CoDeSys PLC Browser window
The browser consists of a command entry line and a result/display window.
CoDeSys V2.3
6-57
PLC Browser
In a selection box the input line displays a list of all the commands entered since the start of the project (input history). They are available for re-selection until the project is closed. Only commands, which differ from those already existing, are added to the list. The entered command is sent to the controller with . If there is no Online connection, the command is displayed in the result window in the same way as it is sent to the controller, otherwise the response from the controller is shown there. If a new command is sent to the controller, the content of the result window is deleted. Commands can be entered in the form of command strings , the use of macros is possible as well:
6.12.2
Command entry in the PLC Browser Basically the PLC-Browser makes available the 3S standard commands hard-coded in the run-time system. It is concerned with functions for direct memory manipulation, for the output of project- and status functions as well as for run-time monitoring. They are described in the browser's ini-file, which is an integral part of the Target Support Package. These standard commands can be further supplemented by specialized ones, e.g. self-diagnostic functions or other status messages of the control application. The expansion of the command list must be carried out both in the customer interface in the run-time system as well as through additional entries in the Browser ini-file. When opening the project the command list available in the PLC-Browser is generated based on the entries in the Browser ini-file. It can be accessed as input help using the .. key in the dialog „Insert standard command' or using . Also the command 'Insert' 'Standard commands' can be used to get the command list. A command can be typed in manually to the command line or it can be selected from the list by a double-click on the appropriate entry. The general command syntax is: The keyword is the command. With which parameters it can be expanded is described in the respective tooltip in the entry help window. The command, which has been sent, is repeated in the output data window, the controller's response appears below it. Example: Request for the project Id from the controller with the command 'pid' Entry in command line:
pid... Output in result window:
pid Project-ID: 16#0025CFDA A help text can be supplied for each standard command with ?. This is similarly defined in the ini-file. The following commands are firmly integrated in the run-time system and contained in the ini-file with the corresponding entries for entry help, tooltips and help:
6-58
Command
Description
?
The run-time system supplies a list of the available commands
mem
Hexdump of a memory area
memc
Hexdump relative to the start address of the code in the controller
memd
Hexdump relative to the data base address in the controller
reflect
Reflect current command line, for test purposes
dpt
Read
filecopy
Copy file [from] [to]
filerename
Rename files [old] [new]
filedelete
Delete file [filename]
saveretain
Save retain variables
restoreretain
Load retain variables
setpwd
Set password on controller Syntax: setpwd [level] can be '0' (default) just valid concerning logins from the programming system, or '1' valid for all applications
delpwd
Delete password on controller
Note: The first word of the command sequence entered is interpreted as keyword. If a keyword is preceeded by a „?' (e.g. „mem ?'), the ini-file will be searched for the existence of a help section to this keyword. If one is available, nothing is sent to the controller, but only the help text is displayed in the output data window.
If the first word of the command entry () is not recognized by the controller, the response 'Keyword not found' will appear in the result window.
6.12.3
Use of macros during the command entry in PLC-Browser If a command associated with a macro is entered in the command line, this is expanded before it is sent to the controller. Then the response in the result window appears in a similarly expanded form. The entry syntax is: is the command. Macros are: %P
CoDeSys V2.3
If NAME is a POU-name, the expression is expanded to , otherwise there is no alteration
6-59
Tools
%V
If NAME is a variable name, the expression is expanded to #:, otherwise there is no alteration (this notation #: is interpreted by the controller as a memory address)
%T
If NAME is a variable name, the expression is expanded to , otherwise there is no alteration.
%S
If NAME is a variable name, the expression is expanded to , otherwise there is no alteration.
The % character is ignored if the escape symbol (Backslash) is placed in front. The escape symbol as such is only transmitted if written . Example: Entry in command line: (memory dump of the variable .testit ?)
mem %V.testit Output in result window:
mem #4:52 03BAAA24 00 00 00 00 CD CD CD CD ..ÍÍÍÍ
6.12.4
Further PLC Browser options In the 'Extras' menu or in the PLC-Browser's toolbar there are the following commands for handling the command entry or history list: With History forward and History backward you can scroll backwards and forwards through the query results already carried out. The history recording is continued until you leave the project. With Cancel command
you can break off a query which has been initiated.
With Save history list you can save the query results carried out up until that point in an external text file. The dialogue 'Save file as' will appear, in which you can enter a file name with the extension „.bhl' (Browser History List). The command Print last command opens the standard dialogue to print. The current query plus the output data in the message window can be printed.
6.13
Tools The object 'Tools' will be available in the 'Resources' tab if the functionality is enabled for the currently set target system. It shows all available shortcuts (connections) to executable files of external tools, which can be activated by a double-click in order to call these external programs from within CoDeSys. It is defined by the target file which and how many shortcuts are allowed. Depending on this definition the user can add or delete new shortcuts in the 'Tools' folder. For example the Tools folder in the Object Organizer might look like this:
6-60
CoDeSys V2.3
6 - The Resources
In this example four tools-shortcuts are installed. One serves for starting another CoDeSys programming sytem, one for opening the assembler listing in a text editor and two further shortcuts are available to open PDF-files. Shortcuts marked with a ' cannot be modified in CoDeSys. The shortcuts may contain the connection to an editor, e.g. notepad.exe, or to a certain PDF-file, so that a doubleclick on the entry would open a notepad window showing the assembler listing respectively would open the Acrobat Reader showing the PDF-file. Additionally you can define certain files which should be downloaded to the PLC as soon as the shortcut is activated. See also: • Properties of the available Tool shortcuts • Creating new Tool Shortcuts • Deleting Tool Shortcuts • Executing Tools Shortcuts • Saving Tool Shortcuts • Frequently asked questions concerning 'Tools'
6.13.1
Creating new Tool Shortcuts Select the entry 'Tools' or a shortcut entry in the Resources tree of the Object Organizer and select command 'Add Object' in the context menu or in the 'Project' 'Object' menu to open the dialog 'Create Shortcut': Dialog 'Create Shortcut'
CoDeSys V2.3
6-61
Tools
The table lists all tools for which new shortcuts (connections) can be created. According to the definitions in the target file the following parameters are displayed: ID of the tool, default Name of the shortcut and the Name of the executable file. In order to create a(nother) shortcut for one of the offered tools, select this tool by a mouse-click in the 'ID' column. Hereupon you can modify the default name of the shortcut in the edit field Name of the shortcut and confirm with OK. This will only work if you enter a name which is not yet used. OK closes the dialog and the new shortcut will be inserted in the Resources tree, represented by the shortcut name and a shortcut number which is 1 higher than the highest one used for a instance of this tool up to now. In the area below the name field appropriate hints concerning the user inputs will be displayed.
6.13.2
Properties of available Tool Shortcuts (Object Properties) By a mouse-click on the plus sign at entry 'Tools' in the Resources tab of the Organizer a list of the available shortcuts will open. If you are just starting to set up a new project, you will just see those which are defined in the target file as fix entries. But if the Tools folder already had been modified you might find another shortcuts, added by a user in CoDeSys. You can view the global tool properties (valid for all shortcuts listed in 'Tools') as well as the properties of single shortcuts. 1. Tool Properties: If 'Tools' is marked in the Resources tree, you will find the command 'Object Properties' in the context menu or in the menu 'Project' 'Object', which will open the dialog 'Tool Properties'. There you get a table listing all tool shortcuts which might be used for the currently set target. The following parameters are shown: The Id (unique identification number) of the tool, the Name of the shortcut which is used to reference the shortcut in the Object Organizer, and the Name of the executable file of the tool. The button A ' dvanced' expands the dialog resp. closes the extension of the dialog: Dialog 'Tool Properties'
The expanded dialog shows the global properties of the shortcut as defined in the target file. Furtheron an edit field is available where a (working) Directory can be defined which should be used for actions of the executable file. The path will be saved without closing the dialog as soon as you press the Apply button. Properties of the Tool: FixedCount
6-62
Number of shortcuts of the tool, which are inserted unalterably and automatically in the Tools folder. Only if '0' is entered here, the user will be able to create as many shortcuts as desired.
CoDeSys V2.3
6 - The Resources
Please regard: For shortcuts which are defined as 'fix' ones by the target file, the number of possible usage in the Tools folder is predetermined and the properties cannot be modified by the CoDeSys user (cognizable by a ' in the Object Organizer). Exe-Name:
File name or full path of the executable file of the tool. If there is no entry, the file extension of the file, which is given in 'Parameter Template', automatically will cause via Windows the start of the exe file of the according tool. Examples: 'C:programmenotapad.exe', '345.pdf'
DefaultDisplayName: Name which is used to represent the tools in the Object Organizer. Possibly the template $(INSTANCE NUMBER) is used (see below 'Parameter Template'). Parameter Template: Templates for determining the file which should be opened by the tool. The following templates can be used, connected by the appropriate special characters: $(PROJECT_NAME) Name of the currently opened project (File name without extension *.pro'). $(PROJECT_PATH) Path of the directory where the project file is (without indication of the drive). $(PROJECT_DRIVE) Drive where the currently opened project is. $(COMPILE_DIR) Compile directory of the project (including indication of the drive) $(TOOL_EXE_NAME) Name of the exe-file of the tool. $(DISPLAY_NAME) Name of the current shortcut, as used in the 'Tools' folder. $(INSTANCE_NUMBER) Number of the shortcut (Instance number, running number, starting with '1') $(CODESYS_EXE_DIR) Path of the directory where the Codesys exe-file is (including indication of the drive). The conversion of a template you will see in the dialog for the Shortcut Properties (see below) Example: '$(PROJECT_NAME)_$(INSTANCE_NUMBER).cfg' ⇒ The cfg-file with the name _.cfg will be opened in the tool. DownloadFile Templates:
Files, file pathes resp. templates for file which will be copied to the PLC during download. If option Editable is activated, the list of these files will be editable in the properties dialog of the shortcut. If a file name is entered without path, the file will be searched in the directory where the codesys-exe-file is. Example: 'a.up;$(PROJECT_NAME).zaw;$(INSTANCE_NUMBER).upp' ⇒ the files a.up, .pro and .upp will be copied to the PLC during the next download
2. Shortcut Properties: Mark a shortcut entry in the 'Tools' tree in the Object Organizer and select the command 'Object Properties' in the context menu or in the 'Project' 'Object' menu. The dialog 'Shortcut Properties' will open, containing the following items: Command
CoDeSys V2.3
Calling the tool; paths of the exe-file and of the file which is named in 'Parameter' (predefined by the 'Paramet er Template', see above) e.g.: C:programsnotepad.exe D:listingstextfile.txt
6-63
Tools
Parameter
Path of the file which should be called by the tool. This is defined in the target file and can be edited here, if the option 'Editable' (see below) has been activated.
Files to be Primarily you find here the Filenames which are defined by the target file and which downloaded are also described in the Tool Properties (DownloadFileTemplate, see above). If option 'Editable' is activated in the extended dialog (see below) then you can modify the list. For this purpose press button New to open the dialog 'Filename', where you can enter another file resp. a file path. If you enter a file without path, then it will be searched in that directory, where the codesys-exe-file is. Button Delete will remove the currently marked list entry. Button 'Standard' resets the entries of the dialog to the default values defined by the target file. Button 'Apply' saves the done settings without closing the properties dialog. Button 'Advanced' expands the dialog so that it will look as follows : Dialog 'Advanced Properties' of a shortcut
Shortcut Number:
Running number, starting with 1. New shortcuts of the current tool will each get the next higher number. If a shortcut will be removed later, the numbers of the remaining shortcuts will stay unchanged. The shortcut number can be inserted in other definitions by using the template $(INSTANCE_NUMBER) (e.g. see above, 'Parameter Template').
Tool ID:
Unique identification number of the tool; defined in the target file.
Default Number of Number of shortcuts (instances) for a tool. Corresponds to the 'FixedCount' Shortcuts: defined in the target file. See above, Tool Properties. Editable:
If this option is activated, it will be possible to edit the field 'Parameter' resp. the list of files which should be downloaded.
Button OK applies the done settings and closes the Properties dialog.
6-64
CoDeSys V2.3
6 - The Resources
6.13.3
Deleting connections There are a number of possibilities for removing the connection between the output of an element E1 and the input of an element E2: Select the output of element E1 and press the key or execute the command 'Edit' 'Delete'. Several connections will be removed at the same if the output of E1 is connected to more than one of inputs. Select the input of element E2 and press the key or execute the command 'Edit' 'Delete'. Select the input of E2 with the mouse, hold the left mousekey depressed and drag the connection from the input to E2 away. The connection is removed when the left mousekey is released in a free area of the screen.
6.13.4
Executing Tool Shortcuts A shortcut will be executed on a double-click on the entry in the Resources tree or by the command 'Open Object' in the 'Project' 'Object' menu resp. in the context menu (right mouse button). If the execution of the file, which is defined in the shortcut properties (Parameter), fails, then an appropriate error message will appear. If a parameter file will not be found, the exe-file of the tool will be executed and a dialog will open, asking you whether the file should be created. If the exe-file of the tool is not found in the defined path or if no path has been defined, then the standard dialog for selecting a file will be opened and the user will be asked to enter the path of the exe-file. This path will be saved when the dialog is closed by OK and thus will be available for the tool also in other CoDeSys projects.
6.13.5
Saving Tool Shortcuts When the CoDeSys project is saved, the status and settings of the 'Tools' folder in the Resources tree will also be saved. Please note: If you save a project by 'Save as' with a new name, then you must consider the following if you use the template $(PROJECT_NAME) in the definition of the parameter file and of the files which are to be downloaded: If you had added shortcuts for a tool (FixedCount=0) in the old project, then in the new project the file names have to be renamend manually corresponding to the new project name. In contrast for a tool which is defined with a fix number of shortcuts, the template always will be replaced automatically by the current project name !
6.13.6
Frequently asked questions on Tools Why do I get no entry 'Tools' in the 'Resources' ? Only if it is defined in the target file of the currently set target system, the 'Tools' functionality will be available. For which tools already shortcuts are available, which shortcuts can I add in the CoDeSys project ? Open the folder 'Tools' in the 'Resources' tree of the Object Organizer by a double-click on the plus sign. You will see which tools already are connected for the current project. If you have just set up a new project and not yet worked on the Tools list, then just those entries will be displayed, which are predefined unalterably by the definitions in the target file. Otherwise you might see an already project specifically modifed tools list. In order to check, whether the list is extendable by new entries, select the command 'Add Object'. You will get a dialog offering all tools for which additional shortcuts can be created. Which global properties do the available tools have ?
CoDeSys V2.3
6-65
Tools
Mark the entry 'Tools' in the Object Organizer and choose the command 'Object Properties' from the context menu (right mouse button). Expand the appearing dialog by pressing the 'Advanced' button. Now you will see a list of the available tools and the corresponding parameters. Select one of the tools by a mouseclick on the ID-Symbol in order to – for example - get displayed the allowed number of shortcuts for the tool in the field 'FixedCount', or to get displayed which files will be downloaded to the PLC if the shortcut is activated. The file names or paths might be shown in the form of templates, which will be interpreted for each single shortcut as described in the following paragraph: Which individual properties have the available shortcuts ? Mark one of the entries below 'Tools' in the Object Organizer and select the command 'Object Properties' in the context menu (right mouse button). Press button 'Advanced' to get the parameters of the chosen shortcut. Partially they will correspond to the above described global tool properties. If allowed by the definition in the target file you can edit these parameters here. How can I create a shortcut for a tool ? Mark the entry 'Tools' in the Object Organizer and choose the command 'Add Object' from the context menu (right mouse button). You will see a list of available tools, but only of those for which the maximum number of shortcuts (FixedCount) is not yet reached. Choose a tool and press OK. The tool will now be inserted in the Tools folder in the Object Organizer. If you want to insert it once more, then you must enter a different tool name first, which means to mark the new entry as another instance of the same tool. For example you could name the instances of the tool Toolxy 'Toolxy_1', 'Toolxy_2' etc. How can I modify the parameters of a tool ? In order to modify the parameters of a shortcut (instance of a tool connection), mark the shortcut in the Object Organizer and choose command 'Object Properties' from the context menu. It depends on the pre-definition of the tool in the target file, whether the parameters can be edited in the properties dialog. (See in the expanded dialog whether the option 'Editable' is activated. Button 'Standard' resets all edited values to the defaults. How can I execute a tool shortcut ? Perform a doubleclick on the shortcut entry in the Object Organizer or select the command 'Open Object' in the context menu resp. in the 'Project' menu when the entry is marked in the Object Organizer.
6-66
CoDeSys V2.3
7 - ENI
7
ENI
7.1.1
What is ENI The ENI ('Engineering Interface') allows to connect the CoDeSys programming system to an external data base . There the data which are needed during creation of an automation project can be stored. The usage of an external data base guarantees the consistency of the data, which then can be shared by several users, projects and programs. Also it extends the CoDeSys functionality by making possible the following items: •
Revision control for CoDeSys projects and associated resources (shared objects): If a object has been checked out from the data base, modified and checked in again, then in the data base a new version of the object will be created, but the older versions will be kept also and can be called again on demand. For each object and for a whole project the version history will be logged. Two versions can be checked for differences.
•
Multi-User Operation: The latest version of a sample of objects, e.g. of POUs of a project, can be made accessible for a group of users. Then the objects which are currently checked out by one of the users will be marked as 'in the works' and not editable by the other users. Thus several users can work in parallel on the same project without risking to overwrite versions mutually.
•
Access by external tools: Besides the CoDeSys programming system also other tools, which have an ENI too, can access the common data base. These might be e.g. external visualizations, ECAD systems etc., which need the data created in CoDeSys or which also produce data which are needed by other programs.
The ENI is composed of a client and a server part. So it is possible to hold the data base on a remote computer, which is required for multi-user operation. The CoDeSys programming system is a client of the independent ENI Server Process as well as another application, which needs access to the data base (Please see the separate documentation on the ENI Server). Currently the ENI supports the data base systems 'Visual SourceSafe 5.0', 'Visual SourceSafe 6.0', 'MKS Source Intergrity' and a local file system. Objects can be stored there in different 'folders' (data base categories with different access properties). The objects can be checked out for editing and thereby will get locked for other users. The latest version of an object can be called from the data base. Furtheron in parallel you can store any objects just locally in the project as usual for projects without source control.
7.1.2
Preconditions for Working with an ENI project data base Please regard: For a guide concerning installation and usage of the ENI Server provided by 3S – Smart Software Solutions GmbH please see the separate server documentation resp. online help. There you will also find a quickstart guide. Also consider the possibility of using the ENI Explorer which allows to perform data base actions independently from the currently used data base system.
If you want to use the ENI in the CoDeSys programming system in order to manage the project objects in an external data base, the following preconditions must be fulfilled: •
the communication between CoDeSys and the ENI Server requires TCP/IP, because the ENI Server uses the HTTP-Protokoll.
•
an ENI Server (ENI Server Suite) must be installed and started locally or on a remote computer. A license is required to run it with one of the standard database drivers which has been installed with the server. Just the driver for a local file system can be used with a non-licensed ENI Server version.
•
in the ENI Server service control tool (ENI Control) the connection to the desired data base must be configured correctly (Data base). You will automatically be asked to do this during installation, but you can modify the settings later in ENI Control.
CoDeSys V2.3
7-1
Tools
7.1.3
•
a project data base for which an ENI-supported driver is available, must be installed. It is reasonable to do this on the same computer, where the ENI Server is running. Alternatively a local file system can be used, for which a driver will also be provided by default.
•
in the data base administration possibly the user (Client) as well as the ENI Server must be registered as valid users with access rights. Anyway this is required for the 'Visual SourceSafe', if you use another data base system, please see the corresponding documentation for information on the user configuration.
•
for the current CoDeSys project the ENI interface must be activated (to be done in the CoDeSys dialog 'Project' 'Options' 'Project data base'). (It is possible to switch in a user definition in ENI, e.g. for the purpose of defining more detailled access rights as it is possible in the data base administration. But in general it is sufficient if the user who wants to log in to the data base via ENI, is registered in the data base.
•
for the current CoDeSys project the connection to the data base must be configured correctly; this is to be done in the CoDeSys dialogs 'Project' 'Options' 'Project source control.
•
in the current project the user must log in to the ENI Server with user name and password; this is to be done in the Login dialog, which can be opened explicitely by the command 'Project' 'Data Base Link' 'Login' resp. which will be opened automatically in case you try to access the data base without having logged in before.
Working with the ENI project data base in CoDeSys The data base commands (Get Latest Version,Check Out, Check In, Version History, Label Version etc.) which are used for managing the project objects in the ENI project data base, will be available in the current CoDeSys project as soon as the connection to the data base has been activated and configured correctly. See for this the Preconditions for Working with an ENI project data base . The commands then are disposable in the submenu 'Data Base Link' of the context menu or of the 'Project' menu and refer to the object which is currently marked in the Object Organizer. The current assignment of an object to a data base category is shown in the Object Properties and can be modified there. The properties of the data base categories (communication parameters, access rights, check in/check out behaviour) can be modified in the option dialogs of the project data base ('Project' 'Options' 'Project Source Control').
7.1.4
Object categories concerning the project data base There are four categories of objects of a CoDeSys project concerning the project source control: •
The ENI distinguishes three categories ('ENI object categories') of objects which are managed in the project data base: Project objects, Shared objects, Compile files.
•
The category 'Local', to which an object will be assigned if it should not be stored in the data base. That means that it will be handled as it is known for projects without any source control.
Thus in the programming system a CoDeSys object can be assigned to one of the categories 'Project objects', 'Shared objects' or 'Local'; the 'Compile files' do not yet exist as objects within the project. Assigning an object to one of the categories is done automatically when the object is created, because this is defined in the project options dialog 'Project source control', but it can be modified anytime in the 'Object Properties' dialog. Each ENI object category will be configured separately in the settings for the 'Project source control' which are part of the project options ('Project' 'Options'). That means that each category gets defined own parameters for the communication with the data base (directory, port, access right, user access data etc.) and concerning the behaviour at calling the latest version, checking out and checking in. These settings then will be valid for all objects belonging to the category. As a result you will have to log in to each data base category separately; this will be done via the 'Login' dialog.
7-2
CoDeSys V2.3
7 - ENI
It is advisable to create a separate folder for each object category in the data base, but it is also possible to store all objects in the same folder. (The 'category' is a property of an object, not of a folder.) See in the following the three ENI object categories: Project Objects:
Objects which contain project specific source information, e.g. POUs which are shared in a multi-user operation. The command 'Get all latest versions' automatically will call all objects of this category from the data base to the local project; even those, which have not been there so far.
Shared Objects:
Objects which are not project specific, e.g. POU libraries which normally are used in several projects. Attention: The command 'Get all Latest Versions' only will copy those objects of this category from the project folder to the local project, which are already part of the project !
Compile files:
Compile information (e.g. symbol files) which is created by CoDeSys for the current project and which may be needed by other programs too. Example: An external visualization may need not only the project variables, but also the assigned addresses. The latter will not be known until the project is compiled.
Alternatively any objects of the CoDeSys project can be excluded from the project source control and can be assigned to category 'Local', which means that they are just stored with the project as usual for projects without any source control.
CoDeSys V2.3
7-3
8 - The License Manager
8
The License Manager The 3S License Manager is available to handle the licenses for 3S modules, as well as licenses for modules for which an appropriate license information file is provided, on your computer. In CoDeSys you can create a project and provide it as a licensed library. The Licensing Manager will be installed automatically with any 3S module, which requires a license. See also the separate documentation provided with the 3S Licensing Manager.
8.1.1
Creating a licensed library in CoDeSys As is known a CoDeSys project can be saved as a library. If you want to create a licensed library you have to add the appropriate license information. For this perform the command 'File'Save as..', choose data type 'Internal Library' or 'External Library' and press button Edit license info.. In the dialog Edit Licensing Information enter the information described below. The license information will be added to the Project Info. When later on the library will be included in a CoDeSys project, the license information can be checked up in the object properties dialog of the library in the library manager. Dialog: Edit Licensing Information
Common: Name: Enter a name for the library module which is used to represent it in the 3S Licensing Manager. This input is mandatory. Demo mode: Activate this option if the module should be usable in demo mode, that means without any license ID. Enter the number of days after which the 'demo license' should expire. The number of days will be automatically rounded up to the next number which is divisible by ten (10, 20, 30 ..). If no number is entered here, the module will be usable without time limitation !
CoDeSys V2.3
8-1
Tools
Targets: Enter here the target-ID(s) of the target system(s) for which the license should be valid. Multiple inputs must be separated by a comma or a semicolon. Contact: Licensing via phone: / Licensing per via mail: Insert here the phone number resp. email address of the license provider. These inputs are mandatory. Optional information: In the right window you can enter a text referring to the item currently marked in the left window: Description, Manufacturer, Vendor, Pricing information Please note: -
8-2
It is reasonable to protect a library, which has been provided with licensing information, by a password. If you are going to save the project without password you will be pointed to that by a message box. the licensing information of a 3S library is stored internally with the library and will be registered on the computer automatically as soon as the library is included in a project. But the license information of modules which are not provided by 3S must be provided in a separate description file in compatible XML format, which can be read by the 3S Licensing Manager. For this also see the For this also see the separate documentation on the 3S License Manager.
CoDeSys V2.3
9 - DDE Communication with CoDeSys
9
DDE Communication with CoDeSys CoDeSys has a DDE (dynamic data exchange) interface for reading data. CoDeSys uses this interface to provide other applications that also use a DDE Interface with the contents of control variables and IEC addresses If the GatewayDDEServer is used, which works with symbols, CoDeSys is not needed to read variables values from the PLC and to transfer them to applications with an DDE interface. Attention: Direct addresses cannot be read over the DDE server ! For this case you have to define variables in CoDeSys which are assigned to the desired addresses (AT). Attention: The DDE interface has been tested with Word 97 and Excel 97 on Windows NT 4.0. If the DDE communication fails caused by a mismatch of other versions or additionally installed programs on a computer, 3S – Smart Software Solutions cannot take any responsibility.
9.1
DDE interface of the CoDeSys programming system..
Activating the DDE Interface The DDE interface becomes active as soon as the PLC (or the simulation) is logged in. General Approach to Data A DDE inquiry can be divided into three parts: 1. Name of the program (here: CoDeSys), 2. File name and 3. Variable name to be read. Name of the program: CoDeSys File name: complete project path (c:exampleexample.pro). Variable name: The name of a variable as it appears in the Watch and Receipt Manager . Which variables can be read? All addresses and variables are readable. Variables or addresses should be entered in the format used in the Watch and Receipt Manager Examples:
%IX1.4.1
(* Reads the input 1.4.1*)
PLC_PRG.TEST
(* Reads the variable TEST from the POU PLC_PRG*)
.GlobVar1
(* Reads the global variable GlobVar1 *)
Linking variables using WORD In order to get the current value of the variable TEST from the POU PLC_PRG through the DDE interface in Microsoft WORD, a field (e.g., the date) must be inserted in WORD ('Insert' 'Field'). Now when you click on the field with the right mouse button and select the command 'Toggle Field Codes' you can change the field function for the chosen text. In our example, this would look as follows: { DDEAUTO CODESYS 'C:CODESYSPROJECTIFMBSP.PRO' 'PLC_PRG.TEST' } Click on the field with the right mouse button again, then click on 'Update Field' and the desired variable content appears in the text. Linking variables using EXCEL The following must be entered in Microsoft EXCEL before you can assign a variable to a cell.
CoDeSys V2.3
9-1
DDE communcation with the GatewayDDE Server..
=CODESYS 'C:CODESYSPROJECT IFMBSP.PRO'!PLC_PRG.TEST'
When you click on 'Edit' then 'Links', the result for this link will be: Type: CODESYS Source file: C:CODESYSPROJECTIFMBSP.PRO Element: PLC_PRG.TEST
Accessing variables with Intouch Link with your project a DDE Access Name with the application name CODESYS and the DDE topic name C:CODESYSPROJECT IFMBSP.PRO. Now you can associate DDE type variables with the access name . Enter the name of the variable as the Item Name (e.g., PLC_PRG.TEST).
9.2
DDE communcation with the GatewayDDE Server..
Handling of the GatewayDDE Server The GatewayDDE Server can use the symbols which are created in CoDeSys for a project to communciate with other clients or the PLC. (see 'Project' 'Options' 'Symbolconfiguration'). It can serve the DDE interfaces of applications like e.g. Excel. This allows to transmit the variables values of the PLC to an applications, e.g. for the purpose of monitoring. At start of the GatewayDDE Server a window opens, where the configuration of start and communication parameters can be done. A already existing configuration file can be called or the parameters can be set newly. Starting dialog of the GatewayDDE Server
Using the command 'File' 'Open' you can call an already existing file which stores a set of configuration parameters. The standard dialog for selecting a file will open and available files with the extension '.cfg' will be offered. If a configuration file is selected, the configuration parameters and the defined target device are displayed If the option 'File' 'Autoload' is activated, the GatewayDDE Server automatically opens with that configuration, which was active before the last terminating of the server. If the server is started without any predefined configuration and without the setting Autoload, then in the configuration window 'Gateway:' und 'Device:' are displayed. Then you have to set up a new configuration. The command 'File' 'Settings' opens the dialog 'Server settings', in which the following parameters can be set:
9-2
CoDeSys V2.3
9 - DDE Communication with CoDeSys
Dialog for configuring the GatewayDDE Server
Motorola byteorder
Motorola Byteorder is used
Check identity
It will be checked, whether the project ID given by the symbol file is the same as that stored in the PLC.
Updaterate [ms]
Time interval for reading all symbol values from the PLC.
Timeout [ms]
Communication timeout for the used driver.
Tries
Number of retries of the communication driver to transfer a data block (not supported by all drivers !)
To set up the connection to the Gateway, the dialog 'Communication Parameters' is opened by the command 'Online' 'Parameters'. It is the same dialog as you get in CoDeSys with the command 'Online' 'Kommunikationsparameter'. The settings you do here must be the same as in the corresponding CoDeSys Project. The actual configuraiton of the GatewayDDE Server can be stored in a file by the command 'File' 'Save'. The standard dialog for saving a file will open, default for the extension of the file is *.cfg. To get the gateway in active mode, login by the command 'Online' 'Login'. (The gateway symbol in the status bar will get lightened then.) At login the desired connection will be built up and the available symbols can be accessed. These must have been created before in the CoDeSys Project ! To log out use the command 'Online' Logout'. General Approach to Data A DDE inquiry can be divided into three parts: 1. Name of the program (here: CoDeSys), 2. File name and 3. Variable name to be read. Name of the program: CoDeSys File name: complete project path (c:exampleexample.pro). Variable name: The name of a variable as it appears in the Watch and Receipt Manager . Which variables can be read? All addresses and variables are readable. Variables or addresses should be entered in the format used in the Watch and Receipt Manager Examples: %IX1.4.1
(* Reads the input 1.4.1*)
PLC_PRG.TEST (* Reads the variable TEST from the POU PLC_PRG*)
CoDeSys V2.3
9-3
DDE communcation with the GatewayDDE Server..
.GlobVar1
(* Reads the global variable GlobVar1 *)
Linking variables using WORD Start the GatewayDDEServer before activating the inquiry in WORD. In order to get the current value of the variable TEST from the POU PLC_PRG through the DDE interface in Microsoft WORD, a field (e.g., the date) must be inserted in WORD ('Insert' 'Field'). Now when you click on the field with the right mouse button and select the command 'Toggle Field Codes' you can change the field function for the chosen text. In our example, this would look as follows: { DDEAUTO GATEWAYDDESERVER 'BSP.PRO' 'PLC_PRG.TEST' } Click on the field with the right mouse button again, then click on 'Update Field' and the desired variable content appears in the text. Linking variables using EXCEL Start the GatewayDDEServer before activating the inquiry in EXCEL. The following must be entered in Microsoft EXCEL before you can assign a variable to a cell. =GATEWAYDDESERVER ! Beispiel: =GATEWAYDDESERVER 'bsp.pro'!'PLC_PRG.TEST' When you click on 'Edit' then 'Links', the result for this link will be: Type: CODESYS Source file: C:CODESYSPROJECTIFMBSP.PRO Element: PLC_PRG.TEST { DDEAUTO GATEWAYDDESERVER 'BSP.PRO' 'PLC_PRG.TEST' } Command line options for the GatewayDDEServer If the GatewayDDE Server is started by a command line, the following options can be attached: /n
The info dialog does automatically at starting
/s
Display of the dialog window
not
appear
/c
Configuration file to be load automatically l
/o
Go online with the selected configuration (autoload or defined by '/c=')
/s=h
No
/s=i /s=m /s=n
minimized (icon) maximized normal
/c=
Example: Command line: GATEWAYDDE /s=i /c='D:DDEconf_1.cfg'
The GatewayDDE Server will be started, the dialog window will appear as an icon, the configuration which is stored in the file conf_1.cfg will be loaded.
9-4
CoDeSys V2.3
APPENDIX
10
APPENDIX
Appendix A: IEC Operators and additional norm extending functions CoDeSys supports all IEC operators. In contrast with the standard functions functions (see appendix D, Standard library), these operators are recognized implicitly throughout the project. Besides the IEC operators CoDeSys also supports the following operators which are not prescribed by the standard: INDEXOF and SIZEOF (see Arithmetic Operators), ADR and BITADR (see Adress Operators). Operators are used like functions in POU. Attention: At operations with floating point variables the result depends on the currently used target system !
> Arithmetic operators > Bitstring Operators > Bit-Shift Operators > Selection Operators > Comparison Operators > Address Operators > Calling Operators > Type Conversions > Numeric Operators
10.1
Arithmetic Operators..
ADD Addition of variables of the types: BYTE, WORD, DWORD, SINT, USINT, INT, UINT, DINT, UDINT, REAL and LREAL. Two TIME variables can (e.g., t#45s + t#50s = t#1m35s)
also
be
added
together
resulting
in
another
time
Example in IL: LD
7
ADD
2,4,7
ST
Var 1
Example in ST: var1 := 7+2+4+7; Example in FBD:
CoDeSys V2.3
10-1
Arithmetic Operators..
MUL Multiplication of variables of the types: BYTE, WORD, DWORD, SINT, USINT, INT, UINT, DINT, UDINT, REAL and LREAL. Example in IL: LD
7
MUL 2,4,7 ST
Var 1
Example in ST: var1 := 7*2*4*7; Example in FBD:
SUB Subtraction of one variable from another of the types: BYTE, WORD, DWORD, SINT, USINT, INT, UINT, DINT, UDINT, REAL and LREAL. A TIME variable may also be subtracted from another TIME variable resulting in third TIME type variable. Note that negative TIME values are undefined. Example in IL: LD
7
SUB 8 ST
Var 1
Example in ST: var1 := 7-2; Example in FBD:
DIV Division of one variable by another of the types: BYTE, WORD, DWORD, SINT, USINT, INT, UINT, DINT, UDINT, REAL and LREAL. Example in IL: LD
8
DIV
2
ST
Var 1
(* Result is 4 *)
Example in ST: var1 := 8/2; Example in FBD:
10-2
CoDeSys V2.3
IEC Operators and additional norm extending functions
Note:
If you define functions in your project with the names CheckDivByte, CheckDivWord, CheckDivDWord and CheckDivReal, you can use them to check the value of the divisor if you use the operator DIV, for example to avoid a division by 0. The functions must have the above listed names.
See in the following an example for the implementation of function CheckDivReal: Example for the implementation of the function CheckDivReal: FUNCTION CheckDivReal : REAL VAR_INPUT divisor:REAL; END_VAR IF divisor = 0 THEN CheckDivReal:=1; ELSE CheckDivReal:=divisor; END_IF;
Operator DIV uses the output of function CheckDivReal as divisor. In a program like shown in the following example this avoids a division by 0, the divisor (d) is set from 0 to 1. So the result of the division is 799. PROGRAM PLC_PRG VAR erg:REAL; v1:REAL:=799; d:REAL; END_VAR erg:= v1 DIV d
MOD Modulo Division of one variable by another of the types: BYTE, WORD, DWORD, SINT, USINT, INT, UINT, DINT, UDINT. The result of this function will be the remainder of the division. This result will be a whole number. Example in IL: LD
9
MOD
2
ST
Var 1
(* Result is 1 *)
Example in ST: var1 := 9 MOD 2; Example in FBD:
MOVE Assignment of a variable to another variable of an appropriate type. As MOVE is available as a box in the graphic editors FBD, LD, CFC, there the (unlocking) EN/EN0 functionality can also be applied on a variable assignment. Example in CFC in conjunction with the EN/EN0 function: Only if en_i is TRUE, var1 will be assigned to var2.
Example in IL:
CoDeSys V2.3
10-3
Bitstring Operators..
LD
ivar1
MOVE ivar2 ST
ivar2
(* result: var2 erhält Wert von var1 *)
( ! you get the same result with: LD ivar1 ST ivar2 )
Example in ST: ivar2 := MOVE(ivar1); ( ! you get the same result with: ivar2 := ivar1; ) INDEXOF This function is not prescribed by the standard IEC61131-3. Perform this function to find the internal index for a POU. Example in ST: var1 := INDEXOF(POU2); SIZEOF This function is not prescribed by the standard IEC61131-3. Perform this function to determine the number of bytes required by the given data type. Example in IL: arr1:ARRAY[0.4] OF INT; Var1
INT
LD
arr1
SIZEOF ST
Var 1 (* Result is 10 *)
Example in ST: var1 := SIZEOF(arr1);
10.2
Bitstring Operators..
AND Bitwise AND of bit operands. The operands should be of the type BOOL, BYTE, WORD or DWORD. Example in IL: Var1 BYTE LD
2#1001_0011
AND 2#1000_1010 ST
Var 1
(* Result is 2#1000_0010 *)
Example in ST:
10-4
CoDeSys V2.3
IEC Operators and additional norm extending functions
var1 := 2#1001_0011 AND 2#1000_1010 Example in FBD:
Note:
If you have a program step in the SFC like the following
and if you use 68xxx- or C-code generators, please note the following: The allocation of the value of the second input variable at the AND operator module to variable z will not be executed ! This is due to the optmized processing in the SFC in case of value FALSE at the input variable.
OR Bitwise OR of bit operands. The operands should be of the type BOOL, BYTE, WORD or DWORD. Example in IL: var1 :BYTE; LD 2#1001_0011 OR 2#1000_1010 ST var1 (* Result is 2#1001_1011 *) Example in ST: Var1 := 2#1001_0011 OR 2#1000_1010 Example in FBD:
Note:
If you have a program step in the SFC like the following
and if you use 68xxx- or C-code generators, please note the following: The allocation of the value of the second input variable at the OR operator module to variable z will not be executed ! This is due to the optmized processing in the SFC in case of value FALSE at the input variable.
XOR Bitwise XOR of bit operands. The operands should be of the type BOOL, BYTE, WORD or DWORD. Note:
Regard the behaviour of the XOR function in extended form, that means if there are more than 2 inputs. The inputs will be checked in pairs and the particular results will then be compared again in pairs (this complies with the standard, but may not be expected by the user).
Example in IL: Var1 :BYTE; LD 2#1001_0011 XOR 2#1000_1010 ST Var1 (* Result is 2#0001_1001 *) Example in ST: Var1 := 2#1001_0011 XOR 2#1000_1010 Example in FBD:
CoDeSys V2.3
10-5
Bit-Shift Operators
NOT Bitwise NOT of a bit operand. The operand should be of the type BOOL, BYTE, WORD or DWORD. Example in IL: Var1 :BYTE; LD 2#1001_0011 NOT ST Var1 (* Result is 2#0110_1100 *) Example in ST: Var1 := NOT 2#1001_0011 Example in FBD:
10.3
Bit-Shift Operators
SHL Bitwise left-shift of an operand : erg:= SHL (in, n) in gets shifted to the left by n bits. If n > data type width, for BYTE, WORD and DWORD will be filled with zeros. But if signed data types are used, like e.g. INT, then an arithmetic shift will be executed in such cases, that means it will be filled with the value of the topmost bit. Note: Note:
Please note, that the amount of bits, which is regarded for the arithmetic operation, is pretended by the data type of the input variable !. If the input variable is a constant the smallest possible data type is regarded. The data type of the output variable has no effect at all on the arithmetic operation. See in the following example in hexadecimal notation that you get different results for erg_byte and erg_word depending on the data type of the input variable (BYTE or WORD), although the values of the input variables in_byte and in_word are the same.
Example in ST:
10-6
CoDeSys V2.3
IEC Operators and additional norm extending functions
Example in FBD:
Example in IL: LD
16#45
SHL
2
ST
erg_byte
SHR Bitwise right-shift of an operand: erg:= SHR (in, n) in gets shifted to the right by n bits. If n > data type width, for BYTE, WORD and DWORD will be filled with zeros. But if signed data types are used, like e.g. INT, then an arithmetic shift will be executed in such cases, that means it will be filled with the value of the topmost bit. Note:
Please note, that the amount of bits, which is regarded for the arithmetic operation, is pretended by the data type of the input variable !. If the input variable is a constant the smallest possible data type is regarded. The data type of the output variable has no effect at all on the arithmetic operation.
See the following example in hexadecimal notation to notice the results of the arithmetic operation depending on the type of the input variable (BYTE or WORD). Example in ST: PROGRAM shr_st VAR in_byte : BYTE:=16#45; in_word : WORD:=16#45; erg_byte : BYTE; erg_word : WORD; n: BYTE :=2; END_VAR erg_byte:=SHR(in_byte,n); (* Result is 11 *) erg_word:=SHR(in_word;n); (* Result is 0011 *) Example in FBD:
Example in IL:
LD
16#45
SHL
2
ST
erg_byte
ROL Bitwise rotation of an operand to the left: erg:= ROL (in, n) erg, in and n should be of the type BYTE, WORD or DWORD. in will be shifted one bit position to the left n times while the bit that is furthest to the left will be reinserted from the right.
CoDeSys V2.3
10-7
Bit-Shift Operators
Note: Please note, that the amount of bits, which is regarded for the arithmetic operation, is pretended by the data type of the input variable !. If the input variable is a constant the smallest possible data type is regarded. The data type of the output variable has no effect at all on the arithmetic operation. See in the following example in hexadecimal notation that you get different results for erg_byte and erg_word depending on the data type of the input variable (BYTE or WORD), although the values of the input variables in_byte and in_word are the same. Example in ST: PROGRAM rol_st VAR in_byte : BYTE:=16#45; in_word : WORD:=16#45; erg_byte : BYTE; erg_word : WORD; n: BYTE :=2; END_VAR erg_byte:=ROL(in_byte,n); (* Ergebnis ist 16#15 *) erg_word:=ROL(in_word;n); (* Ergebnis ist 16#0114 *) Example in FBD:
Example in IL:
LD
16#45
SHL 2 ST
erg_byte
ROR Bitwise rotation of an operand to the right: erg = ROR (in, n) erg, in and n should be of the type BYTE, WORD or DWORD. in will be shifted one bit position to the right n times while the bit that is furthest to the left will be reinserted from the left. Note:
Please note, that the amount of bits, which is regarded for the arithmetic operation, is pretended by the data type of the input variable !. If the input variable is a constant the smallest possible data type is regarded. The data type of the output variable has no effect at all on the arithmetic operation.
See in the following example in hexadecimal notation that you get different results for erg_byte and erg_word depending on the data type of the input variable (BYTE or WORD), although the values of the input variables in_byte and in_word are the same. Example in ST: PROGRAM ror_st VAR in_byte : BYTE:=16#45; in_word : WORD:=16#45; erg_byte : BYTE; erg_word : WORD; n: BYTE :=2; END_VAR erg_byte:=ROR(in_byte,n); (* Result is 16#51 *) erg_word:=ROR(in_word;n); (* Result is16#4011 *)
10-8
CoDeSys V2.3
IEC Operators and additional norm extending functions
Example in FBD:
Example in IL:
10.4
LD
16#45
SHL
2
ST
erg_byte
Selection Operators All selection operations can also be performed with variables. For purposes of clarity we will limit our examples to the following which use constants as operators.
SEL Binary Selection. OUT := SEL(G, IN0, IN1) means: OUT := IN0 if G=FALSE; OUT := IN1 if G=TRUE. IN0, IN1 and OUT can be any type of variable, G must be BOOL. The result of the selection is IN0 if G is FALSE, IN1 if G is TRUE. Example in IL:
LD
TRUE
SEL
3,4
ST
Var1
LD
FALSE
SEL
3,4
ST
Var1
(* Result ist 4 *)
(* Result ist 3 *)
Example in ST:
Var1:=SEL(TRUE,3,4); (* Result is 4 *) Example in FBD:
Note:
Note that an expression occurring ahead of IN1 or IN2 will not be processed if IN0 is TRUE.
MAX Maximum function. Returns the greater of the two values. OUT := MAX(IN0, IN1) IN0, IN1 and OUT can be any type of variable. Example in IL:
CoDeSys V2.3
10-9
Selection Operators
LD
90
MAX
30
MAX
40
MAX
77
ST
Var1
(* Result is 90 *)
Example in ST: Var1:=MAX(30,40); (* Result is 40 *) Var1:=MAX(40,MAX(90,30)); (* Result is 90 *) Example in FBD:
MIN Minimum function. Returns the lesser of the two values. OUT := MIN(IN0, IN1) IN0, IN1 and OUT can be any type of variable. Example in IL:
LD
90
MIN
30
MIN
40
MIN
77
ST
Var 1
(* Result is 30 *)
Example in ST: Var1:=MIN(90,30); (* Result is 30 *); Var1:=MIN(MIN(90,30),40); (* Result is 30 *); Example in FBD:
LIMIT Limiting OUT := LIMIT(Min, IN, Max) means: OUT := MIN (MAX (IN, Min), Max) Max is the upper and Min the lower limit for the result. Should the value IN exceed the upper limit Max, LIMIT will return Max. Should IN fall below Min, the result will be Min. IN and OUT can be any type of variable. Example in IL:
LD
10-10
90
CoDeSys V2.3
IEC Operators and additional norm extending functions
LIMIT 30,80 ST
Var 1
(*Result is 80 *)
Example in ST: Var1:=LIMIT(30,90,80); (* Result is 80 *);
MUX Multiplexer OUT := MUX(K, IN0,..,INn) means: OUT := INK. IN0, ..,INn and OUT can be any type of variable. K must be BYTE, WORD, DWORD, SINT, USINT, INT, UINT, DINT or UDINT. MUX selects the Kth value from among a group of values. Example in IL:
LD
0
MUX
30,40,50,60,70,80
ST
Var 1
(*Result is 30 *)
Example in ST: Var1:=MUX(0,30,40,50,60,70,80); (* Result is 30 *); Note:
10.5
Note that an expression occurring ahead of an input other than INK will not be processed to save run time ! Only in simulation mode all expressions will be executed.
Comparison Operators..
GT Greater than A Boolean operator which returns the value TRUE when the value of the first operand is greater than that of the second. The operands can be BOOL, BYTE, WORD, DWORD, SINT, USINT, INT, UINT, DINT, UDINT, REAL, LREAL, TIME, DATE, TIME_OF_DAY, DATE_AND_TIME and STRING. Example in IL:
LD
20
GT
30
ST
Var 1
(* Result is FALSE *)
Example in ST: VAR1 := 20 > 30 > 40 > 50 > 60 > 70; Example in FBD:
CoDeSys V2.3
10-11
Comparison Operators..
LT Less than A Boolean operator that returns the value TRUE when the value of the first operand is less than that of the second. The operands can be BOOL, BYTE, WORD, DWORD, SINT, USINT, INT, UINT, DINT, UDINT, REAL, LREAL, TIME, DATE, TIME_OF_DAY, DATE_AND_TIME and STRING. Example in IL:
LD
20
LT
30
ST
Var 1
(* Result is TRUE *)
Example in ST: VAR1 := 20 < 30; Example in FBD:
LE Less than or equal to A Boolean operator that returns the value TRUE when the value of the first operand is less than or equal to that of the second. The operands can be BOOL, BYTE, WORD, DWORD, SINT, USINT, INT, UINT, DINT, UDINT, REAL, LREAL, TIME, DATE, TIME_OF_DAY, DATE_AND_TIME and STRING. Example in IL:
LD
20
LE
30
ST
Var 1
(* Result is TRUE *)
Example in ST: VAR1 := 20 = 40; Example in FBD:
EQ Equal to A Boolean operator that returns the value TRUE when the operands are equal. The operands can be BOOL, BYTE, WORD, DWORD, SINT, USINT, INT, UINT, DINT, UDINT, REAL, LREAL, TIME, DATE, TIME_OF_DAY, DATE_AND_TIME and STRING. Example in IL:
LD
40
EQ
40
ST
Var 1
(* Result is TRUE *)
Example in ST: VAR1 := 40 = 40; Example in FBD:
NE Not equal to A Boolean operator that returns that value TRUE when the operands are not equal. The operands can be BOOL, BYTE, WORD, DWORD, SINT, USINT, INT, UINT, DINT, UDINT, REAL, LREAL, TIME, DATE, TIME_OF_DAY, DATE_AND_TIME and STRING. Example in IL:
LD
40
NE
40
ST
Var 1
(* Result is FALSE *)
Example in ST: VAR1 := 40 40; Example in FBD:
10.6
Address Operators..
ADR Address Function not prescribed by the standard IEC61131-3.
CoDeSys V2.3
10-13
Calling Operators..
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
Var 1
ADR ST
Var 2
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 AWL:
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^;
10.7
Calling 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-14
CoDeSys V2.3
IEC Operators and additional norm extending functions
10.8
Type 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: _TO_ 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 BOOL_TO_INT ST i
(*Result is 1 *)
LD TRUE BOOL_TO_STRING ST str
(*Result is 'TRUE' *)
LD TRUE BOOL_TO_TIME ST t
(*Result is T#1ms *)
LD TRUE BOOL_TO_TOD ST
(*Result is TOD#00:00:00.001 *)
LD FALSE BOOL_TO_DATE ST dat
(*Result is D#1970-01-01 *)
LD TRUE BOOL_TO_DT ST dandt
(*Result is DT#1970-01-01-00:00:01 *)
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 *)
CoDeSys V2.3
10-15
Type Conversions..
(*Result is 'TRUE' *)
(*Result is T#1ms *)
(*Result is TOD#00:00:00.001 *)
(*Result is D#1970-01-01 *)
(*Result DT#1970-01-01-00:00:01 *)
is
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 BYTE_TO_BOOL ST b
(*Result is TRUE *)
LD 0 INT_TO_BOOL ST b
(*Result is FALSE *)
LD T#5ms TIME_TO_BOOL ST b
(*Result is TRUE *)
LD 'TRUE' STRING_TO_BOOL ST b
(*Result is TRUE *)
Examples in FUP:
(*Result is TRUE *)
(*Result is FALSE *)
(*Result is TRUE *)
(*Result is TRUE *)
Examples in St:
b := BYTE_TO_BOOL(2#11010101);
10-16
(* Result is TRUE *)
CoDeSys V2.3
IEC Operators and additional norm extending functions
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
3.5
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 *) 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:
CoDeSys V2.3
10-17
Type Conversions..
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 TIME_TO_STRING ST str
(*Result is 'T#12ms' *)
LD T#300000ms TIME_TO_DWORD ST dw
(*Result is 300000 *)
LD TOD#00:00:00.012 TOD_TO_SINT ST si
(*Result is 12 *)
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. 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 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' *)
10-18
CoDeSys V2.3
IEC Operators and additional norm extending functions
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 St:
b :=STRING_TO_BOOL('TRUE');
(* Result is TRUE *)
w :=STRING_TO_WORD('abc34');
(* Result is 0 *)
t :=STRING_TO_TIME('T#127ms');
(* Result is T#127ms *)
TRUNC Converting from REAL to INT. The whole number portion of the value will be used. When you perform a type conversion from a larger to a smaller type, you risk losing some information. Examples in ST:
i:=TRUNC(1.9); (* Result is 1 *) i:=TRUNC(-1.4); (* result is -1 *). Example in IL:
LD
2.7
TRUNC GE
10.9
%MW8
Numeric Operators..
ABS Returns the absolute value of a number. ABS(-2) equals 2. The following type combinations for input and output variables are possible: IN
OUT
INT
INT, REAL, WORD, DWORD, DINT
REAL
REAL
BYTE
INT, REAL, BYTE, WORD, DWORD, DINT
WORD
INT, REAL, WORD, DWORD, DINT
DWORD REAL, DWORD, DINT SINT
REAL
USINT
REAL
UINT
INT, REAL, WORD, DWORD, DINT, UDINT, UINT
DINT
REAL, DWORD, DINT
UDINT
REAL, DWORD, DINT, UDINT
CoDeSys V2.3
10-19
Numeric Operators..
Example in IL: LD
2
ABS ST
i
(*Result is 2 *)
Example in ST: i:=ABS(-2); Example in FBD:
SQRT Returns the square root of a number. IN can be type BYTE, WORD, DWORD, INT, DINT, REAL, SINT, USINT, UINT, UDINT, OUT must be type REAL. Example in IL: LD
16
SQRT ST
q
(*Result is 4 *)
Example in ST: q:=SQRT(16); Example in FBD:
LN Returns the natural logarithm of a number. IN can be type BYTE, WORD, DWORD, INT, DINT, REAL, SINT, USINT, UINT, UDINT, OUT must be type REAL. Example in IL: LD
45
LN ST
q
(*Result is 3.80666 *)
Example in ST: q:=LN(45); Example in FBD:
10-20
CoDeSys V2.3
IEC Operators and additional norm extending functions
LOG Returns the logarithm of a number in base 10. IN can be type BYTE, WORD, DWORD, INT, DINT, REAL, SINT, USINT, UINT, UDINT, OUT must be type REAL. Example in IL: LD
314.5
LOG ST
q
(*Result is 2.49762 *)
Example in ST: q:=LOG(314.5); Example in FBD:
EXP Returns the exponential function. IN can be type BYTE, WORD, DWORD, INT, DINT, REAL, SINT, USINT, UINT, UDINT, OUT must be type REAL. Example in IL: LD
2
EXP ST
q
(* result is 7.389056099 *)
Example in ST: q:=EXP(2); Example in FBD:
SIN Returns the sine of a number. IN can be type BYTE, WORD, DWORD, INT, DINT, REAL, SINT, USINT, UINT, UDINT, OUT must be type REAL. Example in IL: LD
0.5
SIN ST
q
(*Result is 0.479426 *)
Example in ST: q:=SIN(0.5);
CoDeSys V2.3
10-21
Numeric Operators..
Example in FBD:
COS Returns the cosine of number. The value is calculated in arch minutes. IN can be type BYTE, WORD, DWORD, INT, DINT, REAL, SINT, USINT, UINT, UDINT, OUT must be type Typ REAL. Example in IL: LD
0.5
COS ST
q
(*Result is 0.877583 *)
Example in ST: q:=COS(0.5); Example in FBD:
TAN Returns the tangent of a number. The value is calculated in arch minutes. IN can be type BYTE, WORD, DWORD, INT, DINT, REAL, SINT, USINT, UINT, UDINT, OUT must be type REAL. Example in IL: LD
0.5
TAN ST
q
(*Result is 0.546302 *)
Example in ST: q:=TAN(0.5); Example in FBD:
ASIN Returns the arc sine (inverse function of sine) of a number. . IN can be type BYTE, WORD, DWORD, INT, DINT, REAL, SINT, USINT, UINT, UDINT, OUT must be type REAL. Example in IL: LD
0.5
ASIN ST
q
(*Result is 0.523599 *)
Example in ST: q:=ASIN(0.5);
10-22
CoDeSys V2.3
IEC Operators and additional norm extending functions
Example in FBD:
ACOS Returns the arc cosine (inverse function of cosine) of a number. The value is calculated in arch minutes. IN can be type BYTE, WORD, DWORD, INT, DINT, REAL, SINT, USINT, UINT, UDINT, OUT must be type REAL. Example in IL: LD
0.5
ABS ST
q
(*Result is 1.0472 *)
Example in ST: q:=ACOS(0.5); Example in FBD:
ATAN Returns the arc tangent (inverse function of tangent) of a number. The value is calculated in arch minutes. IN can be type BYTE, WORD, DWORD, INT, DINT, REAL, SINT, USINT, UINT, UDINT, OUT must be type REAL. Example in IL: LD
0.5
ABS ST
q
(*Result is 0.463648 *)
Example in ST: q:=ATAN(0.5); Example in FBD:
EXPT Exponentiation of a variable with another variable: OUT = IN1IN2. IN1 and IN2 can be type BYTE, WORD, DWORD, INT, DINT, REAL, SINT, USINT, UINT, UDINT, OUT must be type REAL. Example in IL: LD
CoDeSys V2.3
7
10-23
Numeric Operators..
EXPT
2
ST
var1
(*Result is 49 *)
Example in ST: var1 := EXPT(7,2); Example in FBD:
10-24
CoDeSys V2.3
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 Appendix C: Datentypen, 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
CoDeSys V2.3
10-25
Constants
(see also Appendix C: Datentypen, Time Data Types) 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 Appendix C: Datentypen, 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:
10-26
$$
Dollar signs
$'
Single quotation mark
$L or $l
Line feed
$N or $n
New line
CoDeSys V2.3
Appendix B: Operands in CoDeSys
$P or $p
Page feed
$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: # 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. specifies the constant. The data entered must fit within the data type specified under . 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: [Index1, Index2]
CoDeSys V2.3
10-27
Addresses
Structure variables can be accessed using the following syntax: . Function block and program variables can be accessed using the following syntax: . 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 ' outside the valid range for variable '! 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 ' for direct indexing' A bit access must not be assigned to a VAR_IN_OUT variable!
10.12 Addresses Address The direct display of individual memory locations is done through the use of special character sequences. These sequences are a concatenation of the percent sign '%', a range prefix, a prefix for the size and one or more natural numbers separated by blank spaces. The following range prefixes are supported: I
Input
Q
Output
M
Memory location
The following size prefixes are supported: X
Single bit
None Single bit B
Byte (8 Bits)
W
Word (16 Bits)
D
Double word (32 Bits)
Examples: %QX7.5 %Q7.5 %IW215
10-28
and Output bit 7.5 Input word 215
CoDeSys V2.3
Appendix B: Operands in CoDeSys
%QB7
Output byte 7
%MD48
Double word in memory position 48 in the memory location.
%IW2.5.7.1
depending on the PLC Configuration
The current PLC Configuration for the program determines whether or not an address is valid. Note:
Boolean values will be allocated bytewise, if no explicit single-bit address is specified. Example: A change in the value of varbool1 AT %QW0 affects the range from QX0.0 to QX0.7.
Memory location You can use any supported size to access the memory location. For example, the address %MD48 would address bytes numbers 192, 193, 194, and 195 in the memory location area (48 * 4 = 192). The number of the first byte is 0. You can access words, bytes and even bits in the same way: the address %MX5.0 allows you to access the first bit in the fifth word (Bits are generally saved wordwise).
10.13 Functions In ST a function call can also appear as an operand. Example: Result := Fct(7) + 3;
TIME()-Function This function returns the time (based on milliseconds) which has been passed since the system was started. The data type is TIME. Example in IL: TIME ST
systime (* Result e.g.: T#35m11s342ms *)
Example in ST: systime:=TIME(); Example in FUP:
CoDeSys V2.3
10-29
Appendix C: Data types in CoDeSys
Appendix C: Data types in CoDeSys 10.14 Standard data types Data types You can use standard data types and user-defined data types when programming. Each identifier is assigned to a data type which dictates how much memory space will be reserved and what type of values it stores. BOOL BOOL type variables may be given the values TRUE and FALSE. 8 bits of memory space will be reserved. see also chapter Appendix B: Operands in CoDeSys, BOOL constants Integer Data Types
BYTE, WORD, DWORD, SINT, USINT, INT, UINT, DINT, and UDINT are all integer data types Each of the different number types covers a different range of values. The following range limitations apply to the integer data types: Type
Lower limit
Upper limit
Memory space
BYTE
0
255
8 Bit
WORD
0
65535
16 Bit
DWORD
0
4294967295
32 Bit
SINT:
-128
127
8 Bit
USINT:
0
255
8 Bit
INT:
-32768
32767
16 Bit
UINT:
0
65535
16 Bit
DINT:
-2147483648
2147483647
32 Bit
UDINT:
0
4294967295
32 Bit
As a result when larger types are converted to smaller types, information may be lost. see also Appendix B: Operands in CoDeSys, Number constants REAL / LREAL REAL and LREAL are so-called floating-point types. They are required to represent rational numbers. 32 bits of memory space is reserved for REAL and 64 bits for LREAL. see also Appendix F: REAL-/LREAL constants STRING A STRING type variable can contain any string of characters. The size entry in the declaration determines how much memory space should be reserved for the variable. It refers to the number of characters in the string and can be placed in parentheses or square brackets. If no size specification is given, the default size of 80 characters will be used. Example of a String Declaration with 35 characters:
CoDeSys V2.3
10-31
Standard data types
str:STRING(35):='This is a String'; see also Appendix B: Operands in CoDeSys, STRING constants Time Data Types The data types TIME, TIME_OF_DAY (abb. TOD), DATE and DATE_AND_TIME (abb. DT) are handled internally like DWORD. Time is given in milliseconds in TIME and TOD, time in TOD begins at 12:00 A.M. Time is given in seconds in DATE and DT beginning with January 1, 1970 at 12:00 A.M. See in the following the time data formats used to assign values for time constants: TIME constants: 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: 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
TIME_OF_DAY Constants, for storing times of the day: begin with 'tod#', 'TOD#', 'TIME_OF_DAY#' or 'time_of_day#' followed by a time with the format: Hour:Minute:Second. Seconds can be entered as real numbers or you can enter fractions of a second. Examples: TIME_OF_DAY#15:36:30.123 tod#00:00:00
DATE_AND_TIME Constants, combination of date and the time of day: begin with 'dt#', 'DT#', 'DATE_AND_TIME#' or 'date_and_time#'. Place a hyphen after the date followed by the time. Examples:
10-32
CoDeSys V2.3
Appendix C: Data types in CoDeSys
DATE_AND_TIME#1996-05-06-15:36:30 dt#1972-03-29-00:00:00
10.15 Defined data types ARRAY One-, two-, and three-dimensional fields (arrays) are supported as elementary data types. Arrays can be defined both in the declaration part of a POU and in the global variable lists. Syntax: :ARRAY [.,.] OF . ll1, ll2, ll3identify the lower limit of the field range; ul1, ul2 and ul3 identify the upper limit. The range values must be integers. Example: Card_game: ARRAY [1.13, 1.4] OF INT; Initializing Arrays: Example for complete initialization of an array: arr1 : ARRAY [1.5] OF INT := 1,2,3,4,5; arr2 : ARRAY [1.2,3.4] OF INT := 1,3(7); (* short for 1,7,7,7 *) arr3 : ARRAY [1.2,2.3,3.4] OF INT := 2(0),4(4),2,3; (* short for 0,0,4,4,4,4,2,3 *) Example of the initialization of an array of a structure: TYPE STRUCT1 STRUCT p1:int; p2:int; p3:dword; END_STRUCT ARRAY[1.3] OF STRUCT1:= (p1:=1,p2:=10,p3:=4723),(p1:=2,p2:=0,p3:=299), (p1:=14,p2:=5,p3:=112); Example of the partial initialization of an Array: arr1 : ARRAY [1.10] OF INT := 1,2; Elements to which no value is pre-assigned are initialized with the default initial value of the basic type. In the example above, the elements anarray[6] to anarray[10] are therefore initialized with 0. Array components are accessed in a two-dimensional array using the following syntax: [Index1,Index2] Example: Card_game [9,2] Note:
If you define a function in your project with the name CheckBounds , you can use it to check for range overflows in your project (see chapter 'What is what in CoDeSys', 'Components of a project', 'Function')
Function Checkbounds If you define a function in your project with the name CheckBounds, you can automatically check for out-of-range errors in arrays. The name of the function is fixed and can only have this designation. Example for the function CheckBounds:
CoDeSys V2.3
10-33
Defined data types
FUNCTION CheckBounds : INT VAR_INPUT index, lower, upper: INT; END_VAR IF index < lower THEN CheckBounds := lower; ELSIF index > upper THEN CheckBounds := upper; ELSE CheckBounds := index; END_IF
The following sample program for testing the CheckBounds function exceeds the bounds of a defined array. The CheckBounds function allows the value TRUE to be assigned, not to location A[10], but to the still valid range boundary A[7] above it. With the CheckBounds function, references outside of array boundaries can thus be corrected. Test Program for the function CheckBounds: PROGRAM PLC_PRG VAR a: ARRAY[0.7] OF BOOL; b: INT:=10; END_VAR a[b]:=TRUE;
Pointer Variable or function block addresses are saved in pointers while a program is running. Pointer declarations have the following syntax: : POINTER TO ; A pointer can point to any data type or function block even to user-defined types. The function of the Address Operator ADR is to assign the address of a variable or function block to the pointer. A pointer can be dereferenced by adding the content operator '^' after the pointer identifier. Example: pt:POINTER TO INT; var_int1:INT := 5; var_int2:INT; pt := ADR(var_int1); var_int2:= pt^; (* var_int2 is now 5 *) Enumeration Enumeration is a user-defined data type that is made up of a number of string constants. These constants are referred to as enumeration values. Enumeration values are recognized in all areas of the project even if they were declared within a POU. It is best to create your enumerations as objects in the Object Organizer under the register card Data types. They begin with the keyword TYPE and end with END_TYPE. Syntax: TYPE :( , ..,); END_TYPE A variable of the type can take on one of the enumeration values and will be initialized with the first one. These values are compatible with whole numbers which means that you can perform operations with them just as you would with INT. You can assign a number x to the variable. If the enumeration values are not initialized, counting will begin with 0. When initializing, make certain the initial values are increasing. The validity of the number will be reviewed at the time it is run. Example: TYPE TRAFFIC_SIGNAL: (Red, Yellow, Green:=10); (*The initial value for each of the colors is red 0, yellow 1, green 10 *)
10-34
CoDeSys V2.3
Appendix C: Data types in CoDeSys
END_TYPE TRAFFIC_SIGNAL1 : TRAFFIC_SIGNAL; TRAFFIC_SIGNAL1:=0; (* The value of the traffic signal is red*) FOR i:= Red TO Green DO i := i + 1; END_FOR; The same enumeration value may not be used twice. Example: TRAFFIC_SIGNAL: (red, yellow, green); COLOR: (blue, white, red); Error: red
(* may not be used for both TRAFFIC_SIGNAL and COLOR.*)
Structures Structures are created as objects in the Object Organizer under the register card Data types. They begin with the keywords TYPE and STRUCT and end with END_STRUCT and END_TYPE. The syntax for structure declarations is as follows: TYPE : STRUCT . . END_STRUCT END_TYPE is a type that is recognized throughout the project and can be used like a standard data type. Interlocking structures are allowed. The only restriction is that variables may not be placed at addresses (the AT declaration is not allowed!). Example for a structure definition named Polygonline: TYPE Polygonline: STRUCT Start:ARRAY [1.2] OF INT; Point1:ARRAY [1.2] OF INT; Point2:ARRAY [1.2] OF INT; Point3:ARRAY [1.2] OF INT; Point4:ARRAY [1.2] OF INT; End:ARRAY [1.2] OF INT; END_STRUCT END_TYPE Example for the initialization of a structure: Poly_1:polygonline := ( Start:=3,3, Point1 =5,2, Point2:=7,3, Point3:=8,5, Point4:=5,7, End := 3,5); Initializations with variables are not possible. See an example of the initialization of an array of a structure under 'Arrays'. You can gain access to structure components using the following syntax: .
CoDeSys V2.3
10-35
Defined data types
For example, if you have a structure named 'Week' that contains a component named 'Monday', you can get to it by doing the following: Week.Monday References You can use the user-defined reference data type to create an alternative name for a variable, constant or function block. Create your references as objects in the Object Organizer under the register card They begin with the keyword TYPE and end with END_TYPE.
Data types.
Syntax: TYPE : ; END_TYPE Example: TYPE message:STRING[50]; END_TYPE; Subrange types A subrange type is a type whose range of values is only a subset of that of the basic type. The declaration can be carried out in the data types register, but a variable can also be directly declared with a subrange type: Syntax for the declaration in the 'Data types' register: TYPE : (.) END_TYPE; must be a valid IEC identifier, is one of the data types SINT, USINT, INT, UINT, DINT, UDINT, BYTE, WORD, DWORD (LINT, ULINT, LWORD).
Is a constant which must be compatible with the basic type and which sets the lower boundary of the range types. The lower boundary itself is included in this range.
Is a constant that must be compatible with the basic type, and sets the upper boundary of the range types. The upper boundary itself is included in this basic type.
Examples: TYPE SubInt : INT (-4095.4095); END_TYPE Direct declaration of a variable with a subrange type: VAR i : INT (-4095.4095); ui : UINT (0.10000); END_VAR If a constant is assigned to a subrange type (in the declaration or in the implementation) that does not fall into this range (e.g. 1:=5000), an error message is issued. In order to check for observance of range boundaries at runtime, the functions CheckRangeSigned or CheckRangeUnsigned must be introduced. In these, boundary violations can be captured by the appropriate method and means (e.g. the value can be cut out or an error flag can be set.). They are implicitly called as soon as a variable is written as belonging to a subrange type constructed from either a signed or an unsigned type.
10-36
CoDeSys V2.3
Appendix C: Data types in CoDeSys
Example: In the case of a variable belonging to a signed subrange type (like i, above), the function CheckRangeSigned is called; it could be programmed as follows to trim a value to the permissible range: FUNCTION CheckRangeSigned : DINT VAR_INPUT value, lower, upper: DINT; END_VAR IF (value < lower) THEN CheckRangeSigned := lower; ELSIF(value > upper) THEN CheckRangeSigned := upper; ELSE CheckRangeSigned := value; END_IF
In calling up the function automatically, the function name CheckRangeSigned is obligatory, as is the interface specification: return value and three parameters of type DINT When called, the function is parameterized as follows: - value: the value to be assigned to the range type - lower: the lower boundary of the range - upper: the upper boundary of the range - Return value: this is the value that is actually assigned to the range type An assignment i:=10*y implicitly produces the following in this example: i := CheckRangeSigned(10*y, -4095, 4095); Even if y for example has the value 1000, then i still has only the value 4095 aft er this assignment. The same applies to the function CheckRangeUnsigned: function name and interface must be correct. FUNCTION CheckRangeUnsigned : UDINT VAR_INPUT value, lower, upper: UDINT; END_VAR Important: If neither of the functions CheckRangeSigned or CheckRangeUnsigned is present, no type checking of subrange types occurs during runtime! The variable i could then take on any value between – 32768 and 32767 at any time! Attention: If neither of the functions CheckRangeSigned or CheckRangeUnsigned is present like described above, there can result an endless loop if a subrange type is used in a FOR loop. This will happen when the range given for the FOR loop is as big or bigger than the range of the subrange type !
Example: VAR ui : UINT (0.10000); END_VAR FOR ui:=0 TO 10000 DO .. END_FOR The FOR loop will never be finished, because ui cannot get bigger than 10000. Also take care of the definition of the CheckRange functions when you define the incremental value of a FOR loop !
CoDeSys V2.3
10-37
Appendix D: CoDeSys Libraries
Appendix D: CoDeSys Libraries 10.16 The Standard.lib library 10.16.1 String functions.. Please Note: String functions are not 'thread safe': When using tasks, string functions may only be used in a single task. If the same function is used in different tasks, there is a danger of overwriting.
LEN Returns the length of a string. Input STR is of type STRING, the return value of the function is type INT. Example in IL: LD
'SUSI'
LEN ST
VarINT1
(* Ergebnis ist 4 *)
Example in FBD:
Example in ST: VarSTRING1 := LEN ('SUSI'); Please Note: String functions are not 'thread safe': When using tasks, string functions may only be used in a single task. If the same function is used in different tasks, there is a danger of overwriting.
LEFT Left returns the left, initial string for a given string. Input STR is type STRING, SIZE is of type INT, the return value of the function is type STRING. LEFT (STR, SIZE) means: Take the first SIZE character from the right in the string STR. Example in IL: LD
'SUSI'
LEFT
3
ST
VarSTRING1
(* Ergebnis ist 'SUS' *)
Example in FBD:
Example in ST: VarSTRING1 := LEFT ('SUSI',3); Please Note: String functions are not 'thread safe': When using tasks, string functions may only be used in a single task. If the same function is used in different tasks, there is a danger of overwriting.
CoDeSys V2.3
10-39
The Standard.lib library
RIGHT Right returns the right, initial string for a given string. RIGHT (STR, SIZE) means: Take the first SIZE character from the right in the string STR. Input STR is of type STRING, SIZE is of type INT, the return value of the function is of type STRING. Example in IL: LD
'SUSI'
RIGHT
3
ST
VarSTRING1
(* Ergebnis ist 'USI' *)
Example in FBD:
Example in ST: VarSTRING1 := RIGHT ('SUSI',3); Please Note: String functions are not 'thread safe': When using tasks, string functions may only be used in a single task. If the same function is used in different tasks, there is a danger of overwriting.
MID Mid returns a partial string from within a string. Input STR is type STRING, LEN and POS are type INT, the return value of the function is type STRING. MID (STR, LEN, POS) means: Retrieve LEN characters from the STR string beginning with the character at position POS. Example in IL: LD
'SUSI'
MID
2,2
ST
VarSTRING1
(* Ergebnis ist 'US' *)
Example in FBD:
Example in ST: VarSTRING1 := MID ('SUSI',2,2); Please Note: String functions are not 'thread safe': When using tasks, string functions may only be used in a single task. If the same function is used in different tasks, there is a danger of overwriting.
CONCAT Concatenation (combination) of two strings. The input variables STR1 and STR2 as well as the return value of the function are type STRING. Example in IL:
10-40
CoDeSys V2.3
Appendix D: CoDeSys Libraries
LD
'SUSI'
CONCAT
'WILLI'
ST
VarSTRING1
(* Ergebnis ist 'SUSIWILLI' *)
Example in FBD:
Example in ST: VarSTRING1 := CONCAT ('SUSI','WILLI'); Please Note: The CONCAT function does not work, if nested over more than five levels. Please Note: String functions are not 'thread safe': When using tasks, string functions may only be used in a single task. If the same function is used in different tasks, there is a danger of overwriting.
INSERT INSERT inserts a string into another string at a defined point. The input variables STR1 and STR2 are type STRING, POS is type INT and the return value of the function is type STRING. INSERT(STR1, STR2, POS) means: insert STR2 into STR1 after position POS. Example in IL: LD
'SUSI'
INSERT
'XY',2
ST
VarSTRING1
(* Ergebnis ist 'SUXYSI' *)
Example in FBD:
Example in ST: VarSTRING1 := INSERT ('SUSI','XY',2); Please Note: String functions are not 'thread safe': When using tasks, string functions may only be used in a single task. If the same function is used in different tasks, there is a danger of overwriting.
DELETE DELETE removes a partial string from a larger string at a defined position. The input variable STR is type STRING, LEN and POS are type INT, the return value of the function is type STRING. DELETE(S TR, L, P) means: Delete L characters from STR beginning with the character in the P position. Example in IL: LD
'SUXYSI'
DELETE
2,23
ST
Var1
CoDeSys V2.3
(* Ergebnis ist 'SUSI' *)
10-41
The Standard.lib library
Example in FBD:
Example in ST: Var1 := DELETE ('SUXYSI',2,3); Please Note: String functions are not 'thread safe': When using tasks, string functions may only be used in a single task. If the same function is used in different tasks, there is a danger of overwriting.
REPLACE REPLACE replaces a partial string from a larger string with a third string. The input variable STR1 and STR2 are type STRING, LEN and POS are type INT, the return value of the function is type STRING. REPLACE(STR1, STR2, L, P) means: Replace L characters from STR1 with STR2 beginning with the character in the P position. Example in IL: LD
'SUXYSI'
REPLACE
'K', 2,2
ST
VarSTRING1
(* Ergebnis ist 'SKYSI' *)
Example in FBD:
Example in ST: VarSTRING1 := REPLACE ('SUXYSI','K',2,2); Please Note: String functions are not 'thread safe': When using tasks, string functions may only be used in a single task. If the same function is used in different tasks, there is a danger of overwriting.
FIND FIND searches for a partial string within a string. The input variable STR1 and STR2 are type STRING, the return value of the function is type STRING. FIND(STR1, STR2) means: Find the position of the first character where STR2 appears in STR1 for the first time. If STR2 is not found in STR1, then OUT:=0. Example in IL:
10-42
LD
'SUXYSI'
FIND
'XY'
ST
VarINT1
(* Ergebnis ist '3' *)
CoDeSys V2.3
Appendix D: CoDeSys Libraries
Example in FBD:
Example in ST: arINT1 := FIND ('SUXYSI','XY'); Please Note: String functions are not 'thread safe': When using tasks, string functions may only be used in a single task. If the same function is used in different tasks, there is a danger of overwriting.
10.16.2 Bistable Function Blocks.. SR Making Bistable Function Blocks Dominant: Q1 = SR (SET1, RESET) means: Q1 = (NOT RESET AND Q1) OR SET1 The input variables SET1 and RESET as well as the output variable Q1 are type BOOL. Declaration example: SRInst : SR ; Example in IL: CAL
SRInst(SET1 := VarBOOL1, RESET := VarBOOL2)
LD
SRInst.Q1
ST
VarBOOL3
Example in FBD:
Example in ST: SRInst(SET1:= VarBOOL1 , RESET:=VarBOOL2 ); VarBOOL3 := SRInst.Q1 ; RS Resetting Bistable Function Blocks Q1 = RS (SET, RESET1) means: Q1 = NOT RESET1 AND (Q1 OR SET) The input variables SET and RESET1 as well as the output variable Q1 are type BOOL. Declaration example: RSInst : RS ; Example in IL: CAL
RSInst(SET := VarBOOL1, RESET1 := VarBOOL2)
LD
RSInst.Q1
CoDeSys V2.3
10-43
The Standard.lib library
ST
VarBOOL3
Example in FBD:
Example in ST: RSInst(SET:= VarBOOL1 , RESET1:=VarBOOL2 ); VarBOOL3 := RSInst.Q1 ; SEMA A Software Semaphore (Interruptible) BUSY = SEMA(CLAIM, RELEASE) means: BUSY := X; IF CLAIM THEN X:=TRUE; ELSE IF RELEASE THEN BUSY := FALSE; X:= FALSE; END_IF X is an internal BOOL variable that is FALSE when it is initialized. The input variables CLAIM and RELEASE as well as the output variable BUSY are type BOOL. If BUSY is TRUE when SEMA is called up, this means that a value has already been assigned to SEMA (SEMA was called up with CLAIM = TRUE). If BUSY is FALSE, SEMA has not yet been called up or it has been released (called up with RELEASE = TRUE). Declaration example: SEMAInst : SEMA ; Example in IL: CAL
SEMAInst(CLAIM := VarBOOL1, RELEASE := VarBOOL2)
LD
SEMAInst.BUSY
ST
VarBOOL3
Example in FBD:
Example in ST: SEMAInst(CLAIM:= VarBOOL1 , RELEASE:=VarBOOL2 ); VarBOOL3 := SEMAInst.BUSY;
10.16.3 Trigger.. R_TRIG The function block R_TRIG detects a rising edge. FUNCTION_BLOCK R_TRIG VAR_INPUT
10-44
CoDeSys V2.3
Appendix D: CoDeSys Libraries
CLK : BOOL; END_VAR VAR_OUTPUT Q : BOOL; END_VAR VAR M : BOOL := FALSE; END_VAR Q0 := CLK AND NOT M; M := CLK; END_FUNCTION_BLOCK The output Q0 and the help variable M will remain FALSE as long as the input variable CLK is FALSE. As soon as S1 returns TRUE, Q will first return TRUE, then M will be set to TRUE. This means each time the function is called up, Q will return FALSE until CLK has falling edge followed by an rising edge. Declaration example: RTRIGInst : R_TRIG ; Example in IL: CAL
RTRIGInst(CLK := VarBOOL1)
LD
RTRIGInst.Q
ST
VarBOOL2
Example in FBD:
Example in ST: RTRIGInst(CLK:= VarBOOL1); VarBOOL2 := RTRIGInst.Q; F_TRIG The function block F_TRIG a falling edge. FUNCTION_BLOCK F_TRIG VAR_INPUT CLK: BOOL; END_VAR VAR_OUTPUT Q: BOOL; END_VAR VAR M: BOOL := FALSE; END_VAR
CoDeSys V2.3
10-45
The Standard.lib library
Q := NOT CLK AND NOT M; M := NOT CLK; END_FUNCTION_BLOCK The output Q and the help variable M will remain FALSE as long as the input variable CLK returns TRUE. As soon as CLK returns FALSE, Q will first return TRUE, then M will be set to TRUE. This means each time the function is called up, Q will return FALSE until CLK has a rising followed by a falling edge. Declaration example: FTRIGInst : F_TRIG ; Example in IL: CAL
FTRIGInst(CLK := VarBOOL1)
LD
FTRIGInst.Q
ST
VarBOOL2
Example in FBD:
Example in ST: FTRIGInst(CLK:= VarBOOL1); VarBOOL2 := FTRIGInst.Q;
10.16.4 Counter.. CTU The function block Incrementer: The input variables CU and RESET as well as the output variable Q are type BOOL, the input variable PV and the output variable CV are type INT. The counter variable CV will be initialized with 0 if RESET is TRUE. If CU has a rising edge from FALSE to TRUE, CV will be raised by 1.Q will return TR UE when CV is greater than or equal to the upper limit PV. Declaration example: CTUInst : CTU ; Example in IL:
10-46
CAL
CTUInst(CU := VarBOOL1, RESET := VarBOOL2, PV := VarINT1)
LD
CTUInst.Q
ST
VarBOOL3
LD
CTUInst.CV
ST
VarINT2
CoDeSys V2.3
Appendix D: CoDeSys Libraries
Example in FBD:
Example in ST: CTUInst(CU:= VarBOOL1, RESET:=VarBOOL2 , PV:= VarINT1); VarBOOL3 := CTUInst.Q ; VarINT2 := CTUInst.CV; CTD Function Block Decrementer: The input variables CD and LOAD as well as the output variable Q are type BOOL, the input variable PV and the output variable CV are type INT. When LOAD_ is TRUE, the counter variable CV will be initialized with the upper limit PV. If CD has a rising edge from FALSE to TRUE, CV will be lowered by 1 provided CV is greater than 0 (i.e., it doesn't cause the value to fall below 0). Q returns TRUE when CVis equal 0. Declaration example: CTDInst : CTD ; Example in IL: CAL
CTDInst(CD := VarBOOL1, LOAD := VarBOOL2, PV := VarINT1)
LD
CTDInst.Q
ST
VarBOOL3
LD
CTDInst.CV
ST
VarINT2
Example in FBD:
Example in ST: CTDInst(CD:= VarBOOL1, LOAD:=VarBOOL2 , PV:= VarINT1); VarBOOL3 := CTDInst.Q ; VarINT2 := CTDInst.CV;
CoDeSys V2.3
10-47
The Standard.lib library
CTUD Function Block Incrementer/Decrementer The input variables CU, CD, RESET, LOAD as well as the output variables QU and QD are type BOOL, PV and CV are type INT. If RESET is valid, the counter variable CV will be initialized with 0. If LOAD is valid, CV will be initialized with PV. If CU has a rising edge from FALSE to TRUE, CV will be raised by 1. If CD has a rising edge from FALSE to TRUE, CV will be lowered by 1 provided this does not cause the value to fall below 0. QU returns TRUE when CV has become greater than or equal to PV. QD returns TRUE when CV has become equal to 0. Declaration example: CTUDInst : CUTD ; Example in IL: CAL
CTUDInst(CU := VarBOOL2, RESET := VarBOOL3, LOAD := VarBOOL4, PV := VarINT1)
LD
CTUDInst.QU
ST
VarBOOL5
LD
CTUDInst.QD
ST
VarBOOL6
LD
CTUDInst.CV
ST
VarINT2
Example in FBD:
Example in ST: CTUDInst(CU := VarBOOL1, CU:= VarBOOL2, RESET := VarBOOL3, LOAD:=VarBOOL4 , PV:= VarINT1); VarBOOL5 := CTUDInst.QU ; VarBOOL6 := CTUDInst.QD ; VarINT2 := CTUDInst.CV;
10.16.5 Timer.. TP The function blockTimer is a trigger. TP(IN, PT, Q, ET) means: IN and PT are input variables of the BOOL and TIME types respectively. Q and ET are output variables of the BOOL and TIME types respectively. If IN is FALSE, Q is FALSE and ET is 0.
10-48
CoDeSys V2.3
Appendix D: CoDeSys Libraries
As soon as IN becomes TRUE, the time will begin to be counted in milliseconds in ET until its value is equal to PT. It will then remain constant. Q is TRUE if IN is TRUE and ET is less than or equal to PT. Otherwise it is FALSE. Q returns a signal for the time period given in PT. Graphic Display of the TP Time Sequence
Declaration example: TPInst : TP ; Example in IL: CAL
TPInst(IN := VarBOOL1, PT := T#5s)
LD
TPInst.Q
ST
VarBOOL2
Example in FBD:
Example in ST: TPInst(IN := VarBOOL1, PT:= T#5s); VarBOOL2 :=TPInst.Q; TON The function block Timer On Delay implements a turn-on delay. TON(IN, PT, Q, ET) means: IN and PT are input variables of the BOOL and TIME types respectively. Q and ET are output variables of the BOOL and TIME types respectively. If IN is FALSE, Q is FALSE and ET is 0. As soon as IN becomes TRUE, the time will begin to be counted in milliseconds in ET until its value is equal to PT. It will then remain constant. Q is TRUE when IN is TRUE and ET is equal to PT. Otherwise it is FALSE. Thus, Q has a rising edge when the time indicated in PT in milliseconds has run out. Graphic display of TON behavior over time:
CoDeSys V2.3
10-49
The Standard.lib library
Declaration example: TONInst : TON ; Example in IL: CAL
TONInst(IN := VarBOOL1, PT := T#5s)
LD
TONInst.Q
ST
VarBOOL2
Example in FBD:
Example in ST: TONInst(IN := VarBOOL1, PT:= T#5s); TOF The function block TOF implements a turn-off delay. TOF(IN, PT, Q, ET) means: IN and PT are input variables type BOOL respectively TIME. Q and E are output variabls type BOOL respectively TIME. If IN is TRUE, the outputs are TRU respectively 0. As soon as IN becomes FALSE, in ET the time will begin to be counted in milliseconds in ET until its value is equal to PT. It will then remain constant. Q is FALSE when IN is FALSE und ET equal PT. Otherwise it is TRUE. Thus, Q has a falling edge when the time indicated in PT in milliseconds has run out. Graphic display of TOF behavior over time:
10-50
CoDeSys V2.3
Appendix D: CoDeSys Libraries
Declaration example: TOFInst : TOF ; Example in IL: CAL
TOFInst(IN := VarBOOL1, PT := T#5s)
LD
TOFInst.Q
ST
VarBOOL2
Example in FBD:
Example in ST: TOFInst(IN := VarBOOL1, PT:= T#5s); VarBOOL2 :=TOFInst.Q; RTC The function block Runtime Clock returns, starting at a given time, the current date and time.
RTC(EN, PDT, Q, CDT) means: EN and PDT are input variables type TIME. Q and CDT are output variables type BOOL respectively DATE_AND_TIME. When EN is FALSE, the output variables Q und CDT are FALSE respectively DT#1970-01-01-00:00:00. As soon as EN becomes TRUE, the time of PDT is set, is counted up in seconds and returned in CDT as long as EN is TRUE (see example in the picture above). As soon as EN is reset to FALSE, CDT is reset to the initial value DT#1970-01-01-00:00:00. Please note that the time in PDT is only set by a rising edge.
10.17 The Util.lib library This library contains an additional collection of various blocks which can be used for BCD conversion, bit/byte functions, mathematical auxiliary functions, as controller, signal generators, function manipulators and for analogue value processing. As some of the functions and function blocks contain REAL variables, an accessory library named UTIL_NO_REAL exists in which these POUs are excluded.
10.17.1 BCD Conversion A byte in the BCD format contains integers between 0 and 99. Four bits are used for each decimal place. The ten decimal place is stored in the bits 4-7. Thus the BCD format is similar to the hexadecimal presentation, with the simple difference that only values between 0 and 99 can be stored in a BCD byte, whereas a hexadecimal byte reaches from 0 to FF. An example: The integer 51 should be converted to BCD format. 5 in binary is 0101, 1 in binary is 0001, which makes the BCD byte 01010001, which corresponds to the value $51=81.
CoDeSys V2.3
10-51
The Util.lib library
BCD_TO_INT This function converts a byte in BCD format into an INT value: The input value of the function is type BYTE and the output is type INT. Where a byte should be converted which is not in the BCD format the output is -1. Examples in ST: i:=BCD_TO_INT(73); (* Result is 49 *) k:=BCD_TO_INT(151); (* Result is 97 *) l:=BCD_TO_INT(15); (* Output -1, because it is not in BCD format *) INT_TO_BCD_ This function converts an INTEGER value into a byte in BCD format: The input value of the function is type INT, the output is type BYTE. The number 255 will be outputted where an INTEGER value should be converted which cannot be converted into a BCD byte. Examples in ST: i:=INT_TO_BCD(49); (* Result is 73 *) k:=BCD_TO_INT(97); (* Result is 151 *) l:=BCD_TO_INT(100); (* Error! Output: 255 *)
10.17.2 Bit-/Byte Functions EXTRACT Inputs to this function are a DWORD X, as well as a BYTE N. The output is a BOOL value, which th contains the content of the N bit of the input X, whereby the function begins to count from the zero bit. Examples in ST: FLAG:=EXTRACT(X:=81, N:=4); (* Result : TRUE, because 81 is binary 1010001, so the 4th bit is 1 *) FLAG:=EXTRACT(X:=33, N:=0); (* Result : TRUE, because 33 is binary 100001, so the bit '0' is 1 *) PACK This function is capable of delivering back eight input bits B0, B1, .., B7 from type BOOL as a BYTE. The function block UNPACK is closely related to this function. PUTBIT The input to this function consists of a DWORD X, a BYTE N and a BOOLean value B. th
PUTBIT sets the N bit from X on the value B, whereby it starts counting from the zero bit. Example in ST: A:=38;
(* binary 100110 *)
B:=PUTBIT(A,4,TRUE); (* Result : 54 = 2#110110 *) C:=PUTBIT(A,1,FALSE); (* Result : 36 = 2#100100 *) UNPACK UNPACK converts the input B from type BYTE into 8 output variables B0,..,B7 of the type BOOL, and this is the opposite to PACK.
10-52
CoDeSys V2.3
Appendix D: CoDeSys Libraries
Example in FBD: Output:
10.17.3 Mathematic Auxiliary Functions DERIVATIVE This function block approximately determines the local derivation. The function value is delivered as a REAL variable by using IN. TM contains the time which has passed in msec in a DWORD and the input of RESET of the type BOOL allows the function block to start anew through the delivery of the value TRUE. The output OUT is of the type REAL. In order to obtain the best possible result, DERIVATIVE approximates using the last four values, in order to hold errors which are produced by inaccuracies in the input parameters as low as possible. Block in FBD:
INTEGRAL This function block approximately determines the integral of the function. In an analogue fashion to DERIVATIVE, the function value is delivered as a REAL variable by using IN. TM contains the time which has passed in msec in a DWORD and the input of RESET of the type BOOL allows the function block to start anew with the value TRUE. The output OUT is of the type REAL. The integral is approximated by two step functions. The average of these is delivered as the approximated integral. Block in FBD: Example: Integration of a linear function:
STATISTICS_INT This function block calculates some standard statistical values:
CoDeSys V2.3
10-53
The Util.lib library
The input IN is of the type INT. All values are initialised anew when the BOOLean input RESET is TRUE. The output MN contains the minimum, MX of the maximum value from IN. AVG describes the average, that is the expected value of IN. All three outputs are of the type INT. Block in FBD:
STATISTICS_REAL This function block corresponds to STATISTICS_INT, except that the input IN is of the type REAL like the outputs MN, MX, AVG. VARIANCE VARIANCE calculates the variance of the entered values. The input IN is of the type REAL, RESET is of the type BOOL and the output OUT is again of the type REAL. This block calculates the variance of the inputted values. VARIANCE can be reset with RESET=TRUE. The standard deviation can easily be calculated as the square root of the VARIANCE.
10.17.4 Controllers PD The PD controller function block:
ACTUAL (actual value) and DESIRED (desired or nominal value) as well as KP, the proportionality coefficient, are all input values of the type REAL. TV is of the type DWORD and contains the derivative action time in msec. Y_OFFSET, Y_MIN and Y_MAX are of type REAL and are used for the transformation of the manipulated variable within a prescribed range. MANUAL, of type BOOL, switches to manual operation. RESET is of the type BOOL and serves to reset the controller. Y = KP ⋅ (∆ + TV δ∆/ δt) + Y_OFFSET whereby ∆=SET_POINT-ACTUAL Y is also limited to the allowed range between Y_MIN and Y_MAX. If Y exceeds this range, LIMITS_ACTVE, a BOOLean output variable, becomes TRUE. If no limitation of the manipulated variable is desired, Y_MIN and Y_MAX are set to 0. If MANUAL is TRUE, then the regulator is suspended , that is Y is not altered (by the controller), until MANUAL becomes FALSE, whereby the controller is re-initialized.
10-54
CoDeSys V2.3
Appendix D: CoDeSys Libraries
A P-controller is easily generated by setting TV to a fixed value of 0. PID The PID controller function block:
Unlike the PD controller, this function block contains a further DWORD input TN for the readjusting time in msec. The output, the manipulated variable (Y) is again of type REAL, and contains, unlike the PD controller, an additional integral part: Y = KP ⋅ (∆ + 1/TN ?∆(t)dt + TV δ∆/ δt) + Y_OFFSET The PID controller can be easily converted to a PI controller by setting TV=0. Because of the additional integral part, an overflow can come about by incorrect parameterization of the controller, if the integral of the error ∆ becomes too great. Therefore for the sake of safety a BOOLean output called OVERFLOW is present, which in this case would have the value TRUE. At the same time, the controller is suspended and will only be activated again by re-initialization.
10.17.5 Signal Generators.. BLINK The function block BLINK generates a pulsating signal. The input consists of ENABLE of the type BOOL, as well as TIMELOW and TIMEHIGH of the type TIME. The output OUT is of the type BOOL. If ENABLE is set to TRUE, BLINK begins, to set the output for the time period TIMEHIGH to TRUE, and then afterwards to set it for the time period TIMELOW to FALSE. Example in CFC:
GEN The function generator generates typical periodic functions: The inputs are a composition consisting of MODE from the pre-defined counting type GEN_MODE, BASE of the type BOOL, PERIOD of the type TIME, of two INT values CYCLES and AMPLITUDE and of the BOOLean RESET input. The MODE describes the function which should be generated, whereby the enumeration values TRIANGLE and TRIANGLE_POS deliver two triangular functions, SAWTOOTH_RISE an ascending,
CoDeSys V2.3
10-55
The Util.lib library
SAWTOOTH_FALL a descending sawtooth, RECTANGLE a rectangular signal and SINE and COSINE the sine and cosine:
TRIANGLE:
TRIANGLE_POS:
SAWTOOTH_RISE:
SAWTOOTH_FALL:
RECTANGLE:
SINUS:
COSINUS:
BASE defines whether the cycle period is really related to a defined time (BASE=TRUE) or whether it is related to a particular number of cycles, which means the number of calls of function block (BASE=FALSE). PERIOD or CYCLES defines the corresponding cycle period. AMPLITUDE defines, in a trivial way, the amplitude of the function to be generated. The function generator is again set to 0 as soon as RESET=TRUE. Example in FBD:
10.17.6 Function Manipulators.. CHARCURVE This function block serves to represent values, piece by piece, on a linear function:
10-56
CoDeSys V2.3
Appendix D: CoDeSys Libraries
IN of the type INT is fed with the value to be manipulated. The BYTE N designates the number of points which defines the presentation function. This characteristic line is then generated in an ARRAY P[0.10] with P of the type POINT which is a structure based on two INT values (X and Y). The output consists of OUT of the type INT, the manipulated value and BYTE ERR, which will indicate an error if necessary. The points P[0].P[N-1] in the ARRAY must be sorted according to their X values, otherwise ERR receives the value 1. If the input IN is not between P[0].X and P[N-1].X, ERR=2 and OUT contains the corresponding limiting value P[0]. Y or P[N-1].Y. If N lies outside of the allowed values which are between 2 and 11, then ERR=4. Example in ST: First of all ARRAY P must be defined in the header: VAR .. CHARACTERISTIC_LINE:CHARCURVE; KL:ARRAY[0.10] OF POINT:=(X:=0,Y:=0),(X:=250,Y:=50), (X:=500,Y:=150),(X:=750,Y:=400),7((X:=1000,Y:=1000)); COUNTER:INT; .. END_VAR Then we supply CHARCURVE with for example a constantly increasing value: COUNTER:=COUNTER+10; CHARACTERISTIC_LINE(IN:=COUNTER,N:=5,P:=KL); The subsequent tracing illustrates the effect:
RAMP_INT RAMP_INT serves to limit the ascendance or descendance of the function being fed: The input consists on the one hand out of three INT values: IN, the function input, and ASCEND and DESCEND, the maximum increase or decrease for a given time interval, which is defined by TIMEBASE of the type TIME. Setting RESET to TRUE causes RAMP_INT to be initialised anew. The output OUT of the type INT contains the ascend and descend limited function value. When TIMEBASE is set to t#0s, ASCEND and DESCEND are not related to the time interval, but remain the same. Beispiel in CFC:
CoDeSys V2.3
10-57
The Util.lib library
RAMP_REAL RAMP_REAL functions in the same way as RAMP_INT, with the simple difference that the inputs IN, ASCEND, DESCEND and the output OUT are of the type REAL.
10.17.7 Analog Value Processing.. HYSTERESIS The input to this function block consists of three INT values IN, HIGH and LOW. The output OUT is of the type BOOL.
If IN goes below the limiting value LOW, OUT becomes TRUE. If IN goes over the upper limit HIGH, FALSE is delivered. An illustrative example:
LIMITALARM This function block specifies, whether the input value is within a set range and which limits it has violated if it has done so. The input values IN, HIGH and LOW are each of the type INT, while the outputs O, U and IL are of the type BOOL.
10-58
CoDeSys V2.3
Appendix D: CoDeSys Libraries
If the upper limit HIGH is exceeded by IN, O becomes TRUE, and when IN is below LOW, U becomes TRUE. IL is TRUE if IN lies between LOW and HIGH. Example in FBD: Result:
10.18 AnalyzationNew.lib library This library provides modules for the analysis of expressions. If a composed expression is FALSE, those of its components can be evaluated which are adding to this result. In the SFC-Editor the flag SFCErrorAnalyzationTable (see chapter 2.2.3) uses this function implicitely for the analysis of expressions in transitions. Example of an expression: b OR NOT(y < x) OR NOT (NOT d AND e) The functions: The following variables are used by all modules: InputExpr: BOOL, expression to be analysed DoAnalyze: BOOL, TRUE starts analysis ExpResult: BOOL, current value of the expression
Different for the particular analyse modules is the output of the result of the analyzation: 1. AnalyzeExpression returns in a string the components of the expression, which are adding to the total value FALSE. Function AppendErrorString is used for this purpose, separating the particular components in the output string by ' ' characters. OutString: STRING, Result of the analysis, Sequence of the concerned components of the expression (e.g. y < x d) 2. AnalyseExpressionTable writes the components of the expression, which are adding to the total value FALSE, to an array. For each component the following information is provided by structure ExpressionResult: name, address, comment, (current)value. OutTable: ARRAY [0.15] OF ExpressionResult; e.g.
3. AnalyseExpressionCombined AnalyseExpressionTable.
CoDeSys V2.3
combines
the
functionalities
of
AnalyzeExpression
plus
10-59
The CoDeSys System Libraries
10.19 The CoDeSys System Libraries Target specifically various CoDeSys System Libraries are available. See an overview and descriptions in the documents folder in the CoDeSys installation directory on your computer.
10-60
CoDeSys V2.3
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.
N
for 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.
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 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
and
Type
in
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
CAL prog1
CN
Call program prog1
CAL inst1
CN
Call function block instance inst1
(vx, vy,.)
vx, vy
CN
Call function fctname and transmit variables vx, vy
RETURN
RET
CN
Leave POU and go back to caller
CoDeSys V2.3
a
10-61
The CoDeSys System Libraries
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
+
ADD
(
Addition
-
SUB
(
Subtraction
*
MUL
(
Multiplication
/
DIV
(
Division
>
GT
(
Greater than
>=
GE
(
Greater or equal
=
EQ
(
Equal
NE
(
Not equal
the POU name is 'GLOBAL_1', the object type is 'GVL' (global variables list) : Replace by a comment text (embraced by single quotation marks), which will be stored in the version history with the particular action.
Commands to configurate the project data base link via the ENI Server: eni on eni off
The option 'Use source control (ENI)' will be activated resp. deactivated (Dialog 'Project' 'Options' 'Project source control')
eni project readonly on eni project readonly off
The option 'Read only' for the data base category 'Project objects' will be activated resp. deactivated (Dialog 'Project' 'Options' 'Project objects')
eni shared readonly on eni shared readonly off
The option 'Read only' für die Datenbank-for the data base category 'Shard objects' will be activated resp. deactivated (Dialog 'Project' 'Options' 'Shared objects')
eni set local The object will be assigned to category 'Local', i.e. it will not be
stored in the project data base (Dialog 'Project' 'Object' 'Properties' 'Data base-connection') eni set shared
The object will be assigned to category 'Shared objects' (Dialog 'Project' 'Object' 'Properties' 'Data base-connection')
eni set project
The object will be assigned to category 'Project objects' (Dialog 'Project' 'Object' 'Properties' 'Data base-connection')
eni server Configures the connection to the ENI Server for the category 'Project objects' (Dialog 'Project' 'Options' 'Project data base');
Example: eni project server EniBatch Batch
localhost
80
batchtestproject
(TCP/IP-Address = localhost, Port = 80, Project name = batchtestproject, User name = EniBatch, Password = Batch) eni compile sym on eni compile sym off
CoDeSys V2.3
The option 'Create ASCII symbol information (.sym)' for the objects of category 'Compile files' will be activated/deactivated (Dialog 'Project' 'Options' 'Project source control' 'ENI settings' for
10-71
Command File (cmdfile) Commands
'Compile files') eni compile sdb on eni compile sdb off
The option 'Create binary symbol information (.sym)' for the objects of category 'Compile files' will be activated/deactivated (Dialog 'Project' 'Options' 'Project source control' 'ENI settings' for 'Compile files')
eni compile prg on eni compile prg off
The option 'Create boot project' for the objects of category 'Compile files' will be activated/deactivated (Dialog 'Project' 'Options' 'Project source control' 'ENI settings' for 'Compile files')
Commands of the menu 'Project' 'Data Base Link' for working with the data base: eni set
The object gets assigned to the named data base category ('Define')
'eni set set : :
The objects which are listed separated by spaces will be assigned to the named data base category. ('Multiple Define') Example: 'eni set project pou:as_fub pou:st_prg' -> the objects (pou) as_fub and st_prg get assigned to category 'Project objects'
eni getall
The latest version of all objects of the named category will be called from the data base ('Get All Latest Versions')
'eni get : :
The objects of the named category, which are listed separated by spaces will be called from the data base. ('Multiple Define'). ('Get latest version') Example: 'eni project get pou:as_fub gvl:global_1' -> the POU as_fub.pou and the global variables list global_1.gvl will be called from the data base
eni checkoutall '
All objects of the named category will be checked out from the data base. The defined comment will be stored with the checkout-action in the version history.
eni checkout ' : :
All objects (Objecttype:POUname) which are listed separated by spaces will be checked out from the data base. The defined comment will be stored with the check-out-action in the version history for each particular object. Example: 'eni project checkout 'for working on xy' pou:as_fub gvl:global_1' -> The POU as_fub and the global variables list global_1 will be checked out and the comment 'for working on xy' will be stored with this action
10-72
eni checkinall '
All objects of the project, which are under source control in the project data base, will be checked in. The defined comment will be stored with the check-in-action.
eni checkin ' : :
All objects (Objecttype:POUname) which are listed separated by spaces will be checked in to the data base. The defined comment will be stored with the check-in-action in the version
CoDeSys V2.3
Appendix F: Command Line-/Command File
history for each particular object. (see above: check out) The defined comment will be stored with the check-in-action in the version history for each particular object.
Keywords for the command parameters: The following keywords, enclosed in '$', can be used in command parameters: $PROJECT_NAME$
Name of the current CoDeSys project (file name without extension '.pro', e.g. 'project_2.pro')
$PROJECT_PATH$
Path of the directory, where the current CoDeSys project file is (without indication of the drive and without a backslash at the end, e.g. 'projectssub1').
$PROJECT_DRIVE$ Drive, where the current CoDeSys project is (without backslash at the end, e.g. 'D:') $COMPILE_DIR$
Compile directory of the current CoDeSys project (with indiciation of the drive and without backslash at the end, e.g. 'D:codesyscompile')
$EXE_DIR$
Directory where the codesys.exe file is (with indication of the drive and without backslash at the end, e.g. D:codesys)
Example of a command file: A command file like shown below will open the project file ampel.pro, will then load a watch list, which was stored as w.wtc, will then start the application program and write – after 1 second delay - the values of the variables into the watch list watch.wtc (which will be saved) and will finally close the project. file open C:projectsCoDeSys_testampel.pro query off ok watchlist load c:workw.wtc online login online run delay 1000 watchlist read watchlist save $PROJECT_DRIVE$$PROJECT_PATH$w_update.wtc online logout file close
This command file will open the project ampel.pro, will load an existing watchlist w.wtc, will start the application program, after 1 second will write the variables values to the watch list w_update.wtc, which will be saved in the directory 'C:projectsCoDeSys_test' and then will close the project again.
A command file is called in a command line like shown here: ' /cmd '
CoDeSys V2.3
10-73
Appendix G: Siemens Import
Appendix G: Siemens Import In the 'Project' 'Siemens Import' submenu, you will find commands which allow you to import POUs and variables from Siemens STEP5 files. The command 'Import from a SEQ symbol file' allows you to import global variables from STEP5 symbol files. Run this command before either the command 'Import from a S5 project file' so that readable symbol names can be created when the POUs are imported. These two commands allow you to import POUs from STEP5 program files. When this done, the POUs are inserted into the open CoDeSys project. You can select whether the POUs will remain in the STEP5 IL language or be converted to an IEC language. We recommend that the CoDeSys project into which you are importing be empty. Of course, you must be certain that the library standard.lib is linked to your project, otherwise you will be unable to import the counter and the timer. Import from a SEQ Symbol File SEQ format is a common format for symbol files in a STEP5 project. Symbol assignments can be read from SEQ symbol files (*.seq). A symbol assignment contains an absolute address for a S5 program element (input, output, memory location, etc.), a corresponding symbol identifier and may also contain comments about the symbol. A SEQ file is text file that contains one assignment of this type per line. Each of the 'Fields' in the line are separated by Tabs. Also each line can only hold one comment which must begin with a semicolon. The symbol assignments in the SEQ file will be translated into global variable declarations based on IEC 61131-3. The symbolic name, the address and the comment (if available) will be transferred during this process. The address will be adapted to IEC 61131-3 (Percent sign, etc.). Since a S5 symbol name can contain characters that are not permitted in an IEC identifier, the names will be changed if necessary. Invalid characters will be replaced by the underscore character. Should there be more than one underscore character in a row, every second one would be replaced by a valid character (e.g., '0'). If a symbol name is changed during the conversion, the original name will be added in a comment after the change. SEQ comment lines will be transferred as comments. Multiple blocks of global variables can be created. Each block consists of less than 64K of text. The SEQ format described is used in Siemens STEP5-PG Software, in most versions of the Siemens STEP7-300/400 and in ACCON-PG from DELTALOGIC. This format is supported in STEP7-SEQ files created in version 3.x or better. STEP7 version 2.x can export a different SEQ format that is not supported. Instead of using separators (Tabs), it is based on a fixed length for the symbolic name and uses blanks if necessary. You first select the SEQ file in a standard Windows dialog box. Then perform the import, when this is done the global variable list will be compiled. Errors may arise during this process when STEP5/7 identifiers are converted into IEC61131-3 compatible identifiers. For example, both STEP5 identifiers 'A!' and 'A?' would be converted into the IEC identifier 'A_'. At this point the following message would appear, 'Multiple declarations with the same identifier A_'. Change one of the variables. Under absolutely no other circumstances should you make any changes to the global variable list. If you identify addresses that are valid in a Siemens PLC but are invalid in your Controller: Leave them alone for now, even if you get a thousand error messages while compiling. The addresses are needed exactly as they are in order to import the POUs. If the project into which you are importing already contains a declaration for a global variable x with its address (e.g., '%MX4.0'), you may find that the SEQ import contains a variable defined with the same address. This is allowed in IEC 61131-3 but is generally not in the best interest of the user. No error message will appear, but your program may not function as it should since the address will be used in different POUs with no contextual reference. To avoid this problem, it is best to import into an empty project or into a project in which no absolute addresses have been used up to this point. STEP5/7 Program Organization Units can be imported, once the SEQ import has been performed. You can also add the inputs and outputs that will be used in the PLC Configuration. These are not required for the STEP5/7 import but the addresses will be checked and may show up as errors when you rebuild the project.
CoDeSys V2.3
10-75
Command File (cmdfile) Commands
Import from a S5 Project File POUs can read from Siemens S5 program files (*.s5d). The code that it uses is MC5 Code that can be run by S5 SPS. In general, MC5 Code corresponds with the STEP5 Instruction List (without symbol names) with which the programmer is familiar. The S5D also contains the line comments from the STEP5 Instruction List. Since an S5D file contains only absolute addresses with no symbol names, CoDeSys searches for the symbol names among the current CoDeSys project variables. If none are found, the absolute address is left unchanged. Therefore, if you feel the symbol name is useful, import the SEQ file before the S5 file. You first select the S5D file in a standard Windows dialog box. Another box pops up which contains the list of POUs from which you can select. It is best to select all of them. You can also select to leave the POUs in the STEP5 IL language or to convert them to IL, LD or FBD. Symbol names will be used in place of absolute names as much as possible. If CoDeSys finds the instruction 'U M12.0' during the import, it will search for a global variable set at memory location M12.0. The first declaration that fits this description will be taken and the instruction will be imported as 'U-Name' instead of 'U M12.0' (the name of the identifier for the memory location is M12.0). At times additional variables may be needed during an import or code conversion. These additional variables will be declared globally. For example, R_TRIG instances are needed to reproduce edgetriggered inputs (e.g., in a S5 counter). Converting S5 to IEC 61131-3 If you select an IEC language as your target language for a STEP5 import, you must be aware that portions of your project cannot be converted into IEC 61131-3. If part of a S5 POU contains code that cannot be converted into IEC 61131-3, an error message will be generated and the critical portion of the original STEP5 IL code will be inserted as a comment in the IEC POU. You must then replace or rewrite this code. System commands that only function in a specific S5 CPU cannot be converted into IEC. The 'STEP5 Core Command List' can be converted into IEC code with a click of a button despite the fact that STEP5 is enormously different in the way it is conceived. The core command list that can be converted to IEC 61131-3 contains all commands that can be converted to LD or FBD in a STEP5 programming system and also all commands that are allowed in a STEP5-PB (Program Block). In addition, of the STEP5 commands allowed only in IL or in FB's (function blocks), the commands that can be converted to IEC are primarily those that are available in every S5 CPU (e.g., absolute and conditional jumps, shift commands, etc.) The only exception or limitation for conversion is related to resetting timers which can be done in STEP5 but not normally in IEC 61131-3. The individual convertible commands: U, UN, O, ON, S, R, = with the following bit operands: I (inputs), O (outputs), M (memory locations), S (S memory locations), D (Data in data blocks) U, UN, O, ON with the following operands: T (Timer), C (Counter) S, R with the following operands: C SU, RU, P, PN with the following operands: E, A, M, D O, O(, U(, ) L, T with the following operand ranges: E, A, M, D, T, C, P (Periphery) and operand sizes: B (byte), W (word), D (double word), L (left byte), R (right byte) L with the following constant formats: DH, KB, KF, KH, KM, KT, KZ, KY, KG, KC SI, SE, SA with the following operands: T ZV, ZR with the following operands: C +, -, X, : with the following operands: F (fixed point number), G (floating point number) +, - with the following operands: D (32 bit fixed point number) !=, >, =, -> . -> ' An instance of a functionblock is used, which calls itself. 3705 ': VAR_IN_OUT in Top-Level-POU not allowed, if there is no Task -Configuration' Create a task configuratin or make sure that there are no VAR_IN_OUT variables used in PLC_PRG. 3720 'Address expected after 'AT' Add a valid address after the keyword AT or modify the keyword. 3721 'Only 'VAR' and 'VAR_GLOBAL' can be located to addresses' Put the declaration to a VAR or VAR_GLOBAL declaration area. 3722 'Only 'BOOL' variables allowed on bit addresses' Modify the address or modify the type of the variable to which the address is assigned. 3726 'Constants can not be laid on direct addresses' Modify the address assignment correspondingly.
10-112
CoDeSys V2.3
Appendix J: Compiler Errors and Warnings
3727 'No array declaration allowed on this address' Modify the address assignment correspondingly. 3728 'Invalid address: '' This address is not supported by the PLC configuration. Check PLC configuration resp. modify address. 3729 'Invalid type ' at address: ' ' The type of this variable cannot be placed on the given address. Example: For a target system working with ‘alignment 2’ the following declaration is not valid: var1 AT %IB1:WORD; 3740 'Invalid type: ' ' An invalid data type is used in a variable declaration. 3741 'Expecting type specification' A keyword or an operator is used instead of a valid type identifier. 3742 'Enumeration value expected' In the definition of the enumeration type an identifier is missing after the opening bracket or after a comma between the brackets. 3743 'Integer number expected' Enumerations can only be initialized with numbers of type INT. 3744 'Enum constant ' already defined' Check if you have followed the following rules for the definition of enumeration values: •
Within one enum definition all values have to be unique.
•
Within all global enum definitions all values have to be unique.
•
Within all local enum definitions all values have to be unique.
3745 'Subranges are only allowed on Integers!' Subrange types can only be defined resting on integer data types. 3746 'Subrange ' is not compatible with Type '' One of the limits set for the range of the subrange type is out of the range which is valid for the base type.
CoDeSys V2.3
10-113
Errors
3747 'unknown string length: '' There is a not valid constant used for the definition of the string length. 3748 'More than three dimensions are not allowed for arrays' More than the allowed three dimensions are given in the definition of an array. If applicable use an ARRAY OF ARRAY. 3749 'lower bound ' not defined' There is a not defined constant used to define the lower limit for a subrange or array type. 3750 'upper bound ' not defined' There is a not defined constant used to define the upper limit for a subrange or array type. 3751 'Invalid string length '' The here defined string length exceeds the maximum value which is defined for the currently set target system. 3760 'Error in inital value' Use an initial value which corresponds to the type definition. To change the declaration you can use the declaration dialog for variables (Shift/F2 or 'Edit'Autodeclare'). 3761 'VAR_IN_OUT' variables must not have an inital value.' Remove the initialization at the declaration of the VAR_IN_OUT variable. 3780 'VAR', 'VAR_INPUT', 'VAR_OUTPUT' or 'VAR_IN_OUT' expected' The first line following the name of a POU must contain one of these keywords. 3781 'END_VAR' or identifier expected' Enter a valid identifier of a END_VAR at the beginning of the given line in the declaration window. 3782 'Unexpected end' In the declaration editor: Add keyword END_VAR at the end of the declaration part. In the texteditor of the programming part: Add an instruction which terminates the last instruction sequence (e.g. END_IF). 3783 'END_STRUCT' or identifier expected' Ensure that the type declaration is terminated correctly.
10-114
CoDeSys V2.3
Appendix J: Compiler Errors and Warnings
3784 'The current target doesn't support attribute ' The target system does not support this type of variables (e.g. RETAIN, PERSISTENT) 3800 'The global variables need too much memory. Increase the available memory in the project options.' Increase the number of segments given in the settings in dialog ‚Project’ ‚Options’ ‚Build’. 3801 'The variable ' is too big. ( byte)' The variable uses a type which is bigger than 1 data segment. The segment size is a target specific parameter and can be modified in the target settings/memory layout. If you do not find this in the current target settings, please contact your PLC manufacturer. 3802 'Out of retain memory. Variable ', bytes.' The memory space available for Retain variables is exhausted. The size of the memory area can be set target-specific in the target settings /memory layout. If you do not find the settings field in the dialog, please contact your PLC manfacturer. (Please regard: If retain variables are used in an function block instance, the complete instance POU will be stored in the retain memory area !) 3803 'Out of global data memory. Variable ', ‚’ bytes.' The memory space available for global variables is exhausted. Der verfügbare Speicherplatz für globale Variablen ist erschöpft. The size of the memory area can be set target-specific in the target settings /memory layout. If you do not find the settings field in the dialog, please contact your PLC manfacturer. 3820 'VAR_OUTPUT' and 'VAR_IN_OUT' not allowed in functions' In a function no output or in_output variables may be defined. 3821 'At least one input required for functions' Add at least on input parameter for the function. 3840 'Unknown global variable '!' In the POU a VAR_EXTERNAL variable is used, for which no global variable declared. 3841 'Declaration of ' do not match global declaration!' The type given in the declaration of the VAR_EXTERNAL variable is not the same as that in the global declaration. 3900 'Multiple underlines in indentifier'Remove multiple underlines in the identifier name.
CoDeSys V2.3
10-115
Errors
3901 'At most 4 numerical fields allowed in addresses' There is a direct assignment to an address which has more than four levels. (e.g. %QB0.1.1.0.1). 3902 'Keywords must be uppercase' Use capital letters for the keyword or activate option ‚Autoformat’ in ‚Project’ ‚Options’. 3903 'Invalid duration constant' The notation of the constant does not comply with the IEC61131-3 format. 3904 'Overflow in duration constant' The value used for the time constant cannot be represented in the internal format. The maximum value which is representable is t#49d17h2m47s295ms. 3905 'Invalid date constant' The notation of the constant dies not comply with the IEC61131-3 format. 3906 'Invalid time of day constant' The notation of the constant dies not comply with the IEC61131-3 format. 3907 'Invalid date and time constant' The notation of the constant dies not comply with the IEC61131-3 format. 3908 'Invalid string constant' The string constant contains an invalid character. 4000 'Identifier expected' Enter a valid identifier at this position. 4001 'Variable ' not declared' Declare variable local or global. 4010 'Type mismatch: Cannot convert ' to '.' Check what data type the operator expects (Browse Online Help for name of operator) and change the type of the variable which has caused the error, or select another variable. 4011 'Type mismatch in parameter ' of ': Cannot convert ' to '.'
10-116
CoDeSys V2.3
Appendix J: Compiler Errors and Warnings
The data type of the actual parameter cannot be automatically converted to that of the formal parameter. Use a type conversion or use another variable type. 4012 'Type mismatch in parameter ' of ': Cannot convert ' to '.' A value with the invalid type is assigned to the input variable '. Replace the variable or constant to one of type or use a type conversion respectively a constant with type-prefix. 4013 'Type mismatch in output ' of ': Cannot convert ' to '.' A value with the invalid type is assigned to the output variable '. Replace the variable or constant to one of type or use a type conversion respectively a constant with type-prefix. 4014 'Typed literal: Cannot convert ' to '' The type of the constant is not compatible with the type of the prefix. Example: SINT#255 4015 'Data type ‘' illegal for direct bit access' Direct bit addressing is only allowed for Integer- and Bitstring datatypes. You are using a variable var1 of type Typ REAL/LREAL or a constant in bit access . 4016 'Bit index ' out of range for variable of type '' You are trying to access a bit which is not defined for the data type of the variable. 4017 'MOD' is not defined for 'REAL' The operator MOD can only be used for integer and bitstring data types. 4020 'Variable with write access or direct address required for 'ST', 'STN', 'S', 'R' Replace the first operand by a variable with write access. 4021 'No write access to variable '%s' allowed' Replace the variable by a variable with write access. 4022 'Operand expected' Add an operand behind the command. 4023 'Number expected after '+' or '-' Enter a digit.
CoDeSys V2.3
10-117
Errors
4024 'Expecting or or .. before '' Enter a valid operand at the named position. 4025 'Expecting ':=' or '=>' before '' Enter one of the both operators at the named position. 4026 'BITADR' expects a bit address or a variable on a bit address'Use a valid bit address (e.g. %IX0.1). 4027 'Integer number or symbolic constant expected' Enter a integer number or the identifier of a valid constant. 4028 'INI' operator needs function block instance or data unit type instance' Check the data type of the variable, for which the INI operator is used. 4029 'Nested calls of the same function are not possible.' At not reentrant target systems and in simulation mode a function call may not contain a call of itself as a parameter. Example: fun1(a,fun1(b,c,d),e); Use a intermediate table. 4030 'Expressions and constants are not allowed as operands of 'ADR' Replace the constant or the expression by a variable or a direct address. 4031 'ADR' is not allowed on bits! Use 'BITADR' instead.' Use BITADR. Please Note:
The BITADR function does not return a physical memory address.
4032 '’’ operands are too few for '. At least ‘’ are needed' Check how many operands the named operator requires and add the missing operands. 4033 '’’ operands are too many for '. At least ‘’ are needed' Check how many operands the named operator requires and remove the surplus operands. 4034 'Division by 0' You are using a division by 0 in a constant expression. If you want to provocate a runtime error, use – if applicable - a variable with the value 0.
10-118
CoDeSys V2.3
Appendix J: Compiler Errors and Warnings
4035 'ADR must not be applied on 'VAR CONSTANT' if 'replaced constants' is activated' An address access on constants for which the direct values are used, is not possible. If applicable, deactivate the option ‚Replace Constants’ in ‚Project’ ‚Options’ ‚Build’. 4040 'Label ' is not defined' Define a label with the name or change the name to that of a defined label. 4041 'Duplicate definition of label '' The label '< Name>' is multiple defined in the POU. Rename the label or remove one of the definitions. 4042 'No more than labels in sequence are allowed' The number of jump labels is limited to '. Insert a dummy instruction. 4043 'Format of label invalid. A label must be a name optionally followed by a colon.'The label name is not valid or the colon is missing in the definition. 4050 'POU '%s' is not defined' Define a POU with the name ' using the command ‘Project’ ‘Add Object’ or change ' to the name of a defined POU. 4051 '%s' is no function' Use instead of a function name which is defined in the project or in the libraries. 4052 '' must be a declared instance of FB '' Use an instance of data type ' which is defined in the project or change the type of to '. 4053 '' is no valid box or operator' Replace ' by the name of a POU or an operator defined in the project. 4054 'POU name expected as parameter of 'INDEXOF' The given paramter is not a valid POU name. 4060 'VAR_IN_OUT' parameter ' of ' needs variable with write access as input' To VAR_IN_OUT parameters variables with write access have to be handed over, because a VAR_IN_OUT can be modified within the POU.
CoDeSys V2.3
10-119
Errors
4061 'VAR_IN_OUT' parameter ' of ' must be used.' A VAR_IN_OUT parameter must get handed over a variable with write access, because a VAR_IN_OUT can be modified within the POU. 4062 'No external access to 'VAR_IN_OUT' parameter ' of '.' VAR_IN_OUT Parameter only may be written or read within the POU, because they are handed over by reference. 4063 'VAR_IN_OUT' parameter ' of ' must not be used with bit addresses.' A bit address is not a valid physical address. Hand over a variable or a direct non-bit address. 4064 'VAR_IN_OUT' must not be overwritten in local action call!' Delete the parameters set for the VAR_IN_OUT variable in the local action call. 4070 'The POU contains a too complex expression' Decrease nesting depth by dividing up the expression into several expressions. Use intermediate variables for this purpose. 4071 'Network too complex' Divide up the network into several networks. 4100 '^' needs a pointer type' You are trying to dereference a variable which is not declared as a pointer. 4110 '[]' needs array variable' [] is used for a variable which is not declared as an array with ARRAY OF. 4111 'Index expression of an array must be of type 'INT' Use an expression of the correct type or a type conversion. 4112 'Too many indexes for array' Check the number of indices (1, 2, oder 3), for which the array is declared and remove the surplus. 4113 'Too few indexes for array' Check the number of indices (1, 2, oder 3), for which the array is declared and add the missing ones.
10-120
CoDeSys V2.3
Appendix J: Compiler Errors and Warnings
4114 'One of the constant indizes is not within the array range' Make sure that the used indices are within the bounds of the array. 4120 '.' needs structure variable' The identifier on the left hand of the dot must be a variable of type STRUCT or FUNCTION_BLOCK or the name of a FUNCTION or a PROGRAM. 4121 ' ' is not a component of ' The component ' is not included in the definition of the object . 4122 '' is not an input variable of the called function block' Check the input variables of the called function block and change ‘' to one of these. 4200 'LD' expected' Insert at least one LD instruction after the jump label in the IL editor. 4201 'IL Operator expected' Each IL instruction must start with an operator or a jump label. 4202 'Unexpected end of text in brackets' Insert a closing bracket after the text. 4203 ' in brackets not allowed' The operator is not valid in a IL bracket expression. (not valid are: 'JMP', 'RET', 'CAL', 'LDN', 'LD', 'TIME') 4204 'Closing bracket with no corresponding opening bracket' Insert an opening bracket or remove the closing one. 4205 'No comma allowed after ')' Remove comma after closing bracket. 4206 'Label in brackets not allowed' Shift jump label so that it is outside of the brackets.
CoDeSys V2.3
10-121
Errors
4207 'N' modifier requires operand of type 'BOOL','BYTE','WORD' or 'DWORD' The N modifier requires a data type, for which a boolean negation can be executed. 4208 'Conditional Operator requires type 'BOOL'Make sure that the expression gives out a boolean result or use a type conversion. 4209 'Function name not allowed here' Replace the function call by a variable or a constant. 4210 'CAL', 'CALC' and 'CALN' require a function block instance as operand' Declare an instance of the function block which you want to call. 4211 'Comments are only allowed at the end of line in IL' Shift the comment to the end of the line or to an extra line. 4212 'Accumulator is invalid before conditional statement' The accu is not defined. This happens if an instruction is preceeding which does not submit a result (e.g. 'CAL'). 4213 'S' and 'R' require 'BOOL' operand' Use a boolean variable at this place. 4250 'Another 'ST' statement or end of POU expected'The line does not start with a valid ST instruction. 4251 'Too many parameters in function '%s' There are more parameters given than are declared in the definition of the function. 4252 'Too few parameters in function '%s' There are less parameters given than are declared in the definition of the function. 4253 'IF' or 'ELSIF' require 'BOOL' expression as condition' Make sure that the condition for IF or ELSIF is a boolean expression. 4254 'WHILE' requires 'BOOL' expression as condition' Make sure that the condition following the ‘WHILE’ is a boolean expression.
10-122
CoDeSys V2.3
Appendix J: Compiler Errors and Warnings
4255 'UNTIL' requires 'BOOL' expression as condition' Make sure that the condition following the ‘UNTIL’ is a boolean expression. 4256 'NOT' requires 'BOOL' operand' Make sure that the condition following the ‘NOT’ is a boolean expression. 4257 'Variable of 'FOR' statement must be of type 'INT' Make sure that the counter variable is of an integer or bitstring data type (e.g. DINT, DWORD). 4258 'Expression in 'FOR' statement is no variable with write access' Replace the counter variable by a variable with write access. 4259 'Start value in 'FOR' statement is no variable with write access' The start value in the ‚FOR' instruction must be compatible to the type of the counter variable. 4260 'End value of 'FOR' statement must be of type 'INT' The end value in the ‚FOR' instruction must be compatible to the type of the counter variable. 4261 'Increment value of 'FOR' statement must be of type 'INT' The incremental value in the ‚FOR' instruction must be compatible to the type of the counter variable. 4262 'EXIT' outside a loop' Use 'EXIT' only within 'FOR', 'WHILE' or 'UNTIL' instructions. 4263 'Expecting Number, 'ELSE' or 'END_CASE' Within a ‘CASE' expression you only can use a number or a 'ELSE' instruction or the ending instruction 'END_CASE'. 4264 'CASE' requires selector of an integer type' Make sure that the selector is of an integer or bitstring data type (e.g. DINT, DWORD). 4265 'Number expected after ',' In the enumeration of the CASE selectors there must be inserted a further selector after a comma. 4266 'At least one statement is required'
CoDeSys V2.3
10-123
Errors
Insert an instruction, at least a semicolon. 4267 'Function block call requires function block instance' The identifier in the functionblock call is no instance. Declare an instance of the desired functionblock or use the name of an already defined instance. 4268 'Expression expected' Insert an expression. 4269 'END_CASE' expected after 'ELSE' -branch' Terminate the 'CASE' instruction after the 'ELSE' part with an 'END_CASE'. 4270 'CASE' constant '%ld' already used' A 'CASE' selector may only be used once within a ‘CASE' instruction. 4271 'The lower border of the range is greater than the upper border.' Modify the area bounds for the selectors so that the lower border is not highte than the upper border. 4272 'Exptecting parameter ' at place in call of '!' You can edit a function call in that way, that also the parameter names are contained, not only the parameter values. But nevertheless the position (sequence) of the parameters must be the same as in the function definition. 4273 Parts of the 'CASE' -Range ' already used in Range ' Make sure that the areas for the selectors which are used in the CASE instruction, don’t overlap. 4274 'Multiple 'ELSE' branch in 'CASE' statement' A CASE instruction may not contain more than one ‚ELSE' instruction. 4300 'Jump requires 'BOOL' as input type' Make sure that the input for the jump respectively the RETURN instruction is a boolean expression. 4301 'POU ' need exactly inputs' The number of inputs does not correspond to the number of VAR_INPUT and VAR_IN_OUT variables which is given in the POU definition. 4302 'POU '%s' need exactly %d outputs'The number of outputs does not correspond to the number of VAR_OUTPUT variables which is given in the POU definition.
10-124
CoDeSys V2.3
Appendix J: Compiler Errors and Warnings
4303 '' is no operator' Replace ' by a valid operator. 4320 'Non-boolean expression ' used with contact' The switch signal for a contact must be a boolean expression. 4321 'Non-boolean expression ' used with coil' The output variable of a coil must be of type BOOL. 4330 'Expression expected at input 'EN' of the box ' ' Assign an input or an expression to the input EN of POU '’. 4331 'Expression expected at input ' of the box ' ' The input of the operator POU is not assigned. 4332 Expression expected at input ' of the box '' The input of the POU is of type VAR_IN_OUT and is not assigned. 4333 'Identifier in jump expected' The given jump mark is not a valid identifier. 4334 'Expression expected at the input of jump' Assign a boolean expression to the input of the jump. If this is TRUE, the jump will be executed. 4335 'Expression expected at the input of the return' Assign a boolean expression to the input of the RETURN instruction. If this is TRUE, the jump will be executed. 4336 'Expression expected at the input of the output' Assign a suitable expression to the output box. 4337 'Identifier for input expected' nsert a valid expression or identifier in the input box. 4338 'Box ' has no inputs'
CoDeSys V2.3
10-125
Errors
To none of the inputs of the operator POU ' a valid expression is assigned. 4339 'Typemismatch at output: Cannot convert ' to '. The type of the expression in the output box is not compatible to that of the expression which should be assigned to it. 4340 'Jump requires 'BOOL' as input type'Make sure that the input for the jump is a boolean expression. 4341 'Return needs a boolean input' Make sure that the input for the RETURN instruction is a boolean expression. 4342 'Expression expected at input 'EN' of the box '' Assign a valid boolean expression to the EN input of the box. 4343 'Values of Constants: ‘’' Input ' of box ' is declared as VAR_INPUT CONSTANT. But to this POU box an expression has been assigned in the dialog 'Edit Parameters' which is not type compatible. 4344 'S' and 'R' require 'BOOL' operand' Insert a valid boolean expression after the Set resp. Reset instruction. 4345 'Unzulässiger Typ für Parameter ' von ': Kann ' nicht in ' konvertieren.' An expression is assigned to input ' of POU box ' which is not type compatible. 4346 'Not allowed to use a constant as an output' You can only assign an output to a variable or a direct address with write access. 4347 'VAR_IN_OUT' parameter needs variable with write access as input' To VAR_IN_OUT parameters only variables with write access can be handed over, because these can be modified within the POU. 4350 'An SFC-Action can not be accessed from outside!' SFC actions only can be called within the SFC POU in which they are defined. 4351 'Step name is no identifier: '' Rename the step or choose a valid identifier as step name.
10-126
CoDeSys V2.3
Appendix J: Compiler Errors and Warnings
4352 'Extra characters following valid step name:'' Remove the not valid characters in the step name. 4353 'Step name duplicated: '' Rename one of the steps. 4354 'Jump to undefined Step: '' Choose an existent step name as aim of the jump resp. insert a step with name ‚’. 4355 'A transition must not have any side effects (Assignments, FB-Calls etc.)' A transition must be a boolean expression. 4356 'Jump without valid Step Name: ' ' Use a valid identifier as aim (mark) of the jump. 4357 'IEC-Library not found' Check whether the library iecsfc.lib is inserted in the library manager and whether the library paths defined in ‘Project’ ‘Options’ ‘Paths’are correct. 4358 'Action not declared: '' Make sure that in the object organizer the action of the IEC step is inserted below the SFC POU and that in the editor the action name is inserted in the box on the right hand of the qualifier. 4359 'Invalid Qualifier: '' In the box on the left hand of the action name enter a qualifier for the IEC action. 4360 'Time Constant expected after qualifier '' Enter next to the box on the left hand of the action name a time constant behind the qualifier. 4361 '%s' is not the name of an action' Enter next to the box on the right hand of the qualifier the name of an action or the name of a variable which is defined in the project. 4362 'Nonboolean expression used in action: '' Insert a boolean variable or a valid action name.
CoDeSys V2.3
10-127
Errors
4363 'IEC-Step name already used for variable: '' Please rename the step or the variable. 4364 'A transition must be a boolean expression' The result of the transition expression must be of type BOOL. 4365 'Time Constant expected after qualifier '' Open dialog ‚step attributes’ for the step ' and enter a valid time variable or time constant. 4366 'The label of the parallel branch is no valid identifier: '' Enter a valid identifier next to the triangle which marks the jump label. 4367 'The label ' is already used' There is already a jump label or a step with this name. Please rename correspondingly. 4368 'Action ' is used in multiple step chains, where one is containing the other!' The action ' is used in the POU as well as in one or several actions of the POU. 4369 'Exactly one network requried for a transition' There are used several FBD resp. LD networks for a transition. Please reduce to 1 network. 4370 'Additional lines found after correct IL-transition' Remove the not needed lines at the end of the transition. 4371 'Invalid characters following valid expression: ' Remove the not needed characters at the end of the transition. 4372 'Step ': Time limit needs type 'TIME' Define the time limits of the step in the step attributes by using a variable of type TIME or by a time definition in correct format (e.g 't#200ms'). 4373 'IEC-actions are only allowed with SFC-POUs' There is an action assigned to a non-SFC-POU (see in the Object Organizer), which is programmed in SFC and which contains IEC actions. Replace this action by one which contains no IEC actions. 4374 'Step expected instead of transition ''
10-128
CoDeSys V2.3
Appendix J: Compiler Errors and Warnings
The SFC POU is corrupt, possibly due to any export-import actions. 4375 'Transition expected instead of step '' The SFC POU is corrupt, possibly due to any export-import actions. 4376 'Step expected after transition '' The SFC POU is corrupt, possibly due to any export-import actions. 4377 'Transition expected after step '' The SFC POU is corrupt, possibly due to any export-import actions. 4400 Import / conversion of POU ' contains errors resp. is not complete.' The POU cannot be converted to IEC 61131-3 completely. 4401 'S5 time constant seconds is too big (max. 9990s).' There is no valid BCD coded time in the accu. 4402 'Direct access only allowed on I/Os.' Make sure that you only access variables which are defined as input or output. 4403 'STEP5/7 instruction invalid or not convertible to IEC 61131-3.' Some STEP5/7 commands are not convertable ato IEC 61131-3, e.g. CPU commands like MAS. 4404 'STEP5/7 operand invalid or not convertible to IEC 61131-3.' Some STEP5/7 operands are not convertable ato IEC 61131-3 respectively an operand is missing. 4405 'Reset of a STEP5/7 timer cannot be converted into IEC 61131-3.' The corresponding IEC timer have no reset input. 4406 'STEP5/7 Counter constant out of range (max. 999).' There is no valid BCD coded ckounter constant in the accu. 4407 'STEP5 instruction not convertible to IEC 61131-3.' Some STEP5/7 instructions cannot be converted to IEC 61131-3, e.g. DUF. 4408 'Bit access of timer or counter words not convertible into IEC 61131-3.'
CoDeSys V2.3
10-129
Errors
Special timer/counter commands are not convertable into IEC 61131-3. 4409 'Contents of ACCU1 or ACCU2 undefined, not convertible into IEC 61131-3.' A command, which connects the both accus, cannot be converted, because the accu values are not defined. 4410 'Called POU not in project.' Import the called POU. 4411 'Error in global variable list.' Please check the SEQ file. 4412 'Internal error no.11' Please contact the PLC manufacturer. 4413 'Error in format of line in data block' In the code which should be imported there is an errouneous date. 4414 'FB/FX name missing.' In the original S5D file the symbolic name of an (extended) POU is missing. 4415 'Instruction after block end not allowed.' A protected POU cannot get imported. 4416 'Invalid command' The S5/S7 command´cannot be disassembled. 4417 'Comment not closed' Close the comment with '*)'. 4418 'FB/FX-Name too long (max. 8 characters)' The symbolic name of an (extended) POU is to long. 4419 'Expected format of line '(* Name: *)' ' Correct the line correspondingly.
10-130
CoDeSys V2.3
Appendix J: Compiler Errors and Warnings
4420 'Name of FB/FX parameter missing' Check the POUs. 4421 'Type of FB/FX parameter invalid' Check the POUs. 4422 'Type of FB/FX parameter missing' Check the POUs. 4423 'Invalid FB/FX call parameter' Check the interface of the POU. 4424 'Warning: FB/FX for call either missing or parameters invalid or has '0' parameters' The called POU is not imported yet or is not correct or has no parameters (in the last case you can ignore the error message). 4425 'Definition of label missing' The aim (label) of the jump is not defined. 4426 'POU does not have a valid STEP 5 block name, e.g. PB10' Modify the POU name. 4427 'Timer type not declared' Add a declaration of the timer in the global variables list. 4428 'Maximum number of open STEP5 brackets exceeded' You may not use more than seven open brackets. 4429 'Error in name of formal parameter' The parameter name may not exceed four characters. 4430 'Type of formal parameter not IEC-convertible' In IEC 61131-3 Timer, counter and POUs cannot be converted as formal parameters. 4431 'Too many 'VAR_OUTPUT' parameters for a call in STEP5 STL'
CoDeSys V2.3
10-131
Errors
A POU may not contain more than 16 formal parameters as outputs. 4432 'Labels within an expression are not allowed' In IEC 61131-3 jump labels may not be inserted at any desired position. 4434 'Too many labels' A POU may not contain more than 100 labels. 4435 'After jump / call, a new expression must start' After jump or call a Load command LD must follow. 4436 'Bit result undefined, not convertible to IEC 61131-3.' The command which is used by VKE verwendet cannot get converted, because the value of the VKE is not known. 4437 'Type of instruction and operand are not compatible' A bit command is used for a word operand or the other way round. 4438 'No data block opened (insert instruction C DB before)' Insert a 'A DB'. 4500 'Unrecognized variable or address' The watch variable is not declared within the project. By pressing you get the input assistant which lists the declared variables. 4501 'Extra characters following valid watch expression' Remove the surplus signs. 4520 'Error in Pragma: Flag expected before '!' The pragma is not correct. Check whether ‘' is a valid flag. 4521 'Error in Pragma: Unexpected element '!' Check whether pragma is composed correctly. 4522 'flag off' pragma expected!' Pragma has not been terminated, insert a 'flag off' instruction.
10-132
CoDeSys V2.3
Appendix J: Compiler Errors and Warnings
4550 'Index out of defined range : Variable OD 'number>, Line .' Ensure that the index is within the area which is defined in the target settings/networkfunctionality. 4551 'Subindex out of defined range : Variable OD 'number>, Line .' Ensure that the subindex is within the area which is defined in the target settings/networkfunctionality. 4552 'Index out of defined range : Parameter OD 'number>, Line .' Ensure that the index is within the area which is defined in the target settings/networkfunctionality. 4553 'Subindex out of defined range : Parameter OD 'number>, Line .' Ensure that the subindex is within the area which is defined in the target settings/networkfunctionality. 4554 'Variablename invalid: Variable OD , Line .' Enter a valid project variable in the filed ‚variable’. Use the syntax . resp. for global variables . 4555 'Empty table-entry, input not optional: Parameter OD , Line You must make an entry in this field. 4556 'Empty table-entry, input not optional: Variable OD , Line ' You must make an entry in this field.
CoDeSys V2.3
10-133
11Index
11
Index A
ABS 10-23 Absolute Value 10-23 Access rights 4-45 ACOS 10-27 Action Associate in SFC 5-34 Action 2-6, 2-16, 4-46 Active step 2-17 ADD 10-5 Add Object 4-42 ADD Operator in AWL 2-9 Add Shared Objects 4-40 Additional CoDeSys Features 1-2 Additional Online Functions 1-1 Address check for PLC configuration 10-94 Address Function 10-17 Addresses 10-32 ADR 10-17 ALIAS 10-40 Alternative branch 2-20 Alternative Branch in SFC 2-20, 5-30 Analyzation of expressions 10-63 AnalyzationNew.lib 10-63 AND 10-8 AND Operator in AWL 2-9 Arc cosine 10-27 Arc sine 10-26 10-26 Arc tangent 10-27 Archive ZIP 4-18 Argument 2-1, 2-3 ARRAY 10-37 Arrays in parameter manager 6-53 ASCII format for trace 6-48 ASIN 10-26 Assignment 2-10, 5-20, 5-22 Assignment Combs 5-22 Assignment operator 2-12 AT 5-5 AT Declaration 5-5 ATAN 10-27 Auto Load 4-4 Auto Save 4-4 Autodeclaration 5-7
B Backup automatic 4-4 Base parameters Bitchannel 6-18 CAN Master 6-26 DP slave 6-21 I/O Module 6-15 Base parameters of a CAN module 6-28 Base parameters of a channel 6-18 Base parameters of a DP Master 6-19 Base parameters of an I/O Module 6-15 Basisparameter Channel 6-18 Batch commands 10-71 Binding of ST operators 2-10 Bit addressing 10-32
CoDeSys V2.3
Bit-addressed variable 5-18 Bit-addressed variables 5-13 BITADR 10-18 Bitchannels 6-18 Block 5-28 BOOL 10-35 BOOL Constants 10-29 BOOL_TO Conversions 10-19 Boot project 4-61 Box 5-21 Breakpoint Delete 5-15 Set 5-15 Breakpoint 1-1, 2-23, 5-13 Breakpoint 5-15 Breakpoint Dialog Box 4-54 Breakpoint position 4-54 Breakpoint Positions in Text Editor 5-14 Browser ini-file 6-58 Build 4-9, 4-22 Bus parameters of the DP master 6-20 BY 2-14 BYTE 10-35 BYTE Constants 10-30 Byte-addressing mode 10-94
C C Modifier in AWL 2-9 CAL 10-18 CAL Operator in AWL 2-9 CALC 2-9 CALCN 2-9 Call tree 4-47 Calling a function 2-1 Calling a function block 2-4, 2-10 Calling function blocks in ST 2-12 Calling POUs with output parameters in text editors 5-13 CAN Configuration 6-26 CAN Maste Base parameters 6-26 CAN Master CAN Parameters 6-26, 6-27 CAN Module CAN module selection at modular slaves 6-28 CAN Module configuration Base parameters 6-28 CAN Parameters 6-27 CAN Module configuration 6-28 CAN Parameters CAN Master 6-26, 6-27 CAN parameters of a CAN module 6-27 CanDevice Base settings 6-31 CAN settings 6-32 Default PDO mapping 6-32 CanDevice 6-31 CanDevice 6-32 CanDevice 6-32 CASE 2-13 CASE instruction 2-13 CASEFOR loop 2-10 CFC
I
Errors
Changing connections 5-40 Create macro 5-44 Cursor positions 5-36 Deleting connections 6-65 Display order 5-41 Edit macro 5-45 EN/ENO 5-39 Expand macro 5-46 Feedback paths 5-46 Insert Box 5-37 Insert Comment 5-38 Insert Input 5-37 Insert Input of box 5-38 Insert inputs/outputs 5-41 Insert Jump 5-38 Insert Label 5-38 Insert Out-Pin 5-38 Insert Output 5-37 Insert Return 5-38 Moving elements 5-40 Negation 5-38 Order – One backwards 5-43 Order – One forwards 5-42 Order – To the beginning 5-43 Order – To the end 5-43 Order according data flow 5-43 Order of execution 5-41 Order topologically 5-42 Properties of POUs 5-40 Select elements 5-40 Set/Reset 5-39 CFC 2-21 CFC in Online mode 5-46 CFC/Back one all macro level 5-46 CFC/Connection marker 5-41 CFC/Copy elements 5-40 CFC/Insert In-Pin 5-38 Change values online 2-23 Channel parameter 6-18 Check In 4-37 Check Out 4-37 Check project 4-32 CheckBounds 10-37 CheckDivReal 10-6 CheckRangeSigned 10-40 CheckRangeUnsigned 10-40 Clean all 4-23 CoDeSys 1-1 Coil 2-22, 5-27 Colors 4-7 Command entry in the PLC Browser 6-58 Command file 10-71 Command Line 10-71 Comment 5-1 Communication Symbolic interface 4-12 Communication 4-12 Communication parameters Quick check 4-61 Communication Parameters Check at Login 4-6 Saving with project 4-6 Communication Parameters 4-6 Communications parameters Dialog 4-60 Communications Parameters 4-60
II
Comparing projects 4-29 Compress 6-47 CONCAT 10-44 Concatenation 10-44 Configuration of CAN modules 6-26 Configuration of Profibus Modules 6-18 Connections 5-40 Connections in CFC 5-41, 6-65 Constant 5-4 Contact 2-22, 5-26 Content Operator 10-18, 10-38 Context Menu 4-3 Context Sensitive Help 4-63 Continuous function chart editor 2-21 Continuous Function Chart Editor (CFC) 5-36 Conversion of Integral Number Types 10-21 Conversions of types 10-19 Convert object 4-43 Converting of old PLC configurations 6-14 Converting S5 to IEC 1131-3 10-80 Copy 4-49 Copy object 4-44 Copying elements in CFC 5-40 Copying in FBD 5-23 COS 10-26 Cosine 10-26 Create Backup 4-4 Create boot project 4-61 Cross Reference List 4-47 CTD 10-51 CTU 10-50 CTUD 10-51 Cursor positions in FBD 5-19 Cursor positions in the CFC 5-36 Cursor Positions in the LD Editor 5-25 Cursor setting in FBD 5-20 Custom Parameters 6-14, 6-18 Cut 4-48 Cutting in FBD 5-23
D Data Base Link Add Shared Objects 4-40 Check In 4-37 Check Out 4-37 Define 4-36 Get All Latest Versions 4-39 Get Latest Version 4-37 Label Version 4-40 Login 4-35 Multiple Check In 4-39 Multiple Check Out 4-39 Multiple Define 4-39 Multiple Undo Check Out 4-39 Project Version History 4-39 Refresh Status 4-41 Show Differences 4-37 Show Version History 4-37 Undo Check Out 4-37 Data Base Link 4-34 Data types 2-8, 4-2 DATE 10-36 DATE Constants 10-29 DATE_AND_TIME 10-36 DATE_AND_TIME Constants 10-30 DATE_TO Conversions 10-22
CoDeSys V2.3
11Index
DCF file for creating Global Variables list 6-3 DDE inquiry General approach to data 9-1 DDE Interface Linking variables using WORD 9-1 Accessing variables with Intouch 9-2 Activate 9-1 Linking variables using EXCEL 9-1 Which variables can be read? 9-1 Debugging 1-1, 2-23, 4-9, 5-13, 5-18 Declaration AT 5-5 automatic 5-7 New 5-9 Pragma 5-9 Declaration 5-2 Declaration Editor Line numbers 5-8 Online Mode 5-11 Declaration Editor 5-2 Declaration keyword 5-6 Declaration of a variable 5-5 Declaration Part 2-1, 5-2 Declaration window 5-1 Declarations as table 5-9 Declare Variable 4-51 Decrementer 10-51 Define 4-36 Delete 4-49, 10-45 Delete a label 5-32 Delete Action in SFC 5-32 Delete Object 4-42 Delete Step and Transition in SFC 5-30 Delete Transition 5-32 Deleting in FBD 5-23 Dereferencing 10-18, 10-38 Desktop 4-6 DINT 10-35 DINT Constants 10-30 Directory 4-8 Display Flow Control 4-59 DIV 10-6 DIV Operator in AWL 2-9 DO 2-14 Docu File 6-7, 6-8 Docuframe file 6-7, 6-8 Document 4-21 Document Frame 6-7, 6-8 Documentation of the project 4-27 Download 4-11, 4-53, 4-61 Download of parameter lists 6-56 Download of PLC configuration 10-94 Download Symbol File 10-94 Download-Information 4-23 DP Master Base parameters 6-19 DP Master 6-19 DP parameters DP master 6-19 DP slave 6-22 DP parameters of the DP master 6-19 Drag&Drop 4-41 DT 10-36 DT_TO Conversions 10-22 DWORD 10-35 DWORD Constants 10-30
CoDeSys V2.3
E Edit Autodeclare 4-51 Edit Copy 4-49 Edit Cut 4-48 Edit Delete 4-49 Edit Find 4-50 Edit Find next 4-50 Edit Input Assistant 4-51 Edit Macros 4-52 Edit Next error 4-51 Edit Paste 4-49 Edit Previous error 4-51 Edit Redo 4-48 Edit Replace 4-50 Edit Undo 4-48 Editing functions 4-48 Editor Body 5-1 Comments 5-1 Declaration part 5-1 IL 5-16 Print margins 5-1 Shortcut mode 5-6 Syntax Coloring 5-6 Editor for Structured Text 5-17 Editor options 4-5 Editors 5-1 ELSE 2-12, 2-13 ELSIF 2-12 EN Input 2-22, 5-27 EN POU 2-22 END_CASE 2-13 END_FOR 2-14 END_IF 2-12 END_REPEAT 2-15 END_TYPE 10-38, 10-39, 10-40 END_VAR 5-4 END_WHILE 2-14 ENI 4-13, 4-34 ENI data base 7-1 ENI Server 7-1 ENI Server Suite 7-1 Entering Trace Variables 6-43 Entry action 2-17, 5-31 Entry or exit actionf 2-17 Enumeration 10-38 EQ 10-17 EQ Operator in AWL 2-9 EXIT 2-10, 2-15 Exit action 2-17 EXIT instruction 2-15 Exit-Action 5-31 EXP 10-25 Expand nodes Collapse nodes 4-42 Exponential Function 10-25 Exponentiation 10-27 Export 4-28 Export file for creating Global Variables list 6-3 Expression 2-10 EXPT 10-27 EXTERNAL 5-5 External library 4-17, 6-9 External trace configuration Load from file 6-48 Load from PLC 6-48, 6-49 Save to file 6-48
III
Errors
Set as project configuration 6-49 External variable 5-5 Extra Monitoring Active 6-42 Extras Add label to parallel branch 5-31 Extras Associate Action 5-34 Extras Auto Read 6-45 Extras Back all macro level 5-46 Extras Back one macro level 5-46 Extras Calculate addresses PLC Configuration Calculate addresses 6-13 Extras Clear Action/Transition 5-32 Extras Compress 6-47 Extras Connection marker 5-41 Extras Convert 6-14 Extras Create macro 5-44 Extras Cursor Mode 6-46 Extras Edit Macro 5-45 Extras EN/ENO in CFC 5-39 Extras Expand macro 5-46 Extras Load values 6-48 Extras Load Watch List 6-41 Extras Menu Clear Action/Transition 5-32 Load Watch List 6-41 View 5-23 Extras Monitoring Options 5-14 Extras Multi Channel 6-46 Extras Negate 5-22 Extras Negate in CFC 5-38 Extras Negate in LD 5-28 Extras Open instance 5-1, 5-23 Extras Options 5-33 Extras Order To the beginning 5-43 Extras Order Display 5-41 Extras Order One backwards 5-43 Extras Order One forwards 5-42 Extras Order Order everything according to data flow 543 Extras Order Order topologically 5-42 Extras Order To the end 5-43 Extras Paste above in LD 5-28 Extras Paste after 5-32 Extras Paste after in LD 5-28 Extras Paste below in LD 5-28 Extras Paste Parallel Branch (right) 5-31 Extras Properties.. in CFC 5-40 Extras Read Receipt 6-42 Extras Read Trace 6-45 Extras Rename Watch List 6-41 Extras Replace element 6-13 Extras Save Trace 6-47 Extras Save Watch List 6-41 Extras Set Debug Task 6-40 Extras Set/Reset 5-23 Extras Set/Reset in CFC 5-39 Extras Set/Reset in LD 5-29 Extras Show grid 6-47 Extras Standard configuration 6-14 Extras Start Trace 6-45 Extras Step Attributes 5-32 Extras Stop Trace 6-45 Extras Stretch 6-47 Extras Time Overview 5-33 Extras Trace Configuration 6-43 Extras Use IEC-Steps 5-34 Extras Write Receipt 6-42
IV
Extras Y Scaling 6-47 Extras Zoom 5-1, 5-47 Extras Zoom Action/Transition 5-32
F F_TRIG 10-49 F4 4-6 falling edge 10-49 FBD Assign 5-20 Box 5-21 Delete 5-23 Extras View 5-23 Input 5-22 Jump 5-21 Negation 5-22 Output 5-22 Return 5-21 Switch to LD 5-23 Switch view to LD 5-23 FBD 2-20 FBD Editor 5-19 FBD/Copy 5-23 FBD/Cursor position 5-19 FBD/Cut 5-23 FBD/Paste 5-23 FBD/set cursor 5-20 Feedback paths in CFC 5-46 Fields 2-1, 10-37 File Save/Mail Archive 4-18 File 4-15 File 4-18 File Close 4-17 File Exit 4-22 File Menu Open 4-16 File New 4-15 File Open 4-16 File Print 4-20 File Printer setup 4-21 File Save 4-17 File Save as 4-17 Find 4-50, 10-46 Find next 4-50 Flag 5-9 Flow control IL 5-16 Flow control 4-59 Flow Control FBD 5-24 Folder 4-41, 4-42 FOR 2-14 FOR loop 2-14 Force values 4-56, 6-42 Forcing 6-42 Function Insert 5-13 Function 2-1 Function 10-33 Function block instance 2-3 Function Block Insert 5-13 Function Block 2-2 Function block call 2-4
CoDeSys V2.3
11Index
Function Block Diagram Online Mode 5-24 Function Block Diagram (FBD) 2-20 Function Block Diagram Editor 5-19 Function block in LD 2-22 Function Block Instances 2-3 Function blocks in the Ladder Diagram 2-22 Function call 2-1 Function declaration 2-1 FUNCTION_BLOCK 2-2 Functionblock in parameter manager 6-53
G Gateway Principle of gateway system 4-60 Quick check 4-61 Gateway 4-60 GatewayDDE Server Handling 9-2 GatewayDDEServer General Approach to Data 9-3 Linking variables using WORD 9-4 GatewayDDEServer/Command line options 9-4 GE 10-16 GE Operator in AWL 2-9 Get All Latest Versions 4-39 Get Latest Version 4-37 Global constant 5-4 Global Constants 6-6 Global Retain Variables 6-6 Global variables 6-2 Global Variables List Create 6-3 Global Variables Lists/Editing 6-5 Global Variables/Constants 6-6 Global variables/Network variables 6-6 Global Variables/Objects 6-2 Global Variables/Persistent Variables 6-6 Global variables/Remanent Variables 6-6 Graphic Editor FBD 5-19 Graphic Editor 5-17 Graphic Editor/CFC 5-36 Graphic Editor/Label 5-18 Graphic Editor/LD 5-24 Graphic Editor/Network 5-18 Graphic Editor/Zoom 5-17 Group assignment of a DP slave 6-25 GT 10-15 GT Operator in AWL 2-9
H Help Context Sensitive 4-63 Help Contents and Search 4-62 Help Menu Contents and Index 4-62 Help Topics Window 4-62 How can I test my project? 1-1 How do I set up my project? 1-1 How is a project structured? 1-1
CoDeSys V2.3
I Identifier 5-5, 10-31 IEC 61131-3 2-25 IEC step 2-17, 5-34 IEC steps 2-18 Iecsfc.lib 2-17 IF 2-12 IF instruction 2-10, 2-12 IL Online mode 5-16 IL 2-2, 2-8 IL Editor 5-16 IL operator 2-9 Implicit at load 4-11 Implicit variables in SFC 2-19 Import from a S5 Project File 10-80 Import from a SEQ Symbol File 10-79 In-/outputs 6-23 In-/outputs of a DP slave 6-23 Include Macro library 4-14 Incrementer 10-50 Incrementer/Decrementer 10-51 INDEXOF 10-8 Initialization 5-5 Initialization with zero 10-94 Initialize zero 10-94 Input and Output Variable 5-3 Input assistant structured 4-51 unstructured 4-51 Input Assistant 4-51 Input in FBD 5-22 Input Variable 5-3 INSERT 10-45 Insert above in LD 5-28 Insert Add Entry-Action 5-31 Insert Add Exit-Action 5-31 Insert Additional Library 6-9 Insert All Instance Paths 6-7 Insert Alternative Branch (left) 5-30 Insert Alternative Branch (right) 5-30 Insert Append subelement 6-13 Insert Assign in FBD 5-20 Insert at Blocks in LD 5-28 Insert below in LD 5-28 Insert Box in CFC 5-37 Insert Box in FBD 5-21 Insert Coil in LD 5-27 Insert Comment in CFC 5-38 Insert Contact in LD 5-26 Insert Declarations keywords 5-6 Insert Function 5-13 Insert Function Block 5-13 Insert Function Block in LD 5-27 Insert Function Block in text editors 5-13 Insert Function in text editors 5-13 Insert in SFC 5-30 Insert In-Pin in CFC 5-38 Insert Input 5-22 Insert Input of box in CFC 5-38 Insert inputs/outputs in CFC 5-41 Insert Insert element 6-13 Insert Jump 5-31 Insert Jump in CFC 5-38 Insert Jump in FBD 5-21 Insert Jump in LD 5-28
V
Errors
Insert Label in CFC 5-38 Insert Menu All Instance Paths 6-7 Alternative Branch (left) 5-30 Alternative Branch (right) 5-30 Append Program Call 6-37 Append Task 6-36 Insert Program Call 6-37 Insert Task 6-36 Parallel Contact 5-26 Placeholder 4-21 Type 5-6 Insert Menu 4-21 Insert Network 5-18 Insert Network (after) or Insert Network (before) 5-18 Insert New Declaration 5-9 Insert New Watch List 6-41 Insert Operand in text editors 5-13 Insert Operators in text editors 5-13 Insert Out-Pin 5-38 Insert Output 5-22 Insert Output in CFC 5-37 Insert Parallel Branch (left) 5-31 Insert Parallel Branch (right) 5-31 Insert Parallel Contact 5-26 Insert Program Call or 'Insert' 'Append Program Call' 637 Insert Return in CFC 5-38 Insert Return in FBD 5-21 Insert Return in LD 5-28 Insert Step Transition (after) 5-30 Insert Step Transition (before) 5-30 Insert Task or Append Task 6-36 Insert Transition-Jump 5-31 Insert Type 5-6 Inserting variables 5-2 Instance Open 5-1, 5-23 Instance 2-3 Instance name 2-3, 2-4 Instruction 2-8, 2-10 Instruction List 2-2 Instruction List (IL) 2-8 Instruction List Editor 5-16 INT 10-35 INT Constants 10-30 Intellisense Function 5-2 Internal library 4-17, 6-9
J JMP Operator in AWL 2-9 Jump 2-20, 5-21, 5-28 Jump in SFC 5-31 Jump Label 5-31, 5-32
K Keyword 5-5, 5-6
L Label 5-31 Label for networks 5-18 Label Version 4-40 Ladder Diagram 2-21
VI
Ladder Diagram (LD) 2-21 Ladder Diagram in Online Mode 5-29 Ladder Editor 5-24 Languages 2-8 LD Cursor Position 5-25 Insert above 5-28 Insert at Blocks 5-28 Insert below 5-28 Insert Box with EN Input 5-27 Insert Coil 5-27 Insert Contact 5-26 Insert Function Block 5-27 Insert Jump 5-28 Insert Parallel Contact 5-26 Insert Return 5-28 Paste after 5-28 LD 2-21 LD as FBD 2-22 LD Editor 5-24 LD Operator in AWL 2-9 LE 10-16 LE Operator in AWL 2-9 lecsfc.lib 2-17 LEFT 10-43 LEN 10-43 Libraries 2-7 Library AnalyzationNew.lib 10-63 Define 6-9 External 4-17, 6-9 Insert 6-9 Internal 4-17, 6-9 Remove 6-10 Standard.lib 6-9 User defined 6-9 Library 2-7 Library directory 4-8 Library Elements Overview 10-65 Library Elements 10-65 Library Manager Usage 6-9 Library Manager 6-8 License Management Add license information 8-1 Creating a licensed library in CoDeSys 8-1 License Management 8-1 LIMIT 10-14 Line Number 5-15 Line number field 4-59, 5-14 Line numbers in Declaration Editor 5-8 Linking variables using EXCEL 9-4 LN 10-24 Load & Save 4-4 Load file from controller 4-61 Load trace configuration 6-43 Load values 6-48 Load Watch List 6-41 Local Variable 5-4 Log Storing 6-12 Log 2-25, 4-9, 6-10 Log file for project 6-10 Log in 4-52 Log Menu 6-11 Logarithm 10-24
CoDeSys V2.3
11Index
Login to Data Base 4-35 Logout 4-53 Loop 2-10 LREAL 10-35 LREAL Constants 10-30 LREAL_TO Conversions 10-21 LT 10-16 LT Operator in AWL 2-9
M Macro 4-9, 4-14 Macro after compile 4-9 Macro before compile 4-9 Macro in CFC 5-44 Macro library 4-14 Macros 4-52 Macros in PLC-Browser 6-59 Main program 2-6 Managing Projects 4-15 Marking blocks in SFC 5-30 MAX 10-13 Memory location 10-33 Menu File Exit 4-22 Project Import 4-29 Window Library Manager 6-8 Menu Edit Autodeclare 4-51 Copy 4-49 Copy/Paste in CFC 5-40 Cut 4-48, 5-23 Delete 4-49 Find 4-50 Find next 4-50 Input Assistant 4-51 Makros 4-52 Next error 4-51 Paste 4-49, 5-23 Previous error 4-51 Redo 4-48 Remove library 6-10 Replace 4-50 Undo 4-48 Menu Extras Add label to parallel branch 5-31 Associate Action 5-34 Auto Read 6-45 Back all macro level 5-46 Back one macro level 5-46 Callstack.. 6-40 Compress 6-47 Connection marker 5-41 Create macro in CFC 5-44 Cursor Mode 6-46 Display order in CFC 5-41 Edit macro in CFC 5-45 EN/ENO 5-39 Enable / disable task 6-40 Expand macro in CFC 5-46 External trace configuration 6-48, 6-49 Insert above 5-28 Insert below 5-28 Link Docu File 6-7, 6-8
CoDeSys V2.3
Make Docuframe file 6-7, 6-8 Monitoring Active 6-42 Monitoring Options 5-14 Multi Channel 6-46 Negate LD Negate 5-28 Negate 5-22 Negate in CFC 5-38 Open instance 5-1, 5-23 Options in SFC 5-33 Order - One backwards 5-43 Order - One forwards 5-42 Order – To the beginning 5-43 Order – To the end 5-43 Order everything according to data flow 5-43 Order topologically 5-42 Paste after 5-28, 5-32 Paste Parallel Branch (right) 5-31 Properties 5-40 Read Receipt 6-42 Read Trace 6-45 Rename Watch List 6-41 Replace element 6-13 Save Trace 6-47 Save trace values 6-47 Save Watch List 6-41 Select All in CFC 5-40 Set Debug Task 6-40 Set/Reset LD Set/Reset 5-29 Set/Reset 5-23 Set/Reset 5-39 Show grid 6-47 Start Trace 6-45 Step Attributes 5-32 Stop Trace 6-45 Stretch 6-47 Time Overview 5-33 Trace Configuration 6-43 Use IEC Steps 5-34 Write Receipt 6-42 Y Scaling 6-47 Zoom Action/Transition 5-32 Zoom to POU 5-1, 5-47 Menu File Close 4-17 New 4-15 Open project from Source Code Manager 4-16 Print 4-20 Printer Setup 4-21 Save 4-17 Save as 4-17 Menu Insert Add Entry-Action 5-31 Add Exit-Action 5-31 Additional Library 6-9 Append subelement 6-13 Assign 5-20 Box 5-21 Box in CFC 5-37 Box with EN 5-27 Coil 5-27 Comment in CFC 5-38 Contact 5-26 Declarations Keyword 5-6
VII
Errors
Function 5-13 Function Block 5-13, 5-27 In-Pin 5-38 Input 5-22, 5-37 Input in CFC 5-37 Input of box in CFC 5-38 Insert at Blocks 5-28 Insert element 6-13 Jump 5-21, 5-28 Jump in CFC 5-38 Jump in SFC 5-31 Label in CFC 5-38 Network (after) 5-18 Network (before) 5-18 New Watch List 6-41 Operand 5-13 Operator Text Editor Insert Operator 5-13 Out-Pin 5-38 Output 5-22, 5-37 Parallel Branch (left) 5-31 Parallel Branch (right) 5-31 Return 5-21, 5-28 Return in CFC 5-38 Step Transition (after) 5-30 Step Transition (before) 5-30 Transition-Jump 5-31 Menu Insert 5-9 Menu Log 6-11 Menu Online Breakpoint Dialog Box 4-54 Communications Parameters 4-60 Create boot project 4-61 Display Flow control 4-59 Download 4-53 Force values 4-56 Load file from controller 4-61 Log in 4-52 Logout 4-53 Release force 4-57 Reset 4-53 Reset (cold) 4-54 Reset (original) 4-54 Run 4-53 Show Call Stack 4-59 Simulation 4-59 Single Cycle 4-55 Sourcecode download 4-61 Step in 4-55 Step over 4-55 Stop 4-53 Toggle Breakpoint 4-54 Write file to controller 4-61 Write values 4-55 Write/Force dialog 4-58 Menu Online 4-52 Menu Projec Document 4-27 Menu Project Add Action 4-46 Add object 4-42 Build 4-22 Check 4-32 Clean all 4-23 Compare 4-29 Convert object 4-43
VIII
Copy object 4-44 Data Base Link 4-34 Delete Object 4-42 Export 4-28 Load Download-Information 4-23 Merge 4-30 Object access rights 4-45 Open instance 4-46 Open object 4-44 Options 4-3 project info 4-30 Properties 4-45 Rebuild all 4-23 Rename object 4-43 Show call tree 4-47 Show Cross Reference 4-47 Siemens Import 4-29 Translate into another language 4-23 User group passwords 4-33 Menu Project 4-34 Menu Window Arrange symbols 4-62 Cascade 4-62 Close all 4-62 Log 6-10 Messages 4-62 Tile Horizontal 4-62 Tile Vertical 4-62 Merge 4-30 Message window 4-2, 4-31, 4-62 MID 10-44 MIN 10-14 MOD 10-7 Modifier 2-9 Modifiers 10-65 Modifiers and operators in IL 2-9 Modul parameters DP master 6-19 Modul parameters 6-17 Modular Slave Modules selection 6-28 Module parameters 6-25 Modulparameter / Custom Parameters of an I/O Module 6-17 Monitoring Watch and Receipt Manager 6-41 Monitoring 2-24, 4-52, 5-11, 5-13 Monitoring 6-42 Monitoring Active 6-42 Monitoring Options 5-14 MOVE 10-7 Moving elements in CFC 5-40 MUL 10-6 MUL Operator in AWL 2-9 Multi Channel 6-46 Multiple Check In 4-39 Multiple Check Out 4-39 Multiple Define 4-39 Multiple Undo Check Out 4-39 Multi-user operation 7-1 MUX 10-15
N N Modifier in AWL 2-9 NE 10-17 NE Operator in AWL 2-9
CoDeSys V2.3
11Index
Negation in FBD 5-22 Negation in LD 5-28 Network 5-18, 5-19 Network editor Online mode 5-18 Network functionality 6-2 Network in FBD 2-20 Network in LD 2-22 Network in SFC 2-16 Network number 5-18 Network number field 4-59 Network variables Editing 6-5 Network Variables 6-2, 6-6 New Declaration 5-9 New Folder 4-42 Next error 4-51 NOT 10-10 Notice at load 4-11 Number Constants 10-30 Number of data 4-9
O Object Access rights 4-45 Add 4-42 Convert 4-43 Copy 4-44 Delete 4-42 Drag&Drop 4-41 Folder 4-41, 4-42 Open 4-44 Properties 4-45 Rename 4-43 Tooltip 4-41 Object 2-1 Object 4-41 Object Organizer Collapse Node 4-42 Expand Node 4-42 New Folder 4-42 Object Organizer 4-2 Object properties 4-45 Objects Managing objects in a project 4-41 OF 2-13 Online 1-1 Online Breakpoint Dialog Box 4-54 Online Change 10-94 Online Communication Parameters 4-60 Online Create boot project 4-61 Online Display Flow Control 4-59 Online Download 4-53 Online Force values 4-56 Online functions 4-52 Online in Security mode 4-6 Online Load file from controller 4-61 Online Login 4-52 Online Logout 4-53 Online messages from Controller 4-52 Online Mode CFC 5-46 Declaration Editor 5-11 FBD 5-24 LD 5-29 Network editor 5-18
CoDeSys V2.3
SFC 5-34 Taskconfiguration 6-38 Text Editor 5-13 Watch and Receipt Manager 6-41 Online Mode 4-52 Online Mode 6-38 Online Release force 4-57 Online Reset 4-53 Online Reset (cold) 4-54 Online Reset (original) 4-54 Online Run 4-53 Online Show Call Stack 4-59 Online Simulation 4-59 Online Single Cycle 4-55 Online Sourcecode download 4-61 Online Step in 4-55 Online Step over 4-55 Online Stop 4-53 Online Toggle Breakpoint 4-54 Online Write file to controller 4-61 Online Write values 4-55 Online Write/Force Dialog 4-58 Open instance 4-46, 5-1, 5-23 Open object 4-44 Open POU 4-46 Open project from PLC 4-16 Operand 2-1, 5-13, 10-29 Operator 5-13 Operators overview 10-65 Operators 10-65 Options for Build 4-9 Options for Colors 4-7 Options for Directories 4-8 Options for Editor 4-5 Options for Load & Save 4-4 Options for Log 4-9 Options for 'Macros' 4-14 Options for Project objects 4-13 Options for Project source control 4-13 Options for 'Symbol Configuration' 4-12 Options for the Desktop 4-6 Options for User information 4-5 OR 10-9 OR Operator in AWL 2-9 Order of execution in CFC 5-41 Output in FBD 5-22 Output parameters 5-13 Output Reset 5-23 Output Set 5-23 Output Variable 5-3
P Parallel branch 2-20 Parallel Branch in SFC 2-20, 5-31 Parallel Contact 5-26 Parallel Contacts 2-22 Parameter List Download with project 6-55 Type 6-52 Parameter List 6-50 Parameter Manager Activating 6-51 Array 6-53 Copy list 6-55 Cut list 6-55
IX
Errors
Cut/Copy/Paste line 6-55 Delete line 6-55 Delete list 6-55 Export 6-56 Fade out and fade in lines 6-55 Format Dec/Hex 6-55 Function block 6-53 Import 6-56 Insert line 6-55 Insert list 6-54 Instance 6-52 Instance list 6-53 Line after 6-55 Liste types 6-52 Monitoring values 6-56 Online Mode 6-56 Parameters 6-52 Paste list 6-55 Rename List 6-55 Sorting lists 6-56 Structure variable 6-53 System Parameters 6-52 Template 6-52, 6-53 Upload and Download 6-56 Variables 6-52 Write values 6-56 Parameter Manager 6-50 Parameter Manager Editor 6-52 Password 4-10 Paste after in LD 5-28 Paste after in SFC 5-32 Paste Parallel Branch 5-31 Pasting 4-49 Pasting in FBD 5-23 PDO 6-28 PDO mapping of a CAN module 6-28 PERSISTENT 5-4 Persistent Global Variables 6-6 Persistent variable 5-4 Persistent Variables 6-6 Placeholder 4-21 PLC Browser Commands 6-58 Function 6-57 History 6-60 ini-file 6-58 Macros 6-59 PLC Browser 6-57 PLC configuration Address check on/off 10-94 Download as file 10-94 PLC configuration 10-94 PLC Configuration Base parameters of a Bitchannel 6-18 Base parameters of a channel 6-18 Base parameters of an I/O Module 6-15 Base settings of a CanDevice 6-31 CAN Configuration 6-26 CAN settings of a CanDevice 6-32 Channel parameters 6-18 Convert old configurations 6-14 Custom Parameters Dialog 6-14 Default PDO mapping of a CanDevice 6-32 DP Master Base parameters 6-19 General settings 6-14 Insert/Append elements 6-13
X
Modul parameters / Custom Parameters of an I/O Module 6-17 Profibus Modules 6-18 Replacing/switching Elements 6-13 Service Data Objects 6-30 Standard configuration 6-14 Symbolic names 6-13 PLC_PRG 2-6 PLC-Browser Cancel command 6-60 Save history list 6-60 POINTER 10-38 POU (Program Organization Unit) 1-1, 2-1, 4-2 Pragma instruction 5-9 Previous error 4-51 Print 4-20 Print margins 5-1 Print range 4-6 Profibus Master Bus parameters 6-20 DP parameters 6-19 Modul parameters 6-19 Profibus Slave Base parameters 6-21 DP parameters 6-22 Group assignm ent 6-25 Module parameters DP slave 6-25 User parameters 6-24 Profibus Slave 6-23 Program 2-5 Project 1-1, 2-1 Project Add Action 4-46 Project Build 4-22 Project Check 4-32 Project Compare 4-29 project data base categories 7-2 project data base 7-1 project data base 7-2 Project data base in CoDeSys Working with 7-2 Project data base in CoDeSys 7-2 Project directory 4-8 Project' 'Document 4-27 Project Export 4-28 Project Global replace 4-32 Project Global Search 4-31 Project Import 4-29 Project info 4-4, 4-30 Project Load Download-Information 4-23 Project Menu Global Replace 4-32 Global Search 4-31 Project Menu 4-31 Project Merge 4-30 Project Object Access rights 4-45 Project Object Add 4-42 Project Object Convert 4-43 Project Object Copy 4-44 Project Object Delete 4-42 Project Object Open 4-44 Project Object properties 4-45 Project Object Rename 4-43 Project Open Instance 4-46 Project Options 4-3 Project Project info 4-30
CoDeSys V2.3
11Index
Project Rebuild all 4-23 Project Show Call Tree 4-47 Project Siemens Import 4-29 Project source control 4-13 Project Translate into another language 4-23 Project User group passwords 4-33 Project version 1.5 4-17 Project version 2.0 4-17 Project version 2.1 4-17 Project Version History 4-39 Projekt Show cross reference 4-47 Properties of a DP slave in slave operation of the Profibus 6-25
Q Qualifier 2-17, 2-18
R R Operator in AWL 2-9 R_TRIG 10-48 Read trace 6-43, 6-45 REAL 10-35 REAL Constants 10-30 REAL_TO Conversions 10-21 Rebuild all 4-23 Recalculation of Module addresses 6-13 Receipt Manager 6-40 Redo 4-48 References 10-40 Refresh Status 4-41 Release force 4-57 Remanent variable 5-4 Remove Library 6-10 Rename Object 4-43 REPEAT 2-10, 2-15 REPEAT loop 2-15 Replace 4-32, 4-50, 10-46 Replace constants 4-9 Replace Element in PLC Configuration 6-13 Reset 4-53, 5-23 Reset (cold) 4-54 Reset (original) 4-54 Reset output 5-29 Resources Global variables 6-2 Library Manager 6-8 Log 6-10 Network variables 6-2 Variable Configuration 6-2, 6-6 Resources 2-7, 4-2, 6-1 Retain 2-3, 5-4 Retain variable 5-4 RETURN 2-10, 2-12, 5-21, 5-28 RETURN instruction 2-12 Return to standard configuration 6-14 Revision control 7-1 RIGHT 10-44 rising edge 10-48 ROL 10-11 ROR 10-12 Rotation 10-11, 10-12 RS 10-47 RTC 10-55 Run 4-53
CoDeSys V2.3
S S Operator in AWL 2-9 S5 10-80 Sample Rate 6-43 Sampling Trace 2-23 Save Mail/Archive 4-18 Save Trace Save Values 6-47 Save Trace 6-47 Save trace values Load trace 6-48 Load values 6-48 Values in ASCII file 6-48 Save trace values 6-47 Screen divider 4-2 SDO 6-30 SEL 10-13 Selecting elements in CFC 5-40 SEMA 10-48 Sequential Function Chart 2-1, 2-4, 2-16 Sequential Function Chart (SFC) 2-16 Sequential Function Chart Editor 5-29 Sequential Function Chart in Online Mode 5-34 Service Data Objects 6-30 Set 5-23 Set output 5-29 Set/Reset coils 2-22 SFC Add Entry-Action 5-31 Add Exit- Action 5-31 Add Label to parallel branch 5-31 Alternative Branch (left) 5-30 Alternative Branch (right) 5-30 Associate Action 5-34 Clear Action/Transition 5-32 Delete jump label 5-32 Delete Step and Transition 5-30 Execution of steps 5-34 IEC Step 5-34 Jump 5-31 Marking blocks 5-30 Online Mode 5-34 Options 5-33 Parallel Branch (left) 5-31 Parallel Branch (right) 5-31 Paste after 5-32 Paste Parallel Branch 5-31 Step Attributes 5-32 Step Transition (after) 5-30 Step Transition (before) 5-30 Time Overview 5-33 Transition-Jump 5-31 SFC 2-1, 2-4, 2-16 SFC Editor 5-29 SFC Flags 2-19 SFC library 2-17 SFCCurrentStep 2-19 SFCEnableLimit 2-19 SFCError 2-19 SFCErrorAnalyzation 2-19 SFCErrorPOU 2-19 SFCErrorStep 2-19 SFCInit 2-19 SFCPause 2-19 SFCQuitError 2-19 SFCReset 2-19
XI
Errors
SFCTip 2-19 SFCTipMode 2-19 SFCTrans 2-19 SFCZoom Action 5-32 Shift 10-10 SHL 10-10 Shortcut in Tools Create new 6-61 Shortcut in Tools 6-61 Shortcut Mode 5-6 Shortcuts of Tools 6-62 Show Call Stack 4-59 Show Differences 4-37 Show grid 6-47 Show Version History 4-37 SHR 10-11 Siemens Import 4-29, 10-79 Simulation 2-25, 4-52, 4-59 SIN 10-25 Sine 10-25 Single Cycle 2-23, 4-55 Single step 2-23, 4-55 SINT 10-35 SINT Constants 10-30 SIZEOF 10-8 SoftMotion Komponenten 1-2 Source control 4-13 Sourcecode download 4-61 Sourcedownload 4-11 SQRT 10-24 Square Root 10-24 SR 10-47 ST 2-10, 5-17 ST Editor 5-17 ST operand 2-10 ST operator 2-10 ST Operator in AWL 2-9 Standard Function 6-9 Standard Library 6-9 Standard POUs 2-1 Standard.lib 6-9 Start Trace 6-45 Statistics 4-30 Status bar 4-3, 4-6 Step 2-16 Step Attributes 5-32 Step in 4-55 Step Init 2-17 Step over 4-55 Step Transition (after) 5-30 Step Transition (before) 5-30 Stepping 5-13, 5-18 Stop 4-53 Stop Trace 6-45 Stretch 6-47 STRING 10-35 STRING Constants 10-30 String functions 10-43 STRING_TO Conversions 10-23 STRUCT 10-39 Structure variables in parameter manager 6-53 Structured Text 5-17 Structured Text (ST) 2-10 Structures 2-1, 10-39 SUB 10-6 SUB Operator in AWL 2-9 Subrange types 10-40
XII
Switch translation 4-27 Symbol configuration 4-12 Symbol file 4-12, 5-9 Symbol File download 10-94 Symbolic interface 4-12 Symbolic names 6-13 Syntax Coloring 5-2, 5-6 System Events in the Task Configuration 6-37 System Flag 10-31 System Libraries 10-64
T Table Editor 5-9 TAN 10-26 Tangent 10-26 Target 6-33, 6-49 Target File 6-34, 6-49 Target Settings Dialog 6-34, 6-50 Target Settings 6-33 Target Settings 6-49 Target Settings_ 6-33 Target system 8051 10-92 Target-Support-Package 6-34, 6-49 Task Configuration Append Task 6-36 Callstack 6-40 Enable / disable task 6-40 Execution order 6-38 Insert Program Call 6-37 Insert Task 6-36 Set Debug Task 6-40 System Events 6-37 Working in 6-35 Task Configuration 6-35 Taskconfiguration in Online Mode 6-38 status of a task 6-38 time flow 6-38 Text editor Online mode 5-13 Text Editor Breakpoint 5-14 Calling POUs 5-13 Insert Function 5-13 Insert mode 5-12 Insert Operand 5-13 Line Number 5-15 Line number field 5-14 Overwrite mode 5-12 Text Editor 5-12 The Continuous Function Chart Editor (CFC) 2-21 The Standard 2-25 THEN 2-12 TIME 10-36 TIME Constants 10-29 Time Management in SFC 5-33 TIME_OF_DAY 10-36 TIME_OF_DAY Constants 10-29 TIME_TO Conversions 10-22 TIME-Function 10-33 Timer 10-52 tnf-File 6-34, 6-49 TO 2-14 TO_BOOL Conversions 10-20 TOD 10-36
CoDeSys V2.3
11Index
TOD_TO Conversions 10-22 TOF 10-54 Toggle Breakpoint 4-54 TON 10-53 Tool bar 4-6 Tools Creating new Shortcuts 6-61 Executing Shortcuts 6-65 Frequently asked questions 6-65 Object Properties 6-62 Saving Tool Shortcuts 6-65 Shortcut 6-62 Tools 6-62 Tooltip SFC 5-34 Tooltip 4-41, 5-13, 5-18, 5-24, 5-29 Tooltip for comment 5-1 TP 10-52 Trace Automatically Read 6-45 Load from file 6-48 Load from PLC 6-49 Save to file 6-48 Save trace values 6-47 Set as project configuration 6-49 Trace Buffer 6-46 Trace Configuration ASCII file 6-48 Auto Read 6-45 Compress 6-47 Cursor Mode 6-46 Load values 6-48 Multi Channel 6-46 Read Trace 6-45 Sample Rate 6-43 Save Values 6-47 Selection of Trace variables 6-45 Show grid 6-47 Start Trace 6-45 Stop Trace 6-45 Stretch 6-47 Trace Buffer 6-46 Trigger 6-43 Values in ASCII file 6-48 Y-Scaling 6-47 Trace Variable 6-45 Transition 2-17 Transition / Transition condition 2-17 Transition-Jump 5-31 Translate into another language 4-23 Translate Project (into another Language) 4-26 Translation Switch view to another language 4-27 Translation file Creation 4-24 Translation file 4-23 Trigger 2-23, 6-43, 10-52 Trigger Edge 6-43 Trigger Level 6-43 Trigger Position 6-43 TRUNC 10-23 TSP 6-34, 6-49 Turn-off delay 10-54 Turn-on delay 10-53 Type 5-6, 10-38, 10-39, 10-40 Type Conversions 10-19 Typed Literal 5-4
CoDeSys V2.3
Typed Literals 10-31
U UDINT 10-35 UDINT Constants 10-30 UINT 10-35 UINT Constants 10-30 Undo 4-48 Undo Check Out 4-37 UNTIL 2-15 Upload of parameter lists 6-56 User group 4-32 User group passwords 4-33 User information 4-5 User parameters DP slave 6-24 User-defined Libraries 6-9 USINT 10-35 USINT Constants 10-30
V VAR 5-4 VAR_CONFIG 6-2, 6-6 VAR_CONSTANT 5-4, 6-6 VAR_EXTERNAL 5-5 VAR_GLOBAL 6-2 VAR_IN_OUT 5-3 VAR_INPUT 5-3 VAR_INPUT CONSTANT 5-40 VAR_OUTPUT 5-3 VAR_PERSISTENT 5-4, 6-6 VAR_RETAIN 5-4, 6-6 Variable Insert in Editor 5-2 Variable Configuration Insert Instance Paths 6-7 Variable Configuration 6-6 Variable declaration 5-9 Variable name 5-5 Variables 10-31 Variables declaration 5-5 Visualization 2-8, 4-2 Voreinstellung 6-33
W Watch and Receipt Manager Force Values 6-42 Insert New Watch List 6-41 Load Watch List 6-41 Offline Mode 6-40 Online Mode 6-41 Read Receipt 6-42 Rename Watch List 6-41 Save Watch List 6-41 Write Receipt 6-42 Watch and Receipt Manager 6-40 Watch and Receipt Manager 6-42 Watch List 6-40 Watch Variable 5-11, 5-24 What is CoDeSys 1-1 GatewayDDEServer 9-3 WHILE 2-14 WHILE loop 2-10, 2-14
XIII
Errors
Window 4-62 Window Arrange Symbols 4-62 Window Cascade 4-62 Window Close All 4-62 Window Log 6-10 Window Messages 4-62 Window set up 4-62 Window Tile Horizontal 4-62 Window Tile Vertical 4-62 WORD 10-35 WORD Constants 10-30 Work space 4-2 Write file to controller 4-61 Write protection password 4-10 Write Receipt 6-42 Write values 4-55 Write/Force Dialog 4-58
XIV
X XE 1-1 XOR 10-9 XOR Operator in AWL 2-9
Y Y Scaling 6-47
Z Zoom Action in SFC 5-32 Zoom in graphic editors 5-17 Zoom to POU 5-1, 5-47 Zoom Transition 5-32
CoDeSys V2.3