Anda di halaman 1dari 15

CoDeSys provided by FESTO and CANopen

1st Part
CoDeSys pbF and CANopen
functionality

The basics

NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

12.02.2015

12.02.2015

12.02.2015

CoDeSys provided by FESTO and CANopen: presentation overview

1. CANopen functionality supported by CoDeSys pbF:


- CANopen libraries
- CANopen implicit variables
- CANopen operation under CoDeSys pbF
2. CANopen Master configuration
3. CANopen Slave configuration

NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

1. CANopen functionality supported by CoDeSys pbF:


- CANopen libraries
- CANopen implicit variables
- CANopen operation under CoDeSys pbF
2. CANopen Master configuration
3. CANopen Slave configuration

NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

CANopen on PLCs CoDeSys (v.2.3.9)


For CoDeSys v.2.3.9, some important functions have been integrated
For example, the CANopen network configurator.
CANopen is used for managing remote peripherals.
For PLCs, the CANopen controller provides CANopen Master functionality
It is therefore declared as CANopen-Master in the PLC configurator.

NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

12.02.2015

CANopen functionality under CoDeSys pbF


If the CANopen network is selected (Master declared):
-CoDeSys inserts all LIBRARIES required to ensure operation of the CAN network
- CoDeSys generates a list of implicit Global Variables for the CAN network along with the
constants and instances of Function Blocks for CAN

NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

12.02.2015

12.02.2015

CANopen functionality under CoDeSys pbF: CANopen libraries


To ensure correct operation of the CANopen network ,
the following CoDeSys libraries are used:
3S_CanDriver.Lib
to perform the basic CAN controller functions
3S_CanOpenManager.lib
the basic functions and services for CANopen
3S_CanOpenMaster.lib
the functions and services for the CANopen Master

And of course, the EDS files for each slave which form part
of the user's CANopen network
NOTE:
CoDeSys also offers 3S_CanOpenNetVar.lib and 3S_CanOpenDevice.lib libraries,
but sometimes unused on some PLCs.
NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

CANopen functionality under CoDeSys pbF: CANopen libraries

CANopen
COMPLIANCE

CoDeSys
COMPATIBILITY

EASE of use

NSC-F-FR/W.Gomolka

The CoDeSys CANopen libraries comply with


specification CiA DS301 v.4.01

They are supported (compatible) by all of the CoDeSys


kernels (runtime systems) implemented in the various
PLCs (targets).

The CANopen network configurator and the applied


protocols are optimised and identical for each CoDeSys
system (kernel, programming system)
CoDeSys pbF and CANopen

12.02.2015

CANopen functionality under CoDeSys pbF: CANopen Implicit Variables


CanOpen implicit Variables: automatically generated by the CAN Configurator
They are located in the Global Variable List (Resources )

MAX_MASTERINDEX
A constant which corresponds to the maximum
number of Masters supported by the PLC
configuration
MAX_NODEINDEX
A constant which corresponds to the number of slave
nodes contained in the PLC configuration

pCANopenMaster:
Instance of the Function Block CanOpenMaster (Master functionality).
pCanOpenNode:
Instance of the Function Block CanOpenNode (Slave management).
NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

12.02.2015

CANopen functionality under CoDeSys pbF: CANopen Implicit Variables


Function Block:

CanOpenMaster

(*) Current status of Master


Used only when a Master Object
Dictionary is accessed
Index of received Messages
Master index number
If = TRUE
NMT Command: Start all Slaves
If = TRUE
NMT Command: Reset all Slaves
nStatus represents the current status of the CANopen Master:
-1 : Disabled
0-2 : Startup phase
3 : Slave initialisation
4 : Slaves initialised, Start command sent
5 : Start command ended, the CANopen network is operational
NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

12.02.2015

CANopen functionality under CoDeSys pbF: CANopen Implicit Variables


Function Block: CanOpenNode
Important I/O variables

dwHeartbeatTime: DWORD;
Interval in msec, used to control the reception of
Heartbeat messages from the node.
In the configurator, it is advisable to set the value 1.5
times higher than the node Hearbeat time.

EmcyMsg: CAN_Message;
The last Emergency Message
sent by the node

nStatus: INT;
Current status of the node.
0 : not defined
1 : The node is reset by the CANopen Master
2 : Master waits ~ 300 ms before reading object 0x1000 (Device Type). The status then changes to 3.
3 : Master starts (request 0x1000) the slave configuration via SDO messages
4 : Configuration completed and the node awaits the command Start Node; once this command is received, the status changes to 5.
5 : Normal operating status. The node receives and sends the PDO telegrams. Ditto for Master status!!
97: The Optional node has not been detected at startup
98: The node has responded to the Device Type request (object 0x1000) with a different value (EDS file)
99: LifeTime exceeded . Node monitoring error (Nodeguarding error)
NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

12.02.2015

10

CANopen functionality under CoDeSys pbF : CANopen communication

Principle of CANopen operation under CoDeSys:


CoDeSys generates the operation sequences for the CAN controller:
- a CANopen network startup sequence
- The cyclical data exchange sequence on CANopen (CanOpenMaster/Node)
These sequences are performed by higher priority tasks and cannot be modified by the
users program.
Master functionality is provided by means of the CanOpenMaster

Function Block

The data and node monitoring (Node Guarding, Heartbeat) are carried out by means of
the CanOpenNode Function Block

NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

12.02.2015

11

CANopen functionality under CoDeSys pbF : CANopen operation


(PLC startup)

The startup sequence (Boot)

1) Resetting node

The CANopen network always starts up with the same sequence of


actions:

2) Checking node
(type and profile)

1.All Slaves are reset

3) Loading Configuration Data


(SDO)

2. The type and profile (Object 0x1000) of each Slave are checked
a) If the Slave responds and is OK, it is configured (see p.3)
b) If the Slave responds but is not OK, it will still be configured, but
declared as INCORRECT (wrong type)
c) If the Slave does not respond, it is declared as NON-EXISTENT

4) Configuration of node
monitoring
(Nodeguarding, heartbeat)
5) Node startup
6) Initialisation of all
configured PDOs

3. Each correct Slave is configured (SDO telegrams sent with the configuration
parameters declared in the configurator)
4.If node monitoring has been enabled for Master, the monitoring parameters
(Nodeguarding, Heartbeat) are sent and node monitoring is enabled
5.Master executes node startup (NMT Start remote Node)
6.At the end, all of the declared PDOs are enabled and Master sends the PDOs
(Slave R_PDO) to the relevant slaves

(Transfer of PDOs)
NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

12.02.2015

12

CANopen functionality under CoDeSys pbF : CANopen operation


After successful configuration and startup (boot), CANopen operation consists of the
following cyclical sequence:
CANRead(0);

(* read the CAN inbound buffer*)

pCanOpenMaster[0]();
pCanOpenNode[x]();

(* network management by CANopen Master *)

pCanOpenPDO_Rx[0]();

(*receive telegrams: T_PDO-Slave R_PDO-Master *)

(* dialogue with the CANopen Slaves *)

< run user application program >


pCanOpenPDO_Tx[0]() ;

(* send telegrams: T_PDO-Master R_PDO-Slave *)

MgrClearRxBuffer(params)

(* reset CAN communication buffer *)

NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

12.02.2015

13

12.02.2015

14

12.02.2015

15

1. CANopen functionality supported by CoDeSys pbF:


- CANopen libraries
- CANopen implicit variables
- CANopen operation under CoDeSys pbF
2. CANopen Master configuration
3. CANopen Slave configuration

NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

CANopen Master configuration under CoDeSys: CAN parameters

NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

CANopen Master configuration under CoDeSys: CAN parameters


The baud rate parameter defines the transmission
speed used on the CANopen network
The PDO messages can be sent in transmission mode:
synchronous or asynchronous.
A synchronisation message (Sync) is sent in
synchronous mode:
With a unique number Sync.COB-ID
In the time interval specified (in sec) by the
parameter Com.Cycle Period
In the time window specified (in sec) by the
parameter Sync.Windows Length
And if the Activate option is confirmed
Note:
If the value Sync.Windows Length or Com.Cycle Period is
defined as 0: no Sync message is sent
NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

12.02.2015

16

Transmission of PDO messages: synchronous / asynchronous mode

Com.Cycle Period
Sync.Window
length

NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

12.02.2015

17

12.02.2015

18

CANopen Master configuration under CoDeSys: CAN parameters


The Node-Id parameter defines the CANopen
network node (COB-ID).
It is used in the exchange of messages on
CANopen to identify (COB-ID) a message
sender/receiver
Its value must be between 1 and 127 (decimal)
Not to be confused with the Module Number, (Module-Id)
used in PLC Configuration (base parameters)

NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

CANopen Master configuration under CoDeSys: CAN parameters

If the Automatic Startup option is enabled, the CAN


network is initialised and starts automatically:
after the project has been loaded, and/or
after the PLC has been rebooted.

Otherwise, the CAN network must be started by a


specific function inside the application program
(explicit service)

NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

12.02.2015

19

12.02.2015

20

12.02.2015

21

CANopen Master configuration under CoDeSys: CAN parameters

If the Support DSP301,V4.01 and DSP306 option is


enabled, the CANopen Master will support all of the
CANopen slaves that comply with these specifications.

In this case, it is possible to implement a Heartbeat


monitoring function, the frequency of which must be
defined in ms.

This functionality is an alternative to another


monitoring function: NodeGuarding

NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

1. CANopen functionality supported by CoDeSys pbF:


- CANopen libraries
- CANopen implicit variables
- CANopen operation under CoDeSys pbF
2. CANopen Master configuration
3. CANopen Slave configuration
-

NSC-F-FR/W.Gomolka

CAN Slave parameters


PDO telegram configuration (mapping)
SDO object configurations

CoDeSys pbF and CANopen

CANopen Slave configuration under CoDeSys: to begin


The configurator for a CANopen Slave under CoDeSys complies with specification CiA
DS301 v.4.01
The configuration options for a CANopen module (node) are defined in an EDS file
(Electronic Data Sheet file)
To configure the CANopen network, an EDS configuration file is required for each
node, which is to be included in the configured network
The EDS file must be supplied by each equipment manufacturer of the CANopen
equipment and must comprise three parts:
Information on the version of the EDS file
General description of the equipment
Object Dictionary for the equipment with all default values

NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

12.02.2015

22

Configuration of a CANopen Slave under CoDeSys : EDS file for the Slave
By default, under CoDeSys pbF, the available
slaves are located in the CANopen equipment
catalogue
If the slave is not contained in this catalogue,
the EDS file must be imported.
==========================================================

1. Click on CanOpenMaster(PLC

Configuration)

2. In the Extra menu, select the Add


configuration file. option.
3. In the Select configuration file window,
select the appropriate EDS file
==========================================================

After the file has been saved, the corresponding


Slave is automatically added to the CANopen
equipment catalogue
NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

12.02.2015

23

12.02.2015

24

CANopen Slave configuration under CoDeSys : Inserting the Slave


Inserting the CANopen Slave :
1. Right click on CanOpenMaster(PLC Configuration)
2. In the popup menu, select the Append
Subelement option
3. From the available equipment catalogue, select
the desired Slave: (e.g., FB14 for CPX-FB14)

Once the Slave has been selected, the configuration


dialogue window for the selected Slave appears.

NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

CANopen Slave configuration: base parameters

For the selected Slave, theCANopen configurator reserves a certain number of Inputs and Outputs
(%I,%Q..) for available objects and mappable into PDO messages .
Their number and allocation (CAN Inputs/Outputs) depends on the default configuration defined
in the EDS file
NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

12.02.2015

25

12.02.2015

26

12.02.2015

27

CANopen Slave configuration :


CAN parameters
General section:
Node-ID
The parameter Node-ID identifies the Slave Number
on CANopen
It is used to identify (COB-ID) a sender/receiver of the
CANopen message
Its value must be between 1 and 127 (decimal) and it
correspond to the configured slave number (e.g., DIL switches)
Not to be confused with Module Number (Module-Id) used in
PLC Configuration (base parameters)

NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

CANopen Slave configuration :


CAN parameters
General section: Write DCF
If the Write DCF option is enabled, the compiler
generates a DCF (Device Configuration File) for the
configured slave.
This file has the same name as the EDS file of the
Slave, with the Node-ID added
The DCF contains only the configuration data for the
configured slave (Node-ID) .

Note:
if DCF is used instead of EDS, only the CAN Input/Output
addresses can be modified.

NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

CANopen Slave configuration :


CAN parameters
General section: Create all SDOs

If the Create all SDOs option is enabled,


SDOs are created for all of the objects declared
in the Object Dictionary (EDS file)
Otherwise, the configurator generates SDOs
only for the modified objects in Service Data
Objects tab.
Note: At startup (boot), the Master sends an SDO
(read request) for the object 0x1000 (Device Type).
If the Slave responds within 0.5 sec, the other SDO
configuration telegrams will be sent to the Slave

NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

12.02.2015

28

12.02.2015

29

12.02.2015

30

CANopen Slave configuration :


CAN parameters
General section: other available options
If the Reset Node option is enabled, the Slave
executes an auto-reset when network connection is
detected.
If the Optional Device option is enabled, the Master
only tries to read Slave object 0x1000 (DeviceType)
once. If the Slave does not respond or answer is
incorrect, the Slave is ignored and will be marked as
Non-Existent
If the No initialization option is enabled, the Master
immediately puts the Slave into operation mode,
without sending it the configuration SDOs.

NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

CANopen Slave configuration:


CAN parameters
Node guard section
If Nodeguarding (node monitoring) is enabled,
the Master (cyclically) sends a monitoring message
to the Slave.
The time interval (in ms) is specified in the
parameter Guard Time.
If the Slave does not respond or its response is not
correct, it is declared invalid (disconnected)
If the missing number of Master requests defined
by Life Time Factor is exceeded, the Slave is
considered to be disconnected from the network.
If nothing is defined

(Guard Time and Life Time Factor

have the value 0), NodeGuarding

of the Slave is not

carried out.
NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

10

CANopen Slave configuration:


CAN parameters
Heartbeat settings section
The Heartbeat functionality is an alternative to the
Nodeguarding function
It operates in Producer /Consumer mode
If Activate Heartbeat generation is enabled, the Slave
sends Heartbeat messages in the time interval specified
(in ms) in the parameter Heartbeat Producer Time.
If the Activate Heartbeat Consumer option is enabled,
the Slave monitors the Heartbeat messages sent by the
Master.
If such messages are no longer received, the Slave
deactivates its I/Os.

NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

12.02.2015

31

CoDeSys pbF and CANopen

12.02.2015

32

CoDeSys pbF and CANopen

12.02.2015

33

CANopen Slave configuration:


CAN parameters
Emergency telegram section
The emergency message Emergency telegram is
sent by the Slave if an internal malfunction occurs. Its
contents are defined by the manufacturer.
If the Emergency option is enabled, the Slave sends
this message immediately with COB-ID (0x80 +NodeID)
and the appropriate contents (error code, problems)
The contents of this message can be read in the
EmcyMsg field of the output variables of Function
Block pCANopenNode (CANopen Implicit Variables).

NSC-F-FR/W.Gomolka

CANopen Slave configuration:


CAN parameters
Info... (button) section

Click on Info to display the data:

FileInfo and DeviceInfo


Inside the EDS/DCF file used for Slave
configuration

NSC-F-FR/W.Gomolka

11

1. CANopen functionality supported by CoDeSys pbF:


- CoDeSys pbF: CANopen libraries
- CoDeSys pbF: CANopen implicit variables
- CANopen operation under CoDeSys pbF
2. CANopen Master configuration
3. CANopen Slave configuration
-

NSC-F-FR/W.Gomolka

Slave CAN parameters


PDO telegram configuration (mapping)
SDO object configurations

CoDeSys pbF and CANopen

12.02.2015

34

CANopen Slave configuration : PDO telegram mapping

PDO (Process Data Objects) messages are used for real time data transfers,

PDO communication corresponds to the Producer-Consumer operational model

By default, each CANopen node can access the 8 PDO messages:


4 Transmit PDO (TPDO): the messages sent by CANopen node
4 Receive PDO (RPDO): the messages received by CANopen node

Each PDO message (Transmit or Receive) is identified by identifier: COB-ID

A PDO message is restricted to 8 bytes (64 bits) of data

The operation of allocating Objects in the PDO message is performed via PDO Mapping

NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

12.02.2015

35

CANopen Slave configuration : Mapping of the PDO telegram (message)

The Receive PDO mapping and Send PDO mapping tabs are used to modify the PDO messages
defined (by default) in the EDS file of the configured Slave.

The left-hand column contains all the mappable Objects that can be added ( >> button) to the
PDO messages (right-hand column).

The Delete button is used to delete objects from a PDO,

The Insert PDO button is used to create an additional PDO message (right-hand column)

The Properties button is used to edit the PDO properties, (in accordance with CANopen standard).

NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

12.02.2015

36

12

CANopen Slave configuration : PDO telegram mapping


Examples

NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

12.02.2015

37

CANopen Slave configuration: PDO characteristics

The Properties button is used to edit the PDO properties, defined in CANopen.

NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

12.02.2015

38

CANopen Slave configuration: PDO characteristics

Transmission modes for a PDO:

synchronous synchronisation by reception of a SYNC object (1 to 240 objects):


- acyclic: synchronous transmission (with SYNC) but not cyclical (e.g., initiated following a change of status on
an input)
- cyclic: synchronous (SYNC) and cyclical transmission
- RTR only: synchronous transmission (SYNC), initiated by the reception of an RTR message (remote
transmission request ) from the other node,
asynchronous
- RTR only: asynchronous transmission, initiated by the reception of an RTR message (remote transmission
request ) from the other node,
- asynchronous transmission initiated by the presence of an Object specified in the equipment profile (e.g.,
Event timer) or by an event (e.g., change of status on an input).
NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

12.02.2015

39

13

1. CANopen functionality supported by CoDeSys pbF:


- CANopen libraries
- CANopen implicit variables
- CANopen operation under CoDeSys pbF
2. CANopen Master configuration
3. CANopen Slave configuration
-

CAN Slave parameters


PDO telegram configuration (mapping)
SDO object configurations

NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

12.02.2015

40

CANopen Slave configuration: SDO parameters

Often, for activation of the configured PDOs, it is also necessary to complete some SDO
parameters (objects) available in the Slaves Object Dictionary , e.g.,:

Object 6005h Interrupt Enable to authorise the transmission of Digital Inputs,


Objects 6423h, 6424h, 6425h, 6426h to define the conditions for sending Analogue Inputs

Otherwise, despite being present, the object configured in PDOs may not be sent

NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

12.02.2015

41

CANopen Slave configuration: SDO parameters


SDO for Analogue Inputs on Valve Terminal CPX
Object 0x6423: Analogue Input Global Interrupt Enable

This object authorises the transmission of analogue inputs (in accordance with DS401)
Value to be entered in object 0x6423:
0 Disable (transmission not authorised)
1 Enable (transmission authorised)

NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

12.02.2015

42

14

CANopen Slave configuration: SDO parameters


SDO for Analogue Inputs on Valve Terminal CPX
Object 0x6421: Analogue Input Interrupt Trigger

This object defines how the analogue input must be checked to start the transmission
Values to be entered in the object 0x6421:
Bit 0 Upper limit exceeded
Bit 1 Lower limit exceeded
Bit 2 Change of value greater than Delta
Bits 3-7: Reserved

NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

12.02.2015

43

CANopen Slave configuration: SDO parameters


SDO for Analogue Inputs on Valve Terminal CPX
Objects 0x6421: Analogue Input Interrupt Trigger: Trigger Value

To start the transmission of an analogue input, the values corresponding to the properties
selected for object 0x6421must be entered
These values are contained in the following objects:
Object 0x6424 Upper limit value
Object 0x6425 Lower limit value
Object 0x6426 Delta Value

NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

12.02.2015

44

12.02.2015

45

End of 1stPart

NSC-F-FR/W.Gomolka

CoDeSys pbF and CANopen

15

Anda mungkin juga menyukai