Canopen Hands-On Tutorial: Canopen Magic Prods Eval
Canopen Hands-On Tutorial: Canopen Magic Prods Eval
An Introduction to CANopen
using
CANopen Magic ProDS Eval
Presented by Olaf Pfeiffer
EMBEDDED SYSTEMS ACADEMY
CANopenHOT
July 2005 www.CANopenMagic.com
Slide 1
Prerequisites
CANopenHOT
July 2005
Slide 2
www.esacademy.com
Embedded Systems Academy CANopen Hands-On Tutorial
Published by
Annabooks / RTCBooks
3 Parts
• Using CANopen
Introductory level up to system
integration
• CANopen Engineering
Developing CANopen nodes
• CANopen Reference
Quick access to all info required by
integrators and developers
www.CANopenBook.com
CANopenHOT
July 2005
Slide 3
Contents
www.esacademy.com
Embedded Systems Academy CANopen Hands-On Tutorial
Physical Settings
CANopenHOT
July 2005
Slide 6
www.esacademy.com
Embedded Systems Academy CANopen Hands-On Tutorial
High-end PC or Plant
Workstation Management
PC or Plant
Workstation Control
16 to 32 bit Controller
Coupler
Slide 7
Slide 8
www.esacademy.com
Embedded Systems Academy CANopen Hands-On Tutorial
NOTE:
CANopen Magic ProDS Eval
Does not simulate network speed, available
CANopenHOT
bandwidth only depends on the performance
July 2005 of the PC on which the simulation runs
Slide 9
Hands-On:
Getting started
Start CANopen Magic ProDS Eval
Slide 10
www.esacademy.com
Embedded Systems Academy CANopen Hands-On Tutorial
Network Nodes
Terminator Terminator
Trunk Line Tap Tap Tap Tap
Node Node
Node Drop Line
Node
Node Node
Node
www.esacademy.com
Embedded Systems Academy CANopen Hands-On Tutorial
Hands-On:
Network Configuration
From the main menu, select
Options – Configure Network
Or press the Network Configuration tool button
CANopenHOT
July 2005
Slide 13
Hands-On:
Add nodes to the simulation
In the Network Configuration window,
click on the ‘Add Node” button
Add two digital I/O nodes to the system
1. Node ID ‘1’
2. Name ‘Digital I/O’
3. EDS File
‘Peak Digital 1.eds’
from EDS directory
4. Add ‘2’ nodes
5. Choose the simulated
product
‘PCAN MicroMod Digital 1’
6. Click the ‘OK’ button
CANopenHOT
July 2005
Slide 14
www.esacademy.com
Embedded Systems Academy CANopen Hands-On Tutorial
Hands-On:
Run network simulation
Open Trace window, to see simulated network traffic
• From the main menu, select View – Trace
To run the simulation, go to the main window and
select the simulation tab
Click on ‘Run’ to run the simulation of individual
nodes or on the green triangle to run all nodes
Simulation tab
Run all nodes
CANopenHOT
July 2005
Slide 15
Hands-On:
View first messages
Look at the Trace window
Each node produced 2 messages
• Bootup (701h and 702h)
• Emergency Clear (81h and 82h)
CANopenHOT
July 2005
Slide 16
www.esacademy.com
Embedded Systems Academy CANopen Hands-On Tutorial
CANopenHOT
July 2005
Slide 17
CAN ID
IDs not listed are From To Communication Objects
free and may be
used by system 0h NMT Service
integrator 80h SYNC Message
81h FFh Emergency Messages
IDs used for the 100h Time Stamp Message
PDOs and SDOs
are derived by 181h 1FFh 1st Transmit PDO
adding the 201h 27Fh 1st Receive PDO
Each CANopen “node ID”-1 to the 281h 2FFh 2nd Transmit PDO
node MUST “From” start
address 301h 37Fh 2nd Receive PDO
have a unique
381h 3FFh 3rd Transmit PDO
node ID in the
range of With this scheme, 401h 47Fh 3rd Receive PDO
1 to 127 the node ID gets 481h 4FFh 4th Transmit PDO
inserted into bits 0 501h 57Fh 4th Receive PDO
to 6 of the CAN 581h 5FFh Transmit SDO
message identifier
CANopenHOT
July 2005
601h 67Fh Receive SDO
Slide 18 701h 77Fh NMT Error Control
www.esacademy.com
Embedded Systems Academy CANopen Hands-On Tutorial
Boot-up, Heartbeat,
Network Management (NMT)
Boot-up message,
heartbeat production, heartbeat consumption
NMT state machine, NMT Master Message
Power-On Reset
Reset Node
Stopped
CANopenHOT
Operational
July 2005
Slide 20
www.esacademy.com
Embedded Systems Academy CANopen Hands-On Tutorial
0 1
0
request indication
CANopenHOT
CAN-ID = 700h + Node-ID
July 2005
Slide 21
Heartbeat
time
Heartbeat-Time Slave 1
Heartbeat-Time Slave 2
CANopenHOT
July 2005
CAN-ID = 700h + Node-ID
Slide 22
www.esacademy.com
Embedded Systems Academy CANopen Hands-On Tutorial
Hands-On:
Set heartbeat times
Open Network Overview window
• From the main menu, select View – Trace
CANopen Magic now actively scans for nodes
connected to the network
• Nodes ‘1’ and ‘2’ are detected
• Their identification is read and displayed
Set Heartbeats for all nodes to 1s
Click to activate
1000ms = 1s heartbeats
CANopenHOT
July 2005
Slide 23
Hands-On:
Use Trace to verify heartbeat timing
Switch to the Trace Window
• Clear trace
• Enable static trace view
• Use relative timestamps
Periodically transmitted heartbeats are displayed
Relative
Clear Static View Timestamps
CANopenHOT
July 2005
Slide 24
www.esacademy.com
Embedded Systems Academy CANopen Hands-On Tutorial
Hands-On:
Send NMT Master Message
NMT (Network Management) Master Message
• Switches the NMT state of individual or all nodes
Shortcuts to In main window go to the
NMT messages Network Management tab
Here NMT Master
messages can be
NMT tab generated addressed to
individual nodes (the one
currently selected) or all
nodes
Shortcuts to transmit
‘NMT to all nodes’ are
available in the tool bar
CANopenHOT
July 2005
Slide 25
Object Dictionary
www.esacademy.com
Embedded Systems Academy CANopen Hands-On Tutorial
Slide 27
Slide 28
www.esacademy.com
Embedded Systems Academy CANopen Hands-On Tutorial
CANopenHOT
July 2005
Slide 29
CANopen
SDO - Service Data Object Communication
CANopenHOT
July 2005
Slide 30
www.esacademy.com
Embedded Systems Academy CANopen Hands-On Tutorial
Node 1
Master Tx SDO: 581h
Sends SDO Rx SDO: 601h
requests to each
node by using Node 2
CAN ID: Tx SDO: 582h
600h + Node ID Rx SDO: 602h
CANopenHOT
July 2005
Slide 31
Hands-On:
Reading Object Dictionary entries
Object Dictionary entries can be accessed from the
main window, choose Read or Write Tab
www.esacademy.com
Embedded Systems Academy CANopen Hands-On Tutorial
www.esacademy.com
Embedded Systems Academy CANopen Hands-On Tutorial
PDO
Predefined Connection Set, Linking
Per default, each node has access to 8 PDOs,
messages with process data in them
• 4 Transmit PDOs (TPDO)
• 4 Receive PDOs (RPDO)
Per default, all transmit PDOs are received and
handled ONLY by the master
Per default, ONLY the master is allowed to use the
CAN message IDs used for transmit PDOs
• So it’s only the master who can send data to the
nodes
With dynamic linking, PDOs are re-assigned
• Nodes can be configured to
- Use specific CAN IDs for transmit PDOs
- Listen to specific CAN IDs for receive PDOs
CANopenHOT
July 2005
Slide 35
Hands-On:
Viewing the PDO Configuration
Switch to Network Overview window
Click on ‘View PDOs’ button for node ‘1’
Note the default CAN-IDs used
• They are from the Default Connection Set
CANopenHOT
July 2005
Slide 36
www.esacademy.com
Embedded Systems Academy CANopen Hands-On Tutorial
Slave X
TPDO_1_X
Master TPDO_2_X
RPDO_1_M
RPDO_2_M RPDO_1_X
TPDO_1_M RPDO_2_X
TPDO_2_M
RPDO_3_M Slave Y
RPDO_4_M TPDO_1_Y
TPDO_3_M TPDO_2_Y
TPDO_4_M
RPDO_1_Y
CANopenHOT
July 2005
RPDO_2_Y
Slide 37 CiA
Hands-On:
Verify default TPDO linking
Reset all nodes
View Trace window, clear contents
Switch all nodes to operational
Play with the digital
switches on the I/O
panel of node ‘1’
In Trace window
observe that each
transition results in
transmission of
message ID 181h
• This is the default
message ID for
TPDO1 of node 1
CANopenHOT
July 2005
Slide 38
www.esacademy.com
Embedded Systems Academy CANopen Hands-On Tutorial
Hands-On:
Verify default RPDO linking (1)
Open the ‘Transmit List’ window
• From the menu select View – Transmit List
Edit the first message by clicking on its Edit button
1. Select ID for node ‘1’,
first RPDO (201h), the
default message ID for
RPDO1 of node 1
2. Enter a message name
3. Enter a trigger option for
the message: key ‘1’
4. Define message length ‘1’
5. Enter data, for example ’5’
6. Click ‘OK’
CANopenHOT
July 2005
Slide 39
Hands-On:
Verify default RPDO linking (2)
In ‘Transmit List’ window,
ensure the message edited is enabled
Press ‘1’ key or click on ‘Tx’ button
to transmit the message
Observe the Input / Output
window of node ‘1’ now
displaying the LED pattern
CANopenHOT
July 2005
Slide 40
www.esacademy.com
Embedded Systems Academy CANopen Hands-On Tutorial
Device X
RPDO_1_X
RPDO_2_X
TPDO_1_X
TPDO_2_X
Device Y
Device Z
RPDO_1_Z TPDO_1_Y
RPDO_2_Z TPDO_2_Y
RPDO_3_Z RPDO_1_Y
TPDO_1_Z RPDO_2_Y
TPDO_2_Z RPDO_3_Y
CANopenHOT
July 2005
Slide 41 CiA
Hands-On:
Changing the PDO Linking
Switch to PDO Configuration window
For node 1, change the CAN-ID for RPDO1
• From 201h to 182h (TPDO1 of node 2)
For node 2, change the CAN-ID for RPDO1
• From 202h to 181h (TPDO1 of node 1)
Slide 42
www.esacademy.com
Embedded Systems Academy CANopen Hands-On Tutorial
Hands-On:
Verify new PDO Linking
After a successful change of the PDO linking the two
Input / Output display windows of nodes 1 and 2 are
‘linked’
Changing the input switches on one of them
changes the LEDs on the other
CANopenHOT
July 2005
Slide 43
CANopenHOT
July 2005
Slide 44
www.esacademy.com
Embedded Systems Academy CANopen Hands-On Tutorial
Hands-On:
Preparation for PDO trigger examples
If you wish to save the current settings, go to the main
menu and select File – Save Project
From the menu, select File – Open Project
• Locate sub-directory ‘Projects/Data Stimulation’
- Choose project ‘Data Stimulation’
This project only simulates one node,
a node used for data stimulation
In the simulation window, select ‘File – Open’
• Locate sub-directory ‘IO Files,
- Choose file ‘COP_Stimulation_Wave.sim’
Press the red, round button to activate the graph
Set ‘Wave1 Per’ to 60 (60s wavelength)
Set ‘Wave1 Ampl’ to 400 (amplitude of 400)
CANopenHOT
July 2005
Slide 45
CANopenHOT
July 2005
Slide 46
www.esacademy.com
Embedded Systems Academy CANopen Hands-On Tutorial
Hands-On:
Event Driven TPDO
Open the Trace window
Set all nodes to operational
Clear the Trace window NOTE: The data
stimulation nodes
Set trace display to static does not use the
default TPDO CAN
Use relative timestamps identifiers!
Slide 48
www.esacademy.com
Embedded Systems Academy CANopen Hands-On Tutorial
Slide 49
Hands-On:
Time Driven TPDO
Open the PDO Configuration window
Select Node 7Ch, Data Stimulator
For TPDO5, CAN-ID 105h, change
• Inhibit time to zero, Event time to 250
Observe in Trace Window:
• Message 105h is now transmitted every 250ms
CANopenHOT
July 2005
Slide 50
www.esacademy.com
Embedded Systems Academy CANopen Hands-On Tutorial
CANopenHOT
July 2005
Slide 51
www.esacademy.com
Embedded Systems Academy CANopen Hands-On Tutorial
Hands-On:
Synchronized TPDO (1)
Switch to PDO Configuration window
For TPDO5 and TPDO7, change
• Inhibit time to zero, Event time to zero
• Sync value to 1 (TPDO5) and 2 (TPDO7)
CANopenHOT
July 2005
Slide 54
www.esacademy.com
Embedded Systems Academy CANopen Hands-On Tutorial
Hands-On:
Synchronized TPDO (2)
Open the ‘Transmit List’ window
• In main window menu, select ‘View – Transmit List’
Edit a message, for example second row
1. Select CAN ID ’80h’
2. Send on key ‘F1’
3. Length: ‘0’
4. Click ‘OK’
In ‘Transmit Messages’
window, enable the
message
Switch back to Trace
www.esacademy.com
Embedded Systems Academy CANopen Hands-On Tutorial
Hands-On:
Inhibit Time
Switch to PDO Configuration window
Default settings for Data Stimulator
• Inhibit Time of 10ms
• NOTE:
The Inhibit Time is specified in multiples
of 100 microseconds
NOTE: The accuracy of the
For TPDO5, change simulation cannot be as
• Sync: 0 good as with an embedded
system. Due to other tasks
• Inhibit: 1000 (100ms) running on your PC
• Event 200 (200ms) timestamps can vary by
several percentage points
Observe in Trace window:
• In steep areas of the waveform, messages are
transmitted more often, but never faster than 100ms
CANopenHOT • In flat areas of the waveform, messages are
July 2005
transmitted less often, but never less than 200ms
Slide 57
PDO contents,
which Object Dictionary entries are in a PDO
www.esacademy.com
Embedded Systems Academy CANopen Hands-On Tutorial
Slide 59
D In 1 D In 2 A In 1 A In 2 Unused
TPDO1
Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7 Byte 8
Slide 60
• Unused bytes are not transmitted
www.esacademy.com
Embedded Systems Academy CANopen Hands-On Tutorial
Hands-On:
PDO Mapping Preparation
Examine available Object Dictionary entries from
• Documentation of a CANopen node…
• Accessing the information from the EDS
Switch to the main window, Read tab
• Click on ‘Select’ to access the EDS browser
• Browse for entries that you would like to map
into one PDO, for example
- [2101h,01h] Up counter 1, 32-bit value
- [2201h,02h] Down counter A, 16-bit value
- [2401h,02h] Wave 1, 16-bit value
• Make sure the total of bits does not exceed 64,
as that is the maximum payload of a single PDO
Slide 61
Hands-On:
Change PDO Mapping
Select a PDO to change, for example TPDO3
• For Map 1, select [2101h,01h] Up counter 1
• For Map 2, select [2201h,02h] Down counter A
• For Map 3, select [2401h,02h] Wave 1
• When done, make sure to set Map Num to ‘3’
and enable PDO
www.esacademy.com
Embedded Systems Academy CANopen Hands-On Tutorial
Hands-On:
Verify New Mapping (1)
Ensure the Data Stimulation node produces data
for the counters and the waveforms
• In simulation window select menu ‘File – Open’
- Select file ‘COP_Stimulation_Count.sim’
Change sliders for ‘Count Up 1’ and ‘Count Down A’
• Verify that there is action in the graph window
- Click red, round button to enable graph
CANopenHOT
July 2005
Slide 63
Hands-On:
Verify New Mapping (2)
Switch to Trace window and observe data contents
of message 103h, column data (hex)
• Note: CANopen uses Little Endian notation
- Least significant byte comes first
• First 4 bytes are the 32-bit value of the up counter
• Next 2 bytes are the 16-bit value of the down counter
• Last 2 bytes are the 16-bit value of the waveform
CANopenHOT
July 2005
Slide 64
www.esacademy.com
Embedded Systems Academy CANopen Hands-On Tutorial
CANopenHOT
July 2005
Slide 66
www.esacademy.com
Embedded Systems Academy CANopen Hands-On Tutorial
Hands-On:
Generate DCF and restore DCF
All the current settings of the Data Stimulation node
can be saved into a DCF
In the main window make sure that the node you would
like to generate a DCF for is currently selected
From the menu select ‘File – Generate DCF from Node’
• Specify a directory and file name for the file
Slide 67
Advanced Features
www.esacademy.com
Embedded Systems Academy CANopen Hands-On Tutorial
Slide 69
CANopenHOT
July 2005
Slide 70
www.esacademy.com
Embedded Systems Academy CANopen Hands-On Tutorial
Slide 71
CANopen Magic
• www.CANopenMagic.com
Book recommendation
• www.CANopenBook.com
Embedded Systems Academy
• www.ESAcademy.com
CANopenHOT
July 2005
Slide 72
www.esacademy.com