Sie sind auf Seite 1von 59

CPX-CEC-...

Table of Contents
1 CPX-CEC-... ......................................................................................................................................... 1
1.1 Modular valve terminal with integrated controller CPX-CEC-... .................................................... 1
1.2 CoDeSys provided by Festo for CPX-CEC-... .............................................................................. 1
1.2.1 What is CoDeSys provided by Festo? .............................................................................. 1
1.2.2 Additional functions for CPX-CEC-... ................................................................................ 2
1.2.3 Documentation and Help .................................................................................................. 2
1.2.4 Designated use ................................................................................................................. 3
1.2.5 Service .............................................................................................................................. 3
1.2.6 Target group...................................................................................................................... 3
1.2.7 Important user information ................................................................................................ 3
1.2.8 Marking special information in the target system-specific Help......................................... 3
1.3 Overview of functions and libraries .............................................................................................. 5
1.3.1 Function overview ............................................................................................................. 5
1.3.2 Libraries .......................................................................................................................... 14
1.4 Preliminary work ........................................................................................................................ 16
1.4.1 Prerequisites ................................................................................................................... 16
1.4.2 Preparing the PC ............................................................................................................ 16
1.4.3 Installing the target system ............................................................................................. 17
1.4.4 Selecting the target system............................................................................................. 20
1.5 CPX-CEC-... PLC configuration ................................................................................................. 21
1.5.1 IP address setting ........................................................................................................... 22
1.5.2 Target system settings .................................................................................................... 24
1.5.3 General parameter information ....................................................................................... 25
1.5.4 System parameter settings ............................................................................................. 26
1.5.5 Rotary switch settings ..................................................................................................... 26
1.5.6 Manual I/O configuration of the CPX system .................................................................. 27
1.5.7 Configuring RS-232 (CPX-CEC only) ............................................................................. 31
1.5.8 Configuring SoftMotion for CPX-CEC-M1 ....................................................................... 32
1.6 CPX module descriptions ........................................................................................................... 35
1.6.1 System configuration tabs............................................................................................... 35
1.7 Online configuration/online mode............................................................................................... 37
1.7.1 Determining the network configuration ........................................................................... 37
1.7.2 CPI scan ......................................................................................................................... 38
1.8 Diagnosis ................................................................................................................................... 39
1.8.1 Diagnostic options with the PLC configuration in online status ....................................... 39
1.8.2 Error and diagnostic information ..................................................................................... 40
1.9 Diagnosis in the user program ................................................................................................... 41
1.9.1 Example: A short-circuit on the 5th output channel of the 3rd module (8DI/8DO) ........... 42
1.9.2 Error handling by the CPX-CEC-... ................................................................................. 44
1.9.3 CANopen fieldbus master diagnosis ............................................................................... 46
1.10 Application and programming instructions ................................................................................. 52
1.10.1 I/O update ....................................................................................................................... 52
1.10.2 Using CANopen masters ................................................................................................ 52
1.10.3 CPX-MMI use and program downloads .......................................................................... 52
1.11 Appendix .................................................................................................................................... 53
1.11.1 Festo terms and conditions for the use of software packages ........................................ 53

2 Glossary ............................................................................................................................................ 55

3 Index .................................................................................................................................................. 57
1 CPX-CEC-...
1.1 Modular valve terminal with integrated controller CPX-CEC-...
You can find a complete description of the Festo CoDeSys controller CPX-CEC-... in the manual P.BE-
CPX-CEC-EN (see also CPX-CEC_en.pdf on CD-ROM).
A complete development environment based on CoDeSys 2.3.x from the company 3S - Smart Software
Solutions GmbH exists for the Festo CoDeSys controller CPX-CEC-.... This environment supports a large
number of different controllers from various manufacturers. These devices incorporate a wide range of
different features and functions.
In order to use a controller (target system) under CoDeSys, a so-called Target Support Package
is required for the relevant target system. The package allows access to the system functions of
the target system and includes useful information in the form of an online Help function. The
Target Support Package renders CoDeSys functions useable for the relevant device or restricts
them, depending on the circumstances.

CoDeSys 2.3.x can support all the features and functions of these devices with the relevant Target Support
Package. CoDeSys provided by Festo therefore contains many functions that are only available on certain
controllers. Not all of these functions are supported by all Festo CoDeSys controllers.
The function overview that follows shows which functions of CoDeSys provided by Festo are
supported by the CPX-CEC-….

1.2 CoDeSys provided by Festo for CPX-CEC-...


The manual applies to the following controller types:
– CPX-CEC (with RS-232 communication interface)
– CPX-CEC-C1 (with CANopen communication interface)
– CPX-CEC-M1 (with CANopen communication interface and SoftMotion software package)
Unless otherwise mentioned, the instructions and explanations in this manual always apply to all controller
types.

1.2.1 What is CoDeSys provided by Festo?


CoDeSys stands for Controller Development System and is a development environment for PLC systems.
The control sequences are implemented with CoDeSys. CoDeSys simplifies communication with the
hardware by using five programming languages that comply with standard IEC 61131-3. The fact that
CoDeSys can be used independently of the hardware manufacturer allows the implementation of control
tasks in larger networks based on a uniform standard.
CoDeSys provided by Festo is a complete development environment for Festo CoDeSys controllers such
as the CPX-CEC, CPX-CEC-C1 and CPX-CEC-M1. It is based on the development environment CoDeSys
2.3.x from 3S - Smart Software Solutions GmbH that supports a wide range of controllers from different
manufacturers. These devices incorporate a wide range of different features and functions.

In order to use a controller (target system) under CoDeSys, a so-called Target Support Package
is required for the relevant target system. The package allows access to the system functions of
the target system and includes useful information in the form of an online Help function. The
Target Support Package renders CoDeSys functions useable for the relevant device or restricts
them, depending on the circumstances.

CoDeSys provided by Festo contains many functions that are only available on certain
controllers. Not all functions are supported by all Festo CoDeSys controllers.
The CPX-CEC-... function overview that follows shows which functions of CoDeSys provided by
Festo are supported by the CPX-CEC-.....

1
CPX-CEC-...

1.2.2 Additional functions for CPX-CEC-...


CoDeSys provided by Festo offers the following additional functions that have been specially adapted to
the CPX-CEC-...:
Additional function Brief description

Libraries for the Festo CoDeSys – System libraries that provide access to the special hardware
controller and software functions of the CPX-CEC-... (e.g. access to
real-time clock, file system, communication interfaces, etc.).
– Other target system-specific libraries for the CPX-CEC-...

Network configuration of the Festo Special dialogs for setting the communication parameters of the
CoDeSys controller network configuration
Parameterisation of the Festo Special dialogs for accessing CPX-CEC-... parameters and data
CoDeSys controller
Online and offline hardware Configuration of the CPX and determination of the actual
configuration, SCAN functions configuration for the CPX-CEC-...
Diagnostic options with the PLC Diagnosis using the PLC configuration
configuration in online status

Detailed information on additional functions is included in the sections that follow.

1.2.3 Documentation and Help


CoDeSys provided by Festo includes:
– Original documentation and Help relating to CoDeSys 2.3.x from 3S - Smart Software Solutions
GmbH.
– Target system-specific documentation and Help from Festo for Festo CoDeSys controllers and
CoDeSys provided by Festo.
The target system-specific Help for Festo CoDeSys controllers is only displayed if the Festo CoDeSys
controller is configured as the target system. Help pages are accessed via "Target" in the contents index of
the online Help window, as shown in the screenshot below:

Figure: Target system-specific Help for Festo CoDeSys controllers

2
Modular valve terminal with integrated controller CPX-CEC-...

1.2.4 Designated use


With CoDeSys provided by Festo, the user who is familiar with the component connected to the PC can
undertake the configuration, commissioning and programming of the supported controllers.
Observe the standards specified in the relevant sections, as well as national and local laws and technical
regulations.

1.2.5 Service
Please contact your local Festo Service partner if you have any technical problems
(see http://www.festo.com).

1.2.6 Target group


This manual is intended exclusively for technicians trained in control and automation technology who have
experience in installing and commissioning programmable logic controllers.

1.2.7 Important user information


Danger categories
This document contains information on possible dangers that can occur if the product is not used as
designated. These danger warnings are marked with a signal word (warning, caution, etc.), placed on a
grey background and additionally marked with a pictogram. A distinction is made between the following
danger warnings:

Warning
... means that serious injury to people and damage to property can occur if this warning is not
heeded.

Caution
... means that injury to people and damage to property can occur if this warning is not heeded.

Note
... means that damage to property can occur if this warning is not heeded.

You can find details on how special information is represented under "Marking special information".

1.2.8 Marking special information in the target system-specific Help


You can find information on how danger warnings are represented under "Important user information".

Pictograms
The following pictograms mark passages in the text that contain special information.
Information: Recommendations, tips and references to other sources of information.

Accessory: Information on necessary or useful accessories for the Festo product.

Environment: Information on the environmentally friendly use of Festo products.

Text markings
1. Figures denote activities that must be carried out in the order specified.
• Bullets denote activities that may be carried out in any desired order.
– Hyphens denote general listings.

3
CPX-CEC-...

Further conventions
[Project] [New] Menu items are framed in square brackets, for example the [New ...] command in the
[Project] menu opens a new project.

"OK" The names of windows, dialogues and buttons, e.g. "Message window," "Extract
project," "OK" as well as designations are displayed in inverted commas.

CTRL Names of keys on the PC keyboard are represented in the text with uppercase letters
(e.g. ENTER, CTRL, C, F1, etc.).

CTRL + C For some functions you need to press two keys simultaneously. For example, press
and hold down the CTRL key and also press the C key. This is represented in the text
as CTRL + C.

If "click" or "double-click" is mentioned, this always applies to the left-hand mouse


button. If the right-hand mouse button is to be used, this will be explicitly mentioned.

4
Modular valve terminal with integrated controller CPX-CEC-...

1.3 Overview of functions and libraries


1.3.1 Function overview
This function overview specifies which functions are supported or not supported by the CPX-CEC-... and
which defaults are applied when a new project for this target system is created.

Functionality/functions Supported

Project options Load & Save Yes

User Information Yes

Editor Yes

Working area Yes

Colors Yes

Directories Yes

Log Yes

Build Debugging Yes

Replace constants Yes

Nested Yes
comments

Create binary file of the Yes


application

Actions hide Yes


programs

Treat LREAL as REAL Yes

Number of data segments Yes

Exclude objects Yes

Compiler version Yes

Macro before compile Yes

Macro after compile Yes

Check automatically Yes

Passwords Yes

Source download Source code only Yes

All files Yes

Implicit at load Yes

Notice at load Yes

Implicit on create boot project Yes

Only on demand Yes

Symbol configuration Yes

Database connection Yes

Macros Yes

5
CPX-CEC-...

Functionality/functions Supported

Manage projects All functions Yes


Manage objects All functions Yes
General editing All functions Yes
functions

Functionality/functions Supported

General online Login Yes


functions (part 1)
Logout Yes

Download Yes

Start Yes

Stop Yes

Reset Yes

Reset (cold) Yes

Reset (original) Yes

Toggle breakpoint Yes

Breakpoint dialog Yes

Step over Yes

Step in Yes

Single cycle Yes

Write values Yes

Force values Yes

Release force Yes

Write/Force dialog Yes

Functionality/functions Supported

General online Show call stack Yes


functions (part 2)
Display flow control Yes
Simulation mode Yes
Communication parameters Yes
Sourcecode download Yes
Create boot project Yes
Write file to PLC Yes
Read file from PLC Yes
1)
Online change Yes
VAR PERSISTENT Yes
1) The content of addresses may shift when Online change is selected.

6
Modular valve terminal with integrated controller CPX-CEC-...

Functionality/functions Supported

Window All functions Yes


Editors (languages) Instruction list (IL) Yes
Structured text (ST) Yes
Sequential function chart (SFC) Yes
Function block diagram (FBD) Yes
Ladder diagram (LD) Yes
Continuous function chart (CFC) Yes
PLC Settings Automatic calculation of addresses Adjustable
configuration
Check for overlapping addresses Yes
Save configuration files in project Yes
HW scan Yes
Status Yes
Diagnosis from target system Yes
Alarm All functions Yes
configuration
Global All functions Yes
variables
Library manager All functions Yes
Log All functions Yes

Functionality/functions Supported

Task configuration Append task Name Yes


1)
Priority (0-31) Yes
Cyclic Yes
Freewheeling Yes
Triggered by event Yes
Triggered by external event Yes
Watchdog Yes
Time
Sensitivity
Append program call Yes
1) If the priority is the same, the longer waiting time is decisive

7
CPX-CEC-...

Functionality/functions Supported
1)
System events start Yes
stop
before_reset
after_reset
shutdown
excpt_cycletime_overflow
excpt_watchdog
excpt_divide_by_zero
CPX_System_Fault
CAN_error_passive
CAN_bus_off
Task configuration in All functions Yes
online mode
Task processing The task with the valid condition is executed: this means after the Yes
time specified under "Interval" has expired or after a leading
edge from the condition variable specified under Event.
If several tasks have a valid condition, the task with the highest Yes
priority is executed.
If several tasks have a valid condition and the same priority, the Yes
task with the longest waiting time is executed.
In online mode, the program calls for each task are processed in Yes
the sequence in which they appear in the task editor from top to
bottom.
PLC_PRG processed as a cyclic task with 10 ms and watchdog. Yes
2)

Extras-> Set debug task Yes


Extras-> Enable/Disable task Yes
Extras-> Callstack Yes
1) The controller is a pre-emptive multitasking system where high-priority tasks can interrupt and
supersede low-priority tasks. The system events are executed in a context where the task with the
highest priority supersedes all other tasks. A system event should therefore contain only a very short
code.
– Tasks with priorities between 0 and 16 run in the real-time context of the operating system so that the
execution of these tasks is timed precisely!
On the other hand, this means that these kind of tasks have priority over operating system functions
such as network traffic. This must be taken into consideration when programming loops so as not to
block the system. Infinite loops in real-time tasks must be avoided at all costs.
– Tasks with priorities >= 17 are not executed in the real-time context and can therefore be interrupted
by network traffic, for example.
The IEC task with the highest priority that is running as an event-triggered task should be used for error
handling. Within the context of the event, the system only calls the event that this task is waiting for
(information that would otherwise be lost such as the exact time stamp is retained if required; this should
only include information assigned to global variables).
2) Some functions (e.g. SysRTCSetTime) may trigger the watchdog.

8
Modular valve terminal with integrated controller CPX-CEC-...

Functionality/functions Supported

Watch and recipe Offline Insert -> New watch list Yes
manager mode
Extras -> Rename watch list Yes
Extras -> Save watch list Yes
Extras -> Load watch list Yes
Online Extra -> Monitoring active Yes
mode
Extras -> Write recipe Yes
Extras -> Read recipe Yes
Force values and write to watch manager Yes
Working area All functions Yes

Functionality/functions Supported/name

Target settings Target Name Festo CPX-CEC/CPX-CEC-C1


Platform Festo CPX-CEC-M1

Parameter size adapted to type Only relevant for X86

Functionality/functions Setting

Target settings Memory Base, area Fixed setting


Layout
Size (code) 4 MB
Size per segment (global) 8 MB
Size (flag) 8 KB
Size (input) 8 KB
Size (output) 8 KB
1)
Size, retain 30 KB
Retain in own segment On
Total size of data memory 8 MB
Maximum number of global data segments 1
Maximum number of POUs 4096
1) 12 bytes are used by the run-time system, leaving 30708 bytes available for the application.

9
CPX-CEC-...

Functionality/functions Supported

Target settings General I/O configuration: Configurable Yes


I/O configuration: Download as file No (attached
to program
code)
I/O configuration: No address check Yes/option of
setting
Support CANopen configuration Yes
Support preemptive multitasking Yes/fixed
Online change Yes/option of
setting
Update unused I/Os Yes/option of
setting
Single task in multitasking No
Byte addressing mode No/fixed
Initialize zero Yes/fixed
Download symbol file Yes/option of
setting
Symbol config from INI file No
PLC browser Yes
Trace Yes
VAR_IN_OUT as reference Yes/fixed
Initialize inputs Yes/fixed
Load bootproject automatically Yes/option of
setting
1)
SoftMotion Yes
Retain forcing No/fixed
Save No
Cycle independent forcing No
1) Only in the CPX-CEC-M1 variant

10
Modular valve terminal with integrated controller CPX-CEC-...

Functionality/functions Supported

Target settings Network Support parameter manager Yes/option of setting


functionality 1)
Support network variables Yes /option of setting
Names of supported network Yes
interfaces
Index ranges for parameters Yes
Index ranges for variables Yes
Index ranges for mappings Yes
Subindex range Yes
Visualization Display width in pixel Yes/option of setting
Display height in pixel Yes/option of setting
2)
Use 8.3 file format Yes /option of setting
Alarmhandling in the PLC No
Store trend data in the PLC Yes/option of setting
Activate system variable Yes/option of setting
'CurrentVisu'
Supported fonts in the target No
Simplified input handling Yes/option of setting
Web visualization No
Inhibit download of visualization files Yes/option of setting
Target visualization No
Use VISU_INPUT_TASK Yes/fixed
Deactivate task generation No
Keyboard usage for tables Yes/option of setting
1) Network variables are only supported via UDP.
2) MS-DOS file name convention (8+3 characters).

11
CPX-CEC-...

Functionality/functions Supported

Trace All functions Yes


PLC browser All functions Yes
Parameter manager All functions Yes
ENI All functions No
IEC operators and Arithmetic operators Yes
additional functions
that upgrade Bit string operators Yes
standards
Bit shift operators Yes
Selection operators Yes
Comparison operators Yes
Address operators Yes
Call operator Yes
Type conversions Yes
Numerical operators Yes
Parameters in Constants BOOL constants Yes
CoDeSys
TIME constants Yes
DATE constants Yes
TIME_OF_DAY constants Yes
DATE_AND_TIME constants Yes
Numerical constants Yes
REAL and LREAL constants Yes
STRING constants Yes
Typed constants Yes
Variables Variables Yes
1)
System flags (implicitly declared variables in the No
TSP)
Addresses %+range prefix + size prefix + number (e.g. Yes
%QX4.7)
1) System flags must be created in the controller.

12
Modular valve terminal with integrated controller CPX-CEC-...

Functionality/functions Supported

Data types in Standard BOOL Yes


CoDeSys data types
Integer data types Yes
REAL/LREAL Yes
String Yes
Time data types Yes
Defined data Array Yes
types
Pointer Yes
List type Yes
Structures Yes
References Yes
Subcategory type Yes
Operators in Operators Yes
CoDeSys
Functions of the Standard.lib library Yes
Functions of the Util.lib library Yes
Command line Command line instructions Yes
instructions
Command file instructions Yes
Keyboard operation All functions Yes
Siemens import All functions Yes
DDE communication All functions Yes
CoDeSys All functions Yes
visualisation
1)
CoDeSys HMI All functions Yes
1)
CoDeSys licence All functions Yes
management
Tools for activating All functions No
external applications
2)
SoftMotion All functions Yes
1) Not included in the scope of delivery of CoDeSys provided by Festo.
2) Only in the CPX-CEC-M1 variant with restrictions (see the chapter "Configuring SoftMotion for CPX-
CEC-M1")

13
CPX-CEC-...

1.3.2 Libraries
CoDeSys provided by Festo offers the following libraries for the Festo CoDeSys controller.

Library Description Source

Standard.lib Modules that the IEC61131-3 requires as standard 3S


modules for an IEC programming system. – Standard
Util.lib Modules for BCD conversion, bit/byte functions, libraries for
mathematical help functions, controllers, signal CoDeSys
generators, function manipulators and analogue value
processing.
AnalyzationNew.lib Modules for analysing expressions.
IecSfc.lib ActionControl

3S_CanDrv.lib Only for internal use in combination with the CANopen 3S


3S_CANopenManager.lib master. – CANopen
3S_CANopenMaster.lib libraries

BusDiag.lib Diagnosis for CANopen bus systems. 3S


– Target
system-
specific
libraries that
are specially
adapted to the
CPX-CEC-....

1)
SysLibCallback.lib System libraries that provide access to the special
SysLibCom.lib hardware and software functions of the Festo
CoDeSys controller (e.g. access to real-time clock, file
SysLibDir.lib system, communication interfaces, etc.).
SysLibEvent.lib System libraries other than those listed are not
SysLibFile.lib approved for the CPX-CEC-....
SysLibFileAsync.lib
SysLibFileStream.lib
SysLibGetAddress.lib
SysLibIecTasks.lib
SysLibMem.lib
SysLibPLCConfig.lib
SysLibProjectInfo.lib
2)
SysLibRtc.lib
SysLibSem.lib
3)
SysLibSockets.lib
3)
SysLibSocketsAsync.lib
SysLibStr.lib
SysLibSymbols.lib
SysLibTask.lib
SysLibTime.lib
SysLibVisu.lib
SysTaskInfo.lib
NetVarUdp_LIB_V23.lib
4)
ModbusTCPSrv.lib Modules for communicating via Modbus TCP. 3S (additional
libraries)
– Modbus
libraries for
CoDeSys

14
Modular valve terminal with integrated controller CPX-CEC-...

Library Description Source

Festo_CameraControl.lib Modules for access (non-blocking) to the Compact Festo AG & Co.
Vision System SBO...-Q(-WB), e.g. triggering of an KG
image, reading in of results.
Communication is via Telnet.
Festo_CAN_Controller.lib Modules for status monitoring of the CANopen master.

Festo_EasyIP.lib Modules for easy data exchange between EasyIP-


compatible controllers and devices.
Festo_Motion.lib Modules for parameterising and controlling motor units
and motor controllers from Festo.
Festo_CPX.lib Function blocks for the CPX valve terminal.
Festo_CPX_extern.lib Hidden library that is loaded automatically in a CPX-
CEC-... project.
The library provides functions that are required by
other Festo libraries.
1) The SysLibCallback.lib supports the system events listed under "System events".
2) SysRtcCheckBattery and SysRtcGetHourMode are not supported. A time specification between
2000.01.01-00:00:00 and 2038.01.19-03:14:07 is valid.
3) Only ports larger than 15000 should be used for the application.
4) View additional descriptions for the application under:
...\Targets\Festo\"Controller"\Help\[Language]....

Note
• Note that only the functions and function blocks from the Standard.lib library are standardised
according to IEC61131-3. Functions and function blocks from other libraries are manufacturer-
specific.

When CoDeSys provided by Festo is installed, the following libraries are also installed
automatically together with the Target Support Package (TSP) for the Festo CoDeSys controller:
– Standard.lib, Util.lib, IecSfc.lib, SysLibCallback.lib, SysLibTime.lib, SysTaskInfo.lib
– SM_DriveBasic.lib, SM_PLCOpen.lib, SM_ERROR.lib, DummyDrive.lib, SM_CNC.lib,
SM_TRAFO.lib (CPX-CEC-M1 only)
Subject to change.
If the library is not included in your library manager, you can add the library using the 'Additional
library' dialog box.

Only use libraries that are approved for the CPU module. A list of libraries approved for Festo
CoDeSys controllers is included in the installation directory under
...\Targets\Festo\"Controller"\Library\....

Recommendation: Always use the latest module versions. Visit www.festo.com for information on
the current module versions of Festo libraries.

15
CPX-CEC-...

1.4 Preliminary work


1.4.1 Prerequisites
Hardware
– CPX-CEC-... with active CoDeSys run-time system
– Ethernet network components
– PC (Windows 2000 or higher) with Ethernet interface

Software
– CoDeSys V2.3 provided by Festo
– Target Support Package: Festo CPX-CEC-... compatible with firmware

Important documentation for controller hardware and software


Filename Contents

CPX-CEC_en.pdf Manual for Festo controller (English)


CoDeSys_V23_E.pdf Manual for CoDeSys programming system (English)
CoDeSys_Visu_V23_E.pdf Manual for CoDeSys visualisation (English)
OPC_20_how_to_use_E.pdf Documentation for OPC server V2.0, installation and use
(English)

Table: List of important user documentation

After installing CoDeSys pb Festo, you will find further documentation in the program directory of
CoDeSys provided by Festo on your PC:
...\CoDeSys V2.3\Documents
...\CoDeSys V2.3\Targets\Festo\"Controller"\Help
Subfolders contain the documents in different languages.

1.4.2 Preparing the PC


The following software package is required to use CoDeSys pb Festo for CPX-CEC-...:
CoDeSys V2.3 provided by Festo with TSP for CPX-CEC-...
• Alternatively, use:
– the CD-ROM provided,
– the installation package downloaded from the Internet (see http://www.festo.com/download).
Install the software packages on your PC if a previous version of these packages is installed or if no
packages are installed at all. Information on installation and system requirements for the software
packages is included in the relevant user documentation.

16
Modular valve terminal with integrated controller CPX-CEC-...

1.4.3 Installing the target system


If the software package "CoDeSys V2.3 provided by Festo" has already been installed and operated with
other controllers, the Target Support Package (TSP) for the new target system may have to be installed.
The Target Support Package contains information on the controllers (target system) required by "CoDeSys
V2.3 provided by Festo".
Depending on the controller you will require the following Target Support Package:
– "Festo CPX-CEC / CPX-CEC-C1".
– "Festo CPX-CEC-M1".

The Target Support Package is often provided as a ZIP file. The file must be unpacked prior to
installation.
• Use a temporary folder to do this.
• Make sure that the structure of the folders in the ZIP file remains the same.

• Install the Target Support Package using the program "InstallTarget".


This program is located in the Start menu under Programs\Festo Software\CoDeSys V2.3 by Festo.

Figure: Adding Target Support Packages using "InstallTarget"

Packages that have already been installed are displayed under "Possible Targets".
Note
The old version must be uninstalled before the new version for an existing TSP can be installed.
• Remove the old version using the "InstallTarget" program.
• Delete the directory of the old TSP from your file system.

• Click the "Open" button to select the Target Support Package.

17
CPX-CEC-...

Figure: Opening the Target Support Package

• Select the file "CPX-CEC.tnf", for example, from the temporary folder that you created when
unpacking the ZIP file. Then click "Open".
The Target Support Package is added on the left side under "Possible Targets".

Figure: Possible and installed target systems

• Enter the path of the directory where you wish to install the Target Support Package under "Installation
directory". You can also change the installation directory using the "..." button.
• Highlight the target system to be installed on the left and click the "Install" button.
If the installation directory specified is not available, the following message asks whether you wish to
create the directory.
• If so, click "Yes" to confirm.
The new Target Support Package should then appear on the right under "Installed Targets".

18
Modular valve terminal with integrated controller CPX-CEC-...

Figure: Target system is added to "Installed Targets"

• Click the "Close" button to exit the program.


The temporary folder that was created during the unpacking process can now be deleted together with all
contents because it is no longer required.

19
CPX-CEC-...

1.4.4 Selecting the target system


A new project must be created before a target system can be selected.
• Select the [File] [New] menu command. The "Target Settings" window is then opened.

Figure: New project

• Select the relevant entry to configure projects on the Festo CoDeSys controller.
• Click "OK" to confirm this target system setting.

The next window opens automatically so that you can create a new programming module.

Figure: Creating a programming module

• Select the program type from the "Type of POU" field.


• Select a programming language ("ST" for "Structured Text" in this example) from the "Language of the
POU" field.
• Click "OK" to close the window.

20
Modular valve terminal with integrated controller CPX-CEC-...

1.5 CPX-CEC-... PLC configuration


The PLC configuration includes a description of the target system settings. The description specifies which
controller components are used and how they are configured.
• Select the "Resources" tab in the Organizer object.

Figure: Opening the PLC configuration

• Double-click on the "PLC Configuration" item to open the respective window.


The target system and all components (inputs, outputs, CANopen bus, etc.) are displayed in a tree
structure in the left section of the "PLC Configuration" dialog window.

Figure: PLC configuration

Other settings are available on different tabs. The most important settings are described in the following
chapters.
Appropriate variables must be defined so that outputs and inputs or diagnostic information and parameters
can be read and written. These variables are usually created as global variables and are defined in the
declaration part using the following syntax:
o Variable name AT address: data type;
Refer to the CoDeSys general online Help for more detailed information on defining global
variables.

21
CPX-CEC-...

1.5.1 IP address setting


In the "Network Configuration" dialog, you can:
– search within the network,
– add a connection to a controller,
– modify network settings for the listed controllers,
– set a controller as a so-called active PLC.
In the delivery status of the CPX-CEC-..., a search for an automatically assigned IP address (via the DHCP
protocol) is carried out when it is switched on for the first time. The located IP address is shown in the
screenshot.
After searching unsuccessfully for about 15 seconds, the CPX-CEC-... selects the configured static IP
address automatically. The default address on delivery is 192.168.2.50.

Figure: Network configuration

Key:
Connection established to the device

No connection to the device

Connection to the device not possible, convert IP address if necessary

Option Explanation

PLC Name Defines a name for the connected CPX-CEC-....


IP IP address of the device.
You can freely select the address in a closed, local network consisting
exclusively of your devices and your PC depending on the network settings of
your PC. If your network is connected to your company network, you must ask
for the permitted IP addresses (usually from your IT department).
Subnetmask Netmask of the device.
The netmask for IP addresses defines with "0" as a placeholder, the bits
which are used for addressing the slave (host ID). A 1 as placeholder defines
the bits which contain the network address (net ID).
Gateway Gateway address.
The IP address of a gateway is necessary if stations from other networks
(other net ID) are to be able to connect with the device. If a gateway is
entered, it will be assumed that a connection to other networks is possible.
"Enable DHCP" Defines whether the IP address, netmask and gateway are to be assigned
checkbox automatically.
• Select this setting if you are using a DHCP server in your network and if
the IP address as well as the netmask are to be assigned automatically via
the DHCP protocol (DHCP stands for Dynamic Host Configuration
Protocol).
"OK" button Accepts the settings undertaken and transfers them to the appropriate device.

22
Modular valve terminal with integrated controller CPX-CEC-...

In this dialog, you can modify the network settings of the selected device and enter an IP address
manually:
1. Highlight the CPX-CEC-... root module in the PLC configuration and select the "Network configuration"
tab.
Click the "Search network" button. An automatic search for compatible devices is then run. Located
devices are displayed in the list on the "Network configuration" tab.
2. Highlight the device whose network configuration you would like to modify on the "Network
configuration" tab.
3. Now undertake the network settings: open the "Network Configuration" dialog using the "Change
settings" button.
Figure: "IP configuration" tab for the Festo CoDeSys controller

– Check "Enable DHCP" if you are using a DHCP server.


– Otherwise, enter the desired IP address, netmask and gateway address manually (see example
below).
4. Then click "OK".
The DHCP server assigns the IP address in the network and the modified settings are transferred to
the device. The CPX-CEC-... then reboots automatically.
5. Click the "Search network" button again. The device with the new network settings is detected again
and displayed in the list on the "Network configuration" tab.
6. Select the required CPX-CEC-... from the list and click the "Set as active PLC" button.
The IP address is adopted in the CoDeSys communication settings.

Example of possible settings:


– IP address of the PC: 192.168.2.1
– Netmask: 255.255.255.0.
– IP address of the first Festo CoDeSys controller: 192.168.2.50 (default)
– IP address of the second Festo CoDeSys controller: e.g. 192.168.2.51 (must be configured)
If the search for the CPX-CEC-... within the network is unsuccessful (e.g. if the device is located in a
remote subnet e.g. VPN, remote maintenance, etc.), the CPX-CEC-... can be added manually. The only
requirements are that the IP address of the device is known and that communication with the device is
actually possible via TCP/IP.

23
CPX-CEC-...

1.5.2 Target system settings


The "Target Settings" dialog window is located in the "Object Organizer".
• Activate the "Resources" tab and double-click on the relevant entry to open the "Target Settings"
dialog window.

Figure: Opening the target settings

The name of the target system is located at the top of the dialog window (CPX-CEC-... in this case).
The dialog window expands and displays all functions for setting the CPX-CEC-... on five tabs.
– Target Platform
– Memory Layout
– General
– Network functionality
– Visualization

Figure: Target settings

24
Modular valve terminal with integrated controller CPX-CEC-...

"General" tab

Figure: Target settings "General" tab

1. "Load bootproject automatically" function


Note
The boot project in the controller can be overwritten automatically.
• Deactivate the "Load bootproject automatically" function if necessary.

2. "No address check" function


Note
The "No address check" option in the "Target Settings" dialog relates to the check of I/O
addresses used in the PLC code. CoDeSys can determine whether a PLC program references an
incorrect address.
In contrast, the "Check for overlapping addresses" option ensures that the address ranges of
individual modules in the PLC configuration are not exceeded, which can be extremely useful
when defining the module addresses manually.

The CoDeSys general online Help contains information on all other settings for the target system.

1.5.3 General parameter information


The representation and options for setting CPX module parameters vary depending on the
connection mode:
– Offline: parameters can be set
– Online: active parameters are displayed
The modified parameters are transferred to the CPX system and activated as soon as an online
connection is established.

25
CPX-CEC-...

1.5.4 System parameter settings


The system parameter settings for the overall CPX system are configured as follows:
1. Select the CPX module in the "PLC Configuration" window.
2. Switch to the "System Parameters" tab.
3. Change the individual parameter values if required.

Figure: System parameter settings

1.5.5 Rotary switch settings


The complete description for the Festo CoDeSys controller CPX-CEC P.BE-....-... contains
information on rotary switch settings for the CPX-CEC-... (see also CPX-CEC_en.pdf on CD-ROM).

The rotary switch is permanently assigned to a variable in the PLC configuration. The marking in the
configuration area makes this input address available as a global variable (%IB0, %IX0.0 to %IX0.7) so
that all the programs in the controller can access this variable.
The controller is in stop status when the rotary switch is set to 0.

Figure: Display of the rotary switch value in the PLC configuration

26
Modular valve terminal with integrated controller CPX-CEC-...

1.5.6 Manual I/O configuration of the CPX system


You can define the setpoint configuration manually using the "PLC Configuration" of CoDeSys provided by
Festo. After a new project is created for the CPX-CEC-..., a list of basic CPX-CEC-... modules appears in
the configuration tree of the PLC configuration.
The context menu for the module selected in the configuration tree contains commands for appending and
deleting elements or subelements.
– IOModules support menu commands such as "Scan module configuration" and "Append Subelement".
– Inserted modules only support the menu command "Insert Element".

Scan module configuration


You can use this command to read in the module configuration of the CPX system.
Prerequisite: the CPX-CEC-... is configured correctly and addressable via the network.

Deleting elements and subelements


Elements are deleted by clicking on the element with the right mouse button and executing the "Delete"
command in the context menu.
Elements or subelements can only be replaced if you:
1. Delete the subelement that is not required ([Delete] command in the context menu),
2. Insert a new element (see below).

Inserting elements
For CPX-CEC:
– RS232
For CPX-CEC-C1:
– CANopen masters
For CPX-CEC-M1:
– SoftMotion (alternatively CANopen masters)
– VirtualBusInterface
For IOModules:
– Local CPX modules
For CANopen-Master:
– CANopen stations appear in a list if the required configuration files (EDS) are available.

The screenshot below shows an example of manual configuration of the I/O system of CPX:
Figure: Inserting CPX modules

27
CPX-CEC-...

Addressing settings
• Please read the instructions in the CoDeSys basic documentation relating to "Automatic calculation of
addresses" and "Check for overlapping addresses".

Figure: CPX-CEC settings

Options for modifying the "base parameters" of a module:


• Edit the addresses for the I, O and diagnosis specified automatically by CoDeSys.
• Enter the address ranges for I, O and diagnosis manually when the "Automatic calculation of
addresses" option is disabled.
Tip for adding a module to an existing project at a later time:
• Specify the address manually.
This will prevent subsequent module addresses from shifting.

Note
You must assume responsibility for the consequences of specifying address ranges manually and
disabling the option "Check for overlapping addresses".
• Check the distribution of the address ranges.

Figure: Base parameters when selecting modules

28
Modular valve terminal with integrated controller CPX-CEC-...

Configuring CANopen masters (CPX-CEC-C1 and CPX-CEC-M1 only)


A CANopen module is added to the PLC configuration as follows:
• Open the context menu in the left half of the "PLC Configuration" window with the right mouse button.

Figure: Adding a CANopen module

• Click on the "Append Subelement" command and then "CANopen-Master..." to add the CANopen
master.

Figure: PLC configuration with CANopen module

29
CPX-CEC-...

Configuring CANopen slave modules (CPX-CEC-C1 only)


A CANopen slave module is added to the PLC configuration as follows:
• Add a CANopen slave module using the "Append Subelement" item in the context menu (right mouse
click on the "CANOpen-Master" item).

Figure: Appending a CANopen slave module

The CANopen slave module is subordinate to the CANopen master in the tree structure.

Figure: PLC configuration with CANopen slave modules

• Then close the "PLC Configuration" window.

30
Modular valve terminal with integrated controller CPX-CEC-...

1.5.7 Configuring RS-232 (CPX-CEC only)


An RS232 interface can be configured on the CPX-CEC:
• Select the CPX-CEC controller in the "PLC Configuration" window.
• Open the context menu with the right mouse button.
• Select the "Append Subelement" menu item and then "RS232" in the context menu.

Figure: Selecting RS232 (CPX-CEC only)

• Set the following module parameters for the RS232 node:


Module parameter Value Note

Protocol – None RS-232 interface of the CPX-CEC


(free programming with corresponds to COM2
SysLibCom.lib)
– CoDeSys Protocol
(serial interface to FED)
Baudrate 9,600 ... 230,400 bit/s

Figure: Module parameters for RS232 (CPX-CEC only)

Note
The transmission rate is limited when using an FED on the serial interface.
• Set the baud rate to max. 38,400 bit/s.

The CoDeSys general online Help contains the documentation for using the libraries for the serial
interface. For CPX-CEC, Syslibcom.lib must be used with the parameter COM2.

31
CPX-CEC-...

1.5.8 Configuring SoftMotion for CPX-CEC-M1


Note
Licence errors can occur during compilation if there are multiple CoDeSys instances open at the
same time.
• Close all CoDeSys programs and open only one CoDeSys instance.

The CoDeSys software package SoftMotion is available as an extension for the CPX-CEC-M1 controller. It
allows coordinated multi-axis movements with a CPX terminal. Specific CPX-CEC-M1 controller features
are produced in accordance with the CPX system properties.

1. Motor controllers supported


Motor controller From version Remarks

CMMP−AS 3.5.1501.2.1
CMMS−AS 1.3.0.1.11
CMMS−ST 1.3.0.1.7 The following firmware versions are not supported:
– Version 1.3.0.1.10
– Version 1.3.0.1.12

SFC−LAC 1.05
SFC-LACI 1.0
CMMD 1.4

2. Number of axes
The number of axes in SoftMotion is basically unlimited. However, we recommend using no more than 8
axes on a CPX-CEC-M1.

3. Cycle time/interpolation time


Different interpolation times (cycle times) must be observed depending on the connected axis type (see
PLC Configuration screenshot). The interpolation time (time for the processing of the motion modules)
should basically correspond to the time base of the interpolator.

If using at least one motor controller of type CMMD, CMMS, SFC-LAC or SFC-LACI in an axis
group:
• Set the interpolation time to 8 ms.
If only motor controllers of type CMMP-AS are used, differing settings (e.g. 4 ms) are also
possible.

4. SoftMotion functions
The function range essentially corresponds to SoftMotion documentation. Deviations are permitted where
hardware and software functions are not available (e.g. no encoder function in CPX).
SoftMotion functions that are not supported or have restricted support:
SoftMotion functions Remarks

MC_ReadActualTorque Not supported


MC_ReadBoolParameter No specific parameters defined
MC_ReadParameter No specific parameters defined
MC_WriteBoolParameter No specific parameters defined
MC_WriteParameter No specific parameters defined
SMC_SetTorque Not supported
SMC_SetControllerMode Only "Position" is supported

32
Modular valve terminal with integrated controller CPX-CEC-...

Figure: Setting the cyclic communication data

Only POS is supported in the cyclic communication data.

5. FCT settings for SoftMotion


The table below lists the FCT settings for SoftMotion, differentiated according to all drive controllers
supported.
FCT setting CMMP CMMS-ST SFC-LAC
CMMS-AS SFC-LACI
CMMD-AS

Control interface CANopen CANopen CANopen


type
CAN address/node Set using FCT Set using DIL Set using FCT
number switch
Bit rate 125 kBaud, 125 kBaud, 125 kBaud,
250 kBaud, 250 kBaud, 250 kBaud,
500 kBaud or 500 kBaud or 500 kBaud or
1 MBaud 1 MBaud 1 MBaud
set using DIL switch
Protocol/data profile DS402 DS402 DS402
Factor group Not used Not used –
Supply voltage Internal only Internal only Internal or external

Carrying out configuration


External access must be activated for synchronisation with SoftMotion:
1. Open the "MotionTask" area in the task configuration.
2. Activate the event type "triggered by external event".
3. Select "CANopen_SYNC" as the event.
4. Make sure that the priority of the MotionTask is set to a RealTime priority.

Figure: Task configuration

33
CPX-CEC-...

1. Open the desired axis group in the PLC configuration.


2. Enter the value "8000 µs" for the cycle time/interpolation time.

Figure: PLC configuration

A VirtualBusInterface can be added to the SoftMotion PLC configuration.

Figure: PLC configuration

Note
The controller must be reset after changing the cycle time.
• Switch the device back on again.

All other instructions can be found in the documentation for SoftMotion in CoDeSys. The document
'CoDeSys_SoftMotion_V23_E.pdf' is stored in the directory: C:\Program Files\Festo\CoDeSys
V2.3\Documents\English\...

34
Modular valve terminal with integrated controller CPX-CEC-...

1.6 CPX module descriptions


1.6.1 System configuration tabs
Base parameters
The "Base parameters" tab provides information on the selected module.
• Select the CPX module in the "PLC Configuration" window.
• Select the "Base parameters" tab.

Figure: Configuring base parameters

Module ID
The "Module ID" tab contains information on the CPX module.
• Select the CPX module in the "PLC Configuration" window.
• Select the "Module #x" tab.
All static module information is displayed.

Figure: Module ID

35
CPX-CEC-...

Parameters
The "Parameters" tab contains information on the connected modules that can be modified in offline
status.
• Select the CPX module in the "PLC Configuration" window.
• Switch to the "Parameters" tab.
• Change the individual parameter values if required.

Note
Parameter changes are only transferred to the controller system and only come into effect after a
download in online mode.

Figure: Parameters

Idle mode
The behaviour of the outputs of a module when the controller switches to stop status and idle mode is
active can be defined on the Idle Mode tab.
Idle mode must be activated under "System parameter settings" before these values can be set.
• Select the CPX module in the "PLC Configuration" window.
• Switch to the "Idle Mode" tab.
• Set the values in the drop-down list boxes in the list.

Figure: Idle mode

36
Modular valve terminal with integrated controller CPX-CEC-...

1.7 Online configuration/online mode


1.7.1 Determining the network configuration
Requirement for system scan functions
The scan functions in the following chapters require a connection to a CPX-CEC-... via the Ethernet
network.
See IP address setting.
The CPX-CEC-... connected to the programming system is marked with a blue dot on the "Network
configuration" tab.

Figure: Network configuration

CPX module scan


If no CPX modules have been configured yet, read in the current CPX configuration from the control
system as follows:
• Move the mouse pointer over the entry "IOModules" in the CPX-CEC-... tree.
• Open the context menu with the right mouse button.
• Select the "Scan module configuration" menu item.

Figure: Scan module configuration

This procedure generates a current configuration profile of the CPX system in the PLC configuration tree.
Parameters of individual CPX modules can now be displayed and modified by clicking on the module
entries in the tree. See General parameter information.

If the project already includes a prepared CPX module configuration, the above command
sequence initiates a comparison of this configuration and the current configuration. Any differences
between the configurations must be eliminated before work with the system can continue. Note the
relevant messages that appear when the "Scan module configuration" command is executed.

37
CPX-CEC-...

1.7.2 CPI scan


The configuration of a CPI module in the CPX configuration can also be read in in combination with the
controller.
If no modules have been configured yet in the CPI module, read in the current CPI configuration from the
control system as follows:
• Select the entry CPI in the "PLC Configuration" window.
• Switch to the "CP Modules" tab.
• Click the "Scan" button (at the bottom right of the tab) to start the search for CP modules.

Figure: CPI scan

The located modules then appear on the tab.


• Enter the parameters of the CPI module and the connected individual modules.
As in configuration mode when the controller is not connected, these parameters are transferred to the
CPX system when the online connection is active and the project is downloaded.
Once the "Module" tab is read in and selected, the I/O data of the CPI module is listed in the PLC
configuration tree.

Figure: Complete CPI scan

Note
The module configuration in the project and the module configuration in the device should be
identical.
• Any differences must be eliminated before work with the system can continue.
• Note the relevant messages that appear when the "Scan" command is executed.

38
Modular valve terminal with integrated controller CPX-CEC-...

If the project already includes a prepared CPI module configuration, the above command
sequence initiates a comparison of this configuration and the current configuration. Any
differences between the configurations must be eliminated before work with the system can
continue. Note the relevant messages that appear when the "Scan" command is executed.

1.8 Diagnosis
1.8.1 Diagnostic options with the PLC configuration in online status
The basic settings for the diagnosis memory are made in the PLC configuration:
• Select the CPX module in the "PLC Configuration" window.
• Select the "Trace Parameters" tab.
• Enable the required options.
Downloading transfers all diagnostic settings to the CPX system and enables them.

Figure: Diagnosis of the CPX configuration

You can carry out a complete diagnosis of the CPX terminal in the PLC configuration in CoDeSys. The
CPX terminal must be connected online to your PC.
The status of the CPX system is displayed under the root node on the System Status tab.
Diagnostic messages for modules are indicated in the PLC configuration directly in the configuration tree
by means of flashing red modules.

Figure: System status

Viewing current diagnostic messages


• Click on the red flashing module.
• Open the "Diagnosis" tab on the right.
• Read the diagnostic message.
The module and channel-related diagnostic message can be read out in the PLC configuration in this way.

39
CPX-CEC-...

Figure: Current diagnostic message

Diagnosis memory
• Click on the memory in the Diagnosis tab. The diagnosis memory is displayed.

Figure: Diagnosis memory display

Alternatively, you can also read out the diagnosis memory in the root node of the CPX-CEC-.... The
diagnosis memory is created for the CPX system as a whole, not for individual modules. It holds a
maximum of 40 entries in remanent storage.

1.8.2 Error and diagnostic information


The error and diagnostic information of the CPX-CEC-M1 can be found in the 3S documentation, chapter
"CoDeSys SoftMotion" (see also SoftMotion 3S online Help).

40
Modular valve terminal with integrated controller CPX-CEC-...

1.9 Diagnosis in the user program


The following options are available for evaluating diagnostic results in the user program:
– Evaluation of CPX diagnostic information in the flag area
– CPX-specific diagnostic event CPX_System_Fault
– CPX-specific modules for diagnosis in Festo_CPX.lib

Evaluation of CPX diagnostic information in the flag area


The CPX master writes the CPX diagnostic information to the system table. This is documented in Chapter
B.2.1 of the CPX system manual. The CoDeSys run-time system copies the diagnostic data unmodified to
the diagnostic addresses of the modules to a predefined flag area.
The CPX diagnostic data consists of:
– System diagnosis (also global diagnosis) (8 bytes)
– Module diagnosis (4 bytes per module)
– Channel diagnosis (1 byte per channel)

System diagnosis
The global diagnosis is written to the diagnostic address of the "CPX-CEC-..." node.
This address is permanently set to the first eight bytes of the memory area: %MB0 - %MB8.
CoDeSys bus diagnosis
The data of the run-time system bus diagnosis is written to the diagnostic area of the abstract IOModules
node. The data size is 141 bytes.

Figure: Address assignment of the CPX diagnostic data in the flag area

Module and channel diagnosis


The module diagnosis and the channel diagnosis are written to the diagnostic addresses of the relevant
modules.
The following applies:
– the first four bytes relate to the module diagnosis
– the other four bytes relate to the channel diagnosis.
The input channels are displayed first followed by the output channels, as documented in the system
manual.

41
CPX-CEC-...

Figure: Controller configuration - diagnostic address

1.9.1 Example: A short-circuit on the 5th output channel of the 3rd module (8DI/8DO)
System diagnosis
Variable a is declared as follows:

a AT %MB0 : ARRAY[0..1000] OF BYTE;

where
a[0] = 2#00100010
a[1] = 2#01000011
a[2] = 2#00000010
a[3] = 2#00000000
a[4] = 2#00000000
a[5] = 2#00000000
a[6] = 2#00000000
a[7] = 2#00000000

Byte 1 System description table B/38

Bit 1 Error at output


Bit 5 Short circuit/overload

Byte 2 System description table B/39

Bits 0..5 Module number = 3


Bit 6 Diagnostic data is available

Byte 3 System description table B/40

Bits 0..7 Error number

42
Modular valve terminal with integrated controller CPX-CEC-...

Module and channel diagnosis


a[177] = 2#00000100
a[178] = 2#00000010
a[179] = 2#00000000
a[180] = 2#00000000

a[192] = 2#00000000
a[193] = 2#00000010
a[194] = 2#00000000
...
Bytes 1..4: Module diagnosis System description table B/41

Byte 1 Number of the first faulty channel = 4 (=5th channel)


Byte 2 Module fault number

Bytes 5..20: Channel diagnosis System description table B/41

Bytes 5..12 8 input channels


Bytes 13..20 8 output channels

43
CPX-CEC-...

1.9.2 Error handling by the CPX-CEC-...


Warning
If an error occurs, the controller is not stopped and program processing continues. Unwanted
actuator movements can cause collisions resulting in serious injury.
• Integrate error handling mechanisms for all error categories in the user program.
• Make sure that nobody enters the positioning range of the drives or other connected actuators.

The CoDeSys controller offers the following error handling mechanisms in user programs:
– System event CPX_system_fault
– Channel/module diagnosis in the flag words
– Module support in Festo_CPX.lib

CPX-specific system event "CPX_system_fault"


The CPX-specific system event "CPX_system_fault" starts a specific error program as soon as a CPX
class 1-3 error occurs (SF LED flashes).
The program linked by the operator is executed once for the incoming event.
A function registered to the system event "CPX_system_fault" is implemented so that error handling can
be initiated.

Figure: System events

This system event occurs upon every error.


In the example, a distinction is made between two different cases:
– A message is issued when medium-level errors occur.
– If serious errors occur, another message is issued and the IEC program stops.

44
Modular valve terminal with integrated controller CPX-CEC-...

• Start the system event calls with the name (prefix) "callback".

Figure: Creating the CALLBACK_CAN block

Error handling program


The system reads out the error number first of all by accessing the diagnostic memory (%MB2 = system
fault number) or using the CPX library "Festo_CPX.lib".
The text is then issued and the "SysStopPlcProgram" function from the SysLibPlcCtrl.lib library stops the
IEC program if necessary.

Figure: Error handling program

Festo_CPX.lib library
The Festo_CPX.lib library description includes other CPX-specific modules for diagnosis and error
information.

45
CPX-CEC-...

1.9.3 CANopen fieldbus master diagnosis


For diagnosis of the CAN string, the following diagnostic information is provided in online mode with the
CANopen master:
Diagnostic Remarks
information

Receive message Number of CAN messages received.


count
Transmit message Number of CAN messages transmitted.
count
Receive error Maximum value of the receive error counter (see information below).
count (max)
Transmit error Maximum value of the transmit error counter (see information below).
count (max)
Receive error Current value of the receive error counter (RECEIVE ERROR COUNT in
count (current) accordance with CAN Specification 2.0).
– The value should be 0 if possible.
– <![endif]&gt;A value of 96 or higher is referred to in the CAN Specification as a
"heavily disturbed bus".
– A value of 128 or higher means that the node is in the "Error passive" status.

Sendefehler Current value of the transmit error counter (TRANSMIT ERROR COUNT in
(aktuell) accordance with CAN Specification 2.0).
– The value should be 0 if possible.
– A value of 96 or higher is referred to in the CAN Specification as a "heavily
disturbed bus".
– <![endif]&gt;A value of 128 or higher means that the node is in the "Error
passive" status.
– A value of 256 or higher means that the node is in the "Bus off" status.

Controller Status The current status of the CAN node in accordance with CAN Specification 2.0:
– <![endif]&gt;CANC_STATE_NORMAL: Normal operating status, all error
counters < 128.
– CANC_STATE_PASSIVE: Receive error counter > 127 or transmit error counter
> 127.
– CANC_STATE_BUS_OFF: Transmit error counter > 255.

"Error passive" This counter specifies how often the CANC_STATE_PASSIVE status has been
count reached.
"Bus off" count This counter specifies how often the CANC_STATE_BUS_OFF status has been
reached.

The maximum values provide reference values for determining whether there are errors on the
bus. However, there is no guarantee that all counter value changes have been recorded.
"Reset counters" resets all counters apart from the current receive/transmit error counts to 0.

46
Modular valve terminal with integrated controller CPX-CEC-...

Figure: Diagnosis of the CANopen master

In correspondence with this information, the following functions in Festo_CANController.lib can be called in
the program:
Function Description Return values

CAN_GetControllerState Reads out the CAN – CANC_STATE_NORMAL: Normal operating


controller status status, all error counters < 128
– CANC_STATE_PASSIVE: Receive error
counter > 127 or transmit error counter >
127
– CANC_STATE_BUS_OFF: Transmit error
counter > 255; no CAN communication
CAN_RestartController Resets the CAN 1 ... OK
controller 0 ... Error

Note
• Only call the "CAN_RestartController" function when the controller status is
"CANC_STATE_BUS_OFF".

47
CPX-CEC-...

Fieldbus master diagnosis via diagnostic flags


The fieldbus master (CANopen) provides its diagnostic information in the flag area.

Figure: CANopen master diagnostic address

The following structure is copied by the CANopen driver to the configured diagnostic address of the
fieldbus master:
TYPE GETBUSSTATE:
STRUCT
BOLDENABLE:BOOL;
ENABLE:BOOL;
DRIVERNAME:POINTER TO STRING;
DEVICENUMBER:INT;
READY:BYTE;
STATE:INT;
EXTENDEDINFO:ARRAY[0..129] OF BYTE;
END_STRUCT
END_TYPE

Note
The GetBusState is updated automatically at the end of the PLC cycle (write outputs).
• Use a minimum of 1 output in the project because the call is implemented in the write function.
• For example, enter the line %QB12 in the IEC code of the structured text and assign a specific
value.

Structure elements and their meaning:


Element Possible values Meaning Use

BOLDENABLE FALSE Previous status of ENABLE Set by system


TRUE
ENABLE FALSE Diagnostic function is not executed Set by system
TRUE Diagnostic function is executed
DRIVERNAME ZERO No driver name Set by system
DEVICENUMBER 0 CAN master index Set by system
READY 0 Diagnostic function has not yet been Set by system
1 executed
Diagnostic function has been
executed
STATE 1 BUS OK Set by system
2 BUS faulty
3 No BUS communication
4 BUS stopped
EXTENDEDINFO Bit0:=1 Slave configured Set by system
Bit1:=1 Slave actually available
Bit2:=1 Slave has diagnostic info

48
Modular valve terminal with integrated controller CPX-CEC-...

In the Extendedinfo array, one diagnostic byte is available for each connected CANopen slave. The
CANopen node ID of the slaves is used as an index in the array. The evaluation of bit 2 (slave has
diagnosis) must be edge sensitive because it is toggled internally in the system.

Example:
Diagnosis for the slave with CANopen node ID 4.
VAR
CanDriverName:STRING:='CAN Driver';
CanDiag AT%MB196: GETBUSSTATE;
CanDiagNode : DiagGetState;
END_VAR

IF (CanDiag.EXTENDEDINFO[4] AND 16#04) = 16#04 THEN


CanDiagNode.ENABLE := TRUE;
CanDiagNode.DEVICENUMBER := pCANopenMaster[0].wDrvNr;
CanDiagNode.DRIVERNAME := ADR(CanDriverName);
CanDiagNode.BUSMEMBERID := 4;
CanDiagNode();
END_IF

Fieldbus master diagnosis via function block


Alternatively, the diagnostic information of the fieldbus master can be read out via the module call
DiagGetBusState().

Input parameter Values Meaning

ENABLE FALSE Diagnostic function is not executed


TRUE Diagnostic function is executed
DRIVERNAME "CAN DRIVER" Driver name
DEVICENUMBER 0 CAN master index

Return parameter Values Meaning

READY 0 Diagnostic function has not yet been executed


1 Diagnostic function has been executed
STATE 1 BUS OK
2 BUS faulty
3 No BUS communication
4 BUS stopped
EXTENDEDINFO Bit0:=1 Slave configured
Bit1:=1 Slave actually available
Bit2:=1 Slave has diagnostic info

49
CPX-CEC-...

Example of fieldbus master diagnosis via flag:


VAR
CanDriverName : STRING := 'CAN Driver';
CanDiagNode : DiagGetState;
CanDiag AT%MB328 : GETBUSSTATE;
DiagAvailable : BOOL := FALSE;
END_VAR
(*Diagnose by flag*)
IF((CanDiag.EXTENDEDINFO[4] AND 16#04) = 16#04) THEN
DiagAvailable := TRUE;
END_IF
IF DiagAvailable = TRUE THEN
CanDiagNode.ENABLE := TRUE;
CanDiagNode.DRIVERNAME := ADR(CanDriverName);
CanDiagNode.DEVICENUMBER := pCanOpenMaster[0].wDrvNr;
CanDiagNode.BUSMEMBERID := 4;
CanDiagNode();
END_IF

Example of fieldbus master diagnosis via function block:


VAR
CanDiagNode : DiagGetState;
CanDriverName : STRING := 'CAN Driver';
CanDiagFB:DiagGetBusState;
DiagAvailable : BOOL := FALSE;
END_VAR
(*Diagnose by function block*)
CanDiagFB.DEVICENUMBER := pCanOpenMaster[0].wDrvNr; CanDiagFB.DRIVERNAME :=
ADR(CanDriverName); CanDiagFB.ENABLE := TRUE; CanDiagFB();
IF((CanDiagFB.EXTENDEDINFO[4] AND 16#04) = 16#04) THEN
DiagAvailable := TRUE;
END_IF
IF DiagAvailable = TRUE THEN
CanDiagNode.ENABLE := TRUE;
CanDiagNode.DRIVERNAME := ADR(CanDriverName);
CanDiagNode.DEVICENUMBER := pCanOpenMaster[0].wDrvNr;
CanDiagNode.BUSMEMBERID := 4;
CanDiagNode();
END_IF

50
Modular valve terminal with integrated controller CPX-CEC-...

Fieldbus slave diagnostic information


Alternatively, the diagnostic information of a fieldbus slave can be read out via the module call
DiagGetState().
Input parameter Values Meaning
1)
ENABLE – Diagnostic function is always executed
DRIVERNAME "CAN DRIVER" Driver name
DEVICENUMBER 0 CAN master index
BUSMEMBERID 0...129 CAN node ID
1) Enable is not evaluated.

Return parameter Values Meaning

READY 0 Diagnostic function has not yet been executed


1 Diagnostic function has been executed
STATE -1 Invalid parameter
0 Block not enabled
1 Fetch diagnostic information
2 Diagnostic information is available
3 No diagnostic information available
EXTENDEDINFO 0 Used internally
1 Used internally
2 Used internally
3 Used internally
4 ... 11 EMERGENCY telegram (meaning depends on the CAN
slave used)
12 CAN node ID

Note
After the diagnostic information is read out, it is deleted from the CAN stack and the module
status is reset.
• Acknowledge the error.

Refer to the document 'CANopen for 3S Runtime Systems V2_3_5_0.pdf' for important information and a
detailed description on using the 3S CANopen master.
The document is stored in the directory: C:\Program Files\Festo\CoDeSys
V2.3\Targets\Festo\"Controller"\Help\English\...

51
CPX-CEC-...

1.10 Application and programming instructions


1.10.1 I/O update
The run-time system of the CPX-CEC-... operates with a task-dependent I/O update which only updates
outputs that are assigned to a task. CoDeSys automatically detects which outputs a task is using.
Exercise caution when using pointers to outputs because CoDeSys cannot automatically detect which
output is being accessed by means of a pointer. Referencing this output with the following sample calls is
enough to guarantee an I/O update on an output:
%QB0;
or
pByOut := ADR(%QB0)

1.10.2 Using CANopen masters


A start telegram is sent to each CANopen station as standard. The sending of a "Start All Nodes" telegram,
node ID = 0 should be initiated from the IEC application.
The application must always set the bUseStartAllNodes flag of the master once to this end when the
controller starts up, as shown in the following example (bInit is defined by the application):
IF NOT bInit THEN
pCanOpenMaster[0].bUseStartAllNodes := TRUE;
bInit := TRUE;
END_IF

Note
This flag must not be set cyclically as otherwise individual nodes will no longer start correctly after
a failure.

1.10.3 CPX-MMI use and program downloads


Note
Parameters modified by CPX−MMI and Festo_CPX.lib are only overwritten during the project
download if parameter changes have also been made in the CoDeSys project.

52
Modular valve terminal with integrated controller CPX-CEC-...

1.11 Appendix
1.11.1 Festo terms and conditions for the use of software packages
I. Property rights and scope of use
The product comprises data processing programs and the corresponding program descriptions. It is
described below in its entirety as the software package.
Festo or third parties have the protective rights of these software packages. In so far as the rights extend
to third parties, Festo has appropriate rights of use. Festo grants the purchaser with the purchase and
simultaneous recognition of the following conditions the use in conformity with these conditions as follows:
1. Scope of use
a) The purchaser of the software package receives a simple non-transferable right of use and is authorised
to use this exclusively for his own internal purposes as a tool for components from Festo on any desired
number of machines within his firm's premises (location of use).
b) The conditions under a) also apply if the software package is used with other programs or is run in
conjunction with these programs.
c) The software package, even when used in conjunction with other programs, may be copied any number
of times and kept at the location of use of the purchaser for the purpose of data backup and elimination of
faults. Reproduction for other purposes, especially for passing on to third parties or for processing or use
different from the above stated use is not permitted.
2. Copyright note
Every program contains a copyright note. This note must be transferred to every copy, edit and every part
of the program that is combined with other programs.
3. Any conditions of other manufacturers contained in this software package are invalid.
II. Exporting the software package
When exporting the software package, the purchaser must observe the export conditions of the Federal
Republic of Germany and of the purchasing country.
III. Warranty
1. Festo guarantees that the software program it created corresponds with the application description and
program specification but not that the functions included in the software run entirely without interruptions
and errors or that the functions included in the software can run or meet the requirements in all
combinations selected by and in all conditions of use designated by the purchaser.
2. Defects in the software material which the purchaser gives notice of in writing in an understandable form
within the limitation period will be rectified by Festo within a reasonable period under the exclusion of all
further warranty claims by supplying a revised edition.
3. If Festo does not fulfil its obligation to rectify the defect within a reasonable period, or if the improvement
fails, the purchaser is entitled to demand a reasonable reduction of the charge for use or withdraw from the
contract.
4. The warranty claims expire after 3 months. The period of limitation commences on transmission/transfer
of the licence material.
5. The warranty is not valid for defects caused by changes made by the purchaser himself to the
conditions of use created for the program and indicated in the documentation/specification. If the defect
cannot be ascertained after a check or if the fault is caused by circumstances for which Festo is not
responsible, the purchaser shall bear the costs incurred by Festo.
6. Festo points out explicitly that it is not possible according to the state of technology to create
programmed software that functions without problems for all applications and combinations intended by
the user or that is compatible with these.
As a rule the software must therefore be used in the designated manner as specified in the program
description and in the user instructions. At the moment when the software is transferred or made available,
it is in a state in which it will function under normal operating and application conditions.
7. The responsibility for the correct selection and for the consequences arising from the use of the software
in the environment selected by the user, as well as the therewith intended and produced results shall be
borne by the user/purchaser himself. The same applies to the written documentation supplied with the
software. Use of the programmed software does not, therefore, exempt you as the customer from the
obligations and responsibility to observe and comply with computer and security-related conditions and
also a comprehensive function test.
IV. Liability/limitations of liability
1. Claims for damage by the purchaser and especially liability for consequential damage are excluded,
irrespective of the legal grounds; this also applies to claims for impossibility, inexecution, collateral
negligence, tort and default.
2. Furthermore, Festo is not liable for inadequate economic success or for third party damage or claims,
with the exception of claims arising from the infringement of third party property rights.

53
CPX-CEC-...

3. The limitations of liability as per paragraphs 1 and 2 do not apply if, in cases of intent or gross
negligence or lack of warranted characteristics, a compulsory liability exists. In such a case, Festo's liability
is limited to the damage discernable by Festo when the concrete circumstances are made known.
V. Safety guidelines/documentation
Warranty and liability claims in conformity with the aforementioned regulations (items III and IV) may be
raised only if the user has observed the safety guidelines of the documentation in conjunction with the use
of the machine and its safety guidelines. The user himself is responsible for ensuring that our software
package is compatible with the machine employed.

54
2 Glossary

C
CoDeSys provided by Festo: CoDeSys stands for Controller Development System and is a
development environment for PLC/IPCs. CoDeSys provided by Festo allows the configuration,
commissioning and programming of different Festo components and devices.

D
DHCP: Dynamic protocol for automatic assignment of IP addresses (Dynamic Host Configuration
Protocol).

E
Ethernet: Physical protocol and network for connecting various devices.

G
Gateway: The IP address of a gateway is necessary if stations from other networks (other net ID) are
to be able to connect with the device. If a gateway is entered, it will be assumed that a connection
to other networks is possible.

I
IP address: An IP address is used to address a network as well as an individual station in the
network. For this the IP address contains the net ID (specifies the address of a network) and the
host ID (specifies the address of an individual station in this network). The numbers in an IP
address which represent the net ID and the host ID are defined by the specification of a so-called
"netmask".

M
MAC address (MAC-ID): Fixed assigned address clearly marked for Ethernet device (Media Access
Control).

N
Netmask: The netmask for IP addresses defines the bytes used for addressing the stations (host ID)
by means of "0" as a placeholder. A 1 as placeholder defines the bytes which the contain the
network address (Net-ID).

R
Router: Device for establishing networks. The router is responsible for passing on data, which is not
intended for one's own segment, to another segment or to the next router.

S
Switch: Various network ranges can be separated by means of a so-called switch. A switch analyses
the data packages and passes them on only to the slaves addressed. This increases the data
throughput of the network. Formerly hubs simply passed on the data packages, but nowadays
switches are used. An Ethernet network therefore has a real-time facility.

T
Target Support Package (TSP): All of the configuration and expansion files that are required to make
a specific controller (target system) usable for the CoDeSys provided by Festo programming
environment are combined in a Target Support Package.
TCP/IP: Combination of the protocols TCP and IP, the most widely used protocol for communication
via Ethernet.

55
3 Index

A I
Additional ..................................................... 1 IP ............................................................... 37
C IP address .................................................. 22
CoDeSys provided by Festo ........................ 1 L
D Libraries for the
Festo CoDeSys controller....................... 14
Documentation and Help ............................. 1
M
F
Manual control configuration .......... 22, 26, 27
Function overview for
CoDeSys provided by Festo .................... 5 P
Preferences for the
Festo CoDeSys controller......................... 5

57

Das könnte Ihnen auch gefallen