About this manual Overview: documentation modules for CR0452
>
Document
Contents / Description
Data sheet
Technical data in a table
Installation instructions
(are supplied with the
device)
Instructions for installation, electrical installation, and commissioning
Technical data
Programming manual
Functions of the setup menu of the device
Creation of a CODESYS project with this device
Target settings with CODESYS
Programming of the device-internal PLC with CODESYS
Description of the device-specific CODESYS function libraries
System manual
"Know-How ecomatmobile"
Know-how about the following topics (examples):
Overview Templates and demo programs
CAN, CANopen
Control outputs
Visualisations
Overview of the files and libraries
1.2 Overview: documentation modules for CR0452
The documentation for this devices consists of the following modules:
(Downloads from ifm's website →www.ifm.com )
About this manual How is this documentation structured?
>
Date
Theme
Change
2014-03-24
Visualisation limits
Information concerning the permissible drawing area
2014-04-29
FB CAN_REMOTE_RESPONSE
More precise description of the function block
ENABLE
2014-05-12
Limitations CAN
Limitations added for CAN, CANopen and CAN J1939
2014-06-30
Name of the documentation
"System manual" renamed as "Programming manual"
2015-01-13
Structure of documentation for error codes, system
flags
• error flags:
now only in the appendix, chapter System flags
• CAN / CANopen errors and error handling:
now only in the system manual "Know-How"
• error codes, EMCY codes:
now in the appendix, chapter Error tables
2015-03-10
Available memory
Description improved
2017-01-13
Software manual for CODESYS 2.3
hint to download from the ifm homepage removed
2018-07-09
List of the ifm branch offices
removed
1.4 How is this documentation structured?
This documentation is a combination of different types of manuals. It is for beginners and also a
reference for advanced users. This document is addressed to the programmers of the applications.
How to use this manual:
Refer to the table of contents to select a specific subject.
Using the index you can also quickly find a term you are looking for.
At the beginning of a chapter we will give you a brief overview of its contents.
Abbreviations and technical terms → Appendix.
In case of malfunctions or uncertainties please contact the manufacturer at:
Contact →www.ifm.com
We want to become even better! Each separate section has an identification number in the top right
corner. If you want to inform us about any inconsistencies, indicate this number with the title and the
language of this documentation. Thank you very much for your support!
We reserve the right to make alterations which can result in a change of contents of the
documentation. You can find the current version on ifm's website:
→www.ifm.com
>
204
1508
1.5 History of the instructions (CR0452)
What has been changed in this manual? An overview:
What previous knowledge is required? .................................................................................................... 8
Start-up behaviour of the controller .......................................................................................................... 9
Notes: serial number ................................................................................................................................ 9
WARNING
Non-observance of these instructions can lead to property damage or personal injury.
ifm electronic gmbh does not assume any liability in this regard.
► The acting person must have read and understood the safety instructions and the corresponding
chapters in this manual before working on and with this device.
► The acting person must be authorised to work on the machine/equipment.
► The acting person must have the qualifications and training required to perform this work.
► Adhere to the technical data of the devices!
You can find the current data sheet on the ifm website.
► Note the installation and wiring information as well as the functions and features of the devices!
→ supplied installation instructions or on the ifm website.
Homepage →www.ifm.com
>
2.1 Please note
6091
11779
No characteristics are warranted with the information, notes and examples provided in this manual.
With the drawings, representations and examples given no responsibility for the system is assumed
and no application-specific particularities are taken into account.
► The manufacturer of the machine/equipment is responsible for ensuring the safety of the
machine/equipment.
► Follow the national and international regulations of the country in which the machine/installation is
to be placed on the market!
213
>
2.2 What previous knowledge is required?
This document is intended for people with knowledge of control technology and PLC programming
with IEC 61131-3.
To program the PLC, the people should also be familiar with the CODESYS software.
The document is intended for specialists. These specialists are people who are qualified by their
training and their experience to see risks and to avoid possible hazards that may be caused during
operation or maintenance of a product. The document contains information about the correct handling
of the product.
Read this document before use to familiarise yourself with operating conditions, installation and
operation. Keep the document during the entire duration of use of the device.
Safety instructions Start-up behaviour of the controller
>
WARNING
Danger due to unintentional and dangerous start of machine or plant sections!
► When creating the program, the programmer must ensure that no unintentional and dangerous
start of machines or plant sections after a fault (e.g. e-stop) and the following fault elimination can
occur!
Realise restart inhibit.
► In case of an error, set the outputs concerned to FALSE in the program!
2.3 Start-up behaviour of the controller
6827
15233
11575
A restart can, for example, be caused by:
• Voltage restoration after power failure
• Reset after the watchdog responded because the cycle time was too long
• Error elimination after an E-stop
To ensure safe controller behaviour:
► monitor the voltage supply in the application program.
► In case of an error switch off all relevant outputs in the application program.
► Additionally monitor actuators which can cause hazardous movements in the application program
(feedback).
► Monitor relay contacts which can cause hazardous movements in the application program
(feedback).
► If necessary, ensure that welded relay contacts in the application project cannot trigger or continue
hazardous movements.
>
2.4 Notes: serial number
20780
► In the user's production facility, draw a diagram of the controller network in the machine. Enter the
serial number of each controller installed into the network diagram.
► Before downloading a software component, read out this serial number and check the network
diagram to make sure that you are accessing the right controller.
Cable for power supply and CAN between the display and the BasicController when the
cover EC0402 is used
EC0454
5 m cable for power supply and CAN between the display and the BasicController
---
"Maintenance Tool" software for updating firmware, runtime system and application
program
Download →www.ifm.com
>
3.1 Information about the device
This manual describes of the ecomatmobile family for mobile machines of ifm electronic gmbh:
BasicDisplayXL: CR0452
The display is part of the family of the BasicController: CR040n, CR041n, CR043n.
>
3.1.1 Accessories
A wide range of accessories is available for the BasicDisplay. Examples:
975
15407
15406
You can find accessories for the article on ifm's website:
→www.ifm.com > Select your country > [Data sheet search] > article no. > [Accessories]
CAN interfaces .......................................................................................................................................15
CAN: interfaces and protocols ................................................................................................................15
CAN interface
CAN 1
CAN 2
CAN 3
CAN 4
Default download ID
ID 127
ID 126
ID 125
ID 124
CAN protocols
CAN Layer 2
Interface does not
exist
Interface does not
exist
Interface does not
exist
CANopen
SAE J1939
3.3 Interface description
3.3.1 CAN interfaces
Connections and data → data sheet
>
CAN: interfaces and protocols
The device is equipped with only one CAN interface.
The interface can be used with the following functions:
• RAW-CAN (Layer 2): CAN on level 2 (→ chapter Function elements: RAW-CAN (Layer 2) (→ p. 52))
• CANopen master / CANopen slave (→ chapter Function elements: CANopen (→ p. 80))
Software modules for the device ............................................................................................................16
Programming notes for CODESYS projects ...........................................................................................19
Operating states .....................................................................................................................................22
Performance limits of the device ............................................................................................................25
Runtime system ......................................................................................................................................17
Application program ................................................................................................................................17
The software in this device communicates with the hardware as below:
14107
14110
*) The runtime system version number must correspond to the target version number in the CODESYS target system setting.
→ chapter Set up the target (→ p. 36)
The user is responsible for the reliable function of the application programs he designed. If necessary,
he must additionally carry out an approval test by corresponding supervisory and test organisations
according to the national regulations.
Bootloader
14111
On delivery ecomatmobile controllers only contain the boot loader.
The boot loader is a start program that allows to reload the runtime system and the application
program on the device.
The boot loader contains basic routines...
• for communication between hardware modules,
• for reloading the operating system.
The boot loader is the first software module to be saved on the device.
>
Runtime system
14112
Basic program in the device, establishes the connection between the hardware of the device and the
application program.
→ chapter Software modules for the device (→ p. 16)
On delivery, there is normally no runtime system loaded in the controller (LED flashes green at 5 Hz).
Only the bootloader is active in this operating mode. It provides the minimum functions for loading the
runtime system, among others support of the interfaces (e.g. CAN).
Normally it is necessary to download the runtime system only once. Then, the application program can
be loaded into the controller (also repeatedly) without affecting the runtime system.
The runtime system is provided with this documentation on a separate data carrier. In addition, the
current version can be downloaded from the website of ifm electronic gmbh:
→www.ifm.com
>
Application program
15274
14118
Software specific to the application, implemented by the machine manufacturer, generally containing
logic sequences, limits and expressions that control the appropriate inputs, outputs, calculations and
decisions.
The visualisation pages and embedded graphics are part of the CODESYS application program.
FB, FUN, PRG in CODESYS .................................................................................................................19
Note the cycle time! ................................................................................................................................20
Important note to program the device ....................................................................................................20
Creating application program .................................................................................................................21
Using ifm maintenance tool ....................................................................................................................22
Distribution of the application program ...................................................................................................22
NOTE
Function blocks must NOT be called in functions!
Otherwise: During execution the application program will crash.
All function elements must NOT be called recursively, nor indirectly!
An IEC application may contain maximum 8000 function elements; in this device maximum 512
function elements!
3.4.2 Programming notes for CODESYS projects
Here you receive tips how to program the device.
► See the notes in the CODESYS programming manual.
>
FB, FUN, PRG in CODESYS
In CODESYS we differentiate between the following types of function elements:
FB = function block
• An FB can have several inputs and several outputs.
• An FB may be called several times in a project.
• An instance must be declared for each call.
• Permitted: Call FB and FUN in FB.FUN = function
• A function can have several inputs but only one output.
• The output is of the same data type as the function itself.PRG = program
• A PRG can have several inputs and several outputs.
• A PRG may only be called once in a project.
• Permitted: Call PRG, FB and FUN in PRG.
7426
15410
Background:
All variables of functions...
• are initialised when called and
• become invalid after return to the caller.
Function blocks have 2 calls:
• an initialisation call and
• the actual call to do something.
Consequently that means for the function block call in a function:
• every time there is an additional initialisation call and
Risk that the device acts too slowly!
Cycle time must not become too long!
► When designing the application program the above-mentioned recommendations must be
complied with and tested.
► If necessary, the cycle time must be optimised by restructuring the software and the system
set-up.
Note the cycle time!
For the programmable devices from the controller family ecomatmobile numerous functions are
available which enable use of the devices in a wide range of applications.
As these units use more or fewer system resources depending on their complexity it is not always
possible to use all units at the same time and several times.
>
Important note to program the device
Applies to the following devices:
• BasicController relay CR0431► For the time of programming interconnect the connections B:1 (VBB15) and B:8 (VBBs).
Otherwise programming is not possible.
Background:
The controller resets all outputs when programming begins, also SUPPLY_SWITCH.
Without VBB15 the controller would be separated from the voltage supply and is switched off.
When the controller is switched on again, the device is in bootloader mode.
The programmer has to load the Basic System to the device again.
Then reload the application program to the device.
The application program is generated by the CODESYS 2.3 programming system and loaded in the
controller several times during the program development for testing:
In CODESYS: [Online] > [Login] > load the new program.
For each such download via CODESYS 2.3 the source code is translated again. The result is that
each time a new checksum is formed in the controller memory. This process is also permissible for
safety controllers until the release of the software.
8007
Graphics: Creation and distribution of the software
The ifm Maintenance Tool serves for easy transfer of the program code from the programming station
to the controller. As a matter of principle each application software can be copied to the controllers
using the ifm Maintenance Tool. Advantage: A programming system with CODESYS licence is not
required.
Here you will find the current ifm Maintenance Tool:
Homepage →www.ifm.com
>
Distribution of the application program
8493
We recommend the following sequence, if the application software is to be copied to the series
machine and used:
Saving the software
After completion of program development the latest version of the application program loaded in
the controller using the ifm Maintenance Tool has to be read from the controller and saved on a
data carrier using the name project_file.RESX. Only this process ensures that the application
software and its checksums are stored.
Download of the software.
To equip all machines of a series production with an identical software only this file may be loaded
in the controllers using the ifm Maintenance Tool.
An error in the data of this file is automatically recognised by the integrated checksum when
loaded again using the ifm Maintenance Tool.
>
3.4.3 Operating states
After power on the ecomatmobile device can be in one of five possible operating states:
• BOOTLOADER
• INIT
• STOP
• RUN
• SYSTEM STOP
>
INIT state (Reset)
Premise: a valid runtime system is installed.
This state is passed through after every power on reset:
> The runtime system is initialised.
> Various checks are carried out, e.g. waiting for correctly power supply voltage.
> This temporary state is replaced by the RUN or STOP state.
> The LED lights orange.
Change out of this state possible into one of the following states:
A transition into this state is possible in the following cases:
• if the supply voltage is too low.
In the ERROR state:
> The outputs of the device are switched off.
> Processing of the application program is stopped.
> System parameters are saved.
> The LED flashed red with 5 Hz.
A transition from this state into one of the following states is possible:
• INIT (after power-on-reset)
• RUN
• STOP
• FATAL ERROR
>
FATAL ERROR state
A transition into this state is possible in the following cases:
• memory error (RAM / Flash)
• exception error
• runtime system error
In the FATAL ERROR state:
> The outputs of the device are switched off.
> The application program is terminated.
> The runtime system is terminated.
> The LED lights red.
A transition from this state into one of the following states is possible:
In this device, a watchdog monitors the program runtime of the CODESYS application.
If the maximum watchdog time (application program: 100 ms; visualisation: 1 200 ms) is exceeded:
> the device changes to the "Timeout Error" state
> all processes are stopped (reset)
> all outputs are switched off
> the screen goes black
> the status LED flashes red at 10 Hz
Eliminate the fault:
Delete application program!
PowerOn Reset
Reload the application program into the device
If the watchdog in question fails:
> a second watchdog leads the device to the state "Fatal Error"
> the status LED lights red
Eliminate the fault:
PowerOn Reset
If unsuccessful:
Goto Bootloader
PowerOn Reset
Reload the runtime system into the device
Reload the application program into the device
If unsuccessful:
Hardware error: return device to ifm!
8 bit = 28 colours = 256 colours can be represented
Required memory space
< 76 Kbytes, depending on the image content for RLE compression
Visualisation limits
Embedded displays, used e.g. in ecomatmobile devices, cannot provide the full colour scope of
bitmap graphics because the available power reserves are restricted. Nevertheless, the following
preparations enable bitmap images in the device:
Correct selection of the motifs,
clever shifting of colours or
clever compilation of a colour palette and
the correct scaling of the bitmaps before using them in the device.
Performance limits of the device (→ p. 25)
Table: specifications for the start image
The graphics used in the project may be larger than the specified image size. In this case, however,
only a (selectable) section of the image will be visible.
Colours:
The device supports 28 (= 256) colour nuances.
► Create bitmap (BMP) with 256 colours:
8337
8465
8464
>
Resample / scale image
If an image is loaded in the device which does not meet the requirements for size or colour, it is
resized before it is displayed and the colours used are "checked".
Each time the image is opened, it must be resampled. This often leads to much longer times to
change from one image to the other. Corrective measures:
► First carry out all transformations of the bitmap or the image in an image processing program on
your computer.
Only for BasicDisplay: The colour palette is adapted when the image is integrated into the project
by CODESYS. On the device itself no adaptations will be made (size, scaling, colour).
► Only save the suitably transformed images in the visualisation of the device.
A polyline is to consist of maximum 5 anchor points; not scalable
A polyline is not to enclose any area.
Curve
--
Not supported
Rectangle
+
No problems known
Rounded rectangle
--
Not supported
Circle, ellipse
+
No problems known
Polygon
o
A polygon is to consist of maximum 10 anchor points; not scalable
Pie chart
--
Not supported
Visualisation
--
Not supported
Button
--
Not supported
Table
--
Not supported
Scroll bar
--
Not supported
Trend curve
--
Not supported
Alarm table
--
Not supported
Scales
+
Create scale as BMP file
Pointer instrument
+
Represent pointer instrument as BMP file with a superposed CoDeSys
polygon
Bar graph
+
Create scale as BMP file
Represent value as a superposed CoDeSys rectangle
Histogram
+
Create scale as BMP file
Represent value as a superposed CoDeSys rectangle
Graphic file
+
Up to 256 per project possible
• BMP ¹)
• BMP RLE compressed
• TIFF ¹)
• JPEG ¹)
Graphics scaling mode
o
Supported for circle, ellipse, rectangle, line, polyline, polygon
ActiveX element
--
Not supported
Pointer diagram
--
Not supported
Edit tools
--
Not supported
+
o
--
can be used without problem
can be used with restrictions
cannot be used
CODESYS visualisation elements
Bitmap graphics (BMP) chapter Visualisation limits (→ p. 26)
Not all CODESYS functions can be executed successfully on this device:
453
¹) During the integration into the project the file is converted into an RLE compressed bitmap.
From the CODESYS version 2.3.9.24 an additional dialogue opens when an image is integrated.
Using this dialogue the file is adapted to the Colour palette used for the device. During the colour
conversion you can select between 'most similar colour' (deactivate [Dithering]) and 'Dithering'.
Drawing area:
The left upper corner marks the home position (0,0) of the virtual and physical drawing area.
Virtual drawing area = 2,560 x 1,536 pixels
(enlarges the physical drawing area)
Elements in the virtual drawing area are not calculated.
The left upper corner marks the home position (0,0) of the virtual and physical drawing area.
Virtual drawing area (X/Y coordinates) = -32768...+32767
(enlarges the physical drawing area)
All objects including their outer dimensions must be within the borders of the virtual drawing area
even after scaling or shifting!
Otherwise the visualisation will not be correct any more.
Elements in the virtual drawing area are not calculated.
>
Texts
The smallest font size which is clearly visible on the device is 11 point.
Permissible fonts:
- Arial (standard)
- Lucida Console
Permissible font size [Pixel] and font weight:
- Arial: 11 (standard), 16, 24, 32 (all only normal)
- Lucida Console: 16, 24, 48*) (all only normal)
*) Lucida Console in the font size 48 only has the following characters:
Rotate the element around a defined pivot point
Indicate the angle of rotation
angle of rotation in [degree]
positive value = rotation clockwise
negative value = rotation anticlockwise
Shift
Shifting of the element:
horizontal
vertical
only within the drawing area
max. until leaving the drawing area
Relative shifting of
• rectangle
• ellipse / circle
Each edge of the element can be shifted by a specified number of pixels via an
INT type variable:
basic position of the 4 edges = zero
new value shifts this edge by the specified value
Shift direction for value > 0:
horizontal edge down
vertical edge to the right
Shift direction for value < 0:
horizontal edge up
vertical edge to the left
Device
BasicController: CR040n, CR041n,
CR043n
BasicDisplay: CR045n
ioControl: CR205n
SmartController: CR253n
PDM360 NG: CR108n, CR120n
Criterion
max. FiFo transmit
- with FB CAN_TX...
- with FB CAN_TX_ENH...
4 messages
16 messages
4 messages
16 messages
max. FiFo receive
- with FB CAN_RX_..._FIFO
32 messages
32 messages
Movement of elements
Image and text elements can be moved on the display in a defined manner.
7392
>
Limitations for CAN in this device
17975
FIFO (First In, First Out) = Operating principle of the stack memory: The data packet that was
written into the stack memory first, will also be read first. Each identifier has such a buffer (queue).
Some Raw-CAN function elements enable transmitting and receiving of several messages in one PLC
cycle as the messages are temporarily stored in a FiFo:
- CAN_TX..., → Function elements: transmit RAW-CAN data
- CAN_RX_ENH_FIFO (→ p. 62)
- CAN_RX_RANGE_FIFO (→ p. 66)
The number of FIFo messages is limited. The following limitations of the devices are valid:
Reinstall the runtime system ..................................................................................................................33
Update the runtime system.....................................................................................................................34
Verify the installation ..............................................................................................................................34
1016
The device configurations described in the corresponding installation instructions or in the Appendix
(→ p. 188) to this documentation are used for standard devices (stock items). They fulfil the requested
specifications of most applications.
Depending on the customer requirements for series use it is, however, also possible to use other
device configurations, e.g. with respect to the inputs/outputs and analogue channels.
Risk of data loss!
In case of power failure during the data transmission data can be lost so that the device is no longer
functionable. Repair is only possible by ifm electronic.
► Ensure an uninterrupted power supply during the data transmission!
NOTE
The software versions suitable for the selected target must always be used:
• runtime system (ifm_CR0452_Vxxyyzz.RESX),
• PLC configuration (ifm_CR0452_Vxx.CFG),
• device library (ifm_CR0452_Vxxyyzz.LIB ) and
• the further files.
V
xx: 00...99
yy: 00...99
zz: 00...99
version
target version number
release number
patch number
The basic file name (e.g. "CR0452") and the software version number "xx" (e.g. "01") must always have
the same value! Otherwise the device goes to the STOP mode.
The values for "yy" (release number) and "zz" (patch number) do not have to match.
4.1.1 Reinstall the runtime system
14635
8486
On delivery of the ecomatmobile controller no runtime system is normally loaded (LED flashes green
at 5 Hz). Only the boot loader is active in this operating mode. It provides the minimum functions for
loading the operating system (e.g. RS232, CAN).
Normally it is necessary to download the runtime system only once. The application program can then
be loaded to the device (also several times) without influencing the runtime system.
The runtime system is provided with this documentation on a separate data carrier. In addition, the
current version can be downloaded from the website of ifm electronic gmbh:
→www.ifm.com
8651
8485
The following files must also be loaded:
• the internal libraries (created in IEC 1131) required for the project,
• the configuration files (*.CFG) and
• the target files (*.TRG).
It may happen that the target system cannot or only partly be programmed with your currently
installed version of CODESYS. In such a case, please contact the technical support department of ifm
electronic gmbh.
Contact →www.ifm.com
The runtime system is transferred to the device using the separate program "Maintenance Tool". (The
program can be downloaded from ifm's website, if necessary):
→www.ifm.com
Normally the application program is loaded to the device via the programming system. But it can also
be loaded using the "Maintenance Tool" if it was first read from the device.
Risk of data loss!
When deleting or updating the runtime system all data and programs on the device are deleted.
► Save all required data and programs before deleting or updating the runtime system!
GET_SW_INFO (→ p. 164)
Delivers information about the system software of the device:
• software name,
• software version,
• build number,
• build date
4.1.2 Update the runtime system
13269
An older runtime system is already installed on the device. Now, you would like to update the runtime
system on the device?
14158
For this operation, the same instructions apply as in the previous chapter 'Reinstall the runtime
system'.
>
4.1.3 Verify the installation
14637
► After loading of the runtime system into the controller:
• Check whether the runtime system was transmitted correctly!
• Check whether the correct runtime system is loaded in the controller!
► 1st test:
Test with the ifm maintenance tool if the correct runtime system version was loaded:
• Read name and version of the runtime system in the device!
• Manually compare this information with the target data!
► 2nd test (optional):
Check in the application program if the correct runtime system version was loaded:
• read name and version of the runtime system in the device!
• Compare this data with the specified values!
The following FB serves for reading the data:
► If the application detects an incorrect version of a runtime system:
Set up the programming system manually .............................................................................................35
Set up the programming system via templates ......................................................................................39
Set up the target .....................................................................................................................................36
Activate the PLC configuration ...............................................................................................................37
CAN declaration (e.g. CR1080) ..............................................................................................................38
The software versions suitable for the selected target must always be used:
• runtime system (ifm_CR0452_Vxxyyzz.RESX),
• PLC configuration (ifm_CR0452_Vxx.CFG),
• device library (ifm_CR0452_Vxxyyzz.LIB ) and
• the further files.
V
xx: 00...99
yy: 00...99
zz: 00...99
version
target version number
release number
patch number
The basic file name (e.g. "CR0452") and the software version number "xx" (e.g. "01") must always have
the same value! Otherwise the device goes to the STOP mode.
The values for "yy" (release number) and "zz" (patch number) do not have to match.
Set up the target
13136
11379
When creating a new project in CODESYS the target file corresponding to the device must be loaded.
► Select the requested target file in the dialogue window [Target Settings] in the menu
[Configuration].
> The target file constitutes the interface to the hardware for the programming system.
> At the same time, several important libraries and the PLC configuration are loaded when selecting
the target.
► If necessary, in the window [Target settings] > tab [Network functionality] > activate [Support
parameter manager] and / or activate [Support network variables].
► If necessary, remove the loaded (3S) libraries or complement them by further (ifm) libraries.
► Always complement the appropriate device library ifm_CR0452_Vxxyyzz.LIB manually!
8485
The following files must also be loaded:
• the internal libraries (created in IEC 1131) required for the project,
• the configuration files (*.CFG) and
• the target files (*.TRG).
It may happen that the target system cannot or only partly be programmed with your currently
installed version of CODESYS. In such a case, please contact the technical support department of ifm
The PLC configuration is automatically loaded with the target system. The PLC configuration maps the
contents of the file CR0452.cfg in CODESYS. Like this, the programmer has easy access to
predefined system and error flags, inputs and outputs as well as to the CAN interfaces of the device.
To access the PLC configuration (e.g. CR1080):
► Click on the tab [Resources] in CoDeSys:
► Double-click on [PLC Configuration] in the left column.
> Display of the current PLC configuration ( following figure):
> Based on the configuration the following is available in the program environment for the user:
System and error flags
Depending on the application and the application program, these flags must be processed and
evaluated. Access is made via their symbolic names.
Structure of the inputs and outputs
These can be directly symbolically designated (highly recommended!) in the window [PLC
Configuration] (example → figure below) and are available in the whole project as [Global
Variables].
If the device is operated as a slave, the selection [CanSlave_Device] would also be possible.
For the simpler configuration as a master, all CAN Layer 2 and network variable functions can also be
used.
CAN declaration (e.g. CR1080)
In the CODESYS PLC configuration you now have to declare the CAN interface(s).
► Right-click on the name of the PLC configuration. [CANopen Interface [FIX]] of the desired CAN
interface.
► Click on [Append Subelement].
► Even if the device is operated as a CANopen slave: Click on [CANopen Master...]:
10080
>The CAN parameters of the PLC configuration are displayed. Some CAN parameters are already
set as default:
► If the device is operated on CAN Layer 2 or as a slave via network variables or CAN_RX /
CAN_TX:
Check whether the correct baud rate is set for the device (baud rate must be identical for all
► In the menu [File] > [Save as ...] give a sensible name to the project and save it in the requested
When installing the ecomatmobile DVD "Software, tools and documentation", projects with
templates have been stored in the program directory of your PC:
…\ifm electronic\CoDeSys V…\Projects\Template_DVD_V…
► Open the requested template in CODESYS via:
[File] > [New from template…]
>CODESYS creates a new project which shows the basic program structure. It is strongly
recommended to follow the shown procedure.
directory.
► In the application program always call an own instance of the FB CANOPEN_ENABLE (→ p. 81)
for every CAN interface!
>
4.2.2 Set up the programming system via templates
13745
ifm offers ready-to-use templates (program templates), by means of which the programming system
In this device, do NOT use the following functions from the 3S library SysLibPlcCtrl.lib:
- FUN SysSaveRetains
- FUN SysRestoreRetains
NOTE
In this device, do NOT use the following functions from the 3S library SysLibPlcCtrl.lib:
- FUN SysSaveRetains
- FUN SysRestoreRetains
4.4.1 Retain variables
Retain variables can be saved automatically in a protected memory area and be reloaded
automatically during a reboot.
Typical applications for retain variables are for example:
• operating hours which are counted up and retained while the machine is in operation,
• position values of incremental encoders,
• preset values entered in the monitor,
• machine parameters,
i.e. all variables whose values must not get lost when the device is switched off.
All variable types, also complex structures (e.g. timers), can be declared as retain.
► To do so, activate the control field [RETAIN] in the variable declaration (→ window).
8672
14166
>
Save retain variables
9853
In the device the data type RETAIN is only stored in the volatile memory (RAM) during the runtime.
To save the data permanently, at the end of each cycle they are automatically be saved in the FRAM
memory ¹).
¹) FRAM indicates here all kinds of non-volatile and fast memories.
>
Read back retain variables
9854
After power on and before the first program cycle the device automatically writes the saved data back
to the working memory once. To do so, no additional FBs must be integrated into the application
program.
Global network variables are used for data exchange between controllers in the network. The values
of global network variables are available to all CODESYS projects in the whole network if the variables
are contained in their declaration lists.
► Integrate the following library/libraries into the CODESYS project:
All CODESYS function elements (FBs, PRGs, FUNs) are stored in libraries. Below you will find a list of
all the ifm libraries you can use with this device.
This is followed by a description of the function elements, sorted by topic.
5.1 ifm libraries for the device CR0452
14235
>
5.1.1 Required libraries
If you do not want to base the initial programming of this device on an ifm template, you should be
sure to integrate at least the following libraries into your project:
>
Libraries required for network variables
If you want to work with network variables, you will need the following libraries in addition:
ifm function elements ifm libraries for the device CR0452
>
Function element
Short description
BASICDISPLAY_INIT (→ p. 183)
Initialises the screen of the BasicDisplay in the first PLC cycle
Function element
Short description
GET_TEXT_FROM_FLASH (→ p. 177)
Reads texts of the type STRING from the flash memory via FLASH_READ (→ p. 160)
NORM_DINT (→ p. 179)
Normalises a value [DINT] within defined limits to a value with new limits
NORM_REAL (→ p. 180)
Normalises a value [REAL] within defined limits to a value with new limits
PDM_PAGECONTROL (→ p. 184)
Controls invoking of certain visualisation pages
TOGGLE (→ p. 181)
Setting and resetting of a Boolean variable with only one input bit
Function element
Short description
CAN_ENABLE (→ p. 53)
Initialises the indicated CAN interface
Configures the CAN baud rate
CAN_RECOVER (→ p. 54)
Activate / deactivate the automatic bus off handling
Restart the CAN interface in case of bus off
CAN_REMOTE_REQUEST (→ p. 76)
Send a corresponding request and return the response of the other device as a result
CAN_REMOTE_RESPONSE (→ p. 78)
Provides data to the CAN controller in the device which is automatically sent as a response to the
request of a remote message
CAN_RX (→ p. 59)
Configures a data receive object and reads out the receive buffer of the data object
CAN_RX_ENH (→ p. 60)
• Configures a data receive object and reads out the receive buffer of the data object
• Frame type and mask can be selected
CAN_RX_ENH_FIFO (→ p. 62)
• Configures a data receive object and reads out the receive buffer of the data object
• Frame type and mask can be selected
• Several CAN messages per cycle possible
CAN_RX_RANGE (→ p. 64)
• Configures a range of data receive objects and reads out the receive buffer of the data objects
• Frame type and mask can be selected
CAN_RX_RANGE_FIFO (→ p. 66)
• Configures a range of data receive objects and reads out the receive buffer of the data objects
• Frame type and mask can be selected
• Several CAN messages per cycle possible
CAN_SETDOWNLOADID (→ p. 55)
= Set CAN download ID
Sets the download identifier for the CAN interface
CAN_STATUS (→ p. 56)
Get status information on the CAN bus selected:
BAUDRATE, DOWNLOAD_ID, BUSOFF, WARNING_RX, WARNING_TX, VERSION, BUSLOAD
and reset if required: BUSOFF, WARNING_RX, WARNING_TX
CAN_TX (→ p. 69)
Transfers a CAN data object (message) to the configured CAN interface for transmission at each
call
5.1.3 Library ifm_CR0452_Init_Vxxyyzz.LIB
This ifm library contains the following function blocks:
>
5.1.4 Library ifm_PDMsmart_util_Vxxyyzz.LIB
This ifm library contains the following function blocks:
>
15286
15289
5.1.5 Library ifm_RAWCan_NT_Vxxyyzz.LIB
This ifm library contains the following function blocks:
ifm function elements ifm libraries for the device CR0452
Function element
Short description
CAN_TX_ENH (→ p. 71)
Transfers a CAN data object (message) to the configured CAN interface for transmission at each
call
CAN-specific characteristics can be set
CAN_TX_ENH_CYCLIC (→ p. 73)
Cyclically transfers a CAN data object (message) to the configured CAN interface for
transmission
CAN-specific characteristics can be set
Function element
Short description
CANOPEN_ENABLE (→ p. 81)
Initialises the indicated CANopen master interface
Configures the CAN baud rate
CANOPEN_GETBUFFERFLAGS (→ p. 83)
= CANopen get buffer flags
Provides information on the buffer flags
The flags can be reset via the optional inputs.
CANOPEN_GETEMCYMESSAGES (→ p. 120)
= Get CANopen emergency messages
Lists all emergency messages that have been received by the controller from other nodes in the
network since the last deletion of messages
The list can be reset by setting the according input.
CANOPEN_GETERRORREGISTER (→ p. 122)
= Get CANopen error register
Reads the error registers 0x1001 and 0x1003 from the controller
The registers can be reset by setting the respective inputs.
CANOPEN_GETGUARDHBERRLIST (→ p. 116)
= get CANopen guard and heartbeat error list
Lists all nodes in an array for which the master has detected an error:
guarding error, heartbeat error
The list can be reset by setting the according input.
CANOPEN_GETGUARDHBSTATSLV (→ p. 117)
= CANopen slave get guard and heartbeat state
Signals the following states to the controller in slave operation:
node guarding monitoring, heartbeat monitoring
The signalled errors can be reset by setting the respective input.
CANOPEN_GETNMTSTATESLAVE (→ p. 90)
= CANopen slave get network management state
Signals the network operating status of the node
CANOPEN_GETODCHANGEDFLAG (→ p. 94)
= Get object directory changed flag
Reports any change of value for a particular object directory entry
CANOPEN_GETSTATE (→ p. 85)
= CANopen set state
Request the parameters of the master, a slave device or a specific node in the network
CANOPEN_GETSYNCSTATE (→ p. 112)
= CANopen get SYNC state
• Reads the setting of the SYNC functionality (active / not active),
• reads the error state of the SYNC functionality (SyncError)
CANOPEN_NMTSERVICES (→ p. 91)
= CANopen network management services
Updates the internal node status
and, depending on the NMT command entries:
• triggers an NMT command or
• triggers the initialisation of a node
CANOPEN_READOBJECTDICT (→ p. 95)
= CANopen read object directory
Reads configuration data from the object directory of the device
CANOPEN_SDOREAD (→ p. 99)
= CANopen read SDO
Reads an "Expedited SDO" = Expedited Service Data Object
CANOPEN_SDOREADBLOCK (→ p. 101)
= CANopen read SDO block
Reads the indicated entry in the object directory of a node in the network via SDO block transfer
CANOPEN_SDOREADMULTI (→ p. 103)
= CANopen read SDO multi
Reads the indicated entry in the object directory of a node in the network
>
5.1.6 Library ifm_CANopen_NT_Vxxyyzz.LIB
This ifm library contains the following function blocks:
ifm function elements ifm function elements for the device CR0452
CAN_RECOVER
Parameter
Data type
Description
ENABLE
BOOL := FALSE
TRUE: No automatic recovery after CAN bus off
FALSE: Automatic recovery after CAN bus off
CHANNEL
BYTE
CAN interface (1...n) depending on the device
RECOVER_EXECUTE
BOOL
TRUE (only for 1 cycle):
restart of CAN interface
remedy bus off condition
FALSE: function element is not executed
InhibitTime
(optional use of the parameter)
TIME := T#1s
Waiting time between bus off and restart of the CAN interface
Unit type = function block (FB)
Unit is contained in the library ifm_RawCAN_NT_Vxxyyzz.LIB
Symbol in CODESYS:
7512
>
Description
7513
CAN_RECOVER has the following tasks:
to activate / deactivate the automatic bus off handling
to restart the CAN interface in case of bus off
>In case of bus off: CAN Controller deletes all buffers (including the buffers of the other protocols).
If CAN_RECOVER is not used (ENABLE=FALSE):
> in case of a bus off a recovery attempt is automatically made after 1 s.
> after 4 failed recovery attempts in a row the affected CAN interface is deactivated.
ifm function elements ifm function elements for the device CR0452
CAN_SETDOWNLOADID
Parameter
Data type
Description
EXECUTE
BOOL := FALSE
FALSE TRUE (edge):
execute function element once
otherwise: function element is not active
A function element already started is processed.
CHANNEL
BYTE
CAN interface (1...n) depending on the device
DOWNLOAD_ID
BYTE
1...127 = set download ID
0 = read download ID
Parameter
Data type
Description
RESULT
BYTE
feedback of the function block
(possible messages → following table)
Value
dec | hex
Description
0
00
FB is inactive
1
01
function block execution completed without error
8
08
function block is active
242
F2
Error: setting is not possible
= Set download ID
Unit type = function block (FB)
Unit is contained in the library ifm_RawCAN_NT_Vxxyyzz.LIB
Symbol in CODESYS:
7516
>
Description
The download ID is required for data exchange when connecting the runtime system and the
CODESYS development environment. When the device is started the download ID is set with the
default value from the hardware configuration.
With CAN_SETDOWNLOADID this value can be set in the PLC program (e.g. using certain inputs).
The changed ID is also written into the hardware configuration.
feedback of the function block
(possible messages → following table)
Value
dec | hex
Description
0
00
FB is inactive
1
01
function block execution completed without error
5
05
FB is being processed – still receiving
9
09
CAN is not active
242
F2
Error: setting is not possible
Unit type = function block (FB)
Unit is contained in the library ifm_RawCAN_NT_Vxxyyzz.LIB
Symbol in CODESYS:
7586
>
Description
7588
CAN_RX is used for receiving a message.
The FB limits itself to a few functions and the required memory space is low.
CAN_RX filters for the set identifier. If several CAN messages with the same identifier are received in
one cycle, only the last / latest message is available.
filter mask for the identifier:
if ID_MASK bit = 0, CAN ID bit may be = 0 or 1
if ID_MASK bit = 1, CAN ID bit must be = ID bit
= CAN RX enhanced with FiFo
Unit type = function block (FB)
Unit is contained in the library ifm_RawCAN_NT_Vxxyyzz.LIB
Symbol in CODESYS:
7615
>
Description
In addition, CAN_RX_ENH_FIFO provides a FiFo for the received data (as opposed to CAN_RX_ENH
(→ p. 60)). Thus several CAN messages can be received in one cycle.
In this event:
► Deactivate and reactive the FB via ENABLE.
>The FiFo is deleted and can be newly filled.
Description to the filter mask: →CAN_RX_ENH (→ p. 60) > chapter Description
Unit is contained in the library ifm_RawCAN_NT_Vxxyyzz.LIB
Symbol in CODESYS:
7592
>
Description
7594
CAN_RX_RANGE provides the following settings:
select the message type (11 or 29 bits),
define an identifier range.
CAN_RX filters for the set identifier. If several CAN messages with the same identifier are received in
one cycle, only the last / latest message is available.
Unit is contained in the library ifm_RawCAN_NT_Vxxyyzz.LIB
Symbol in CODESYS:
7522
>
Description
7523
CAN_TX sends a standard message per cycle.
The FB limits itself to a few functions and the required memory space is low.
>If an instance of this FB is called several times during a cycle, the data is also sent several times.
In case of the simple functions CAN_TX and CAN_RX, it is determined by means of the ID whether a
standard or an extended frame is to be sent. With the enhanced versions this is set via the input
EXTENDED. Therefore, extended frames in the ID area 0...2047 cannot be sent via the easy
functions.
= CAN TX enhanced cyclic
Unit type = function block (FB)
Unit is contained in the library ifm_RawCAN_NT_Vxxyyzz.LIB
Symbol in CODESYS:
7568
>
Description
CAN_TX_ENH_CYCLIC serves for cyclical transmitting of CAN messages.
Otherwise, the FB corresponds to CAN_TX_ENH (→ p. 71).
► Set the period duration via the parameter PERIOD.
Unit is contained in the library ifm_RawCAN_NT_Vxxyyzz.LIB
Symbol in CODESYS:
7625
>
Description
In order to request a remote message, an according requirement is dispatched via
CAN_REMOTE_REQUEST and the response of the other device is sent back as result.
Unit is contained in the library ifm_CANopen_NT_Vxxyyzz.LIB
Symbol in CODESYS:
7785
>
Description
CANOPEN_ENABLE allows to switch the CANopen master on or off.
► In the application program always call an own instance of the FB CANOPEN_ENABLE (→ p. 81)
for every CAN interface!
If the master is restarted after a stop, all other connected nodes also have to be re-initialised.
Without CANOPEN_ENABLE, the CANopen master is started automatically, as far as this has been
selected in the configuration.
The configured baud rate is only adopted if CAN_ENABLE (→ p. 53) has not been activated before.
ifm function elements ifm function elements for the device CR0452
CANOPEN_GETBUFFERFLAGS
Parameter
Data type
Description
EXECUTE
BOOL := FALSE
FALSE TRUE (edge):
execute function element once
otherwise: function element is not active
A function element already started is processed.
CHANNEL
BYTE
CAN interface (1...n) depending on the device
ResetRXFlags
(optional use of the parameter)
BOOL := FALSE
TRUE: Provide fag status at the output and then reset
FALSE: function element is not executed
ResetTXFlags
(optional use of the parameter)
BOOL := FALSE
TRUE: Provide flag status at the output and then reset
FALSE: function element is not executed
= Get buffer flags
Unit type = function block (FB)
Unit is contained in the library ifm_CANopen_NT_Vxxyyzz.LIB
Symbol in CODESYS:
7890
>
Description
CANOPEN_GETBUFFERFLAGS supplies information on the buffer flags.
The flags can be reset via the optional inputs.
The function block returns the state of the overflow flags.
ifm function elements ifm function elements for the device CR0452
CANOPEN_SETSTATE
= Set state
Unit type = function block (FB)
Unit is contained in the library ifm_CANopen_NT_Vxxyyzz.LIB
Symbol in CODESYS:
7858
>
Description
7860
Via CANOPEN_SETSTATE, parameters of the master, a slave device or a node in the network can be
set.
The treatment of the NMT state of master, node or device is carried out in the CAN stack or via the
commands of the FB CANOPEN_NMTSERVICES (→ p. 91). At the same time admissibility checks are
carried out. For reasons of consistency no inputs are provided for this purpose.
ifm function elements ifm function elements for the device CR0452
>
Parameter
Data type
Description
EXECUTE
BOOL := FALSE
FALSE TRUE (edge):
execute function element once
otherwise: function element is not active
A function element already started is processed.
CHANNEL
BYTE
CAN interface (1...n) depending on the device
NODE
BYTE
Node ID = ID of the node (0...127)
Device as CANopen master:
Value = 0:
The changes only refer to the device itself.
Value not 0:
Node ID of a node in the network the parameters of which are to be
changed. The established settings are only adopted for this node (not
for the device).
Device as CANopen slave:
In slave mode, the node ID of the slave can be set via this input.
Value = 0:
no action
Value not 0:
The function block adopts this value as the new node ID of the device.
GlobalStart
(optional use of the parameter)
BOOL := TRUE
Requirement: FB must be called immediately after starting the IEC
program. This setting overwrites the setting of the configuration.
TRUE: Start all participants simultaneously
FALSE: Start all participants one after the other
CfgTimeout
(optional use of the parameter)
TIME := T#0ms
set configuration timeout for a node:
Value = 0:
no action – retain configuration data
Value not 0:
overwrite data from the configuration with the new value
InitNoSdos
(optional use of the parameter)
BOOL := FALSE
To the node indicated in NODE, during initialisation,...
TRUE: do not send configuration data
FALSE: send configured SDOs
Parameter
Data type
Description
RESULT
BYTE
feedback of the function block
(possible messages → following table)
Value
dec | hex
Description
0
00
FB is inactive
1
01
FB execution completed without error – data is valid
waiting time of the FB for the initialisation
when the time has elapsed, the FB stops waiting.
0 = use value from the configuration
= Network management services
Unit type = function block (FB)
Unit is contained in the library ifm_CANopen_NT_Vxxyyzz.LIB
Symbol in CODESYS:
7843
>
Description
Depending on its NMT command entries, CANOPEN_NMTSERVICES either triggers an NMT
command or the initialisation of a node.
NMT = Network-ManagemenT
The function block updates the internal node status. If a state transition to CANopen (→ system
manual "Know-How ecomatmobile" > NMT state) should not be permitted, the command is not
executed.
A CANopen device can automatically change its CANopen state by means of the FB:
preoperational operational
ifm function elements ifm function elements for the device CR0452
CANOPEN_SDOREAD
Parameter
Data type
Description
EXECUTE
BOOL := FALSE
FALSE TRUE (edge):
execute function element once
otherwise: function element is not active
A function element already started is processed.
CHANNEL
BYTE
CAN interface (1...n) depending on the device
NODE
BYTE
ID of the node
permissible values = 1...127 = 0x01...0x7F
IDX
WORD
index in object directory
SUBIDX
BYTE
sub-index referred to the index in the object directory
Timeout
(optional use of the parameter)
TIME := T#10ms
waiting time of the FB for the response
when the time has elapsed, the FB stops waiting.
value = 0: use value from the configuration
= SDO read
Unit type = function block (FB)
Unit is contained in the library ifm_CANopen_NT_Vxxyyzz.LIB
Symbol in CODESYS:
7791
>
Description
CANOPEN_SDOREAD is an easy function block for editing "Expedited SDOs", i.e. SDOs with max.
4 bytes of user data. This type usually represents the bigger part of the SDO communication.
Expedited SDO = Expedited Service Data Object
A considerable amount of memory space can be saved due to the limitation of the data volume to
max. 4 bytes of user data, as this FB only needs to reserve 4 bytes as buffer storage and does not
create a large data array itself.