Post on 04-Dec-2015
description
1
12.02.2015 1NSC-F-FR/W.Gomolka CoDeSys pbF and CANopen
CoDeSys provided by FESTO and CANopen
1st Part
CoDeSys pbF and CANopenfunctionality
The basics
NSC-F-FR/W.Gomolka CoDeSys pbF and CANopen 12.02.2015 2
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 12.02.2015 3
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
2
NSC-F-FR/W.Gomolka CoDeSys pbF and CANopen 12.02.2015 4
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 PLC�s, 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 5
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 6
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 PLC�s.
3
NSC-F-FR/W.Gomolka CoDeSys pbF and CANopen 12.02.2015 7
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)
CANopen functionality under CoDeSys pbF: CANopen libraries
CANopen COMPLIANCE
CoDeSys COMPATIBILITY
EASE of use
NSC-F-FR/W.Gomolka CoDeSys pbF and CANopen 12.02.2015 8
CanOpen implicit Variables: automatically generated by the CAN Configurator
They are located in the Global Variable List (Resources )
CANopen functionality under CoDeSys pbF: CANopen Implicit Variables
MAX_MASTERINDEXA constant which corresponds to the maximum number of Masters supported by the PLC configuration
MAX_NODEINDEXA 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 9
Function Block: CanOpenMaster
Index of received Messages
Master index number
If = TRUE NMT Command: Reset all Slaves
(*) Current status of Master
Used only when a Master Object Dictionary is accessed
CANopen functionality under CoDeSys pbF: CANopen Implicit Variables
If = TRUE NMT Command: Start all Slaves
nStatus represents the current status of the CANopen Master:
-1 : Disabled 0-2 : Startup phase3 : Slave initialisation
4 : Slaves initialised, Start command sent5 : Start command ended, the CANopen network is operational
4
NSC-F-FR/W.Gomolka CoDeSys pbF and CANopen 12.02.2015 10
Function Block: CanOpenNodeImportant I/O variables
CANopen functionality under CoDeSys pbF: CANopen Implicit 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 messages4 : 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 11
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
user�s 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
CANopen functionality under CoDeSys pbF : CANopen communication
NSC-F-FR/W.Gomolka CoDeSys pbF and CANopen 12.02.2015 12
1) Resetting node
2) Checking node(type and profile)
3) Loading Configuration Data (SDO)
4) Configuration of node monitoring
(Nodeguarding, heartbeat)
5) Node startup
6) Initialisation of all configured PDOs
(Transfer of PDOs)
(PLC startup)
CANopen functionality under CoDeSys pbF : CANopen operation
The startup sequence (Boot)
The CANopen network always starts up with the same sequence of actions:
1.All Slaves are reset
2. The type and profile (Object 0x1000) of each Slave are checkeda) 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
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
5
NSC-F-FR/W.Gomolka CoDeSys pbF and CANopen 12.02.2015 13
•After successful configuration and startup (boot), CANopen operation consists of the following cyclical sequence:
CANopen functionality under CoDeSys pbF : CANopen operation
CANRead(0); (* read the CAN inbound buffer*)
pCanOpenMaster[0](); (* network management by CANopen Master *)
pCanOpenNode[x](); (* dialogue with the CANopen Slaves *)
pCanOpenPDO_Rx[0](); (*receive telegrams: T_PDO-Slave �R_PDO-Master *)
< 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 14
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 12.02.2015 15
CANopen Master configuration under CoDeSys: CAN parameters
6
NSC-F-FR/W.Gomolka CoDeSys pbF and CANopen 12.02.2015 16
• 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
CANopen Master configuration under CoDeSys: CAN parameters
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 17
Com.Cycle Period
Sync.Window length
Transmission of PDO messages: synchronous / asynchronous mode
NSC-F-FR/W.Gomolka CoDeSys pbF and CANopen 12.02.2015 18
• 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)
CANopen Master configuration under CoDeSys: CAN parameters
7
NSC-F-FR/W.Gomolka CoDeSys pbF and CANopen 12.02.2015 19
• 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)
CANopen Master configuration under CoDeSys: CAN parameters
NSC-F-FR/W.Gomolka CoDeSys pbF and CANopen 12.02.2015 20
• 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
CANopen Master configuration under CoDeSys: CAN parameters
NSC-F-FR/W.Gomolka CoDeSys pbF and CANopen 12.02.2015 21
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
8
NSC-F-FR/W.Gomolka CoDeSys pbF and CANopen 12.02.2015 22
• 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
CANopen Slave configuration under CoDeSys: to begin
NSC-F-FR/W.Gomolka CoDeSys pbF and CANopen 12.02.2015 23
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 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.
9
NSC-F-FR/W.Gomolka CoDeSys pbF and CANopen 12.02.2015 25
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 26
CANopen Slave configuration : CAN parameters
• The parameter �Node-ID� identifies the Slave Numberon 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)
�General� section: Node-ID
NSC-F-FR/W.Gomolka CoDeSys pbF and CANopen 12.02.2015 27
CANopen Slave configuration : CAN parameters
• 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.
�General� section: Write DCF
10
NSC-F-FR/W.Gomolka CoDeSys pbF and CANopen 12.02.2015 28
CANopen Slave configuration : CAN parameters
• 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
�General� section: Create all SDOs
NSC-F-FR/W.Gomolka CoDeSys pbF and CANopen 12.02.2015 29
CANopen Slave configuration : CAN parameters
• 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.
�General� section: other available options
NSC-F-FR/W.Gomolka CoDeSys pbF and CANopen 12.02.2015 30
CANopen Slave configuration: CAN parameters
• 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.
�Node guard� section
11
NSC-F-FR/W.Gomolka CoDeSys pbF and CANopen 12.02.2015 31
CANopen Slave configuration: CAN parameters
• 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.
�Heartbeat settings� section
NSC-F-FR/W.Gomolka CoDeSys pbF and CANopen 12.02.2015 32
CANopen Slave configuration: CAN parameters
• 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).
�Emergency telegram� section
NSC-F-FR/W.Gomolka CoDeSys pbF and CANopen 12.02.2015 33
CANopen Slave configuration: CAN parameters
• Click on �Info�� to display the data:
« �FileInfo� and �DeviceInfo�
Inside the EDS/DCF file used for Slave
configuration
�Info...� (button) section
12
NSC-F-FR/W.Gomolka CoDeSys pbF and CANopen 12.02.2015 34
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- Slave CAN parameters- PDO telegram configuration (mapping)- SDO object configurations
NSC-F-FR/W.Gomolka CoDeSys pbF and CANopen 12.02.2015 35
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 36
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).
13
NSC-F-FR/W.Gomolka CoDeSys pbF and CANopen 12.02.2015 37
CANopen Slave configuration : PDO telegram mapping
Examples
NSC-F-FR/W.Gomolka CoDeSys pbF and CANopen 12.02.2015 38
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 39
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).
CANopen Slave configuration: PDO characteristics
14
NSC-F-FR/W.Gomolka CoDeSys pbF and CANopen 12.02.2015 40
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 41
� Often, for activation of the configured PDOs, it is also necessary to complete some SDO
parameters (objects) available in the Slave�s 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
CANopen Slave configuration: SDO parameters
NSC-F-FR/W.Gomolka CoDeSys pbF and CANopen 12.02.2015 42
SDO for Analogue Inputs on Valve Terminal CPX
� 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)
CANopen Slave configuration: SDO parameters
Object 0x6423: Analogue Input Global Interrupt Enable
15
NSC-F-FR/W.Gomolka CoDeSys pbF and CANopen 12.02.2015 43
� 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
CANopen Slave configuration: SDO parameters
Object 0x6421: Analogue Input Interrupt Trigger
SDO for Analogue Inputs on Valve Terminal CPX
NSC-F-FR/W.Gomolka CoDeSys pbF and CANopen 12.02.2015 44
� To start the transmission of an analogue input, the values corresponding to the propertiesselected 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
CANopen Slave configuration: SDO parameters
Objects 0x6421: Analogue Input Interrupt Trigger: Trigger Value
SDO for Analogue Inputs on Valve Terminal CPX
NSC-F-FR/W.Gomolka CoDeSys pbF and CANopen 12.02.2015 45
End of 1stPart