CAN Open Implementation
CAN Open Implementation
and
Marketing:
Research Studies Press Ltd.
15/16 Coach House Cloisters, 10 Hitchin Street, Baidock, Hertfordshire, England, SG7
6AE
Distribution:
NORTH AMERICA
Taylor & Francis Inc.
47 Runway Road, Suite G, Levittown, PA 19057 - 4700, USA
ASIA-PACIFIC
Hemisphere Publication Services
Golden Wheel Building, 41 Kallang Pudding Road #04-03, Singapore
EUROPE & REST OF THE WORLD
John Wiley & Sons Ltd.
Shripney Road, Bognor Regis, West Sussex, England, PO22 9SA
The sustaining technology that has enabled our KBE economy to develop and
expand is based on the ubiquitous silicon chip and the consequent “digitalisation” of
data, which has provided a mechanism that allows Computation, Communication and
Control to be integrated into a seamless process.
We began the last decade of the 20th Century with an emerging conceptual model of
a PC (personal computer) on every desk. Th etechnology was driven by 16 bit
microprocessors operating around 25MHz, with a Disk Operating System (DOS). The
World Wide Web had not been invented, telephones were largely analogue and
restricted to “physical” connections.
The last ten years have seen the rapid growth in chip manufacturing capacity that
now enables manufacturers to offer everyone the computing capacity of what was once
called a “Super Computer”, only 15 years ago, for the price of a family holiday on the
“Algarve”, for example.
But the key to the infrastructure that will sustain the Knowledge Based Economy of
the 21st Century is the digital communication or NETWORKING facility that now,
increasingly, underpins our modern lifestyle. The Network now transforms “Islands of
Computation” into a seamless computing tool that provides both a central platform for
Industrial and Commercial applications, and a service for the general public to use. A
measure of the rapid integration of networking in our daily lives can be found, for
example, on the “Bill Boards”, that consistently provide WWW addresses, that invite
the general public to visit their “virtual” shopping of “facilities” site. Major retail chains
now provide customers with “free” NET access, for good commercial reasons, let me
quickly add.
The speed of this change is truly overwhelming. We are all having to "run fast" to
"stand still" and the "need to know" is of paramount importance. This book presents
detailed and specialist knowledge of a particular network instantiation that has gained
rapid acceptance in the Industrial domain as a technology that can sustain the needs of
the Manufacturing Industry and a range of consumer products, of which a car is an
example.
For Engineers who are working in the Automation and Control Industries a
knowledge and understanding of CAN Network is not only desirable it is ESSENTIAL,
because it is part and parcel of the modern industrial infrastructure.
In welcoming this book to the series it epitomizes the conceptual model that
stimulated the series: the recognition that the Integration of Computing, Contfol and
Communication would provide the infrastructure for the world economy in the 21st
Century, and that the Books in this series would address the component parts of that 21st
Century Infrastructure.
This Book presents a very important component of that 21st Century Infrastructure.
My congratulations and thanks to the Authors for the clarity and detail of their
presentation.
Derek Wilson
University of Southern Queensland, Australia
March 2000
CANopen is a success story...
What started as a public funded project, was adopted, enhanced and matured by
mainly small and medium sized companies under the roof of the international user and
manufacturer association "CAN in Automation" (CiA). Not being dominated by any of
the major global players, CANopen had the chance to gain flexibility and the features
needed for applications beyond standard industrial automation. CANopen caters for
both centralized and distributed control architectures, for fast real time communication
as well as for parameter up- and download. It is scalable, preserves all CAN features
and runs on almost any type of micro-controller. Thus CANopen meanwhile is not only
the world de-facto standard for interoperable CAN based automation solutions, but for
all sorts of embedded communication tasks as well. Consequently CANopen was
accepted for international standardisation.
The CANopen success was always driven by technology, not by marketing. This
book explains CANopen technology, its implementation and its application. In doing so,
it will contribute in the typical CANopen way to the CANopen success story.
The authors are also grateful to Mr Richard McLaughlin, from the Open Device
Vendor Association (ODVA), for reviewing the book and for his valuable suggestions
and contributions.
While participating in the writing of this book Manuel Barbosa was the recipiënt of
the BD/13641/97 scholarship from the Fundacao para a Ciência e Tecnologia, Programa
PRAXIS XXI ( Portugal).
Preface
CANopen Implementation: Applications to Industfial Networks is intended to be a
reference book both for field engineers who are interested in implementing CAN and
CANopen in their devices and for students specialising in Automation and Control
Engineering. Modern networking applies to all branches of engineering courses and
sustains new industrial infrastructures.
In recent times the introduction of computers into the manufacturing workplace, in
the form of Information Technology (IT) in general and automation in particular, has
revolutionised the way in which the manufacturing industry operates. This applies to the
general organisation and procedures adopted by the manufacturing industry as well as to
specific methods and techniques of manufacture. The advantages of these changes come
in different forms.
One of the most important improvements made possible through the use of
Information Technology is the replacement of workers in dangerous environments with
lower cost machines. Other advantages may involve immediate savings, decreasing
production costs by reducing waste, reducing processing time, reducing the number of
defective products, lower failure rates and better quality products. Therefore, the reader
should never lose sight of why the technology is used. It is not for love of technology,
or the desire to use the latest ideas, but because the application of technology brings
commercial advantages.
This book will describe the application of computer technology and communication
technology as it relates to the shop floor in the automation arena. In particular, this book
will describe this relationship at the 'work cell' level and below, and how the use of
decentralised or distributed control application can affect and improve the design and
performance of manufacturing systems.
The field of automation and control is constantly expanding with the introduction of
innovative techniques, particularly with the advent of lower cost and higher power
information technology tools. Therefore, training in the fields of communication
systems, intelligent manufacturing, production units and distributed control systems
environments is essential to maintain a successful and competitive manufacturing
industry. A steering group created by the Department of Trade and Industry for the
technology foresight programme in the UK (white paper 1993) has acknowledged this
fact. This group has identified 'the harnessing of technologies in sensors and
automation', to improve the production services, as one of the top priority strategie
themes. This is also emphasised as a key area by the sector panel on manufacturing,
production and business processes. The work of the panel provides strong indication
that sensor and control technology will become even more important in the future.
Therefore, the market for expertise in these areas is very wide at the regional, national
and even international levels.
Communication in a factory environment consists of different networking levels
ranging from the network inside a machine to the network running around the shop
floor, the design room and subsequently management and finance at the corporate level
where worldwide communication may be involved. Moreover, it is certain that the
Internet will be widely used by companies to exchange information at the highest level.
In fact the 21st century may see the advance of a factory completely remotely controlled
over the Internet from one central site elsewhere in the world. However, this may only
be made possible if an efficiënt and reliable communication system is employed.
The advent of new manufacturing philosophies is placing new strains on
manufacturers, forcing them to modernise their enterprises and apply novel
technologies. For example, if a manufacturer operates a Just-In-Time system (JIT), it
will require smaller order sizes but a very reliable supply of components and raw
materials from its various suppliers. The impact of this is that if a large manufacturer
decides to implement JIT technology there is a knock-on effect to its suppliers. They,
too, may need to adopt JIT practices, as may their suppliers in turn. So once a major
manufacturer has decided to change its working methods its suppliers must also adapt if
they wish to keep their customers. The implementation of such manufacturing strategies
requires a degree of flexibility and adaptability that can only be achieved by applying
innovative techniques.
Within the manufacturing process itself the emphasis is on the speed of response of
the system. This enables the manufacturing system to cope with changes in customer
orders and requirements, scheduling of work to make full use of the system, etc. If
several different products are manufactured, this may require different processing times
at different sites within the factory to ensure a balanced flow of work through the
system, avoiding bottle-necks and large queues of work waiting to be processed, or
alternatively machines lying idle with no work to process. The manufacturing system
must be able to cope with all the various demands and priorities that are required of it;
in a word it must be flexible.
The use of distributed systems is one of the new techniques that is gaining
increasing popularity in the manufacturing arena, at the shop-floor level. Fieldbuses are
at the heart of these distributed systems as they are used to interconnect the different
intelligent devices that comprise the systems. As one of these fieldbuses, the Controller
Area Network (CAN) has gained extensive popularity, leading to the appearance of a
wide range of CAN hardware products on the market.
CANopen is a fieldbus protocol based on CAN, designed to be 'future-proof, and
provides a flexible and powerful open industrial communication solution with many
attractive features. CANopen is one of the fieldbus protocols currently available on the
market and is already being used widely in the manufacturing industry. It has been
developed by the European Community and is supported by large manufacturers such as
Bosch, Siemens and Philips. It is hoped that CANopen will gain further momentum,
becoming one of the most important fieldbus protocols in the world.
The reasons for the authors writing this book are threefold. Firstly it is to provide the
readers with the basic knowledge and understanding of fieldbus technology without
covering in detail the theoretical aspects, which are not necessary for field engineers to
implement fieldbuses in their products. Secondly, CAN and CANopen have been
chosen because they are one of the most prominent fieldbus systems on the market. The
market evaluation made by the CAN in Autornation group (CiA) shows that the use of
CAN in most of European passenger cars and the decision by truck and off-road vehicle
manufacturers to adopt CAN technology guarantee the availability of CAN chips for
more than ten years. Other high-volume markets such as domestic appliances and
industrial control also increase the CAN sales figures. In fact, the CiA World Wide Web
site indicates that up to March 1999 more than 150 million CAN nodes had been
installed worldwide (CiA web site, October 1999). Thirdly, to the best of the authors'
knowledge there is no textbook available on the market that describes CAN and
CANopen simply, enabling readers to enjoy reading and understanding the technology.
More specifïcally, as a guide for those wishing to implement CAN and CANopen in
their products, the book is an excellent support. The authors have also been encouraged
by many field engineers to write the book because without thorough explanation of
CANopen Device and Communication Profiles, implementations are time consuming
and expensive.
Contents
CHAPTER 1 INTRODUCTION.................................................................................... 1
1.1 BACKGROUND ................................................................................................... 1
1.1.1 The Factory as a Control System ................................................................... 2
1.1.2 Just In Time.................................................................................................... 3
1.1.3 Communication in a Factory Environment .................................................... 3
1.1.4 Typical Production Control Components ...................................................... 4
1.1.5 Flexible Manufacturing Systems ................................................................... 5
1.2 THE ISO/OSI REFERENCE MODEL.................................................................. 7
1.2.1 The General Framework Of The OSI Reference Model................................ 7
1.2.2 Application Layer ........................................................................................ 10
1.2.3 Presentation Layer........................................................................................ 10
1.2.4 Session Layer ............................................................................................... 10
1.2.5 Transport Layer............................................................................................ 11
1.2.6 Network Layer ............................................................................................. 11
1.2.7 Data Link Layer ........................................................................................... 11
1.2.8 The Physical Layer....................................................................................... 12
1.2.9 Layer Management & Control ..................................................................... 13
1.3 NETWORKING AND ITS BENEFITS .............................................................. 13
1.4 BASIC NETWORKING CONCEPTS ................................................................ 14
1.4.1 Data Transmission........................................................................................ 14
1.4.2 Data Synchronisation ................................................................................... 17
1.4.2.1 Asynchronous Sampling....................................................................... 18
1.4.2.2 Synchronous Sampling......................................................................... 18
1.4.3 Networking Topologies................................................................................ 20
1.4.4 Frame Concept ............................................................................................. 21
1.4.5 Medium Access Control............................................................................... 22
1.4.5.1 Poll/Select............................................................................................. 22
1.4.5.2 Carrier Sense Multiple Access with Collision Detection (CSMA/CD) 24
1.4.5.3 Token Ring and Token Bus MAC........................................................ 24
1.4.5.4 Slotted Ring.......................................................................................... 25
1.4.6 Error Checking Mechanisms........................................................................ 26
1.4.6.1 Checksum ............................................................................................. 26
1.4.6.2 Parity Check ......................................................................................... 26
1.4.6.3 Cyclic Redundancy Check ................................................................... 28
1.4.7 Network Operational Models....................................................................... 29
1.4.7.1 Master/Slave Networks ........................................................................ 30
1.4.7.2 Peer-to-Peer .......................................................................................... 30
1.4.7.3 Producer/Consumer Model................................................................... 31
1.4.8 Network Performance .................................................................................. 32
1.5 NETWORK SELECTION CRITERIA ............................................................... 34
1.6 CONCLUSIONS ................................................................................................. 36
CHAPTER 2 CAN: CONTROLLER AREA NETWORK........................................ 38
2.1 INTRODUCTION ............................................................................................... 38
2.2 CAN PHYSICAL LAYER .................................................................................. 40
2.2.1 Bit Timing Configuration............................................................................. 41
2.2.2 Physical Connection..................................................................................... 43
2.2.3 CAN Bus Basic Operation ........................................................................... 45
2.3 CAN DATA LINK LAYER ................................................................................ 46
2.3.1 Frame Formats ............................................................................................. 46
2.3.2 Message Filtering ......................................................................................... 47
2.3.3 Bus Arbitration............................................................................................. 48
2.3.4 Error Handling ............................................................................................. 49
2.4 CAN HARDWARE IMPLEMENTATIONS ...................................................... 51
2.4.1 CAN Controller Organisation ...................................................................... 51
2.4.2 Basic CAN vs Full CAN Implementations .................................................. 52
2.4.3 Stand-alone vs Embedded CAN Controllers ............................................... 54
2.4.4 Overview of the CAN Hardware Market ..................................................... 55
CHAPTER 3 INTRODUCTION TO CANOPEN ...................................................... 56
3.1 BACKGROUND ................................................................................................. 56
3.2 ORIGIN AND STRUCTURE OF THE CANopen SPECIFICATIONS...................... 58
3.3 CANopen APPLICATION LAYER FUNCTIONALITY .................................. 61
3.3.1 Introduction .................................................................................................. 61
3.3.2 Master/Slave Communication Relationships ............................................... 63
3.3.3 Client/Server Communicatio n Relationships.............................................. 63
3.3.4 Producer/Consumer Relationships - Push/Pull Model................................. 64
3.4 CANopen OBJECTS AND THE OBJECT DICTIONARY ............................... 65
3.4.1 Device Modelling in CANopen ................................................................... 65
3.4.2 CANopen Data Types and Encoding Rules ................................................. 66
3.4.3 Object Dictionary Structure ......................................................................... 67
3.4.4 Object Dictionary Representation ................................................................ 69
3.4.5 Object Dictionary Implementation............................................................... 70
3.4.6 CANopen Communication Objects for Application Data Transfer............. 70
3.5 SERVICE DATA OBJECTS............................................................................... 71
3.5.1 General Description ..................................................................................... 71
3.5.2 Segmented SDO Transfer ............................................................................ 72
3.5.2.1 Segmented SDO Download.................................................................. 73
3.5.2.2 Segmented SDO Upload ...................................................................... 75
3.5.3 Expedited SDO Transfers ............................................................................ 76
3.5.3.1 Expedited SDO Download ................................................................... 76
3.5.3.2 Expedited SDO Upload ........................................................................ 77
3.5.4 Block SDO Transfers ................................................................................... 78
3.5.4.1 Block SDO Download.......................................................................... 78
3.5.4.2 Block SDO Upload............................................................................... 83
3.5.5 Abort SDO Transfer Protocol ...................................................................... 87
3.5.6 SDO Configuration Through the Object Dictionary.................................... 88
3.6 PROCESS DATA OBJECTS .............................................................................. 89
3.6.1 General Description ..................................................................................... 89
3.6.1.1 Write PDO............................................................................................ 89
3.6.1.2 Read PDO............................................................................................. 90
3.6.2 PDO Triggering Modes................................................................................ 91
3.6.3 PDO Transmission Types ............................................................................ 91
3.6.4 Configuration of Process Data Objects Through the Object Dictionary...... 93
3.6.4.1 PDO Communication Parameters ........................................................ 94
3.6.4.2 PDO Mapping Parameters.................................................................... 96
3.7 OTHER PRE-DEFINED CANopen COMMUNICATION OBJECTS....................... 99
3.7.1 Synchronisation Object (SYNC).................................................................. 99
3.7.2 Emergency Object...................................................................................... 100
3.8 COMMUNICATION OBJECTS FOR NETWORK MANAGEMENT................... 102
3.8.1 Introduction ................................................................................................ 102
3.8.2 State Diagram of a CANopen Device and NMT Module Control Services
................................................................................................................................. 103
3.8.3 CANopen Network Management Error Control Services ......................... 106
3.8.3.1 Node Guarding and Life-guarding Services....................................... 106
3.8.3.2 Heartbeat Service ............................................................................... 108
3.8.4 Pre-defined Connection Set ....................................................................... 110
3.8.5 Allocation of Identifiers by a Configuration Tool ..................................... 111
3.8.6 CANopen Network Boot-up Procedure ..................................................... 111
3.8.7 Minimum Capability Device...................................................................... 112
3.9 ELECTRONIC DATA SHEETS (EDS) AND DEVICE CONFIGURATION
FILES (DCF).............................................................................................................. 113
3.9.1 Structure of an Electronic Data Sheet ........................................................ 113
3.9.1.1 File Information Section..................................................................... 114
3.9.1.2 General Device Information Section .................................................. 114
3.9.1.3 Object Dictionary Sections................................................................. 115
3.9.1.4 Additional EDS Sections.................................................................... 116
3.9.2 DCF-specific Sections and Keywords ....................................................... 117
3.10 OTHER CANopen FEATURES...................................................................... 117
3.10.1 Definition of a CANopen Manager device .............................................. 118
3.10.2 SDO Manager and Dynamic Establishment of SDO Connections .......... 119
3.10.3 Programmable Device I/O ....................................................................... 120
3.10.4 Configuration Manager ............................................................................ 120
3.10.5 Multiplexor PDO and Node Group Addressing....................................... 120
CHAPTER 4 CANOPEN IMPLEMENTATION ISSUES ...................................... 122
4.1 INTRODUCTION ............................................................................................. 122
4.2 USING CAN HARDWARE IN A CANopen CONTEXT................................ 122
4.2.1 Revision of CAN Hardware Platforms ...................................................... 122
4.2.2 Message Reception: CANopen Filtering Requirements ............................ 124
4.2.3 Transmission of CANopen Data ................................................................ 125
4.2.4 CAN Messages and Message Bursts.......................................................... 127
4.2.5 Minimising Message Bursts o n a CANopen Network.............................. 128
4.3 IMPLEMENTATION OF MULTIPLE DEVICE MODULES......................... 129
4.4 OTHER SOFTWARE AND HARDWARE CONSIDERATIONS .................. 131
4.4.1 The Processor/CAN Controller Interface................................................... 131
4.4.2 Hardware Access to I/O Devices ............................................................... 132
4.4.3 Software Overheads ................................................................................... 132
4.4.4 Implementation Remarks ........................................................................... 132
4.5 CONSTRUCTING A CANopen NETWORK .................................................. 134
4.6 INFORMATION FOR CANopen DEVICE DEVELOPERS AND
MANUFACTURERS ................................................................................................ 135
4.7 AN EXAMPLE OF CANopen-B ASED SYSTEM INTEGRATION .............. 136
4.7.1 Constructing a CANopen Network (An Example) .................................... 136
4.7.1.1 Step One - Collecting Information ..................................................... 137
4.7.1.2 Step Two - Distributing the Application ............................................ 138
4.7.1.3 Steps Three and Four - Selecting Appropriate CANopen Devices .... 141
4.7.2 Usage of CANopen Communication Objects (An Example) .................... 142
4.7.2.1 NMT Communication Objects ........................................................... 143
4.7.2.2 Service Data Objects .......................................................................... 143
4.7.2.3 Process Data Objects .......................................................................... 144
4.7.3 Message Exchange in CANopen Networks (An Example) ....................... 144
CHAPTER 5 CANOPEN CONFORMANCE TESTING........................................ 148
5.1 INTRODUCTION ............................................................................................. 148
5.2 EDS TESTS ....................................................................................................... 149
5.2.1 Completeness Tests.................................................................................... 150
5.2.1.1 Mandatory Sections Test .................................................................... 150
5.2.1.2 Standard Sections Test ....................................................................... 150
5.2.2 Value Ranges Test ..................................................................................... 153
5.2.3 Consistency Tests....................................................................................... 154
5.2.3.1 Dummy Usage Test ............................................................................ 154
5.2.3.2 Supported Objects Test ...................................................................... 155
5.2.3.3 Object Links Test ............................................................................... 155
5.2.3.4 PDO Mappings Test ........................................................................... 155
5.3 DEVICE TESTS ................................................................................................ 156
5.3.1 Protocol Verification Tests ........................................................................ 157
5.3.1.1 Service Data Objects Test .................................................................. 157
5.3.1.2 PDO Communication Parameter Test ................................................ 158
5.3.1.3 PDO Mapping Parameter Test ........................................................... 159
5.3.2 Object Dictionary Tests ............................................................................. 160
5.3.2.1 Communication Specific Area Test ................................................... 160
5.3.2.2 Device and Manufacturer Specific Area Test .................................... 161
5.3.2.3 Remaining Area Test.......................................................................... 162
5.3.3 Parameter Storage/Restorage Test ............................................................. 162
5.3.4 Emergency Test.......................................................................................... 163
5.3.5 Error Control Tests..................................................................................... 163
5.3.5.1 Node Guarding and Life-guarding Test ............................................. 163
5.3.5.2 Heartbeat Test..................................................................................... 164
5.3.5.3 Heartbeat / Node Guarding Precedence Test ..................................... 164
5.3.6 Synchronisation Test.................................................................................. 165
5.3.7 Verification of Network States .................................................................. 166
5.3.8 Verification of State Transitions ................................................................ 168
5.4 THE CANopen TEST INTERFACE (C.O.T.I.)................................................ 169
CHAPTER 6 EXAMPLE OF A CANOPEN IMPLEMENTATION ..................... 172
6.1 INTRODUCTION ............................................................................................. 172
6.2 OVERVIEW OF THE SAB-C167CR-LM MICROCONTROLLER ............... 173
6.3 HARDWARE IMPLEMENTATION................................................................ 175
6.3.1 Introduction ................................................................................................ 175
6.3.2 Circuit Schematics and Explanation .......................................................... 176
6.3.2.1 The C167 Microcontroller and Supporting Hardware ....................... 176
6.3.2.2 The CAN Physical Layer ................................................................... 177
6.3.2.3 The I/O Lines...................................................................................... 177
6.3.2.4 Additional Remarks............................................................................ 178
6.4 SOFTWARE IMPLEMENTATION ................................................................. 178
6.4.1 Introduction ................................................................................................ 178
6.4.2 The Module Control Block ........................................................................ 180
6.4.2.1 Initialisation........................................................................................ 180
6.4.2.2 Implementation of NMT Services ...................................................... 181
6.4.3 The Service Data Object and Object Dictionary Block ............................. 182
6.4.3.1 The Object Dictionary ........................................................................ 183
6.4.3.2 Object Dictionary Read and Write Operations................................... 185
6.4.4 The Process Data Object Block ................................................................. 185
6.4.4.1 Event PDOs ........................................................................................ 185
6.4.4.2 Synchronous PDOs............................................................................. 186
6.4.5 The Emergency Object Block .................................................................... 186
CIRCUIT SCHEMATICS ......................................................................................... 188
GLOSSARY ................................................................................................................ 190
REFERENCES ........................................................................................................... 191
Flow chart: a guide to readers
1
CHAPTER 1
Introduction
Chapter Objectives
When you have completed this chapter you should:
• Be able to identify the manufacturing structure and its utilisation by man to create a
better environment to live in and better working conditions.
• Be able to identify the needs for system integration.
• Understand the concept of distributed control systems technology in an automation
environment.
• Be familiar with typical cell components such as sensors and actuators.
• Understand the concept of distributed control and decentralised intelligence in the
context of fïeldbuses.
• Be familiar with protocols normally used in production cells in an automation
environment.
• Be able to identify the requirement for a fieldbus selection.
• Know the benefits of fieldbus systems in the automation arena.
1.1 BACKGROUND
In recent times the introduction of computers into the manufacturing workplace, in
the form of Information Technology (IT) in general and automation in particular, has
revolutionised the way in which the manufacturing industry operates. This applies to the
general organisation and procedures adopted by manufacturing industry as well as
specific methods and techniques of manufacture.
The advantages of these changes come in different forms. They may replace
workers in dangerous environments with lower cost machines; also they may involve
immediate savings, decreasing production costs by reducing waste, reducing processing
time, reducing the number of defective products, lower failure rates and better quality
products.
Concurrently, there are many other advantages, which may be less direct but often
have greater impact in the longer term:
• Greater knowledge of IT and its utilisation by humans to create a better living
environment and working conditions.
• Greater understanding of the manufacturing process, allowing easier
identification of bottle-necks.
• Better production scheduling, making maximum use of the production facilities.
• Greater flexibility in response to changes in design, customer requirements and
competition.
• Shorter 'lead times' in designing new products.
• Faster identification of faults in both product and processing machinery.
• Ability to identify deterioration in equipment before actual failure, reducing
production 'down time'.
In a system that must be flexible, its individual components and processing systems
must also be flexible. They must be capable of changing their operational parameters,
2
tooling or processing operations at short notice, perhaps on a job to job basis. This is
where computer based automation comes into effect.
Computer systems imply programmability and decision making capability, i.e.
intelligence; intelligent production systems, cells & work stations and even individual
cell components are at the heart of the flexible capability of advanced manufacturing
systems.
It is for these reasons that this new technology is considered an asset. Although as
engineers it is the technology that interests us, for business it will be the advantages that
the application of this technology can bring to production. This will be the driving force
in bringing the technology to the work place.
As can be seen from Figure 1.1, the factory and its manufacturing system may be
thought of as a control system consisting of several feedback loops. In these loops man
and machine are integrated with one another.
Product design is based on externally obtained information and drives the
manufacturing effort. Manufacturing capabilities constrain and shape the product
design. Manufacturing requires an input of materials and its output is delivered to the
market via distribution and sales.
Marketing gathers internal and external information and feeds back information to
improve product design, manufacturing and sales. Sales are also fed through finance to
the corporate management and the corporate management will influence the product
design decisions.
All this interaction obviously requires adequate communication at all levels.
3
networks such as TOP and MAP are not suitable to implement the communication
mechanisms required in the shop floor. Accordingly, lower level networks such as CAN
protocols could not possibly be used to perform tasks that require a lot more than the
simple interconnection of sensors and actuators on an automation cell.
A typical production line consists of a transportation system and several flexible
manufacturing cells. The transportation system itself will have various sensors and
actuators mounted on it to control and monitor pallet positions and to log product
information and process controllers. A typical flexible manufacturing cell consists of
sensors, actuators, process controllers, manual stations, mechanical linkages and
pneumatic components.
All these elements need to communicate with each other e.g. sensors and actuators
need to be connected to the process controller and even between process controllers
linkage may be required to allow co-ordination of the whole manufacturing line.
Consider the diagram in the Figure 1.3.
In this simple system products are routed through different parts of the line
depending on the product that is being made. The progress of the product through the
system is monitored by sensors such as bar code readers that monitor its position in the
production system at any moment in time thereby providing a quality control check.
Figure 1.4 A conventional production cell control system, courtesy of Mr. R. McLaughlin
(ODVA)
This solution has other disadvantages in a situation where the addition of new
components is required. For example, a component that uses a special type of interface
can be very difficult and costly to integrate in an existing system. Also, if each cell is
self-contained, each cell controller must individually be re-programmed at the location
in the production line.
6
Figure 1.5 A typical networked production cell, courtesy of Mr. R. McLaughlin (ODVA)
To overcome the above disadvantages, i.e. to reduce the cost of implementation and
to provide ease of integration, the use of fieldbuses is a solution that is being
increasingly adopted in the automation industry. A typical fieldbus-based system is
represented in Figure 1.5.
The network depicted in Figure 1.5 is a fieldbus. It can been seen that rather than
connecting each constituent element to the controller, all these elements are locally
connected to the same fieldbus, a shared communication medium. A fieldbus is an
innovative solution to a permanent need of systems integrators: ensuring efficient
communication between the constituent elements of a production cell. Information
Technology and the development of low cost microcontrollers with integrated
networking capabilities has meant that control components from simple on/off sensors
upwards now have their own intelligence and ability to communicate with one another.
This gave way to a new concept in the manufacturing arena: the Distributed Control
System, also called a Decentralised Control System.
Using a network offers advantages over a conventional system. For starters, in a
Distributed Control System, only a single set of wires needs to be routed around the
cell, often including the power cables, hence less physical connectors are required. This
leads to another improvement: cost reduction. Additionally, new devices are easily
connected to the system and better diagnostics and fault finding mechanisms can be
implemented. A Distributed Control System also introduces a greater flexibility and the
ability for controllers to operate over larger geographical areas. Finally, only one basic
standard interface may be required and, if the network is sufficiently standardised, there
will be no tie to a single vendor.
7
The example in Figure 1.6 illustrates the basic layout of a production cell with a
conveyor transportation mechanism and a PLC acting as the cell controller. In this
example, the conveyor system in the production cell carries two pallets moving in a
closed track. Pneumatic actuators and two inductive proximity sensors at two pallet
station positions allow the system to monitor and control the position of each pallet.
One of the pallets has an extra metal tag, which is detected by the sensors and used for
pallet identification. All of this information is channelled through a remote digital I/O
module. This module communicates with the cell controller via CAN bus using the
CANopen protocol.
The essence of the model is that data are passed between two application processes,
A and B, by methods which are unknown and largely transparent to the application
itself. As the two applications operate on different machines, they are known as 'remote
application processes'. These applications link to the communications system by using
the services of the uppermost layer of the Reference Model, the Application Layer. In
turn the Application Layer uses the services of the layer below it, the Presentation Layer
without the need for knowledge of any lower layers. There are 7 layers in the model,
each layer being used by the layer immediately above it, and using the services of the
layer immediately below. The functionality of all lower layers is hidden and completely
transparent in their operation.
The seven layers, from the highest (layer 7) to lowest (layer 1), are called
Application, Presentation, Session, Transport, Network, Data Link and Physical Layers.
Each layer within the system, as well as calling the layer immediately below it, is in
effect in communication with the equivalent layer in the other process. The concept of
the OSI model envisages associations, or agreements to co-operate, being set up
between each of the seven layers of the co-operating end systems. These so-called
'corresponding elements' are then responsible for negotiating levels of reliability of
service and data flow control. The rules governing the interactions between the
equivalent layers are known as 'layer protocols'.
In any given layer, the two co-operating systems' active elements, or 'peer entities' as
they are called, communicate with each other by following a set of agreed rules, known
as 'layer protocols for peer entities'. These protocols determine the way in which the
peer entities co-operate to provide the layer functionality.
Data are transferred between the two application processes (A and B), by being
passed down through the layers of one system before being passed over the transmission
medium. Data are transferred between layers in the form of 'data units' (DU). Each layer
9
may add control information to each data unit, and this control information is used to
organise communication between the peer entities in the two remote systems.
Each layer passes its data to the level below in the form of a 'protocol data unit'
(PDU). The next layer adds 'protocol control information' (PCI) to that data unit, now
known as the 'service data unit' (SDU), to produce its own protocol data unit. This new
PDU is then passed down to the next lower layer, and so on down to the Physical Layer.
The Physical Layer then possesses a complete transmittable 'data frame', which can be
transferred through the transmission medium. This process is shown in Figure 1.8.
The complete transmitted frame is then received by the second system. As the frame
is passed up through the layered structure of the receiving system B, each PCI header is
stripped off at its respective layer. When a data unit is passed on by the Application
Layer in system B only the user data remains.
The information contained in the various PCI headers, added by the entities in the
layers of system A, is removed by peer entities within system B. The information held
in the PCI headers influences the way an individual layer responds to the SDUs which
they receive from or pass to the next highest level.
With this concept, the services of each layer of functionality of the Reference Model
can be isolated from each other, avoiding the problems of interaction between functions
that often occur in less well-defined architectures. Each layer is only aware of its
immediately adjacent layers, above and below, and generally passes on user data units
without modification or understanding. Each layer communicates with the underlying
layer by invoking the services that this layer offers, or particular functions within these
services, known as 'service elements'.
The reader should note that as the ISO/OSI Reference Model is designed to
encompass the most complex communication links, some communication systems may
not use all seven layers of the model (unused layers are often called Null Layers). This
10
may be due to the fact that a particular communications network operates within very
strict and limited parameters, so the functionality of some of the layers is not required.
Or it may be that certain commercial systems are only defined up to a certain level
(counting from the Physical Layer upwards), leaving it to the users to make their own
decisions about the higher level functionality that they need to implement. In the
following, the functionality of each layer is discussed in more detail.
The main purpose of the Data Link Layer is to deal with this fact and minimise the
number of errors passed on to the higher layers. This is achieved by constructing the
data into a recognisable structure known as 'data frame'. This method is used to detect,
and where possible rectify, errors introduced by the physical medium during the
transmission process. Such systems usually analyse the content of a data frame before
transmission and add control information to the data so that errors can be detected and
eventually corrected on the receiver end. A very common error detection mechanism is
the Cyclic Redundancy Check, whereby the transmitter includes in the frame a code,
which is calculated based on the contents of the data. The receiver then performs its
own calculation to obtain an equivalent code based on the data it received. If the two
codes do not match then an error has occurred in the transmission.
Additionally, the Data Link Layer deals with three other main areas of
communication. These are:
• Flow Control - this is used to cope with the problems inherent with a fast sender
sending messages to a slow receiver. Some method must be employed to slow down
a fast sender while the slow receiver handles previously transferred messages.
• Link Management - this deals with the rules that a sender and receiver must follow
in order to exchange information. For example, a sender and receiver may need to
identify themselves to each other and be willing and ready to communicate before
exchanging any data.
• Medium Access Control - this controls access to the transmission medium itself. Its
purpose is to cope with the problem of two or more stations sending data at the same
time: either by preventing the problem from happening, or by recognising a 'data
collision' (two stations trying to send messages on the transmission medium at the
same time), and resolving the problem so that data and messages are not lost.
If a broadband system is in use, the Physical Layer will also have to:
• Perform modulation and demodulation functions - to extract signals on a set
frequency band from other signals, using filter systems to reject 'noise' generated
from other frequency channels.
• Providing a channel with a desired bandwidth and low error rate performance.
13
Although the Physical Layer describes the connection to the transmission medium, it
does not dictate the actual form of the transmission medium, nor its specific
performance characteristics. Over long distance connections, signals may deteriorate to
a state that they can no longer be accurately read by the receiving station. Devices
known as 'repeaters' can be installed to cope with this problem. Repeaters are effectively
signal boosters; all incoming signals are simply passed on, but with signal strength
restored to acceptable levels. The most obvious application is in very long distance
systems, such as the Trans-Atlantic phone system.
• Vendor independence, in case the standard is widely accepted in industry e.g. open
protocols.
Networks allow transferring data via a standard system of wiring that is shared by
multiple devices. Any standard system of wiring, e.g. a twisted pair of wires between
devices, will have the immediate benefit cost cutting in terms of quantity required,
installation and implementation. The other benefit is that of less maintenance and fault
diagnostics costs. These advantages have been felt in the use of CAN in the automotive
industry, where the reduction in wiring costs was significant and widely recognised.
The use of networking reduces the number of controllers otherwise required. Not
only can the physical size of the system be greater but also tasks can be delegated on
other devices connected to the network thereby decreasing the processor load. This
yields obvious cost benefits and may also allow greater coordination of a system as all
actions can be controlled and supervised by one central controller.
Network systems can, in general, be easily expanded. Moreover, when standard
devices are employed, the task of expansion can come down to simply adding a few
metres of network cable and connectors.
The diagram in Figure 1.10 shows two devices connected and communicating over
the physical media. It is perfectly acceptable to have more than two devices sharing the
same media although this depends on the line drivers or transceivers and the type of
network used. Several common standards exist for data transmission over a network or
point-to-point communications link. All that differs between them is the current and
voltage signal levels, which determine the level for logic '0' and a logic '1'. The signal
properties differ with respect to noise and maximum data rates.
Figure 1.11 shows a typical end-to-end TTL line driver. Typical signal levels are
+V=+12 to +15 Volts and -V=-12 to -15 Volts. With this type of end-to-end connection,
data rates are restricted to less than 115 Kbit/s. Maximum line length is normally about
15 metres.
The standard 20mA current loop uses current rather than voltage levels for the
representation of logic levels. This substantially increases distances and is extremely
popular in industry (particularly in process control arenas). A simple arrangement for
current driven signals is illustrated in Figure 1.12.
16
To transmit logic '0' the transmitter opens its current switch. At the receiving end no
current is detected or flowing and therefore it interprets the signal as a zero. When the
transmitter transmits logic T it closes its current switch, current flows around the loop,
the receiver detects this and indicates a one has been transmitted. The noise immunity of
the system is much higher than for voltage driven systems. However, the rejection of
common mode noise in the current loop arrangement is less than that of the voltage
driven arrangement. Typically, current loops are used to transmit over distances of up to
lkm but transmission rates are relatively low due to limitations in the switching circuits.
In RS422 (Figure 1.13) logic 1 and logic 0 are represented by the polarity of a
differential voltage. Rt is a terminating resistor used to terminate the lines so as to
reduce unwanted reflected signals, decreasing signal distortion. This system has good
common-mode rejection properties.
Figure 1.14 shows the RS485 arrangement. This system is a variant on the RS422
standard with the essential difference being that several transmitters and receivers can
share the same pair of wires. This requires special techniques to ensure that no two
transmitters try to send information at the same time, causing data corruption. For this
reason, the RS485 arrangement has been used as the basic concept for many networking
systems such as Profibus and CAN.
Figure 1.15 Sampling: (a) sampling correctly, (b) sample time too long, (c) sample time too
short
From Figure 1.15 it is possible to evaluate how important it is that the sampling
clock at the receiver end is synchronised with the clock of the transmitter (the
18
transmitter clock is responsible for the parallel-to-serial conversion process). Two types
of bit sampling exist: asynchronous sampling and synchronous sampling.
Generally, the start of the transmission synchronises the clock at the receiver end
with that of the transmitter and from this point on both clocks run asynchronously from
cne another. RS232 works on this principle. Here transmission rates are governed more
by the accuracy of the timing components than by the quality and propagation
properties of the interconnections. Nowadays this is less of a problem, as components
are manufactured with precision and therefore timing accuracy has improved.
Superimposing clock and data signals however, can create difficulties in decoding
the incoming pulse train. This is particularly true in the example of Figure 1.17 where
the receiving electronics must decode three different bus signal levels. An alternative
method is to use the transitions that will inevitably occur within the pulse train itself.
This requires the use of a resynchronisation method whereby the sampling process at
the receiving end is synchronised at periodic intervals during reception of the pulse
train. For this purpose, a digital phase locked loop (DPLL) may be used, as shown in
Figure 1.18.
The bit encoding scheme must ensure that the DPLL has enough bit transitions in
order to resynchronise sampling. The most common process is to insert extra stuff bits
as part of the bit stream where there may be a continual series of ones or zeroes. For
example, CAN networks insert a bit of the opposite polarity every 5 bits of the same
value. Another alternative is to use the Manchester encoding scheme.
The Manchester encoding scheme encodes logical Ts and 'O's as signal transitions,
as shown in Figure 1.19.
To extend the length of a bus, repeaters are sometimes used. An example of a Bus
network with a repeater is shown in Figure 1.22.
• SOF - contains information, in the form of a bit pattern, denoting to receivers that it
is the start of the transmission. This may include bit patterns for synchronisation of
the receiver clock or for governing access to the bus.
• CF - contains information regarding the length of the data and the type of data
included in the frame.
22
• DF - contains any information included in the frame. Different networks will have
different maximum data lengths in each frame.
• ECF - contains information that allows the receiver to check the validity of the data
and/or control fields.
• EOF - contains, in general, a fixed format bit pattern denoting to receivers and
prospective transmitters of information that the frame is at an end.
Note that a frame may not have all of these fields present. One of the simplest
frames is that used by RS232. The format of an RS232 frame is shown in Figure 1.24.
The start bit represents the SOF and is used by a receiver to resynchronise its clock
so that sampling of subsequent bits is achieved successfully. There is no control field as
the format of the frame is agreed in advance i.e. both transmitter and receiver will
always use the same frame format. The data field consists of seven or eight bits of data.
The parity bit (which may not necessarily be present) represents the error check field
and the stop bits are at the end of the frame.
1.4.5.1 Poll/Select
In a Poll/Select mechanism only one station on the network (the master) is allowed
to initiate transmissions. The master polls devices for information and will only request
information from a device once its previous request has been successfully completed.
An error detection mechanism is inherent within this method of communication: a node
23
failing to reply to a request after a certain predefined time-out period may have failed.
The Poll/Select method is shown in Figure 1.25.
This type of communication can be made quite fast for small networks, although the
loading on the master and the response times and data update rates increase as the
number of nodes on the bus grows.
Node A transmitting
Node B transmitting
On network initialisation node A has the token and may transmit data. When node A
has finished transmitting data it passes the token to node B which can then start
transmitting. When node B has finished it passes the token to node C. If node C has no
data to send it immediately passes the token to node A.
The two variants of this token passing arrangement, i.e. Token Bus and Token Ring,
work in exactly the same way, if we forget about the network topology: in a Token Bus
network the token passing is in a logical ring, where one node logically follows another.
In a real time control environment small amounts of data need to be transmitted at
regular intervals. To prevent a node from continually transmitting data and
monopolising the token each node is configured to hold the token for a limited period of
time, known as the Token Hold Time (THT). Care must be taken to make the THT
small enough to give the network fast response times but large enough to allow the node
to transmit its data within its allotted THT: otherwise a data build up can occur on the
node.
Initially all slots are maiked as empty. When a node detects an empty slot it fills in
the frame with data and the destination address for the data. It then marks the slot as
full. The slot is then circulated through each node until the destination address matches
the address of the node. If the addresses do not match, the node simply ignores the slot.
If the addresses match, the node reads the data and sets the acknowledgement field. The
slot re-circulates until it reaches the source (original transmitting node) which detects
the acknowledgement and marks the slot as empty. If there is no acknowledgement an
error has occurred.
26
Disadvantages are that this type of bus requires a monitor node and the frame length
is fixed, requiring multiple slots for large amounts of data. The time taken to transmit
data increases with the number of nodes in the ring.
1.4.6.1 Checksum
The simplest form of error check is the checksum. In a checksum consecutive bytes
in the frame are added together to form the checksum value. Note that the checksum
may be done on the whole frame or just the data section of the frame. An example of a
checksum calculation is shown below.
However, this method does not detect all errors (or even a large enough portion of
them):
It is seen that in the cases given above both checksums are correct while the data is
erroneous.
The parity bit is calculated by performing successive XOR operations of the serially
received bits. The mechanism is illustrated in Figure 1.30.
Table 1.1 shows an example of a parity bit calculation. This scheme is useful in
detecting single bit errors that may occur between the transmitter and receiver i.e. if one
bit is in error it will be detected. However, if two bits or more are in error the same
parity bit may result, in which case the error will go undetected. Therefore, the parity bit
scheme used in RS232 is said to have a Hamming Distance of 2 i.e. two binary words
28
may share the same parity value as long as they differ in more than 1 bit value, as
shown in the Table 1.2.
A variant of the parity bit check is the block parity bit check. In this case successive
data bytes are not only parity checked across each row but corresponding bits in
successive data bytes are also checked. This principle is shown in Table 1.3.
Note that this parity bit error check scheme permits detecting two or, in some cases,
more bit errors in the transmission. Additionally, if no more than one bit error occurs
during the transmission, it is possible to locate the erroneous bit and therefore correct it.
Let:
• N(x) be a frame of length k bits.
• G(x) be an (n+1) bit number. This is known as the generator polynomial.
• R(x) be an n bit number such than k>n. This is called the remainder of the division.
• Q(x) the quotient of the division
If:
N ( x) × 2 n R( x)
= Q( x) + ,
G ( x) G ( x)
29
Then:
N ( x) × 2 n + R( x)
= Q( x)
G ( x)
111000101 = Q( x)
10001 110010010000
DATA FCS
11001001 0101
10110110 = Q( x)
10001 110010010101
• In this case, the remainder equals zero, R(x) = 0000, indicating a correct reception.
• If there is an error in the received data e.g.
1100010 = Q( x)
10001 110010010111
In most networks the frame format of the message will have both the source and
destination addresses encoded in it. The general format of a frame is shown below.
Transferring information from slave A to slave C requires four telegrams in this type
of network. The master requests to read inputs from slave A. Slave A sends a response
with the input information encoded in it. The master then requests to write this data to
slave C (data in request). Finally slave C confirms the write request has been successful.
The example of this type of network/fieldbus is AS-I (Actuator Sensor Interface).
In the Master / Slave model, data update rates may be slow with an increase in the
number of nodes and more computational effort is required by the master for each new
node added to the network, as the master must poll each node in turn to retrieve data.
1.4.7.2 Peer-to-Peer
Figure 1.32 shows the Peer-to-Peer configuration. In a Peer-to-Peer network, nodes
may communicate directly with one another and the source/destination address scheme
allows the destination node to reply to the source node.
31
This type of network uses MAC methods such as token passing techniques to
control which node can gain access to the bus and therefore initiate a request. Data
transfer is still done on a one-to-one basis but the network loading is less than that of a
Master/Slave network. MODBus-Plus and LONWorks networks work using this type of
topology.
It is also possible to configure nodes to consume more than one item of data i.e.
several different frames with different identifiers. In the Producer/Consumer model,
network loading is considerably reduced as only one telegram is required per data
transaction. Multicasting is not possible with Master/Slave and Peer-to-Peer networks.
On the other hand it is possible to emulate both of these systems on a
Producer/Consumer network. Multicast operations allow all or a subset of nodes on the
network to receive data at the same time. Therefore, multicasting is ideal for application
control and network management where all nodes need to be coordinated together. Note
that Producer/Consumer networks still need MAC methods to prevent two or more
different producers from transmitting at the same time. Producer/Consumer networks
also eliminate the need to poll for data i.e. data may be produced when an event occurs
i.e. change of state of inputs on a device, timer events, etc. Examples of networks using
this model are ControlNet, Foundation Fieldbus and the Controller Area Network.
• Network Model - the more frames required to transfer data between two nodes the
slower the data update times due to higher network loading.
• Protocol Efficiency - measured as the total number of bits in the frame compared to
the number of data bits in the frame i.e.
N Data
Protocol Efficiency =
N Frame
Unfortunately, if the number of data bits is large compared to the total number of
frame bits the protocol efficiency is high but the reaction time of the network may be
reduced. This is due to the fact that a node transmitting a large amount of data will take
up network bandwidth and other nodes cannot transmit their data.
Network performance for two types of MAC systems is illustrated in Figure 1.35.
The graphs show the mean time a frame takes to be transferred across the network
as a function of the offered load. The load is expressed as the fraction of the available
bit rate and is referred to as normalised throughput. The transfer time is defined as the
time from generation of the frame to the time it is successfully received. The graphs
were calculated from simulations where each network had 100 stations randomly
wishing to transmit data on the network.
From graph (a), it can be concluded that token bus systems behave less effectively
than CSMA/CD networks when the frame size is small. This is because, in this instance,
the time taken to pass the token round to the node wishing to transmit is significantly
longer than for a CSMA/CD network which can transmit as soon as the carrier is free.
In the second graph, token bus networks perform much better than CSMA/CD
networks as the longer frame size means that a CSMA/CD network must wait longer
(carrier sense) before trying to transmit a frame. In either case, the probability of a
collision occurring in a CSMA/CD network increases as the network load or throughput
increases. This reaches a critical state when the throughput or network loading
34
approaches 70%. At this point a node may be continually trying to gain access to a
network and continually colliding with other nodes or backing off due to sensing of a
carrier.
Figure 1.36 shows a general procedure for selection of a fieldbus or network. The
procedure was developed by Professor Gerhard Gruhler with contribution from other
members of the ASPIC Consortium (ASPIC Project, 1992 - 1995). This procedure
begins on one hand with the specification of the application requirements and on the
other hand with the gathering and evaluation of data of the bus systems. It is vital that
the requirements of the application are classified as to their relative importance so that
the results of a comparison of how well the characteristics of the evaluated bus systems
match these requirements can be correctly evaluated and, ultimately, a choice can be
made.
In this process, the basic network architecture and network characteristics must be
evaluated with regard to reaction times, maximum transmission rates, transmission
modes, fault detection and error control, types of devices supported, etc. Cabling costs,
cost of nodes and interfaces to the network, installation and configuration costs must
also be recognised. Most importantly it must be assessed whether a licensing fee is
required or if the bus system is open and free to use. Additionally, the future
35
1. Technical Data:
• Geographical Criteria e.g. data bus length and expandability.
• Time Criteria e.g. speed, reaction time and propagation delay.
• Further Technical Criteria e.g. vendor/ user group representation,
communication model and simplicity and flexibility in network
configuration.
2. Strategic Criteria:
• Standards e.g. open or subject to proprietary rights and conformance
testing procedures.
• Availability of components, Software and Services
• Cost
The best possible route to compare several systems may be to select a hypothetical
application and analyse how each system can be used to fulfil the requirements of the
application. Each system can then be evaluated according to the criteria depicted in
Table 1.4.
Most information will be available from the data sheets of the bus systems. The
important issue is to give weighting to various criteria based on their importance
according to the application's requirements. A hypothetical example of the procedure
for selecting a bus is illustrated in Table 1.5.
A weighting factor is assigned to each criterion based on the classification of
application requirements. Each bus system is then evaluated according to each criterion
and a percentage score is given to each one according to how well they perform. Let us
say that the overall maximum points that a bus may gain is a figure of 200. If the bus
system scores 135 out of 200, then the equivalent percentage will be 135/200 or 67.5%.
The formula for calculating the final evaluation result is that of multiplying the group
weighting factor by equivalent percentage, e.g. in this example for the particular case of
bus number 1 and criterion 2.1 the final evaluation result is 15 * 71% = 10.65%.
In the example above, bus number 1 would be selected because it scored better than
the others did. However, in a different application a different bus could have been
selected based on a different weighting allocated to each requirement.
This hypothetical example is based on the extensive evaluation criteria developed
during the EEC project ASPIC. The weighting factors are based on the experience of
several manufacturers forming the ASPIC consortium.
1.6 CONCLUSIONS
Having explored the benefit of the fieldbus systems, it is worth noting that one of
the most prominent higher layer systems on the market is CANopen. It was developed
by the European Community to increase the competitiveness of the market with the
view that SME's should not be tied to major manufacturers. Also it was meant to relieve
the EEC manufacturers' dependency on automation products from the fieldbus
technologies emerging from countries outside the EEC.
CANopen is an ideal networking system for all types of automated machinery. One
of the distinguishing features of the CANopen protocol is its support for data exchange
at various levels of complexity, e.g. at the control level as well as with simple sensors
and actuators. This particularly avoids the use of gateways and bridges, which will add
37
CHAPTER 2
CAN: Controller Area Network
Chapter Objectives
When you have completed this chapter you should:
• Know some of the history of the development of CAN.
• Understand CAN technology.
• Understand how CAN is related to the ISO/OSI Reference Model.
• Identify and understand the Frame format used in CAN.
• Understand the MAC system used in CAN.
• Know the general organisation of a CAN controller.
• Differentiate Basic and Full CAN technology.
• Understand CAN message filtering.
• Understand CAN error handling.
• Identify stand alone and embedded CAN technology.
2.1 INTRODUCTION
CAN is a serial bus system especially suited for networking several intelligent
devices, including sensors and actuators, within a machine or an automation cell. It is a
serial bus system with multi-master capabilities i.e. where several CAN nodes can try to
transmit data at any point in time. Consequently, in CAN, simultaneous transmission
attempts by several nodes may occur. Each message carries an identifier that establishes
a priority system: the node with the highest priority will gain access to the bus and the
remaining nodes (with lower priority) will back off. The identifier is a number carried in
a particular field of the CAN message and it determines the priority of that message: the
higher the priority the faster the bus access. The CAN bus does not need addressing of
subscribers or nodes in the conventional or peer-to-peer manner. Instead messages are
sent to all CAN nodes. Each node then decides, on the basis of the identifier received,
whether the message is intended for that node and if it should process the message. The
relative simplicity of the CAN protocol means that very little cost and effort is required
for training the engineers working in the field.
The Controller Area Network (CAN) was originally developed in the 1980s by
Robert Bosch GmbH in an attempt to solve communication problems between different
control systems in cars. In fact, one of CAN's first uses was the interconnection of
control components such as Anti-Block Systems (ABS) and Acceleration Skid Controls
(ASC). The complexity of the control functions implemented by these systems requires
data transfer mechanisms, which would normally be implemented using dedicated
control lines. However, as the complexity of such devices increased, the number of
control lines and connections required also increased, leading to a situation where in
many of today's car control components the sheer number of control lines has reached
its maximum physical limit. Furthermore, there are now a number of systems in cars,
which require data exchange between several devices. For example in ASC, engine
timing and carburettor control are required when wheel slippage occurs. Additionally,
the information consumed and produced by the ASC will be used by other systems in
the car to accomplish their own tasks. What better than to link such devices via a single
39
set of wires, minimising the number of connections, where data can be quite freely
exchanged, not just between two devices but between several, all at the same time? This
is the basic idea behind CAN.
Needless to say it was not long before this idea migrated from vehicles into the
machinery markets. Nowadays CAN has found its way into diverse areas such as
agricultural machinery, medical instrumentation, elevator controls, fairground rides and
industrial automation control components. It is because of its widespread use (especially
in cars) that a large number of semiconductor manufacturers now produce CAN
devices, making CAN semiconductors relatively inexpensive. The fact that companies
such as Philips, Motorola, National Semiconductors, Siemens and Intel (to name but a
few) are involved in developing CAN technology is a trustworthy indicator that this
technology is guaranteed well into the future.
The original CAN specification, released by Robert Bosch GmbH, is now called
CAN Specification 2.0 - Part A. The reason for this is that an upgraded CAN
specification was released subsequently by the same company, containing both Part A
and a new version of CAN called Part B. CAN Specification 2.0 - Part B, is upward
compatible with CAN Specification 2.0 - PART A. The main difference between the two
versions lies in the fact that the former defines a CAN message format with 11-bit
identifier field, while the latter allows the use of an extended 29-bit identifier. The CAN
Specification 2.0 is in the public domain.
In this chapter the most important aspects of the CAN specification relating to
CANopen protocol will be introduced. CAN Specification 2.0 - Part B will be adopted
not only because it encompasses Part A but also because nowadays most CAN
hardware implementations comply with this newer version of the specification, even if
only passively.
In 1993, CAN became an ISO standard. The ISO Draft International Standard with
reference ISO 11898 is based on the CAN Specification 2.0 but it adopts the classic
CAN message format with 11-bit identifiers. The ISO 11898 standard relates CAN to
the ISO/OSI Reference Model, specifying the CAN Physical Layer, and the CAN Data
Link Layer.
CAN Specification 2.0 did not define a complete Physical Layer for CAN, although
some of the requirements that need to be met by the Physical Layer are specified. These
requirements are, in short, bit encoding/decoding, bit timing and synchronisation. In
fact, in this specification most of the Physical Layer was left for the user to define as
application specific. Therefore, it was necessary, for the purpose of ISO 11898, to set
down a proper Physical Layer definition. Today the ISO 11898 CAN Physical Layer
definition is used throughout the CAN world and has also been adopted in CANopen
and hence will be discussed in this Chapter in more detail.
The functionality specified in the CAN Specification 2.0 can be interpreted, in terms
of the ISO/OSI Reference Model, as being a two layer protocol, as shown in Figure 2.1.
40
Figure 2.1 The CAN protocol and the ISO/OSI Reference Model
In parallel with the specification laid in ISOl 1898 standard, another standard based
on the CAN Specification 2.0 was specified: ISOl 1252. The difference between the two
standards lies in the Physical Layer definitions. ISOl 1252 covers the usage of the CAN
protocol at lower communication speeds than that specified in the ISOl 1898. As such,
the requirements for the implementation of the Physical Layer in ISOl 1252 are less
demanding, making it a cheaper solution. However, the number of applications using
ISOl 1252 is very small when compared with applications based on ISOl 1898.
The maximum length of the CAN bus depends on the baudrate at which it will be
used. CANopen specifies a set of recommended baudrates that should be implemented
by CANopen devices. (For each of these baudrates the recommended bus lengths are
also specified in CANopen, as shown in Table 2.1.) CANopen additionally specifies
that the implementation of the 20Kbit/s baudrate is mandatory for all CANopen devices.
The bit representation used for transmitting messages in the CAN bus is NRZ (non-
return-to-zero) coding that guarantees maximum efficiency in bit coding. However, the
need for frequent transitions on the bus (in order to maintain synchronisation) demands
the implementation of a bit-stuffing mechanism. This bit-stuffing mechanism consists in
the sender inserting a stuff-bit after five consecutive bits of the same polarity (i.e. five Is
or five 0s). The stuff-bit is of reversed polarity in order to force the occurrence of
transitions on the CAN bus (e.g. five Is will be followed by a 0). The receiver removes
the stuff-bits before processing the message. This mechanism is also used for error
control as will be seen in the following sections.
The SYNC_SEG is the part of the bit time used to synchronise the different clocks
on the nodes connected to the bus and where the transition from the previous bit to the
current bit is expected to lie. The PROP_SEG accounts for propagation delays on the
bus. Finally, the segments PHASE_SEG1 and PHASE_SEG2 can be automatically
adjusted by the CAN controller to compensate for synchronisation errors, within certain
limits specified by the programmer. In CANopen it is recommended that, by default
configuration, the bit timing in a node should be prepared to support maximum
propagation delay in the bus i.e. the synchronisation and timing features within the
module/node must be programmed for maximum delay tolerance.
Programming the length of the time segments, shown in Figure 2.3, the total length
of the Nominal Bit Time can be established at the desired value (i.e. at the value that
corresponds to the desired Nominal Bit Rate). Furthermore, the sample point can be
placed at different, locations within the bit time. The CAN specification places the
following limitations on the lengths of the segments:
• The SYNC_SEG must be always 1 Time Quantum long.
• The PROP_SEG is programmable to be 1 to 8 Time Quanta long.
• The PHASE_SEG1 is programmable to be 1 to 8 Time Quanta long.
• The PHASE_SEG2 must be equal to the maximum of PHASE_SEG1 and the
information processing time of the CAN implementation. It is also specified that this
information processing time must be kept smaller than two Time Quanta.
The way in which the configuration of these parameters is performed will depend on
the CAN controller's implementation. As an example, let us take the embedded CAN
controller in the C167 microcontroller from Siemens. The bit timing configuration of
this CAN controller is performed by programming the following bit fields in the bit
timing registers:
• Baudrate Prescaler (BRP) - this parameter permits setting the Time Quantum at
2(BRP+1)·CPU Clock.
43
• Time Segment before Sample Point (TSEG1) - this parameter comprises the
PROP_SEG and the PHASE_SEG1. It can be set to a value ranging from 2 to 15,
indicating TSEG1+1 Time Quanta before the sample point (not including the
SYNC_SEG).
• Time Segment after Sample Point (TSEG2) - this parameter comprises the
PHASE_SEG2. It can be set at a value ranging from 1 to 7, indicating TSEG2+1
Time Quanta after the sample point.
• Synchronisation Jump Width (SJW) - this parameter sets the maximum number of
Time Quanta that can be inserted or removed by the CAN controller from the
PHASE_SEG segments to maintain synchronisation at SJW+1. The SJW parameter
can take values from 0 to 3.
The CAN controller in question provides access to these parameters through a 16-bit
register shown in Figure 2.4.
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
r TSEG2 TSEG1 SJW BRP
Figure 2.4 Bit Timing Register in the C167's embedded CAN controller
To program the CAN controller to operate at a baudrate of W00Kbit/s with the CPU
clock running at 20MHz, the timing parameters could be configured as:
• BRP = 0, setting the Time Quantum at 0.lµs.
• TSEG2 = 7, setting the PHASE_SEG2 and the PHASE_SEG1 at 2 Time Quanta.
• TSEG1 = 6, setting the PROP_SEG at 5 Time Quanta.
• SJW = 3, because in CANopen one must always set the controller to the maximum
propagation delay tolerance.
With this configuration the sample point would be set at 8 Time Quanta within the
bit time i.e. at 80% of the bit time. For most applications the sample point will be set at
around 75% to 88%. This allows for any distortion effects on bit levels that may be
caused by signal propagation and the transmission media, particularly in systems
operating at higher bit rates.
Figure 2.5 Direct connection between the CAN controller and the CAN transceiver
Some CAN controllers interpret the serial signals TxD and RxD differentially rather
than comparing them to ground. When this is the case there will be four wires
connecting the controller to the transceiver: TxO, Txl, RxO and Rxl. Two of these
wires, namely RxO and TxO, will usually be connected to the reference voltages: TxO
on the controller side and RxO on the transceiver side.
An optically isolated connection between the CAN controller and the CAN
transceiver is illustrated in Figure 2.6.
The optocouplers used for this purpose must be high-speed optocouplers specially
designed for this type of application. An example of this type of component is the
HCPL-7710 from Hewlett Packard. The recommended electronic topology for this type
of application can be found in the corresponding datasheets and application notes
published by the manufacturers.
It is common for CAN transceivers to allow the designer to control, up to a certain
point, the R.F.I, generated by the CAN network. This is usually done by changing the
value of a resistor connected to the transceiver that controls the slope of the transitions
on the bus. The steeper the slopes, the higher the R.F.I, generated by the network.
Figure 2.6 Optically isolated connection between CAN controller and transceiver
The pin assignments for the type of connector in Figure 2.7 are shown in Table 2.2.
A detailed description of the electronic connection to the CAN bus is not necessary
for the purpose of this book but it is important to explain how this connection works in
general terms, as it is the basis for the Data Link Layer's operation. This will be done in
the following section.
Each of the transistors shown in the diagram in Figure 2.8 represents the connection
of a CAN node to the CAN bus. Each node can transmit a logic 1 by switching the
transistor off (VCC appears between the bus lines) or a logic 0 by switching the
transistor on (0V appear across the bus lines). This circuit implements what is called a
wired-AND configuration because all modules must be transmitting a logic 1 in order to
have a logic 1 on the bus. In other words, to have a logic 0 on the bus, it is sufficient
that a single node transmits a logic 0. This is the reason why a bit of value 0 is called a
Dominant bit in the CAN bus system, and a bit of value 1 is called Recessive.
As was mentioned earlier, this mechanism is the basis for the operation of the CAN
Data Link Layer, which is discussed in the following section.
As shown in Figure 2.9, the CAN Data Frame is composed of a number of fields:
• Start Of Frame (SOF) Field - This field is composed of a single synchronisation
Dominant bit.
• Arbitration Field - This field has two components. The first one is an 11-bit
identifier, which establishes the message's priority and its identity. The second
component is the Remote Transmission Request bit (RTR) which, if set Dominant,
indicates the Frame contains Data and, if set to Recessive, indicates a Remote
Frame. Remote Frames are exactly the same as Data Frames except that they carry
47
no data and they are used to request the transmission of a data frame with the same
identifier by another node on the bus.
• Control Field - this field has three components. The first is the Identifier Extension
(IDE) bit which, if set Recessive, indicates the transmission of messages with 29-bit
identifiers, as defined in the CAN 2.0-Part B specification. If the IDE bit is set
Dominant it indicates a standard 11-bit identifier. The second component is a
reserved bit (rO), which may be used in future versions of CAN. The last
component is a 4-bit long Data Length Code (DLC), which holds the data byte count
for the message. The DLC field can have values ranging from 0 to 8, indicating the
number of data bytes in the frame.
• Data Field - this is the field where data bytes are sent and can hold between 0 and 8
bytes of data.
• Cyclic Redundancy Check (CRC) Field - this field is used for error checking and
contains a 15-bit CRC code followed by a Recessive delimiter bit.
• Ack. Field - this field is used to ensure that a message has been successfully
received by other node(s). Message reception is acknowledged by inserting a
Dominant bit in the first bit position inside this field, which is always transmitted as
Recessive but is expected to be detected by the transmitter as Dominant. If the Ack
Slot, as it is called, is not filled by a receiver node with a Dominant bit, the
transmitter then knows that the message has not been received correctly and the
transmission is aborted. The second bit position in this field is a Recessive bit
delimiter.
• End of Frame Field - this field is composed of seven recessive bits.
In addition to Data Frames and Remote Frames, the CAN protocol also uses Error
Frames and Overload Frames.
Error Frames are composed of six consecutive bits of the same polarity. These
frames intend to violate the bit-stuffing rule that was mentioned when discussing the
CAN Physical Layer. This is the usual way for aborting transmission of the frames in
which errors were detected. Error Frames are called Active if they are composed of six
Dominant bits and Passive if they are composed of six Recessive bits. The usage of
these frames will be discussed in a forthcoming section.
The details of Overload Frames are not relevant for the purpose of this book.
However, it is important to note that a receiver may use these to delay the transmission
of Data Frames or Remote Frames when it is not ready to receive them.
All CAN frames must be followed by at least three Recessive bits. This is called an
Intermission period. After Intermission the bus goes Idle, meaning that a new
transmission can be initiated.
particular node. This process is called message filtering. The way the filtering is
handled by the designer will depend on the CAN controller being used. This issue will
be further discussed later in this chapter.
It is logical to conclude Chat it is not only possible to perform communication on a
peer-to-peer basis, where a single node accepts the message, but also to perform
broadcast and synchronised communication, whereby multiple nodes can accept the
same message using only a single transmission. The ability to send data on an event
basis means that bus loading is reduced i.e. messages are sent on the basis of necessity
rather than having a fixed schedule for message transmission. This concept is known in
the networking world as the Producer/Consumer mechanism. One difference between
CAN and other fieldbus solutions is that this mechanism requires no interaction from a
bus master or arbiter: it follows the multi-master concept.
It was mentioned in a previous section that a Dominant bit placed by a node on the
bus always prevails over any number of Recessive bits placed on the bus by other
nodes. Hence, a node attempting transmission will only keep control of the bus if the
message it is transmitting has the numerically lowest identifier. This mechanism is the
essence of the Medium Access Control in CAN and an example of its operation is
shown in Figure 2.10.
49
Figure 2.10 Example of the operation of the CAN MAC mechanism, courtesy of Mr. R.
McLaughlin (ODVA)
feature is also used for transmission error control: when a receiver detects six
consecutive equal bits, it knows that a bit stuffing error must have occurred.
• Cyclic Redundancy Check Error - the cyclic redundancy check is performed using
the CRC Field in the CAN frame. The transmitter calculates a CRC code based on
the contents of the message it is sending and inserts the code on the CRC Field. At
the receiver end, the CRC code is recalculated and compared to the one received. If
the codes are different, a CRC error has occurred.
• Form Error - there is a mechanism built into CAN that verifies the structure of the
transmitted frame by checking bit-fields within it against the fixed frame format and
the fixed frame size.
• Acknowledgement Error - it has been mentioned before that all recipients
acknowledge messages by introducing a Dominant bit in the Ack. Slot in the Ack.
Field of the message. If this doesn't happen, it is clear that a transmission error has
occurred and no node has received the message accurately.
To determine in which error state the node is, CAN specifies that each unit must
implement two error counters: one for transmit-errors and the other for receive-errors.
These counters work under a rather complex algorithm, in short, their counts increase
when errors are detected and decrease on successful message transfers. When the CAN
devices are reset they begin to operate in Error Active mode. As errors begin to occur,
the error count increases and eventually they reach a threshold beyond which the node
enters the Error Passive state. If the errors persist, the error counts will keep increasing
until the node shuts itself off, entering the Bus-off state.
If it were not for this mechanism, e.g. if CAN units remained in the Error Active
state regardless of the number of errors detected, this could lead to the loss of all
messages e.g. if a faulty node wrongly assumed that all the messages in the bus were
erroneous. For this reason, this mechanism is called a Fault Confinement feature. The
51
Fault Confinement system was included in CAN with the aim of making a station
capable of recognising its own defects and possibly entering an operating mode where
the network is not affected by them.
registers as well as the control bits in the communication objects are used primarily
by the CPU interface logic.
• The Bit Stream Processor (BSP) controls the data stream between the message
buffer memory (parallel data) and the bus line (serial data). It controls the entire
protocol, differentiates between the frame types and detects frame errors.
• The Error Management Logic receives error messages from the bit stream processor
and, in turn, sends back information about the Error State to the bit stream processor
and the CPU Interface Logic.
• The Bit Timing Logic (BTL) determines the timing of the bits and maintains the
CAN controller synchronised with the edges of the bit stream on the CAN bus. It
monitors the bus through a differential input comparator and determinesthe bit
timings related to the serial bus. The BTL synchronises on a transition at the start of
the frame and re-synchronises on further transitions during reception of the frame.
The BTL also provides programmable time segments to compensate for the
propagation delay times and phase shifts discussed above.
• The Transceiver Control Logic (TCL) consists of bit stuffing logic, programmable
output driver logic, CRC logic and data shift registers. The BSP co-ordinates these
individual elements. Reception, arbitration, transmission and error signalling are
performed by the TCL.
• The Message Buffer Memory stores individual CAN objects for transmission or
reception. The CPU communicates only with this area in order to transmit and
receive messages.The CPU Interface Logic manages the data exchanges.
• The Clock Generator is simply used to derive a suitable clock frequency for the
CAN controller based on the frequency of an external clock oscillator.
In Basic CAN controllers the controller receives all messages irrespective of their
identifier and puts them into a single or dual receive message buffer. It is then up to the
processor collecting the incoming messages to accept or reject these messages.
Therefore, a software receive routine is invoked every time a CAN message is received,
regardless of whether the CAN message is intended for the application or not. This can
add a large amount of software and processing overhead for an application. Overheads
may be reduced in some instances as a Basic CAN controller will normally have an
acceptance filtering scheme allowing the controller to accept all or a subset of the CAN
identifier range. In a Philips 8x592 microcontroller and the Motorola 68HC05X family
of microcontrollers, for example, the filter consists of an Acceptance Mask (AM)
register and an Acceptance Code (AC) register, as shown in Figure 2.13.
Both the Acceptance Code and Mask registers are normally eight bits in length and
the filtering is based on the top 8 bits of the CAN identifier. The Acceptance Mask
register defines whether the corresponding bits in the Acceptance Code register and the
CAN identifier must match to pass the acceptance test (this is done by setting the must-
match bits in the Acceptance Mask to zero).
In Figure 2.13, ID1 fails the acceptance test whilst ID2 passes. It should be noted
that the identifier bits for which the Acceptance Mask has a value of 1 are not taken into
consideration. The same applies to the last three bits of the identifier over which there is
no filtering control. Therefore, if the Acceptance Code in the example is set to
01110111 in binary (119 in decimal), and all bits in the Acceptance Mask are set to
must-match, (the top 8 bits of the identifier must equal the 8 bits of the Acceptance
Code), then a range of identifiers from 952 to 959 decimal will pass the filtering test of
the CAN controller. Obviously, the software must perform further filtering if only some
of these messages are to be accepted.
54
Table 2.4 shows a list of some of the integrated and standalone CAN controllers
available. This is by no means an exhaustive list and many other variants exist (the
same should be noted for Table 2.3). Most of the manufacturers listed here produce
more than one CAN product. Note that most of these CAN controllers support the
extended 29-bit identifier range although some only support 29-bit identifiers passively
i.e. they can be used on the same network as CAN controllers using the extended 29-bit
ID but they use standard 11-bit identifiers only.
56
CHAPTER 3
Introduction to CANopen
Chapter Objectives
When you have completed this chapter you should:
• Know the history of the development of CANopen.
• Understand the CANopen Communication Model.
• Know the structure of a CANopen Object Dictionary.
• Understand the basic CANopen communication mechanisms: PDO and SDO.
• Understand the principle of PDO mapping.
• Know other pre-defined CANopen objects such as the Synchronisation and
Emergency Objects.
• Understand the CANopen boot-up procedure.
• Know the CANopen pre-defined connection set of identifiers.
• Understand the usefulness of Electronic Data Sheets and Device Configuration
Files.
• Know what DS301 and DS302 stand for.
• Be able to construct a CANopen network.
3.1 BACKGROUND
The CAN specification can be mapped onto the two lower layers of the ISO/OSI
Reference Model: the Physical Layer and the Data Link Layer. The CAN Data Link
Layer offers services for transferring and requesting data units no longer than 8 bytes.
These services were sufficient for the original universe of applications in which CAN
was to be used. However, in more complex distributed applications, additional
functionality is required, such as the co-ordinated initialisation of nodes or the
transmission of blocks of data longer than 8 bytes.
In ISO/OSI terms, this means that higher layer services are needed. This was the
reason why the CAN in Automation (CiA) organisation specified the CAN Reference
Model and, within it, the CAN Application Layer (CAL), which is a standard for the top
protocol layer in CAN based systems. The application horizon of CAN was greatly
broadened when the CAL was released and, nowadays, CAL is used in a wide spread of
application fields ranging from medical applications to traffic control.
The CAN Reference Model and the way in which it relates to the ISO/OSI
Reference Model are shown in Figure 3.1.
As can be seen in Figure 3.1 the CAN Reference Model is a three layer model
containing only the Physical Layer, the Data Link Layer and the Application Layer,
which is common in fieldbus protocols.
57
The Physical Layer and the Data Link Layer of this model have already been
discussed in Chapter 2. The Application Layer is, in general terms, the interface
between the data communication environment and the application that uses this
environment to co-operate with other applications. This interfacing is also the task for
which the CAN Application Layer was designed. The reasons for not implementing the
remaining layers in the ISO/OSI Reference Model are as follows:
• Network Layer - the Network Layer is supposed to handle the interconnection of
several networks. As inter-networking never happens in CAN, the services of this
layer were not needed.
• Transport Layer - the purpose of this layer is to guarantee the reliable transfer of
messages of arbitrary length over unreliable networks. In real-time systems,
however, if a transfer fails, it is very likely that the data being transferred are no
longer valid when a new attempt to transfer is made: every transfer attempt stands
on its own and the reliability offered by CAN is sufficient for this type of
application. Furthermore, if an application does need to transfer messages of
arbitrary length, the CAN Application Layer incorporates services for this transfer.
Hence, the services of a Transport Layer are not required in the CAN Reference
Model.
• Session Layer - in real-time control applications the concept of a session is
meaningless and the services offered by the Session Layer are not applicable.
• Presentation Layer - the Presentation Layer basically deals with the encoding of the
data and keeping track of its meaning across the network. In the CAN Reference
Model, a set of basic data types are defined that must be used by all applications to
describe their data. There are also encoding rules that specify how these data types
should be transferred. Additionally, it is assumed that the meaning of the data is
known by all applications beforehand so that the functionality of the Presentation
Layer is no longer required.
58
Usually the master functionality of NMT, DBT and LMT will be centred on one
device that controls the operation of the network. This, however, is not mandatory and
the functions can be performed by different devices.
As will be seen in the next section, CANopen was defined based on the CAN
Application Layer. In fact, in CANopen networks, only a subset of the services
specified in CAL is used; although it must be stressed that for more than 95% of
applications using CAN, this subset is more than adequate. For this reason, the details of
all the services defined in the CAL will not be described here. For more details about
the CAN Application Layer refer to the CAL documentation available from CiA.
• CANopen Device Profiles - a Device Profile defines the way the functionality of a
particular type of device is made accessible through the CAN bus, and what
CANopen Communication Profile tools are needed to access this functionality.
Conceptually there should be a Device Profile for each type of device that can be
used in an industrial environment, connected to a CAN bus. However, at present,
there are only a few standardised Device Profiles: I/O modules (DS401), Drives and
Motion Control (DS402), Human Machine Interfaces (DS403), IEC1131
Programmable Devices (DS405) and Encoders (DS406). Special groups within the
CiA are currently working on the development of new Device Profiles for various
categories of devices that are not yet covered by the existing specifications.
• CANopen Communication Profile, DS301 - the CANopen Communication Profile
is applicable to all devices. It defines how a subset of CAL services can be used to
communicate with a CANopen device and how this device is expected to behave.
All devices are required to implement DS301: the Communication Profile is the
standard interface between CAN and the CANopen Device Profiles. The CANopen
Communication Profile encompasses the real-time object-oriented communication
model as well as the protocols used by all devices in the network.
The CANopen specification relates these concepts to the ISO/OSI Reference Model
by defining the CANopen Reference Model, shown in Figure 3.2.
The CANopen Reference Model, shown in Figure 3.2, is an extended version of the
CAN Reference Model discussed in the previous section. In fact, the CANopen profiles
provide a framework for the development of applications that use CAL services to
communicate. Furthermore, CANopen devices are forced to use CAL in a compatible
way, so that a systems integrator has only to choose the right devices and to perform
minor configuration tasks when building a distributed system. This is an important
advantage of CANopen (and one of the main reasons for its development) when
compared to CAL, where a systems integrator would have to spend a considerable
amount of time devising a way of modelling its application in terms of CAL concepts.
In short, CAL provides a set of communication tools but leaves it to the systems
integrator to figure out how to use them to implement each distributed application.
CANopen complements CAL, defining a standardised way of using CAL services to
implement distributed applications and freeing the systems integrator from this task.
This concept is illustrated in Figure 3.2 where it can be seen that CANopen expands
above the limits set by the ISO/OSI Reference Model and into the domain of the user
application. In fact, the CANopen Device Profiles can be seen as an additional layer
(some authors call it a User Layer or Layer 8) on top of the ISO/OSI seven-layer model,
effectively constraining the way in which distributed applications can be implemented.
60
Since their first release, the CANopen profiles have been revised a number of times
with the objective of making CANopen a self-contained protocol specification that can
be internationally accepted as a standard. In fact, the latest CANopen Communication
Profile release (version 4.0) contains significant changes regarding its predecessors that
make it virtually independent from the CAN Application Layer specifications. This
approach brings great improvement to the readability of the specification as one is no
longer referred to other documents for a detailed description of the communication
protocol rules. Another factor that contributed to make DS301 more accessible to the
reader was that it was possible to discard some of the CAN Application Layer
terminology that did not quite fit in the CANopen context and adopt a more coherent
terminology.
The CANopen profiles define mandatory and optional requirements for devices.
Mandatory requirements are essential for CANopen compatibility and interoperability
and, as such, they must be implemented in all devices, from the most simple to the most
complex. On the other hand, optional requirements may or may not be implemented in a
device. These are often called 'nice to have' features; they are not critical for the
operation of the system and can therefore be left out in the case of simple devices.
However, when these optional features are implemented, this must be done according to
the specification. Additionally, and for the sake of generality, a device may implement
manufacturer specific features which are not covered in either the optional or the
mandatory parts of the CANopen profiles. Hence, the profiles do not constrain future
developments: they cater for new functionality.
61
According to the service primitives that are used in their invocation, Application
Layer services can be classified as:
• Local service - only a Request is used, in which the application triggers a local
network event.
• Provider-initiated service - only an Indication is used, signalling to the application
the occurrence of a local network event.
• Unconfirmed service - an application produces a Request, which requires that an
Indication must be given to an application running in another node.
• Confirmed service - following the same procedure as for an Unconfirmed service,
the remote application then issues a Response. This Response is the11 signalled to
the local application in the form of a Confirmation primitive.
62
• Client/Server.
• Producer/Consumer.
It is important to note that any one of the Consumers may invoke a confirmed
service at any moment in time.
65
From Figure 3.8 it follows that there are two basic types of objects:
Communication Objects - these objects are instances of the Service Object classes
defined in the CANopen Application Layer. Each represents a specific communication
functionality within the device. Communication Objects are specified in the CANopen
Communication profile.
Application Objects - these objects represent device-specific functionality such as
the state of an input digital signal and they are defined in the Device Profile that applies
to the device.
All the objects in a device can be accessed through an Object Dictionary where they
are represented. This principle is shown in Figure 3.8 that shows the Object Dictionary
interacting with all the objects within the device. The Object Dictionary is the most
important part of the device model since it is a map to the internal structure of the
device: if the structure of the Object Dictionary of a particular device is known, then
everything that is needed to build a distributed application using this device is also
known. In other words, knowing a device's Object Dictionary makes it possible to
predict the device's behaviour on the network.
Based on the functionality they offer, Communication Objects can be divided into
two general categories:
66
The pre-defined static and complex data types specified in DS301 are shown in
Table 3.1.
The Index range below 1000H is used to indicate data type definitions, which are
represented in the Object Dictionary only for reference purposes and that are described
in the device's documentation. These entries can, however, be implemented as read-only
objects that hold the bit-length (in the case of simple types) or structure (in the case of
complex types) of an object of that particular type. Table 3.3 shows the CANopen pre-
defined data types and the corresponding object Index. These definitions are mainly
used for compatibility across different computing platforms e.g. the Index for a
particular type definition can be used as an unambiguous code that indicates the type of
a given attribute.
The Index range from 1000H to 1FFFH is reserved for objects that represent
CANopen Communication Profile parameters. They are used in a CANopen network by
all devices. Every device will implement these entries in the same way and, therefore,
the configuration of communication parameters can be performed in the same way for
every device.
The Index range from 2000H to 5FFFH is reserved for objects that represent
manufacturer specific features of a device.
69
The Index range from 6000H to 9FFFH is reserved for objects that represent
features of a device that are standardised in the corresponding Device Profile. In fact, a
Device Profile is essentially the definition of the meaning of these entries for a
particular type of device.
The six columns in the table indicate the following object characteristics:
• The Index for the object, in hexadecimal format. This is used as a 16-bit address to a
given object within the Object Dictionary. The Sub-index is not specified here, since
it is only relevant inside each object. The structure of individual objects is shown
separately.
• The Object's Symbolic Name, which specifies an object code, used for reference
purposes and for standardisation across different computing platforms. These codes
are listed in Table 3.5.
• The Name of the object, which contains a simple textual description of the function
of the object.
• The Type of the entry, which may be simple or complex. The types may also be pre-
defined or manufacturer (device) specific.
• The Access Attribute of the object, which defines the access rights to the object:
read only (ro), write only (wo), read/write (rw) or read only access of a constant
value (const). There are two additional possible values for this parameter, which are
read/write from process input (rww) and read/write from process output (rwr). These
additional values allow automatic tools to check if an entry is suitable for mapping
on a receive PDO (rww) or a transmit PDO (rwr).
70
• The M/O attribute of an object, which indicates if the implementation of this object
is mandatory or optional.
When a detailed description of the Object Dictionary is needed, each object entry is
then described separately and, for each complex object, the meaning of each Sub-index
entry is also shown. Such a detailed description is given in both DS301 and in the
defined Device Profiles. This book does not provide a complete description of all
Object Dictionary entries and only the most relevant ones will be discussed.
From Table 3.6 it is clear that SDO and PDO communication are used for different
purposes in a CANopen network.
In addition to SDOs and PDOs, CANopen defines Communication Objects that are
useful for the implementation of specific data exchange techniques. These objects are:
• Synchronisation Object — this object can be used to synchronise the operation of
CANopen devices.
• Time Stamp Object - this object can be used to establish a global time frame across
a CANopen network.
• Emergency Object - this object can be used for signalling of emergency situations in
CANopen networks which is essential for the implementation of error recovery
mechanisms.
The operation of Service Data Objects and Process Data Objects, as well as the
other Communication Objects defined in CANopen will be described in the following
sections.
The two CANopen services used for SDO transfers are called SDO Download and
SDO Upload and they can be used for writing and reading from the Object Dictionary
respectively. However, given that the data transferred to/from an Object Dictionary
entry is of arbitrary length i.e. it can vary from only a few bytes up to tens of thousands
of bytes depending on the object that is accessed. SDO transfers can follow one of three
procedures that are more suitable for particular circumstances:
• Segmented Transfer - general procedure that can be used in every transfer.
• Expedited Transfer - procedure optimised for very small pieces of data.
• Block Transfer - procedure optimised for large pieces of data.
Figure 3.9 General format for segmented SDO read and write operations
73
When the Client wishes to access the Server's Object Dictionary, it begins by using
either an Initiate SDO Download or an Initiate SDO Upload message. This message will
inform the Server that a transfer has been requested and triggers a response indicating
whether or not the transfer can be carried out.
Following this initialisation stage, a succession of Upload or Download Domain
Segment messages will be used to transfer a series of data segments to/from the Server,
until all the data have been transferred. In Figure 3.9 it is clear that in Upload operations
the data is transferred from the Server to the Client and in Download operations it is
transferred in the opposite direction.
Figure 3.10 shows the data field of the CAN messages to be used in the protocol for
an Initiate SDO Download service. The data fields of the exchanged messages are
structured as a sequence of bit-fields, with the following functions:
• The CCS (Client Command Specifier) bit-field, stored in bits 5 to 7 of byte 0, is
equal to 1 indicating the Initiate SDO Download command.
• The X bits are unused bits and should always be set to zero.
• The E bit (bit 1 in data byte 0) indicates whether the transfer is Expedited (E = 1) or
Segmented (E = 0). Expedited SDO transfers will be discussed in the following
section.
• The S bit indicates whether or not the size of the data is indicated in bytes 4 to 7 of
the CAN message. If S is set to 0, then the size is not indicated.
74
• The Multiplexor is stored in bytes 1 to 3 of the data field. The way in which this
attribute is coded in the telegram is determined by the CANopen data encoding
rules, applied to the data type of the Multiplexor. The Multiplexor is a composite
variable made of an UNSIGNED16 Index and an UNSIGNED8 Sub-index. The
Index is stored in byte positions 1 and 2 with the Least Significant Byte first. The
Sub-index is stored in byte position 3.
• The SCS (Server Command Specifier) contains the value 3, indicating a response to
an Initiate SDO Download command (bits 5 to 7 of byte 0 in the response telegram).
Error or failure indications are given using the Abort SDO Transfer service and
protocol described in Section 3.5.4.2.
The protocol for the Download SDO Segment service is shown in Figure 3.11.
For each segment downloaded, two messages are exchanged between Client and
Server, as shown in Figure 3.11. The request sent by the Client carries the segment of
data, as well as segmentation control information. The Server's response acknowledges
the reception of each segment.
The meaning of the CCS and SCS bit-fields is exactly the same as for the Initiate
SDO Download protocol. However, here, these fields hold the values of 0 and 1,
identifying the Download SDO Segment request and response messages, respectively.
Additional bit-fields are used in the Download SDO Segment protocol for
segmentation control. These bit-fields are:
• The N field determines the size of the data held in bytes 1 to 7 of the CAN data
field. In fact, this field indicates the number of bytes in the telegram that do not
contain data. Its value can range from 0 to 7, and it will indicate that bytes 8-N to 7
will be empty. Note that a null value N means that all bytes contain data.
Additionally, since the maximum value of N is 7, at least one data byte will always
have to be transferred.
• Bit t is a toggle bit and its value alternates between 0 and 1 on successive Download
SDO Segment exchanges. For the first segment, bit t has an initial value of zero.
• The C bit is used to determine whether there are more segments to download. It is
set to 0 if there are more segments to download and to 1 if this is the last segment to
be downloaded.
On reception of the Domain SDO Segment request from the Client, the Server
responds with a message where the toggle bit t must match the toggle bit t in the Client
75
request. This bit is used to synchronise requests and responses and an error should be
signalled if the toggle bits do not match.
Error or failure indications are given using the Abort SDO Transfer service and
protocol described in Section 3.5.4.2.
The protocol for the Initiate SDO Upload service is shown in Figure 3.12.
From Figure 3.12 it is clear that the Initiate SDO Upload protocol is very similar to
the Initiate SDO Download protocol. However, in the Upload case, the data to be
transferred flows from the Server to the Client in the response messages.
The Client initiates the transfer by issuing a request with a CCS of 2 that indicates
an Initiate SDO Upload request. Again, bytes 1, 2 and 3 contain the Multiplexor of the
data block being read. The Server response also has a SCS of 2, indicating an Initiate
SDO Upload response.
In segmented transfers the E bit is set to zero and bytes 4 to 7 indicate the size of the
total data to be uploaded (the observations that were made in the previous section
regarding the S bit apply equally in this protocol). Subsequent Upload SDO Segment
service invocations are then required for uploading the data.
The protocol of the Upload SDO Segment service is shown in Figure 3.13.
76
For the Upload SDO Segment request, the value of the CCS is 3. Once again the
toggle bit t is used to denote alternate requests: it is set to zero for the first request and
toggled on subsequent requests.
On reception of the Upload Domain Segment request, from the Client, the Server
responds using an SCS of 0. The toggle t bit must match that of the request. The N bits
(bits 0 to 3 in byte 0) denote the number of bytes in the telegram that do not contain data
(bytes 8-N to 7). The C bit denotes whether more upload segments are to follow (C with
a value of 0) or that this is the last segment (C with a value of 1).
Figure 3.14 General format for expedited SDO read and write operations
Again, when the Client wishes to access the Server's Object Dictionary, it uses
either an Initiate SDO Download or an Initiate SDO Upload message. This message will
inform the Server that a transfer has been requested and, in the case of a download
operation it also carries the data to be written. The request triggers a response from the
Server indicating whether or not the transfer can be carried out. In the case of an upload
operation this response also carries the data to be read.
Download service presented for segmented downloads is used. Figure 3.15 shows the
protocol for the Initiate SDO Download service in expedited transfers.
The distinction between segmented and expedited transfers is made by bit E. If it is
0 then the transfer is segmented. On the other hand, if bit E is 1 then it is an expedited
transfer.
In expedited SDO downloads the data is carried in byte positions 4 to 7 in the
message sent by the Client to the Server. Bit S (bit 0 in byte position 0) indicates if the
size of the data is carried in bit field N (S equals 1) or if the data size is not indicated at
all (S equals 0).
In fact, if the size of the message is carried in the message, bit field N actually
indicates the number of bytes in the telegram that do not contain data. Its value can
range from 0 to 3, and it will indicate that bytes 8-N to 7 will be empty. Note that a null
value of N means that all bytes contain data. Additionally, since the maximum value of
N is 3, at least one data byte will always have to be transferred.
All the other bit fields in the messages shown in Figure 3.15 are exactly the same as
the ones described for segmented SDO downloads.
The protocol for expedited uploads transfers is very similar to the protocol for
expedited downloads discussed in the previous section. However, in this case, the data
and associated control bit fields (N, E and S) are carried in the response message, from
78
the Server to the Client. The meaning of the information in these fields is the same as
for the expedited SDO download protocol.
All the other bit fields in the messages shown in Figure 3.16 are exactly the same as
the ones described for segmented SDO uploads.
For each block downloaded, several messages are exchanged between Client and
Server, as shown in Figure 3.18. The Client sends all the segments that constitute the
block, one at a time, to the Server and then waits for a confirmation. This confirmation
will indicate which was the last segment successfully received. The Client will then
proceed to download the next block starting from the first data not yet successfully
transferred. Each segment carries 7 bytes of data unless it is the last segment in the
procedure, in which case it will contain the remaining data bytes.
Although the protocol for the SDO Download service must be implemented as a
whole, the procedure for block downloads is specified as three sub-services for easier
understanding:
• Initiate SDO Block Download - through this service, the Client asks the Server to
prepare for receiving data i.e. for a data download. This service is confirmed and the
response will indicate either the success or the failure of the operation. If the
operation is successful, then the Download SDO Block Segment service can be used
to transfer the data.
• Download SDO Block Segment - this service is used by the Client to supply a new
block of data to the Server. Again the service is confirmed and the response will
indicate success or failure of the operation.
• End SDO Block Download - this service is used by the Client to terminate the SDO
transfer upon receiving from the Server the confirmation that all the data have been
successfully received. An optional CRC feature can be included in this service.
Error or failure indications are given using the Abort SDO Transfer service, the
protocol of which will be described in Section 3.5.5.
Figure 3.19 shows the protocol for the Initiate SDO Block Download service.
81
Figure 3.19 shows the data fields of the CAN messages to be used in the protocol of
an Initiate SDO Block Download service. The data fields of the exchanged messages are
structured as a sequence of bit-fields, with the following functions:
• The CCS (Client Command Specifier) bit-field, stored in bits 5 to 7 of byte 0, is
equal to 6 indicating the Initiate SDO Block Download command.
• The X bits are unused bits and should always be set to zero.
• The Client CRC Support (CC) bit indicates to the Server if the Client supports the
CRC feature (CC equal to 1). In the response, the Server will indicate in a similar
way if it supports this functionality in the SC field. If both devices support the CRC
feature this mechanism will be used in the End SDO Block Download service.
• The S bit indicates whether or not the size of the data is indicated in bytes 4 to 7 of
the Client-to-Server CAN message. If S is set to 0, then the size is not indicated.
• The Multiplexor is again stored in bytes 1 to 3 of the data field in the same format as
was described for segmented transfers.
• The SCS (Server Command Specifier) contains the value 5, indicating a response to
an Initiate SDO Block Download command (bits 5 to 7 of byte 0 in the response
telegram).
• The Client Sub-command and Server Sub-command bit fields (CS and SS
respectively) are used to differentiate between the different stages of the block
transfer. In this initialisation stage, these fields hold the value 0.
• Finally, the Block Size field is used by the Server to indicate to the Client how many
segments of data should be in the first block to be transferred. The block size must
be a value in the range 0 < Block Size < 128.
The protocol for the Download SDO Block Segment service is shown in Figure
3.20.
The meaning of the SCS bit-field is exactly the same as for the Initiate SDO Block
Download protocol and it holds the same value. On the other hand, the Server Sub-
command Specifier (SS) holds a value of 2 indicating a block confirmation message.
82
Additional bit-fields are used in the Download SDO Block Segment protocol for
segmentation control. These bit-fields are the following:
• The Sequence Number holds an identification code for each segment transferred.
The first segment will carry a value of 1 and subsequent segments will carry
incremented values until a maximum of 127.
• The C bit is used to determine whether there are more segments to download. It is
set to 0 if there are more segments to download and to 1 if this is the last segment to
be downloaded.
• The Sequence Acknowledge field holds the Sequence Number of the last segment
that the Server received correctly.
• The Block Size field holds the number of segments that should compose the next
block to be transferred. Again, this value must be in the range 0 < Block Size < 128.
Note that all the segments transferred in the Download SDO Block Segment
protocol will contain seven bytes of data. However, this may not be the case in the last
segment of the last block of data. The number of data bytes contained in this final
segment is indicated to the Server during the execution of the End SDO Block
Download service.
Finally, the protocol for the End SDO Block Download protocol is depicted in
Figure 3.21.
When the Server has acknowledged the reception of the last segment of data, the
Client uses the End SDO Block Download protocol to terminate the block transfer
procedure. The bit fields used in this protocol are the following:
83
• The Client Command Specifier still holds a value of 6. However, the Client Sub-
command Specifier holds the value 1, distinguishing this message from the Initiate
SDO Block Download protocol.
• The Server Command Specifier still holds a value of 5. However, the Server Sub-
command Specifier holds the value 1, making a distinction from the previous
protocols.
• If the CRC feature is used, the CRC field holds the result of the CRC calculation
performed by the Client.
• Finally, the N field carries the number of data bytes transferred in the last data
segment in the last data block. N holds a value between 0 and 7 indicating that bytes
8-N to 7 in the last segment do not contain valid data. If the N field carries 0 this
means that all 7 bytes in the last segment are valid.
For each block downloaded, several messages are exchanged between Client and
Server, as shown in Figure 3.23. The Server sends all the segments that constitute the
block, one at a time, to the Client and then waits for a confirmation. This confirmation
will indicate the last segment that was successfully received. The Server will then
proceed to upload the next block starting from the first data not yet successfully
transferred. Each segment carries 7 bytes of data unless it is the last segment in the
procedure, in which case it will contain the remaining data bytes.
An interesting feature was added to the protocol for SDO Block Upload operations.
Since the Client is not aware of the size of the data it will be reading from the Server, it
is possible that the data might not be large enough to justify the use of the block transfer
procedure. For this reason, in the initialisation stage, the Client informs the Server of a
data size threshold below which the Server should switch to the other transfer
procedures. In this situation, the Server can use the segmented procedure, for data that is
more than 4 bytes in length, or the expedited procedure, for data that is up to 4 bytes in
length.
85
Although the protocol for the SDO Upload service must be implemented as a whole,
the procedure for block uploads is specified as three sub-services for easier
understanding:
• Initiate SDO Block Upload - through this service, the Client asks the Server to
prepare for sending data i.e. for a data upload, indicating the data size threshold
below which the block transfer procedure should be abandoned. This service is
confirmed and the response will indicate either the success or the failure of the
operation. If the operation is successful, then the Client sends an indication to the
Server that it can use the Upload SDO Block Segment service to transfer the data.
• Upload SDO Block Segment - this service is used by the Server to supply a new
block of the data to the Client. Again the service is confirmed and the response will
indicate success or failure of the operation.
• End SDO Block Upload - this service is used by the Server to terminate the SDO
transfer, receiving from the Client the confirmation that all the data have been
successfully received. An optional CRC feature can be included in this service.
Error or failure indications are given using the Abort SDO Transfer service and
protocol described in Section 3.5.4.2.
Figure 3.24 shows the protocol for the Initiate SDO Block Upload service. It shows
the data fields of the CAN messages to be used in an Initiate SDO Block Upload
service. The data fields of the exchanged messages are structured as a sequence of bit-
fields, with the following functions:
• The CCS (Client Command Specifier) bit-field, stored in bits 5 to 7 of byte 0, is
equal to 5 indicating the Initiate SDO Block Upload command.
• The X bits are unused bits and should always be set to zero.
• The Client CRC Support (CC) bit indicates to the Server if the Client supports the
CRC feature (CC equal to 1). In the response, the Server will indicate in a similar
way if it supports this functionality in the SC field. If both devices support the CRC
feature this mechanism will be used in the End SDO Block Upload service.
• The Multiplexor is again stored in bytes 1 to 3 of the data field in the same format as
was described for segmented transfers.
• The SCS (Server Command Specifier) contains the value 6, indicating a response to
an Initiate SDO Block Upload command (bits 5 to 7 of byte 0 in the response
telegram).
• The Client Sub-command and Server Sub-command bit fields (CS and SS
respectively) are used to differentiate between the different stages of the block
transfer. In the first two messages, these fields hold the value 0. In the second
message sent by the Client, the CS field carries the value 3.
• The Block Size field is used by the Client to indicate to the Server how many
segments of data should be in the first block to be transferred. The block size must
be a value in the range 0 < Block Size < 128.
• The Protocol Switch Threshold (PST) bit field carries a value that indicates to the
Server a threshold below which it should switch to the normal segmented or
expedited transfer procedures. If the PST is 0 then the protocol switch is not
allowed. If the PST is greater than 0, the Server can optionally switch to another
transfer procedure if the data size is smaller than the PST. Note that if the Server
switches to another protocol, the response to the Client's first message will follow
86
the expedited SDO upload procedure (if the data is up to 4 bytes in length) or the
segmented SDO upload procedure (if the data is over 4 bytes in length). In other
words, if a protocol switch occurs, only the first message shown in Figure 3.24 is
actually used.
• Finally, the S bit indicates whether or not the size of the data is indicated in bytes 4
to 7 of the Server-to-Client CAN message. If S is set to 0, then the size is not
indicated.
The protocol for the Upload SDO Block Segment service is shown in Figure 3.25.
The meaning of the CCS bit-field is exactly the same as for the Initiate SDO Block
Upload protocol and it holds the same value. On the other hand, the Client Sub-
command specifier (CS) holds a value of 2 indicating a block confirmation message.
The remaining bit fields shown in Figure 3.25 serve the same purpose as the ones
described for the Download SDO Block Segment protocol discussed in the previous
section.
Note that all the segments transferred in the Upload SDO Block Segment protocol
will contain seven bytes of data. However, this may not be the case in the last segment
of the last block of data. The number of data bytes contained in this final segment is
indicated to the Client during the execution of the End SDO Block Upload service.
87
Finally, the protocol for the End SDO Block Upload protocol is depicted in Figure
3.26.
When the Client has acknowledged the reception of the last segment of data, the
Server uses the End SDO Block Upload protocol to terminate the procedure. The bit
fields used in this protocol are the following:
• The Client Command Specifier still holds a value of 5. However, the Client Sub-
command Specifier now holds the value 1, distinguishing this message from the
previous protocols.
• The Server Command Specifier still holds a value of 6. However, the Server Sub-
command Specifier holds the value 0, making a distinction from the Initiate SDO
Block Upload protocol.
• If the CRC feature is used the CRC field holds the result of the Cyclic Redundancy
Check calculation performed by the Server.
• Finally, the N field carries the number of data bytes transferred in the final data
segment. N holds a value between 0 and 7 indicating that bytes 8-N to 7 in the last
segment do not contain valid data. If the N field carries 0 this means that all 7 bytes
in the last segment are valid.
The protocol for the Abort SDO Transfer service is very simple. A single
unconfirmed message is sent by the device indicating the failure of the operation, to the
peer device. The Command Specifier (CS) for this message has a value of 4.
88
The reason for the invocation of this service is indicated in the bytes holding an
Abort Code. The Abort Codes that can be used in CANopen are specified in DS301.
Some errors that can be signalled using this service are:
• Protocol errors e.g. toggle bits do not match.
• Index / Sub-index combination does not exist in the Object Dictionary of the Server.
• The range of the uploaded/downloaded data is invalid.
• Incompatibility between the parameter being transferred and other associated
parameters.
• Size mismatch between the Object Dictionary entry, the number of bytes actually
transferred or the size indicated in the Initiate SDO Up- or Download service
(possibly a type error).
• Time-out occurrence (time-outs are usually implemented to prevent the occurrence
of deadlocks caused by the absence of a response).
Note that the Abort SDO Transfer service can only be used in the context of a SDO
transfer. The Abort SDO Transfer service must not be used for other purposes such as
the indication of errors due to communication faults or device application errors.
The structure of each SDO Communication Parameter entry is shown in Table 3.7.
By accessing Sub-indexes 1H and 2H the message identifiers used in the SDO
communication can be modified. Additionally, the most significant bit of these fields
permits enabling or disabling the transmission/reception of these messages. Obviously,
a Service Data Object is only enabled if both of these messages are enabled. The actual
structure of these sub-entries is shown in Table 3.8. Sub-index 3 of the SDO
Communication Parameter structure may hold the Node ID of the peer device in the
Client/Server relationship but this is not of mandatory implementation. An exception to
this rule is the mandatory Server SDO Communication Parameter at Index 1200H in
which Sub-index 3 must not be present. The Node ID parameter will be introduced in
Section 3.8.
89
The protocol for the Write PDO service is shown in Figure 3.28.
As can be seen in Figure 3.28 the service is unconfirmed and the CAN message used
in the transfer carries process data only. The number of data bytes carried by a PDO is
determined by the application of the CANopen data encoding rules to the Application
Objects mapped on the PDO.
As can be seen in Figure 3.29 the service is confirmed. The discussion regarding the
CAN data message used in the protocol for the Write PDO service also applies to the
CAN data message shown in Figure 3.29. In fact, the protocol for the Read PDO service
is an extended version of the one for the Write PDO service, where the PDO
transmission triggering is left to one of the Consumers. To trigger the transmission of
the PDO, the Consumer requesting the PDO simply places on the bus a CAN remote
frame with the identifier assigned to the PDO.
91
Synchronous PDOs can be further divided into cyclic or acyclic. Cyclic PDOs will
be transmitted after a certain number of Synchronisation Objects are received. An
acyclic PDO is transmitted after the reception of a Synchronisation Object, but only
when a particular event, internal to the device, has occurred.
Usually, in automation applications, the nature of the process data travelling on the
bus will belong to one of two very broad categories: Commands and Feedback
messages:
92
The diagram shown in Figure 3.30 illustrates the typical scenario in a CANopen
network using synchronous PDO communication.
At predefined time intervals the Synchronisation Object (SYNC) is transmitted by
one of the devices on the network, called the Synchronisation Object Producer. The
time interval separating the transmission of two Synchronisation Objects is called the
Communication Cycle Period. The Synchronisation Object Producer may or may not be
the same device acting as application or network Master.
When a Synchronisation Object is received, all devices producing synchronous
PDOs place their messages (some of these will be Command messages and the
remaining will be Feedback messages) on the bus. The example in Figure 3.30 assumes
that Feedback messages are assigned higher priority CAN identifiers, which would be a
logical solution in applications where the collection of process data has time-critical
requirements. In any case, all synchronous PDOs will be transmitted during a time
interval that starts with the reception of the SYNC Object, usually called the
Synchronous Window. The actions that are triggered using the synchronous Command
messages are only carried out upon reception of the next Synchronisation Object. This
permits co-ordinated action by several devices in the network.
It is important to note that in Figure 3.30 only synchronous PDO messages are
shown. In a real network, other types of messages such as SDOs or asynchronous PDOs
93
may be transmitted at any time. A careful CAN identifier distribution should be able to
ensure that all communication requirements are met.
As previously mentioned, the transmission of an asynchronous PDO may be
associated with the occurrence of an application event detected in the device. In this
case, it may be transmitted at any time during the operation of the application, based on
the occurrence of this event. The type of application event that triggers the transmission
is either device specific, in which case it is thoroughly described in the applicable
Device Profile, or it is manufacturer specific and it will be explained in the device's
documentation. Typical application events associated with asynchronous PDOs include
the change of state of a set of inputs or an analogue input exceeding a pre-defined
threshold value.
Figure 3.31 shows a typical situation where this type of asynchronous PDO is
useful. A proximity sensor, such as the one shown in Figure 3.31, is a good example of
a control element that may change its state unexpectedly. The fast detection of this type
of event may be very important in some applications. By associating this event with an
asynchronous PDO, the information can be broadcasted on the network as soon as the
event occurs. In this example, the CANopen device asynchronously transmits a PDO
when the analogue voltage exceeds 4V.
Global network aspects, such as between which devices should the PDO transfer
take place, relative priorities to be given to the different PDOs travelling on the bus and
bus loading, should also be kept in mind when performing PDO configuration.
94
The PDO mappings describe the PDO content by listing the sequence and the length
of the mapped Object Dictionary entries that are carried by the PDO. The structure of
each PDO Mapping Parameter entry is shown in Table 3.12.
To describe the contents of a PDO, it is sufficient to indicate how many Object
Dictionary entry values will be carried by the PDO, which are the mapped entries
(Index and Sub-index), in what order are they mapped, and what are their individual
sizes. This description is stored in the values of the Sub-index entries shown in Table
3.12. The structure of the entries from Sub-indexes 1H to 40H is shown in Figure 3.32.
The object length can be a value in the range from 1 to 64, indicating the number of
bits occupied by a particular object.
Object Dictionary entries corresponding to CANopen data types can also be
referenced in the mapping. The parts of the PDO data mapped using this feature will not
be considered by the device receiving the PDO. These parts of the PDO content are
called dummy mappings. Dummy mappings can be very useful e.g. to use a single PDO
to send different pieces of information to different devices whereby each device can be
configured to ignore the data that is not intended for it (this is called a piggy-back
scheme).
The procedure for altering a PDO mapping using SDOs is the following:
• Write the value 0 to Sub-index 0H in the mapping record. If the mapping is not
changeable this write operation will be aborted.
• Write the mapped entries at successive Sub-indexes starting at Sub-index 1H and
using the data format shown in Figure 3.32.
• Write the total number of mapped entries to Sub-index 0H.
97
Digital Input Module also present on the network. Using a single PDO this can be done
in a very simple way:
• The first transmit PDO in the Digital Input Module is configured with the
appropriate identifier, in this case identifier 0x189, and with a transmission type of
5, meaning that the PDO will be transmitted at every fifth occurrence of the SYNC
Object. The mapping of this PDO is set to contain only the object at Index=0x6000
and Sub-index=0x01 which, for Digital Input Modules, maps 8 digital input lines.
• The first receive PDOs in all the Digital Output Modules are configured in exactly
the same way: the appropriate identifier is set to 0x189 and the transmission type to
OxFF, meaning that the contents of the PDO should be immediately passed on to the
digital outputs. The mapping of these PDOs is set to contain only the object at
Index=0x6200 and Sub-index=0x01 which, for Digital Output Modules, maps 8
digital outputs lines.
The Synchronisation Object and the CANopen device functionality associated with
this object are represented in the Object Dictionary by three different entries:
• COB-ID SYNC Message (Index 1005H) - This entry holds the message identifier
used by the Synchronisation Object as an UNSIGNED32 number divided into
several bit fields (Table 3.13). This entry must be implemented by both the Producer
and the Consumers of the Synchronisation Object. Bit 30 in this Object Dictionary
entry is used to trigger the Producer to start transmitting the Synchronisation Object.
The first transmission happens after one Communication Cycle Period has elapsed.
• Communication Cycle Period (Index 1006H) - This entry holds the Communication
Cycle Period in microseconds. It is mandatory for devices that are able to operate as
Producers, for obvious reasons. Devices that only operate as Consumers of the
Synchronisation Object may also implement this entry and use the information in it
internally. A value of zero in this entry deactivates the Communication Cycle
functionality.
• Synchronous Window Length (Index 1007H) - This entry holds the time interval
reserved in a network for transmission of synchronous messages after the SYNC.
100
This parameter allows a device to determine the time instant from which it is
guaranteed that a new command has arrived and prepare itself for co-ordinated
actuation at the beginning of the next Communication Cycle. The value of the
Synchronous Window Length parameter is stored in microseconds. Again, a value
of zero in this entry deactivates the Synchronous Window Length functionality.
CANopen reserves message identifier 80H for the Synchronisation Object as will be
seen in Section 3.8.4.
The Synchronisation Object can be used for synchronisation of data collection and
actuation. However, if time consistence is of prime importance, a global time frame can
be implemented in a CANopen network using another pre-defined Communication
Object: the Time Stamp Object. Time Stamp Objects will not be discussed here. More
information on this type of object can be found in DS301.
The Emergency Object carries eight data bytes and it is structured as shown in
Figure 3.36.
Byte 0 1 2 3 4 5 6 7
Emergency Error Code Error Register Manufacturer Specific Error
Content
(CANopen defined) (Object 1001H) Field
Figure 3.36 Structure of an Emergency Object
The values used in the Manufacturer Specific Error Field should also be explained
in the device's documentation.
Regarding its error status, a device may be in either one of two states: 'Error Free'
and 'Error Occurred'. 'Error Free' means that the device is operating normally, and no
error condition has been detected. 'Error Occurred' means that at least one uncorrected
error condition has been detected on the device. The operation of the device is as
follows:
• After initialisation, the device enters the 'Error Free' state. If no error is detected the
device remains in this state and no Emergency message is sent.
• When an error is detected, an Emergency Object signalling the error is transmitted,
the device enters the 'Error Condition' state (if it is not already there), and the
associated Object Dictionary entries are updated accordingly.
• If some of the errors that have been detected disappear, the device remains in an
'Error Condition' state and must update its Object Dictionary entries accordingly. An
Emergency Object with an Emergency Error Code indicating Error Reset (0000H)
may be transmitted to indicate that the error status has changed but, in this case, the
remaining fields of the message must indicate that some error conditions still remain
uncorrected.
• If all errors are repaired the device returns to the 'Error Free' state and it transmits an
Emergency Object containing an Emergency Error code indicating Error Reset
(0000H). All the other fields in this Emergency Object will also indicate the absence
of errors so that no ambiguity will exist relative to the previous case.
102
The extent to which the detection of an error should affect the functionality of a
device very much depends on the type of functionality implemented in the device. For
this reason the CANopen Communication Profile does not define this aspect of a
device's behaviour, placing it in the scope of the CANopen Device Profiles.
The operation of the Emergency Object is based on the Producer/Consumer Model.
However, only one service is defined for the Emergency Object. This is the Write
EMCY service, through which the Producer notifies the Consumers that its error status
has changed. The protocol for the Write EMCY service is shown in Figure 3.37.
Master, while all the other nodes operate as NMT Slaves. The Master node must
maintain an internal global image of the network in terms of which devices are
connected to it and their individual status. Its task is to use the functionality of the NMT
Communication Objects residing in each Slave node to control the operation of the
entire network.
Each CANopen device is uniquely identified on the network by its Node ID. The
Node ID is a value between 1 and 127, configured on each device using some type of
local mechanism e.g. DIP-switches. The Node ID parameter is used for Slave node
addressing in the services provided by the CANopen NMT Communication Objects.
For this reason, all the devices in a CANopen network must have different Node IDs.
For this reason, the maximum number of nodes in a CANopen network is 127.
However, this number of nodes is sufficient for most industrial automation distributed
control applications.
Each CANopen node implements one NMT Communication Object that offers
services through which the node can be controlled and monitored. The services offered
by NMT Communication Objects are divided into the following functional groups:
• Module Control - these services can be used for the initialisation of the NMT Slaves
that want to take part in the distributed application and for global control of the
application data exchange mechanisms i.e. enabling and disabling this type of
communication in one particular node or in all nodes simultaneously. In fact, before
enabling the application data exchange mechanisms it is required that the Slave
nodes are correctly configured. One of the most important configuration tasks that
must be carried out at this stage is the assignment to devices of all the CAN message
identifiers they need to communicate i.e. for all their Communication Objects. This
assignment of identifiers is normally done statically whereby the systems integrator
defines a priori what identifiers each node uses and for what purpose.
• Error Control - these services are used for supervision of the communication status
of the NMT Slaves. There are three services defined for this purpose: the Node
Guarding Event, the Heartbeat Event and the Life-guarding Event. The two former
services can be used by the NMT Master to monitor the status of NMT slaves. The
Life-guarding service allows the detection of failures in the NMT Master by NMT
Slaves.
3.8.2 State Diagram of a CANopen Device and NMT Module Control Services
A CANopen NMT Slave operates according to a state diagram in which the state
transitions are caused by invocations, by the NMT Master, of the Module Control
services offered by the NMT Communication Objects described in the previous section.
This state diagram is shown in Figure 3.38.
104
into Stopped state, if so stated in the applicable Device Profile. The transitions to
Stopped state, labelled 7 and 8 in the state diagram, are triggered through the Stop
Remote Node service.
At any time, from any state, a node can be forced to reset itself. This reset procedure
can be global i.e. the device will go through the same Initialisation process as on 'Power
on', or it can apply only to the communication parameters of the node. The first type of
reset is represented in the state diagram by the transition labelled 9. It can be triggered
using the Reset Node service. The second type of reset is represented on the state
diagram by the transition labelled 10 and can be triggered using the Reset
Communication service.
The relationships between the transitions in Figure 3.38 and the NMT services
defined in CANopen are summarised in Table 3.14.
Table 3.14 Relationship between NMT services and transitions in Figure 3.38
Transition Service
1 Automatic
2 Automatic
3 Start Remote Node
4 Enter Pre-operational State
5 Enter Pre-operational State
6 Start Remote Node
7 Stop Remote Node
8 Stop Remote Node
9 Reset Node
10 Reset Communication
The protocol for the Module Control NMT services is shown in Figure 3.39. The CS
field indicates a NMT Command Specifier that is used to differentiate between the
106
different services. The Node ID field carries the Node ID of the node to which the
message is intended. If all nodes are being simultaneously addressed then this field will
contain zero. This is the reason why a device can never have a Node ID of 0.
CANopen reserves CAN message identifier 0 to be used in the protocols for the
NMT Module Control services.
The NMT Master issues a remote frame with the message identifier that was
assigned for the Node Guarding polling of a particular device. This message triggers the
transmission of a reply by the Slave, containing a single data byte. In this reply the
Slave indicates which state it is in, using the seven least significant bits in byte 0. The
codes used to signal each state are shown in Table 3.15. Additionally, a Toggle bit (bit 7
in byte 0) is used. The value of this bit must be changed in successive polling cycles and
failure to do so implies the signalling of an error by the NMT Master to its local
application. The value of the Toggle bit for the first transmission should be 0.
Two very important parameters related with the operation of the Node Guarding
protocol are the Guard Time and the Lifetime Factor. These parameters are the basis for
the Life-guarding service and are represented in a Slave's Object Dictionary at indexes
100CH and 100DH respectively.
The Guard Time is the time interval that should elapse between two Node Guarding
polling cycles. The Lifetime Factor defines the time limit for the reception of a Node
Guarding message by the Slave: if a Node Guarding message is not received during this
time, an error will be signalled by the NMT Slave to the application, so that appropriate
action can be taken. The protocol for the Life-guarding service, shown in Figure 3.41, is
based on the procedure just described. The Life-guarding service is therefore a provider-
initiated service, on the NMT Slave side, through which the application is notified of an
error in the Node Guarding protocol, probably due to a failure of the NMT Master.
The Guard Time parameter is indicated in milliseconds. The Lifetime Factor defines
the Life-guarding time limit as a factor of the Guard Time. If the values of the Guard
Time and Lifetime parameters are 0, which is the default situation, the Slave will not
monitor the action of the Master. The implementation of the Guard Time and Lifetime
Factor mechanisms is optional.
Finally, it is important to note that the NMT Master must implement some kind of
time-out mechanism, so that it can signal an error if a Node Guarding reply is not
108
The Heartbeat Producer Time is stored in Index 1017H in the Object Dictionary of
the Heartbeat Producer as a multiple of 1 millisecond. The Heartbeat Consumer time is
stored in Index 1016H in the Object Dictionary of the Heartbeat Consumer. Since the
Heartbeat Consumer can monitor more than one device, the 1016H entry is an ARRAY
with up to 127 entries. Each entry holds an UNSIGNED32 value divided into two bit
fields as shown in Table 3.16.
The identifier used in the Heartbeat protocol is derived from the Node ID of the
Producer as will be seen in Section 3.8.4 and it is unchangeable. In fact, the message
identifier used in the Heartbeat protocol is the same one used in the Node Guarding
protocol. For this reason, the two protocols cannot be active at the same time in a given
device. The CANopen specification states that in devices that implement both the Node
Guarding and the Heartbeat protocol, the latter takes precedence. In other words, when
such a device is configured with a Heartbeat
Producer Time greater than zero, the device assumes that the Heartbeat protocol
should be used and deactivates the Node Guarding mechanism.
110
The Functional Code part of the identifier will determine its priority, according to
the function it will be used for. The Module (Node) ID part of the identifier will permit
different nodes using identifiers from the same functional group without
causing conflicts.
The full set of default identifiers for peer-to-peer communication between
Application Master and Slaves is shown in Table 3.17.
This set-up allocates message identifiers to each device for eight Process Data
Objects (four receive and four transmit PDOs), one Service Data Object (two identifiers
are required for this purpose) and the Emergency Object. An additional identifier is
allocated for the NMT Error Control services (Node Guarding and Heartbeat), as well as
111
the Boot-up Service that share the same message identifier. The Boot-up service will be
discussed in Section 3.8.6.
In addition to the message identifiers that allow the Application Master to
communicate with each Slave on a peer-to-peer basis, the CANopen Pre-defined
Connection Set also reserves message identifiers for messages broadcasted on the bus as
shown in Table 3.18.
In another priority group are the PDOs, which should have lower priority than the
previous objects, but higher than SDOs. Among PDOs, synchronous PDOs should be
given higher priorities so that the behaviour of the cyclic traffic can be more consistent,
as mentioned in Section 3.6.2. Finally the identifiers with lowest priority should be used
for SDOs.
• Once the devices terminate the internal initialisation process, they enter the Pre-
operational state. The entry into Pre-operational state must be signalled by all
devices using the Boot-up service that will be introduced in this section.
• At this stage, the default identifier allocation scheme will be active and SDOs can be
used to further configure the devices. The configuration of CANopen nodes is
usually performed by a Configuration Application residing on the node that operates
as the Client of the default Server SDOs implemented by each device.
• Before starting the normal operation of the network, it might be useful to start the
transmission of the Synchronisation Object, if it is used, while the devices remain in
Pre-operational state. This will permit the devices consuming the Synchronisation
Object to synchronise themselves before normal operation is initiated.
• At this stage Node Guarding, if supported, can be started using the parameters
configured in step one.
• Finally, the devices are placed in Operational state and all types of communication
are then enabled.
The latest version of the CANopen Communication Profile defines a new mandatory
NMT service through which the NMT slaves must signal the end of their initialisation
process, and their entry into Pre-operational state: the Boot-up service.
The protocol for the Boot-up service consists of a single message sent by each
Slave, using the same message identifier used by the Heartbeat protocol or the Node
Guarding protocol. This message must carry one byte only, containing the value zero.
The protocol for the Boot-up service is shown in Figure 3.44.
• Support of the following NMT services: Reset Node, Reset Communication, Enter
Pre-operational State, Start Remote Node, Stop Remote Node and Boot-up.
• Support of one of the following NMT services: Node Guarding or Heartbeat
Message.
The EDS describes only the features of the device that are not configuration
dependent; it is therefore a template that is always a valid description of the device,
regardless of its configuration.
A Device Configuration File, on the other hand, describes not only which objects a
device implements but also their values for a particular configuration. The baudrate and
the Node ID of the device are also included in a DCF. Therefore, several DCFs can be
based on a single EDS, reflecting several possible device configurations.
An EDS should be supplied by the vendor of a particular device as part of its
documentation. If no Electronic Data Sheet is supplied, the default EDS for that
particular type of device (based on the applicable Device Profile) can be used and must
be valid.
Device Configuration Files can be very useful for storing a particular configuration
of a device that will need to be restored later on. It is then possible for an automatic
configuration tool to pick up this file and perform the configuration automatically.
• General Device Information Section - there is only one section in this part of the
EDS and it contains information about the device's manufacturer and product type
information. It also describes what capabilities are implemented on the device e.g.
whether it supports the dynamic mapping of PDOs.
• Object Dictionary Sections - the number of sections in this part of the EDS will
depend on the device's Object Dictionary. These sections list the Object Dictionary
entries that are implemented on the device, along with their default values.
[FileInfo]
FileName= File name according to DOS restrictions
FileVersion= File version ( UNSIGNED8 )
FileRevision= File revision ( UNSIGNED8 )
Description= File description ( 255 characters )
CreationTime= File creation time (characters in format hh:mm(AM|PM))
CreationDate= Date of file creation ( characters in format mm-dd-yyyy )
CreatedBy= Name or description of file creator ( 255 characters )
ModificationTime= Time of last modification (characters in format hh:mm(AM|PM))
ModificationDate= Date of last modification ( characters in format mm-dd-yyyy )
ModifiedBy= Name or description of the modification ( 255 characters)
[DeviceInfo]
VendorName= Vendor name ( 255 characters )
VendorNumber= Vendor code ( UNSIGNED32 )
ProductName= Product name ( 255 characters )
ProductNumber= Product number ( UNSIGNED32 )
ProductVersion= Product version ( UNSIGNED8 )
ProductRevision= Product revision ( UNSIGNED8 )
OrderCode= Product order code (255 characters)
LMT_ManufacturerName= Manufacturer name part of LMT address ( 7 characters )
LMT_ProductName= Product name part of LMT address ( 7 characters )
Baudrate_10= Supported baudrates ( 0 = not supported, 1 = supported )
Baudrate_20=
Baudrate_50=
Baudrate_100=
Baudrate_125=
Baudrate_250=
Baudrate_500=
Baudrate_800=
Baudrate_1000=
SimpleBootUpMaster= Minimum Boot-up master functionality
( 0 = not supported, 1 = supported )
115
The Extended Boot-up Master and Slave functionalities are related with the
CANopen Extended Boot-up Procedure that was included in Version 3.0 of the
CANopen Communication Profile but is not present in Version 4.0. This is also the case
of the LMT Manufacturer Name and LMT Product Name parameters, used by CAL
Layer Management services.
[StandardDataTypes]
0x0001= Supported data types ( 0 = not supported, 1 = supported )
0x0002=
0x0003=
0x0004=
0x0005=
0x0006=
0x0007=
0x0008=
0x0009=
0x000A=
0x000B=
0x000C=
0x000D=
0x000E=
0x000F=
0x0020=
0x0021=
0x0022=
All Data Types defined in DS301 Version 3.0 are listed according to their Object
Dictionary entries, and the supported objects are signalled with a value of 1.
For each of the remaining classes of objects (Mandatory, Optional and Manufacturer
Specific), the supported entries are first listed in an index section and then they are
presented in more detail in object-specific sections.
All supported objects of a given class are listed in an index section with the
following structure:
116
[KEYWORD]
SupportedObjects= Number of supported entries
l=0x<INDEX> 1st supported entry
2=0x<INDEX> 2nd supported entry
3=0x<INDEX> 3rd supported entry
4=0x<INDEX> 4th supported entry
The possible KEYWORD values for these index sections are: MandatoryObjects,
OptionalObjects and ManufacturerObjects. All entries that are listed in these index
sections are then represented in the EDS by additional sections describing them in a
more detail. These sections have the following format for each Object Dictionary entry:
[0x<INDEX>]
SubNumber= Number of Sub-indexes available at this Index ( UNSIGNED8 )
ParameterName= Parameter name ( 255 characters )
ObjectType= Object code (Refer to Table 3.4)
DataType= Object Dictionary Index of the data type of the object.
LowLimit= Low limit of object value (if applicable )
HighLimit= High limit of object value (if applicable )
AccessType= Access type ( ro, wo, rw, rwr, rww )
DefaultValue= Default Value (if applicable)
PDOMapping= Object can or cannot be mapped ( 0 = not supported, 1 = supported )
If, at a given Index, the SubNumber parameter is nonzero, this means that a series of
sections follow, describing each of the Sub-indexes in more detail. These sections have
the following structure:
[0x<INDEX>sub<SUB INDEX>]
ParameterName= Parameter name ( 255 characters )
ObjectType= Object code (Refer to Table 3.4 )
DataType= Object Dictionary Index of the data type of the object.
LowLimit= Low limit of object value (if applicable )
HighLimit= High limit of object value (if applicable )
AccessType= Access type ( ro, wo, rw, rwr, rww )
DefaultValue= Default Value (if applicable )
PDOMapping= Object can or cannot be mapped
( 0 = not supported, 1 = supported )
Note that not all entries in this type of section are mandatory e.g. the DefaultValue
entry may not be applicable to particular Object Dictionary entries.
[Comments]
Lines= Number of comment lines ( UNSIGNED 16 )
Linel= lst line of comments ( 255 characters )
Line2= 2nd line of comments ( 255 characters )
Line3= 3rd line of comments ( 255 characters )
…
117
The second section is used to indicate which data types can be referenced in PDO
mappings so as to program the device to ignore a particular part of the PDO data
(dummy mapping). The format for this section is the following:
[DummyUsage]
Dummy0001= Data type at Index 1 (1 = can be referenced, 0 = cannot be referenced)
Dummy0002= Data type at Index 2 (1 = can be referenced, 0 = cannot be referenced)
Dummy0003= Data type at Index 3 (1 = can be referenced, 0 = cannot be referenced)
Dummy0004= Data type at Index 4 (1 = can be referenced, 0 = cannot be referenced)
Dummy0005= Data type at Index 5 (1 = can be referenced, 0 = cannot be referenced)
Dummy0006= Data type at Index 6 (1 = can be referenced, 0 = cannot be referenced)
Dummy0007= Data type at Index 7 (1 = can be referenced, 0 = cannot be referenced)
Only data types at Indexes 1 to 7 can be used for dummy mapping and these data
types must be supported by the device.
[DeviceCommissioning]
NodeID= Device's Node ID ( UNSIGNED8 )
NodeName= Node name part of the NMT address (7 characters)
Baudrate= Device's baudrate ( UNSIGNED 16 )
NetNumber= Number of the network ( UNSIGNED32 )
NetworkName= Network name ( 255 characters )
LMT_SerialNumber= Serial number part of LMT address ( 14 characters [0-9])
Of these parameters, only the Node Name and the LMT Serial Number have no
parallel in Version 4.0 of the CANopen Communication Profile. Both of these
parameters are related to the CAN Application Layer.
DCFs contain the following keywords in addition to the ones described in the
previous section for EDS files:
• In the File Information section, the parameter 'LastEDS=' is used to indicate the
EDS on which the DCF was based. The EDS name is indicated according to DOS
restrictions.
• In the object sections, the parameter 'ParameterValue=' is used to indicate the value
with which each entry is configured. Additionally, if the Object Type is 'DOMAIN',
it is possible to indicate the files that can be read or written to when downloading or
uploading that Object Dictionary entry using the keywords 'DownloadFile=' and
'UploadFile='. A 'DOMAIN' is a data type used to represent large variable amounts
of data e.g. executable program code.
a system during boot-up. The Configuration Manager may or may not reside on the
same node as the NMT Master.
• SYNC Producer - the SYNC Producer is an optional functionality that is responsible
for transmitting the SYNC Object. It may reside on any node in a CANopen system.
• Time Stamp Producer - the Time Stamp Producer is an optional functionality, which
is responsible for transmitting the Time Stamp object. It may reside on any one node
in a CANopen system.
Although it is not mandatory to do so, it is often the case when most of these
functionalities are implemented on the same node. To describe this characteristic of
CANopen, a new concept is defined in DS302: the CANopen Manager. A node is
called the CANopen Manager if it implements at least the NMT Master and SDO
Manager functionalities and, optionally, the Configuration Manager functionality.
enable the SDOs in each device, matching the input SDO of one device to the output
SDO of the other and vice-versa.
To cope with this problem, DS302 defines a new mechanism called a Multiplexor
PDO. This type of PDO is capable of writing to any Object Dictionary entry. Its format
is illustrated in Figure 3.45.
The Multiplexor field holds the Index and Sub-index of the Object Dictionary entry
to be accessed, coded in a similar way to SDOs. The f field holds a format flag, and the
Address field will have different meanings, depending on the value of the/flag.
The basic mode of operation of the Multiplexor PDO is obtained by setting f to 1
and the Address field to 0. The group of nodes configured to receive this PDO will use
the Multiplexor field to identify the Object Dictionary entry that is being accessed and
update it using the data stored in the Data field.
In addition to this operation mode, the functionality of the Multiplexor PDO is
extended to permit the implementation of two other useful data transfer mechanisms:
• Setting f to 1 and inserting a Node ID in the Address field, it is possible to address
only one of the nodes configured to receive the PDO. This can be a very helpful
feature, since it will permit avoiding a lot of the node configuration work that would
be required to prevent all the other nodes in the group from accepting the
information.
• Setting f to 0, the Address field will hold the Node ID of the source node. This
makes it possible for the receiver to identify the node transmitting the PDO and take
appropriate action based on this information.
CHAPTER 4
CANopen Implementation Issues
Chapter Objectives
When you have completed this chapter you should:
• Understand the difficulties associated with implementing CANopen.
• Understand how a typical CANopen device is implemented.
• Understand how a multiple CANopen device module is implemented
• Be aware that there is a trade off between efficiency and functionality in CANopen
implementations.
• Recognise the message burst problem and its causes in CANopen networks.
• Be able to construct a CANopen network.
• Be familiar with the details of CANopen communication.
4.1 INTRODUCTION
CANopen was developed as the result of an European project that focused on how
CAN technology could be used in industrial automation systems, for real-time control
of components such as digital and analogue I/O devices, drives, man-machine or
machine-operator interfaces, vision systems, and many others. Its purpose is to simplify
system integration and device standardisation in CAN based systems.
As all protocol specifications, CANopen does not contain implementation-specific
information. In fact, the CANopen specification only describes the external behaviour
of devices. For this reason, even after reading the CANopen specifications, one may
still find it difficult to grasp all the aspects of CANopen implementation and CANopen-
based system integration.
This chapter attempts to fill some of the gaps in the information available to
CANopen users. It has been written as a practical guide to CANopen and it is aimed at
both systems integrators and device manufacturers.
It is clear from the previous table that only a small portion of the capabilities of a
typical Full CAN controller would be used in this type of application. In fact, this is the
type of implementation where the usage of a Basic CAN controller would be advisable,
particularly because it is in simple devices that low-cost is more important for the
success of the product on the market.
125
On the other hand, in a CANopen device where two PDOs are to be received,
synchronous PDO communication and time stamping are to be used, and where an
additional Server SDO is to be implemented, eight message objects are likely to be
required for message reception in a Full CAN controller. The required objects for this
particular case and a possible allocation of message reception tasks are summarised in
Table 4.2.
Contrary to the previous example, in this type of implementation the use of a Full
CAN controller is justifiable, simply because of the increased software efficiency that it
brings.
Table 4.2 Typical message object allocation scheme in a Full CAN controller
Service Default Receive Identifier Allocation Object
Network Management 0H(0) 1
Node Guarding 700H+Node ID (1792+Node ID) 2
SDO Request #1 600H+Node ID (1536+Node ID) 3
Receive PDO 1 200H+Node ID (512+Node ID) 4
Receive PDO 2 300H+Node ID (768+Node ID) 5
Synchronisation Object 80H(128) 6
Time Stamp Object 100H(512) 7
SDO Request #2 - 8
are many messages preceding the newly added PDO, the PDO may not be
transmitted within an acceptable period of time. This argument also applies to remote
frame and event modes of PDO transmission.
A solution for this problem, when using a Full CAN controller, is to reserve a
message object purely for transmission of the PDO. Therefore, an interrupt routine
associated with reception of the Synchronisation telegram can initiate transmission of
the PDO simply by flipping a few bits of the corresponding message object. Other,
lower priority messages such as SDOs and Node Guarding responses can be added to
the FIFO queue as normal.
Basic CAN controllers generally have only one transmit buffer so that a similar
arrangement is not possible: all messages must be transmitted through the buffer and
therefore it is not possible to dedicate separate transmit objects for higher priority PDO
transmission. In such a case the transmit interrupt routine must take into account the fact
that there are pending higher priority PDO telegrams to transmit. These can be loaded
into the transmit buffer ahead of any FIFO queued messages (Figure 4.2). In addition,
care must be taken to make sure that the CAN transmit buffer is empty before trying to
load in new telegram data for transmission.
Figure 4.2 Example of a timer tick interrupt routine for message transmission
These arguments also apply to Full-CAN controllers where the number of message
objects is at a premium and one wishes to use only one object for transmission of data,
reserving the others for reception purposes.
In any case, using large queues for message transmission, especially of process
critical data (PDOs), in some ways defeats the purpose of having message
127
Given this data, it is generally not possible for a processor to retrieve a message
from the CAN controller buffer and process it in time before the next message arrives.
In some cases, the CAN hardware implements its own buffering scheme whereby
multiple areas of buffer memory in the hardware are used to store incoming telegrams.
However, in most cases received messages should be placed in a buffer area for
processing at a later date so that they are not overwritten and therefore lost. If possible,
copying to a buffer is best done using the on-chip facilities available. For example, the
Philips 80C592 microcontroller's on-chip DMA facilities allow the transfer of a CAN
message from its receive buffer to internal data memory in a period of two instruction
cycles.
In situations of message bursts at high bus speeds the number of back-to-back
messages is not the only important factor that needs to be taken into consideration. The
128
length of each CAN message also plays a vital role. If all the messages in the 'burst' are
of 8 bytes in length, the processor has more time before having to deal with the next
message in its receive buffer. If the burst contains messages of just a few bytes in
length, a particular processor may not be able to deal with them in time. In other words,
it is not only the number of messages in the burst but also the length of each message
that counts. The authors have encountered this problem at an early stage of
implementation of an automation cell. In their cell, the master (based on a Basic CAN
controller) could quite happily cope with bursts of messages carrying 8 bytes of data,
but it could not cope when those bursts included one or two messages carrying only two
bytes of data.
Finally, it is important to note that a device suffering from message overruns must
be able to detect this situation and notify the application accordingly. If this does not
occur, the application might not be aware that an error had occurred until it was too late
to avoid irrecoverable damage.
In Figure 4.3, three nodes A, B and C are configured to transmit PDOs on every
Synchronisation Object (node A), every other Synchronisation Object (node
B) and every third Synchronisation Object (node C). The highest message burst on
the bus will occur every 6th Communication Cycle, which represents the worst case
situation for this network.
129
Another source of message bursts exists when several nodes are configured to
transmit information in event mode. In this mode, there is no way to predict accurately
when each node will want to transmit information on the bus as this will depend on
application specific events. This is particularly true in a device such as an analogue
input module. For such a module, it is possible to configure it to transmit a PDO
telegram on a difference or delta change (see points C and F in Figure 4.4) of its input
signal. Too small a difference value, e.g. transmit on a change of 1 bit in the input
value, will cause the module to flood the bus with messages.
The problem that device developers faced when they wished to implement the
functionality of several Device Profiles in the same CANopen module was that the
requirements for compatibility with each Profile were conflicting. These conflicts
concerned the use of the same Object Dictionary entries by each type of standardised
device for different purposes.
The approach adopted in the CANopen Communication Profile to resolve the
conflicts associated with Multiple Device Modules consists in a segmentation of the
Object Dictionary areas where such conflicts exist, so as to accommodate the
functionalities of up to eight different standardised devices.
The areas of the Object Dictionary that are affected by these modifications are
shown in Table 4.5.
As can be seen in Table 4.5 the most significant change in the Object Dictionary of
a Multiple Device Module is that the Standardised Profile Object Dictionary section is
divided into eight segments numbered from 0 to 7. The Object Dictionary entries
defined in each Device Profile that is supported by the implementation are stored in one
of these segments, starting on Segment 0. Additionally, at the last Index in each
segment, a Device Type entry similar to the one defined in DS301 for Index 1000H
indicates to which Device Profile corresponds the information stored in that segment.
Complementarily, the entry at Index 1000H is modified to indicate FFFFH in its two
most significant bytes in the case of Multiple Device Module implementations (the two
least significant bytes in this entry indicate the Device Profile code that corresponds to
the device functionality stored in Segment 0 of the Standardised Profile Object
Dictionary area).
Similarly to what happens in the Standardised Profile area of the Object Dictionary,
the Object Dictionary area reserved for Device Profile Data Types was enhanced to
accommodate up to eight different device functionalities. Table 4.5 shows how eight
Object Dictionary Index segments are provided for this purpose in Multiple Device
Modules. The Data Type entries in each of these segments must match the standardised
131
new incoming CAN interrupt and therefore the CAN interrupt line must be disabled
during this period. This in itself creates extra overheads in dealing with incoming and
outgoing CAN messages.
the CAN hardware requirements. In this section the main conclusions of the discussions
in the previous sections regarding CANopen implementations will be summarised.
In general, microcontrollers incorporating Basic CAN controllers (such as the
Motorola 68HC11X and the Philips 80C592) are cheaper than their Full CAN
counterparts (such as the Siemens C167 or the Intel 80C196CA) as they are less
complex at the silicon level. However, for implementation purposes, much less filtering
and message transmission overheads are incurred using a Full CAN device and the
development of a CANopen implementation is somewhat easier, requiring less code and
memory space. However, this should not rule out Basic CAN in CANopen applications
from the very simple to the more complex. It is the experience of the authors that a node
offering quite complex CANopen features can be implemented in approximately 10
Kbytes of ROM and 500 bytes of memory using a Basic CAN device.
It must be remembered that when implementing CANopen software, the decisions
made as to what CANopen features are implemented are dependent on the processing
power of the hardware. Of primary importance at the CAN level is that the software is
able to detect when the hardware has become overrun (i.e. an incoming message has
overwritten a previously received message whose contents were lost in the process). In
general the following factors will have the greatest impact on the successful functioning
of a CANopen device:
• The CAN hardware - a Full CAN controller will interrupt the main device processor
less than a Basic CAN controller (which then has to software filter the message
identifiers). Code and memory space generally will be smaller using a Full CAN
controller. Software filtering of CAN messages requires more complex software and
hardware using a Basic CAN Controller.
• The rate at which PDOs are transmitted between devices in the network - high speed
of transmission may cause overrun in the CAN controller (message loss) or the
inability to respond to PDO information due to overheads on accessing hardware.
The use of confirmed services (SDOs or ad-hoc solutions using PDOs) can alleviate
these problems as a device only sends a new request to write or read data based on
receiving a confirmation acknowledging the previous request.
• Dynamic mapping of PDO data or use of multiplexed PDOs - dynamic mapping
consumes a large amount of processing power. Generally a multiple static mapping
scheme, whereby several PDOs can be enabled or disabled but have predefined or
fixed mappings, requires less processing overheads than a truly dynamic scheme.
• Hardware access schemes - a node that transmits and receives I/O data must be able
to convert this data to and from PDO telegrams. The time taken to access or set this
data can play a large part in how well the device performs and determine its
response times to changes regarding both its inputs and its outputs. Generally, if the
outputs and inputs are memory mapped on a slave device, then access to I/O
functionality will require less processor instruction cycles, compared to the situation
where I/O requires access over some other hardware mechanism. For example,
many expandable I/O module systems have their own internal serial bus system,
which can be slow.
• The baudrate and CAN message lengths - lower baudrates and longer message
lengths increase inter-frame spacing and therefore a device has more time to process
an incoming message when compared with higher baudrates and/or shorter message
lengths.
134
When the preliminary design stage is completed and the practical implementation is
started, the following aspects should be given special attention:
• When installing the cabling, and if some of the devices are to be powered via the
bus, it is important to ensure that the power supplies used for this purpose can
provide sufficient power, and that the voltage drops across the network do not
influence the device's functionality. Additionally, and if the network will be
operating in noisy environments, appropriate shielding must be used to protect the
network from interference.
• If the EMI generated by the CAN bus is damaging to a particular application,
appropriate filtering may be required. Some CAN transceivers, like the Philips
82C250, permit controlling the slope of the transitions of the CAN bus, which is the
source of the EMI, to a certain extent.
• Every node in the network must be set to work at the same baudrate (this is usually
done by setting hardware switches). Furthermore, it is important to ensure that the
length of the network is within the recommended values for a particular baudrate
and that the bus line is properly terminated.
• Every node in the network must have a unique Node ID so that no conflicts arise
when the devices are being addressed. The selection of the Node ID parameter is
also usually done by setting hardware switches.
• When performing the system boot-up it is important to keep track of the default
message identifiers that are allocated to the devices. It is vital that no identifier is
135
allocated for transmission by two different devices, which would result in a conflict
during the operation of the network.
• Before commissioning the network to normal operation, all the CANopen
mechanisms that will be used must be fully configured in a consistent way using
SDOs. For example, if the Synchronisation Object is being used, special care must
be taken when selecting the value of the Communication Cycle Period: its value
must satisfy the timing requirements for the application and all devices in the
network must be capable of handling it. Furthermore, it is vital to ensure that all
nodes are capable of transmitting their PDOs within one Communication Cycle
Period. Note that this configuration stage will also include the allocation of message
identifiers during network boot-up.
• When establishing PDO connections between two devices, it is essential that the
mappings used for the PDOs are compatible. Otherwise the transfer of information
will be meaningless.
Forgetting for a minute the very low probability that an application with these
requirements will ever be needed in a manufacturing process, let us follow the design
procedure established in Section 4.5 and devise a way of implementing it using
CANopen.
137
As can be seen from Figure 4.5, the analogue signals from the temperature sensors
are multiplexed onto a single line that is then connected to the analogue display (a
common voltmeter). The reason for this is that the sensors are all located close to each
other, but about ten metres away from the analogue display. The variation of the signals
from the temperature sensors (after conditioning) is in the range of 0V to 10V and the
138
analogue display's scale is adapted to show appropriate temperature values. The block
of eight switches implements a mechanical process of mutual exclusion whereby only
one of the switches can be on at a time. This block presents at its output eight digital
lines, one for each switch, where 0V indicates an open switch and 24V indicates a
closed switch. The eight digital lines are then coded into a 3-bit binary number,
indicating the selected sensor, and this number is used as the selection code for the
analogue multiplexor. A special circuit shown as the 'binary coding block' in Figure 4.5
performs the conversion to binary. The binary coding block and the analogue
multiplexor are connected through a 3-bit parallel bus.
Finally, let us say that there is no PC available in the original application and one
has to be bought that is equipped with a PC/CAN interface card and that suits the needs
of the system to be implemented.
In short, the task of the systems integrator is to use CANopen to upgrade the
existing system to incorporate a remote PC, monitoring the temperatures of all eight
sensors, whilst maintaining the functionality of the previous system.
In Figure 4.6 it can be seen that we chose to use the PC displaying the temperature
values as the network master. By doing this we avoid having an additional device
connected to the network performing only Network Management services and other
CANopen-related tasks. There are systems on the market that are able to perform these
tasks; however, they represent a significant additional cost. On the other hand this will
force us to include these tasks in the PC application we will have to develop.
In very general terms the operation of the system can be described as follows:
• The PC will sequentially select a different line in the analogue multiplexor using the
remote digital output module.
• For each of these lines the PC will read the value of the temperature from the remote
analogue input module and display it on-screen.
• At the same time, the PC will keep track of the status of the 8-switch block using the
remote digital input module.
• Using this information, the PC is able to identify which of the temperature sensors is
selected to be displayed on the voltmeter and, when this line is read from the
analogue multiplexor, the value collected can also be sent to an analogue output
module connected to the analogue display.
139
In order for it to be possible to select the right CANopen devices to implement this
application, we need first of all to specify in more detail how the network will operate.
Only then can we assess which capabilities are required from each device and choose
from the devices available on the market (from the devices that satisfy the technical
requirements, those that offer more in terms of cost, quality, confidence, etc.).
The first parameter usually to be defined when designing a CANopen network is the
baudrate at which the network will operate. In this case, we estimate the necessary bus
length to be 25 metres. In Chapter 2 it was mentioned that the higher the bus length, the
lower the recommended bus rate for the operation of a network. In fact, 25 metres is the
maximum bus length at which it is recommended to use a baudrate of IMbit/s.
Additionally, by looking at the time constant related to the temperatures that are being
monitored, we can have an idea of how fast the temperature data should be updated.
Since the referred time constant is approximately 10 minutes, it is safe to say that if we
set a frequency of data collection of 1 second, it would be more than enough to provide
a satisfactory resolution. Considering that at 500Kbit/s the biggest CAN message that
can be transmitted takes less than a quarter of a millisecond, it is obvious that at this
baudrate the requirements of this application can be easily met (in fact, even at lOKbit/s
they would be easily met). Let us arbitrarily set the baudrate for this application at
500Kbit/s, since virtually all CANopen devices available on the market support this
value.
140
Having established that the data from the temperature sensors should be updated at
least once a second, one way of guaranteeing this is to implement a data transfer scheme
based on synchronous exchange of data. Given the fact that eight pieces of data have to
be collected from the analogue input module every second, it would be logical to set the
Communication Cycle Period at 125 milliseconds. Figure 4.7 shows how such a
transmission scheme would operate in a situation where, for example, sensor number 2
has been selected to be displayed in the analogue display.
In Figure 4.7 it can be seen that the Synchronisation Object will be transmitted by
the PC every 125 milliseconds, setting the Communication Cycle Period at the
previously defined value. Both the analogue input module and the digital input module
will be configured to transmit a Synchronous PDO on reception of every
Synchronisation message. These PDOs will carry the values of the temperature
readings in the case of the analogue input and the status of the switch block in the case
of the digital input module. The value of each temperature reading will be collected by
the PC and shown on-screen. Simultaneously, the status of the switch block will be
checked and, when the temperature reading coincides with the sensor selected in the
switch block, a message will be sent to the analogue output module connected to the
voltmeter, updating the value being displayed on it. On every Communication Cycle a
different sensor will be selected by the PC, sending a PDO to the digital output module
with a new selection code for the multiplexor. Using this scheme, all temperature
sensors will be read in eight successive Communication Cycles i.e. in one second, as
required.
It remains to be said that although it is important that the PDOs carrying data to the
PC are configured as synchronous PDOs (with a transmission Type parameter with a
value of 1, indicating PDO transmission on every Communication Cycle), it is vital that
the PDOs carrying data transmitted by the PC are configured as asynchronous event
PDOs. This is to guarantee that the data are instantly updated on the outputs of the
digital and analogue output modules when a PDO is received. This is particularly
important in the case of the digital output module so that the multiplexor has enough
time to stabilise its output when switching from one sensor to the other.
141
application in such a way that the default identifiers in the devices are used. If this is
the case, the only configuration that will be required on boot-up consists of setting
the appropriate transmission modes for the PDOs.
• Send the first multiplexor code to the digital output module so that on reception of
the first Synchronisation Object, after the devices are put on Operational state, the
analogue multiplexor selects the first temperature sensor and the analogue input
module can perform the required conversion.
• Start transmitting the Synchronisation Object every 125 milliseconds.
• Move all devices to Operational state.
• For every temperature measurement received, update the corresponding value on-
screen.
• For each reading of the status of the switch-block, check whether the current
temperature measurement value should be sent to the analogue display and, if so,
transmit it.
• On every Communication Cycle send a new multiplexor code to the digital output
module.
The implementation of such an application would be fairly easy even for a systems
integrator with minimal knowledge of CANopen (as long as the software development
know-how was there, of course).
In the next section, examples of the bus-traffic produced by this system both on
boot-up and normal operation are presented.
The Node ID configuration is performed by the system integrator using the facilities
included in each device for this purpose (e.g. dip-switches), prior to connecting the
devices to the network. This allows the modules to communicate, without conflicts,
using the default communication identifier scheme, as soon as they are powered up.
143
The network manager can use these message identifiers to communicate with each
device individually, in order to configure them, before starting the normal operation of
the network.
As will be seen in the next section, device configuration using SDOs is necessary in
this application to set the communication parameters of the PDOs used in each device to
values that meet the requirements of the system.
The parameters that are not supported by I/O Modules in their default configuration
are signalled in Table 4.8. These parameters require configuration using SDOs.
t.tttt iii dd d0 d1 d2 d3 d4 d5 d6 d7
where t.tttt stands for the time instant when the message was recorded (in
seconds), iii stands for the message identifier, dd holds the message direction relative
to the network manager, and d0/d7 are the data bytes. All numerical values are shown
in hexadecimal format.
A boot-up sequence of the system described in the previous sections would look
something like the set of messages shown in Table 4.9. Note that the Node ID of each
CANopen module, referred in the following discussion, can typically be set using DIP-s
witches.
Finally, the configuration of the digital input module (Node 4) consists simply of an
SDO write operation to Index 0x1800 and Sub-index 0x02. This Object Dictionary
entry holds the transmission type parameter for the first transmit PDO of this device
(which is reserved for digital devices) and the value written to it is 0x01 which indicates
a synchronous PDO triggered by the reception of every Synchronisation Object.
After configuring the communication parameters of the devices, the network
manager sends a PDO to the digital output module, setting the initial code for the
analogue multiplexor at zero. This PDO carries only one byte and the three least
significant bits contain the referred code.
Finally, the network manager starts transmitting the Synchronisation Object and
moves all devices to Operational state using a Start Remote Node message addressed to
all devices.
A sequence of messages corresponding to eight Communication Cycles of normal
operation of the same system is shown in Table 4.10.
measurement, respectively. The PDO transmitted by the digital input module contains
two data bytes because the device used in this example has 16 digital input lines. The
switches are connected to the eight least significant of these lines and are mapped on the
first byte of the PDO (in this case switch 2 is selected). The PDO transmitted by the
analogue input device contains eight bytes of data because the device used for this
example has four analogue input channels and each of them takes two bytes in the PDO.
The output of the multiplexor is connected to the first of these channels. Also in every
Communication Cycle, the network manager sends a new multiplexor code to the digital
output module as explained above. Finally, when the switch selected coincides with the
sensor being read (in this case on the second Communication Cycle) a PDO is sent to
the analogue output module updating the temperature value being displayed. The
analogue output module used in this example uses representations for the analogue
values which are compatible with those used by the analogue input module. This means
that the data received from the analogue input module can be sent unaltered to the
analogue output module.
148
CHAPTER 5
CANopen Conformance Testing
Chapter Objectives
When you have completed this chapter you should:
• Understand the purpose of Conformance Testing.
• Be aware of the need for Conformance Testing.
• Know the current status of CANopen Conformance Testing.
• Know the structure of the CANopen Conformance Testing procedures.
• Understand the purpose of each test and how each test will be carried out.
5.1 INTRODUCTION
The CANopen protocol has come a long way since its origin in the European project
ASPIC, and it is taking its final steps towards standardisation, under the control of the
CAN in Automation (CiA) organisation.
At this point, a set of profiles has been produced, that constitutes the CANopen
specifications. It is necessary to ensure that CANopen implementations comply with
these specifications, so that the integrity of the standard can be safeguarded. This
process is called Conformance Testing and it is in this area that much of the work being
done recently on the CANopen protocol is centred.
In Chapter 3 it was established that the CANopen Communication Profile (DS301)
is the central part of the CANopen protocol, as it defines the basic communication
mechanisms that all devices must use and implement in order to communicate.
Additionally, it defines the format of the Electronic Data Sheets (EDS) that should be
provided with CANopen devices, containing information about the features
implemented in the devices, mainly for use with automatic configuration tools. The
Conformance Testing procedures already developed for the CANopen protocol cover
only this central part of the specification.
The Conformance Testing procedures for DS301 were developed by a CiA Special
Interest Group (SIG) established for this purpose. The SIG members are those members
of the CiA that have an interest in the outcome of the activities carried out in the field of
CANopen Conformance Testing.
The results of the work done by the CANopen Conformance Testing SIG were
compiled in a document entitled "Test Description for CANopen Devices" which can be
obtained from the CiA. In short, the issues covered in this document are the following:
• Scope - the document provides a framework for testing conformance to DS301. This
document can also be looked at as a guide for the implementation of a CANopen
Conformance Testing Tool and it was indeed used for this purpose, as will be
discussed further on in this section.
• EDS Test - the document specifies a set of tests to be performed on an EDS file that
must be provided by the manufacturer along with the Device Under Test (DUT).
Since the EDS will be the source of information about the device for automatic
configuration tools (not to mention Conformance Testing Tools themselves), the
testing of this file is as critical as the testing of the device itself.
149
• Device Test - the document specifies a set of tests to be performed on the DUT by a
Conformance Testing tool connected to it through a CANopen network. These tests
refer only to the communication mechanisms defined in DS301.
• CANopen Test Interface - the document states that a CANopen Conformance
Testing Tool must be compatible with different PC/CAN interfaces. This will allow
users to support it with any PC/CAN interface, reducing to a minimum the cost of
the tool. For this to be possible, a standard software interface that will connect the
test tool to the PC/CAN interface is defined. This software will take the form of a
DLL and it will be the only part of the software that depends on the hardware
platform.
The test description produced by CANopen Conformance Testing SIG was used by
the CiA as a basis for the development of a CANopen Conformance Testing Tool. This
tool is now available at the CiA headquarters for official Conformance Testing of
CANopen devices. Manufacturers of CANopen devices can submit their products to the
CiA to obtain Conformance Certification. Additionally, manufacturers can purchase the
official CANopen Conformance Testing Tool from the CiA and use it to detect
implementation errors before submitting their products for official testing.
The authors developed an equivalent set of tools for Conformance Testing of
CANopen devices, as part of a Ph.D. programme at Newcastle University, UK. These
tools perform elaborate testing of the EDS and DUT under Windows 95/98, offering an
intuitive user interface. They can be very useful for pre-conformance testing by the
vendors and manufacturers of CANopen products during the development of their
implementations.
The following sections contain a thorough description of what, according to the
authors' experience, is expected of a conformant CANopen implementation. This
description provides a generic view of these requirements, and it is structured in such a
way that the scope of the tests is emphasised.
described in the following sections. The EDS Conformance tests are divided in three
groups:
• Completeness Tests - these tests aim to check whether the structure of the EDS file
is correct. These tests must be passed before any other analysis of the EDS can be
performed.
• Value Ranges Tests - these tests check whether all the entries in the EDS have
values that are within the value range defined in DS301 for the parameters that they
describe.
• Consistency Tests - these tests check all the cross-references within the EDS file. It
is clear that for these tests to be performed it is required that all the previous ones
must have been passed.
The keywords allowed in the FileInfo section are shown in Table 5.1.
151
The keywords allowed in the DeviceInfo section are shown in Table 5.2.
The keywords allowed in the StandardDataTypes section are shown in Table 5.3.
The keywords allowed in the DummyUsage section are shown in Table 5.4.
The keywords allowed in a section of the type <Index> where the SubNumber
keyword does not appear or has a value of 0 are shown in Table 5.5.
The DefaultValue, HighLimit and LowLimit keywords are not allowed on sections
where the DataType is larger than 8.
The keywords allowed in a section of the type <Index> where the SubNumber
keyword has a value greater than 0 are shown in Table 5.6. In this case, the object is
represented in the EDS by the section being analysed and by one or more sections of the
type <Index>sub<Sub-index>.
Again, the DefaultValue, HighLimit and LowLimit keywords are not allowed on
sections where the DataType is larger than 8.
In the sections Mandatory Objects, OptionalObjects, ManufacturerObjects the
keywords that are allowed depend on the value of the entry SupportedObjects, which is
a mandatory entry in all of these sections. The absence of this keyword (or an invalid
value for this keyword) in any of these sections makes it impossible for the remainder of
the contents of the section to be tested. The valid range for the SupportedObjects
keyword is an integer value between 0x0 and 0xFFFF. When a valid value is found, this
value defines the set of other valid keywords for that section. These keywords are
mandatory and they are of the form <value> where value is an integer number in
decimal representation starting on the value 1 and ending on the value specified in the
SupportedObjects keyword. Obviously if the SupportedObjects entry has a value of 0,
the set of valid keywords is composed only of the SupportedObjects keyword.
The set of valid keywords for the MandatoryObjects, OptionalObjects and
ManufacturerObjects sections is summarised in Table 5.8.
The Comments section works in a similar way to the previous sections: there is a
mandatory keyword, in this case the keyword Lines, with a range of 0x0 to 0xFFFF,
which defines the remaining mandatory keywords of the section. Here, the keywords are
of the format Line<value> and, again, if the Lines entry has a value of 0, no other entry
is allowed in this section.
The set of valid keywords for the Comments sections is summarised in Table 5.9.
The legal range for entries of the type <value> in the sections MandatoryObjects,
OptionalObjects and ManufacturerObjects and <Index>ObjectLinks depends on the
actual section. This is shown in Table 5.12.
154
The ranges for the HighLimit and LowLimit entries depend on the actual data type
of the object. This is shown in Table 5.13. It is also important to keep in mind that the
value of the HighLimit entry cannot be lower the value of the LowLimit entry.
Finally, the range of the DefaultValue entry is set by the HighLimit and LowLimit
entries. When they are not present, the range set by the data type of the object (Table
5.13) applies.
• Finally, the AccessType entry of the referenced section will be checked. In the case
of receive PDOs, valid values for the access type are wo and rww.
The PDO Mapping parameters for transmit PDOs are stored in Indexes ranging from
1A00H to 1BFFH. Each object in this range will be subjected to a test which is similar
to the one described for the receive PDOs. The only difference lies in the test that is
performed on the value of the AccessType entry of the referenced sections. In this case,
the valid values are ro and rwr.
In this section the Device tests will be thoroughly described. All Device tests are
performed sequentially but before each test is initiated the node has to be reset. This can
be achieved by using the NMT Module Control services and it is the only way to ensure
that each test is initiated with the DUT at a well-defined state.
Throughout the description of the Device tests, whenever the Start Remote Node,
Stop Remote Node, Enter Pre-operational State, Reset Communications and Reset Node
protocols are referred to be used, without any other information, it means that the DUT
will be individually addressed using the Node ID parameter. Whenever global
addressing is to be used (Node ID = 0) this will be specifically mentioned in the
description of the tests.
The Device tests are divided into the following eight groups:
• Protocol Verification Tests - these tests aim to verify the correct implementation of
the basic CANopen communication mechanisms: PDOs and SDOs.
157
• Object Dictionary Tests - these tests aim to verify the implementation of the DUT's
Object Dictionary against its EDS and against the CANopen specification.
• Parameter Storage/Restorage Test - these tests aim to complement the Object
Dictionary Tests by verifying features that were left unchecked. In particular, these
tests target the Object Dictionary entries associated with the storage and restorage of
parameters.
• Emergency Tests - these tests aim to verify the implementation of the Emergency
Object and associated Object Dictionary entries.
• Error Control Tests - these tests aim to verify the implementation of the NMT Error
Control mechanisms and associated Object Dictionary entries.
• Synchronisation Tests - these tests aim to verify the implementation of the
Synchronisation Object and associated Object Dictionary entries.
• Verification of Network States - these tests aim to verify the implementation of the
NMT Slave state diagram defined in DS301. In particular, these tests check that the
functionality of the device within each state complies with the standard.
• Verification of State Transitions - these tests aim to verify the implementation of the
NMT Slave state diagram defined in DS301. In particular, these tests check that the
transitions between network states are correctly implemented.
The tests are independent of each other, in such a way that they can be performed in
an arbitrary order. For this to be possible, it was necessary to make the test procedures
redundant in the sense that some of them overlap in their scope.
protocol is tested or no more entries remain. Any errors that are found will be signalled
to the user. The same procedure used to test segmented SDO transfers is then used to
verify block SDO transfers.
For the previous SDO read operations, the default communication identifiers,
defined in CANopen, will be used. The message identifier used for the Client-to-Server
message is equal to 1537+(NODE ID-1). The message identifier used for the Server-to-
Client message is equal to 1409+(NODE ID-1). Throughout the testing of the DUT,
whenever SDO transfers are performed, these identifiers will be used.
Apart from the errors described above, the following SDO protocol errors will also
have to be detected and signalled during this test:
• SDO Response Time-out - the DUT failed to issue a response using the Server-to-
Client identifier within the time period defined by the SDO Timeout parameter
specified for the DUT.
• SDO Protocol Error - the DUT did issue a response, however, this response is not
compliant with the CANopen standard. The protocol errors that will be detected by
the test tool are: more than one SDO responses received, wrong Index or Sub-index,
unknown Server Command Specifier and SDO messages with less than 8 bytes. In
the case of segmented or block SDO transfers there are additional protocol errors
that can occur, such as errors concerning the toggle bit and the size of the data.
These will all be indicated as protocol errors.
Throughout the remainder of this test and the execution of all other tests, whenever
a SDO transfer is performed, time-out errors and SDO protocol errors will have to be
continuously monitored for and they will be signalled when they occur.
Finally, the SDO test will terminate with a verification of the implementation of
other Server SDOs supported by the DUT. If the SDO Communication Parameters of
other Server SDOs are found in the Object Dictionary of the DUT (if they exist, these
parameters will reside in the Index range 1201H to 127FH) the test tool will try to
configure these SDOs with suitable CAN message identifiers. In this case, the
identifiers used in each SDO link must be different from the default message identifiers
allocated to the DUT for SDO communication to prevent conflicts with the mandatory
Server SDO. In cases where the Server SDO configuration is successful, an attempt will
be made to read a mandatory Object Dictionary entry using the newly established SDO
link. Any errors that are found will be signalled to the user.
requirements is found. In CANopen it is specified that the only transmit PDOs that may
be active by default will be located at indexes ranging from 0x1800 to 0x1803. When
this is proved, the DUT will be put to Operational state by means of a Start Remote
Node NMT message. Finally, an RTR message with the identifier used by the detected
PDO will be sent to the DUT. Assuming no CAN errors occur, one of two events will
bring the PDO Test to an end. Either a PDO is received correctly, in which case no error
will be signalled, or a time-out is detected, meaning that the DUT failed to reply within
the PDO Time-out specified for the DUT, in which case a time-out error will be
signalled.
The following steps in the test will only be performed if the PDO Mapping
Parameter has an access type of rw, meaning that it can be altered:
• The tool will attempt to write a new valid mapping for the PDO e.g. the default
mapping but reversing the order of the mapped objects. If this operation does not
160
succeed, an error will be reported to the user. Additionally, the tool will try to write
one mapped object too many to the entry. If the operation is successful, an error will
also be reported.
• Next, the tool will check if the DUT accepts mappings that are too long. This will be
done in two ways. The first way is to write to Sub-index 0 a value larger than 64,
meaning that there would be more than 64 mapped objects, which is not permitted.
If the DUT accepts the value, an error will be signalled. The second way is to map
onto the PDO a set of objects that take more than the 64 bits that are permitted. If
the mapping is accepted, an error will be signalled.
• The next step in the PDO Mapping test will be to try to map an Object Dictionary
entry with Access Type rwr onto the receive PDO, which is not permitted. For this
purpose, the tool will go through the EDS file looking for an entry suitable for
mapping that meets this requirement. If such an entry is found, an attempt will be
made to map it onto the PDO. If the operation succeeds, an error will be signalled.
• Finally, the test will terminate with the tool trying to map onto the PDO a
nonexistent Object Dictionary entry. If the mapping is accepted, an error will be
signalled.
For entries in the range corresponding to transmit PDO mappings, the test
performed will be very similar to the one just described. The only difference lies in the
fact that the tool will attempt to map onto the PDO an entry with access type rww
instead of an entry with access type rwr.
default values of the entries that hold the default communication identifiers
allocated to the device are also verified.
• When writing is not permitted in a particular entry (access types ro or const), an
attempt will be made to perform a SDO write operation to it e.g. using the data
previously read. If the transfer is not aborted, an error will be signalled to the user.
• Finally, if writing is permitted to a particular entry and if one or both of the
HighLimit or the LowLimit values are indicated in the EDS file these must also be
tested. For example, these values can be written to the object and, if any of the
transfers is aborted, an error can be indicated to the user.
it. If the transfer is aborted or any other error occurs, an error will be signalled to the
user.
The test previously described will then be repeated for Sub-index 2 at Indexes
1010H and 1011H. The storage and restorage functionalities accessible through these
entries apply to parameters in the Communication Profile area of the Object Dictionary
only.
• At this point, the test tool will activate the Heartbeat protocol by writing a non-zero
value to Index 1017H in the DUT's Object Dictionary. The reception of a Heartbeat
message is then verified by the test tool, to ensure that the Heartbeat protocol is
operating properly.
• Finally, the test will be terminated with an attempt to activate the Life-guarding
protocol. For this purpose, the Guard Time and Lifetime Factor entries are written
with valid, non-zero, values. This should not affect the Heartbeat protocol and, for
this reason, the test tool then verifies that this protocol is still operating properly.
Finally, for devices that indicated in the data retrieved from Index 1005H that they
may operate as Synchronisation Object Producers, the test will proceed with the
following steps:
• The test tool will use a SDO transfer to configure the Communication Cycle Period
parameter (Index 1006H) to 100 milliseconds.
• The production of the Synchronisation Object will be initiated through the
functionality of Index 1005H.
• The test tool will verify that the Synchronisation Object is received at the correct
rate, within a given tolerance e.g. 20%.
166
Again, the test of the functionality of the Stopped state is almost identical to the Pre-
operational test, therefore a detailed description of this test is not necessary. In short, the
test consists of the following procedure:
• The DUT will be initially reset using the Reset Node service.
• The state of the DUT will be tested using the NMT Error Control protocols to verify
that it is in Pre-operational state.
• The tool will look for an active transmit PDO in the DUT in the same way as in the
Pre-operational test.
• The DUT will be moved to Stopped state using the Stop Remote Node service.
• The mandatory object at Index 1000H will be read and, if the transfer is successful,
this will mean that the SDOs are operating correctly in Stopped state, indicating a
faulty implementation. SDOs must be off-line in the Stopped state.
• The state of the DUT will once again be tested to verify that it is in Stopped state.
• If an active transmit PDO was found in the device, the transmission of that PDO
will be requested and a successful response will indicate a faulty implementation.
PDOs must be off-line in the Stopped state.
Finally, the test of the functionality of the 'Reset' state is also similar to the Pre-
operational state test. There is, however, a difference in that what is being tested is not a
formal network state but, in fact, the restoration of the default status of the device after
it is reset. As before, a detailed description of this is not necessary. In short, the test
consists of the following procedure:
• The DUT will be initially reset using the Reset Node service.
• The state of the DUT will be tested using the NMT Error Control protocols to verify
that it is in Pre-operational state.
• A well-defined set of Object Dictionary entries will be written with non-default
values; if one or more of the transfers are aborted, meaning that the entries are not
supported, the entries are ignored. These entries and the non-default values that are
used for this purpose are shown in Table 5.15. From this Table, it is possible to
verify that one of the modified entries will be the object at Index 1014H, which
holds the COB-ID Emergency Object parameter.
• The DUT will be reset using the Reset Node protocol.
• The test tool will verify the state of the DUT and it is expected that the DUT reports
that it is in Pre-operational state.
• The tool will verify that the default values for the entries that were previously
accessed have been restored: it will perform the required SDO read operations and
compare the read values with the default ones. Any errors or discrepancies will be
signalled to the user.
Table 5.15 Object Dictionary entries used for the State 'Reset' test
Object Dictionary Entry Default Value
Index 1005H 128
Index 1006H 0
Index 1007H 0
Index 1012H 256
Index 1014H 128+Node ID
168
Throughout the Verification of State Transitions tests, the state of the DUT must be
monitored using the Node Guarding protocol and/or the Heartbeat protocol depending
on the services implemented on the device. In the following tests, whenever a state
monitoring is required, the test tool will first try to use the Node Guarding protocol and
then the Heartbeat protocol. Throughout the tests, any errors found in these protocols
will be signalled to the user.
The first step in the transition to Pre-operational state will be to reset the node using
the Reset Node service. The test proceeds, using the NMT Error Control protocols to
verify the state of the DUT, and it is expected that the DUT will report that it is in Pre-
operational state. Any other response will mean that an error exists in the protocol
implementation.
After this, the DUT will be moved into Operational state by the test tool, using a
Start Remote Node message. This transition will be verified using the NMT Error
Control protocols once again. The DUT is expected to report that it is in Operational
state.
The next step will be to return the DUT to Pre-operational state using an Enter Pre-
operational State message. This transition will again be verified using the NMT Error
Control protocols. The DUT is now expected to report that it is in Pre-operational state.
The DUT will then be moved into Stopped state using a Stop Remote Node
message. This transition will once more be verified using the NMT Error Control
protocols. The DUT is expected to report that it is in Stopped state.
Finally, the test tool will move the DUT back into Pre-operational state using the
Enter Pre-operational State command. This final transition will again be verified using
the NMT Error Control protocols. The DUT is expected to report that it is in Pre-
operational state.
The transitions to Pre-operational state will not be completely tested until the
response of the DUT to global addressing in the NMT commands is considered. This
issue is addressed in the remainder of the test: first the DUT will be reset using the
Reset Node command, addressed to all nodes (Node ID = 0), and then the test
previously described is repeated using also global addressing.
The Transition to Operational and Transition to Prepared states tests are very similar
to the Transition to Pre-operational test: the DUT is moved from state to state using the
appropriate CANopen services and its state is monitored using the NMT Error Control
protocols. The procedure for these tests is summarised in Table 5.16 and Table 5.17.
169
Finally, the Transition to Reset test differs slightly from the previous ones, even
though the principles of the test procedure are the same. This procedure is summarized
in Table 5.18. It is important to keep in mind that each transition is verified using the
NMT Error Control protocols.
functionality to the test tool. The development of this DLL is not a complex task,
requiring only a basic knowledge of CAN and of the CAN hardware in question and a
bit of programming.
• COTI_ReadCanStatus - this function can be used by the test tool to monitor the
status of the CAN hardware e.g. if messages have been lost, what is the error status
of the CAN controller, etc.
• COTI_ReadObj - this function can be used by the test tool to retrieve a message
with a particular identifier from the receive queue.
• COTI_TransmitObj - this function can be used by the tool to transmit a message.
• COTI_RequestObj - this function can be used by the test tool to transmit a RTR
message and retrieve the data returned in the response, if a response is received.
• COTI_SetTimeout - this function can be called by the tool to wait for a specified
time delay to elapse. It is used to implement time-out mechanisms.
For a more detailed description of the technical aspects of the C.O.T.I., refer to the
CANopen Conformance Testing specification.
172
CHAPTER 6
Example of a CANopen Implementation
Chapter objectives
When you have completed this chapter you should:
• Know what is a digital I/O module.
• Understand the hardware requirements of a simple digital I/O module.
• Understand the structure of a typical CANopen implementation.
• Know how message transmission is handled in a typical CANopen implementation.
• Know how message reception is handled in a typical CANopen implementation.
• Understand how an Object Dictionary is implemented in a typical CANopen
implementation.
• Understand how synchronous and asynchronous PDOs can be implemented.
6.1 INTRODUCTION
CANopen, based on the popular Controller Area Network (CAN) represents an ideal
networking system for distributed control systems and overcomes some of the
limitations inherent to other network protocols. In order to understand the
implementation of CANopen on devices, an example is given in this chapter which
should aid field engineers to implement CANopen on their own devices. This example
covers a digital I/O implementation.
Often, in industrial automation environments, sensors and actuators have to be
placed at geographically remote locations. It is common for devices of these types to be
located at considerable distances from the processing units that use them to carry out a
particular task. When this is the case, a possible solution, and one that is gaining
increasing popularity, is to use an autonomous I/O module, located close to the sensors
and actuators, providing the application with an interface to these devices. For this to be
possible, the application must be distributed between the remote I/O module and the
local processor(s), by using a communication network such as CANopen, to allow the
different parts to co-operate.
This example describes the development of a CANopen I/O module based on the
SAB-C167CR-LM chip from Siemens. The device is able, on one hand, to interface
with sensors and actuators using digital signals and, on the other hand, to communicate
using the CANopen protocol. In other words, the I/O module makes sensors and
actuators accessible via the CAN bus, using the CANopen protocol (Figure 6.1). The
objective is to show that CANopen can be implemented over new hardware platforms,
in minimum time, with satisfactory results.
173
that permit access to the embedded peripherals. The embedded XRAM provides
2Kbytes of additional on-chip memory. It is
• connected to an internal XBUS and therefore it is accessed as external memory.
• The interrupt system of the C167 is based on a multiple priority interrupt manager.
Interrupt sources may be freely prioritised and they can also be grouped. This allows
the user to prevent interrupt routines of the same priority from interrupting each
other. Each of the possible interrupt sources has a dedicated vector location that
holds the address of the corresponding interrupt service routine. Additionally, each
interrupt source has a dedicated interrupt control register.
• The C167 provides up to 111 parallel I/O lines. These lines may be used for general
purpose I/O, by the integrated peripherals or for the external buses. The operation of
the I/O pins is configurable by accessing dedicated Special Function Registers.
• The C167 has two general-purpose timer units that can be used for timing, event
counting, pulse width measurement and other functions. The first timer unit contains
three timers/counters while the second unit contains two timers/counters and a 16-
bit capture/reload register. Each timer can operate independently or may be
concatenated with another timer of the same unit. There are three Special Function
Registers associated with each timer, which provide access to timer data, timer
control and timer interrupt control.
In addition to these features, and perhaps most important of all for the purpose of
this application, is the fact that the C167 carries an embedded CAN controller.
This integrated CAN controller is capable of handling the transmission and
reception of CAN frames according to the CAN Specification 2.0 i.e. it is able to handle
standard frames (11-bit identifiers) as well as extended frames (29-bit identifiers). It
provides Full CAN functionality on 15 message objects i.e. the filtering can be
performed exclusively by the controller. Moreover, Message Object 15 can also be
configured for Basic CAN functionality i.e. several messages can be accepted and the
remaining filtering done by software. All message objects work independently and can
be manipulated without influencing one another. Each of the message objects has a
unique identifier and its own set of control and status bits.
The CAN controller contains a memory area that provides storage for the 15
message objects and for the global CAN module control and configuration registers.
This memory space is accessible to the CPU (mapped onto the CPU's memory space),
behaving as a dual-port memory area.
The registers that can be used for the general control of the CAN controller are:
• Control Register - this register allows the CPU to put the controller in an
initialisation state, to enable CAN interrupts or perform other control functions.
• Status Register - through this register, the CPU is able to monitor the status of the
controller.
• Bit Timing Register - this register allows the CPU to program the temporal
properties of the frames in the CAN bus.
• Mask Registers - using the two global mask registers, it is possible to control which
message identifiers are accepted by the controller. These registers establish which
bits in the identifiers are relevant for message filtering in all message objects.
175
As mentioned above, in addition to the latter registers, the CPU has also available in
its memory space 15 message objects. Each message object is composed of eight data
bytes, an arbitration register and two control and configuration registers (Figure 6.3).
The Message Control Register is used to act upon each message object (request
transmission, activate object, deactivate object, etc.) as well as to monitor the message
object's status (interrupt pending, new data, etc.). The Message Configuration Register
is used to establish the direction of the message object and to set/get the number of data
bytes in the message. The Arbitration Register plays different roles in transmit and
receive objects: in transmit objects the Arbitration Register holds the message identifier
to be transmitted; in receive objects the Arbitration Register is used for acceptance
filtering.
Since the CAN module is connected to the microcontroller as an X-peripheral, it is
able to interrupt the CPU via a reserved vector called XPO (external Peripheral 0). This
vector is similar to other interrupt vectors in the microcontroller, and it is programmed
via a register called XPOIC.
The on-chip CAN module of the C167 does not incorporate the Physical Layer for
connection to the CAN bus. This must be provided externally by a transceiver.
The four pull-down resistors connected to pins POL.6, POL.7, P0H.1 and P0H.4 are
used to inform the C167 during system reset of the hardware configuration that it will
be operating in.
The twenty pins of the I/O connector are divided into two 10-pin functional blocks
that carry out input and output functions, respectively.
The first ten pins of the connector are assigned to the eight input lines (pins 1 to 8),
ground (pin 9) and VCC (5 V at pin 10). The upper half of the I/O connector is assigned
to the eight output pins (pins 11 to 18) and ground (pin 19). The output lines from the
microcontroller (Port 7) are not connected directly to the external connector. Instead, the
output signals are fed through a current buffer (the 74LS244 chip in Sheet 1), which is
able to supply up to 50mA of DC current in each output line.
Each of the blocks in the diagram will be explained in the following sections,
however, it is important to explain, first of all, how the program works in practice.
Three routines form the basis for the operation of the whole module:
• main() - this is the main procedure of the software, and it controls the global flow of
the program. It basically consists of a while loop in which all aspects of the module's
operation are monitored so that appropriate action is taken as soon as the module's
status changes. A status change can happen due to a modification in the state of the
input lines, due to the occurrence of an internal error or due to the reception of
CANopen data-transfer messages or NMT requests.
• CAN_int( ) - this is the interrupt service routine for the CAN controller. It is
invoked every time an event occurs on the CAN controller. This, in general,
corresponds to the reception of a message that requires processing. This routine
interprets incoming messages and passes them to the appropriate software functional
block by storing them in a memory buffer. This routine also handles autonomously
most of the Node Guarding protocol.
• Tx_serv_int( ) - this is the interrupt service routine for Timer 3 in the
microcontroller, which is programmed to produce an overflow interrupt roughly
every 50ms. Every time such an interrupt occurs, this routine checks the
transmission buffers which connect this part of the software to all of the software's
main functional blocks, and transmits any pending messages as soon as possible.
In short, virtually all tasks related to the exchange of CAN messages are performed
by these two interrupt service routines, which interface with the remaining software
through receive and transmit memory buffers, supported by a set of status flags.
180
6.4.2.1 Initialisation
After 'power on', the module enters its initialisation phase, under the supervision of
the main() module. The following tasks are carried out in this phase:
• Setting of the CAN controller's global configuration. One of the features that must
be configured is the baudrate, which is selected according to the value hardwired in
the configuration jumpers. Baudrate values of 1Mbit/s, 500Kbit/s, 250Kbit/s,
100Kbit/s and 20Kbit/s can be selected by changing the hardwired value from 0 to
4.
• Initialisation of all the message buffers that permit the functional blocks to
communicate with the transmit and receive interrupt service routines.
• Initialisation of the Emergency Object parameters setting the error record to a 'no
error' status.
• Initialisation of an 'inputs-changed' event detector so that event PDOs can operate
properly.
• Configuration of the microcontroller's interrupt service system.
• Initialisation of the Timer 3 system so that the corresponding interrupt service
routine is invoked every 50ms.
• Initialisation of the microcontroller's I/O ports to function as inputs or outputs.
181
When the initialisation procedure is terminated, and just before entering the Pre-
operational state, the implementation automatically carries out the Boot-up Service
protocol. This protocol consists simply in the transmission of a message with the
identifier reserved for the Node Guarding messages and carrying a single byte of data
with a null value. Message object 1 in the CAN controller is used for this purpose.
• Start Remote Node (NMT Command Specifier 1) - this service moves the module
from the Stopped or Pre-operational state to the Operational state.
• Stop Remote Node (NMT Command Specifier 2) - this service moves the module
from the Operational or Pre-operational state to the Stopped state.
• Enter Pre-operational State (NMT Command Specifier 128) - this service causes the
module to leave the Operational or Stopped state and enter the Pre-operational state.
• Reset Node (NMT Command Specifier 129) - this service causes the device to
perform a full hardware and software reset.
• Reset Communication (NMT Command Specifier 130) - this service causes the
device to return to its default communication configuration.
using only one message exchange. Since in this module, all Object Dictionary
entries take no more than 4 bytes, only this expedited transfer mode is implemented.
• Initiate SDO Download - this service is used to perform write operations to the
Object Dictionary. For the same reason as before, only the expedited protocol is
supported.
Additionally, the service Abort SDO Transfer is also supported by the device. This
service permits the module to signal an error in the data transfer protocol. For example,
when a received SDO message contains an unrecognised request Command Specifier,
an Abort SDO Transfer message is sent to the Client carrying an error code that
indicates that a 'service parameter with an invalid value' has been detected.
In the following sections, the Object Dictionary implemented in the device will be
presented, followed by the procedure adopted when performing Object Dictionary
accesses.
All the mandatory Object Dictionary entries and some of the optional ones defined
in the CANopen Communication Profile and in the Device Profile for I/O modules are
implemented. Further information about all entries can be found in these specifications.
The reason why the PDO001 entries are used for the event PDOs is because this is
specified as mandatory in the Device Profile for I/O modules. For the same reason, the
PDO002 entries are left unused, since they are reserved for Analogue I/O
functionalities.
185
the device's functionalities are mapped in the data bytes of the data frame. This mapping
is available in the Object Dictionary, and it may or may not be changeable (in this case
it is fixed).
In the particular case of a Digital I/O module, the mandatory PDOs must map the
values of the I/O lines. Therefore, in this implementation, the first byte in the
receive PDO data frames is mapped onto the eight output lines. On the other hand,
the first byte in the transmit PDO data frames is mapped onto the eight input lines.
In practice, when an event PDO is received, the CAN interrupt service routine
retrieves the first data byte from the data frame, and places it in a memory buffer. In
Operational state, this memory buffer is permanently monitored and when it is full, the
data byte in it is picked up and sent to the digital output lines.
Transmit event PDOs work in a different way. Their transmission is triggered by the
occurrence of an event internal to the module. The event that triggers the transmission
of an event PDO is the detection of a change in the values of the input lines. When such
an event is detected the new value of the input lines is placed in a memory buffer, so
that it can be transmitted the next time the timer interrupt service routine is invoked.
These mechanisms will only operate if the PDOs are enabled in the corresponding
Object Dictionary entries. The start-up configuration defined by CANopen for I/O
modules enables the default PDOs.
• Byte 3 holds an application specific error code that specifies the error that has been
detected, as will be explained below.
• The remaining bytes hold additional application specific information about the error
condition, such as the number of errors that have to be reported and the state of the
device.
In this particular module, the possible sources for internal errors are:
• SDO OVERRUN - this error is signalled when an SDO message is received before
the previous one has been processed. In this case, the application specific error code
is 4.
• COMMUNICATION ERROR: CAN BUS-OFF - this error is signalled when the
CAN interrupt service routine is invoked due to the CAN controller entering the
bus-off state. In this case, the application specific error code is 12H.
The Emergency Object is represented in the Object Dictionary by three entries: the
Error Register, the Pre-defined Error entries and the COB-ID Emergency Object entries.
188
APPENDIX 1
Circuit schematics
189
190
Glossary
BSP Bit Stream Processor JIT Just In Time
References
Barbosa M, Farsi M and Carvalho A [1998] "Implementation of a CANopen Digital I/O
Module Based on the SAB-C167CR-LM", Proceedings of IECON'98, Aachen,
1998.
Barbosa M, Farsi M and Ratcliff K [1998] "CANopen Implementation Made Easy",
Department of Electrical & Electronic Engineering, University of Newcastle upon
Tyne, 1998.
CiA [1996] "CAN - A Serial Bus System Not Just For Vehicles", CAN in Automation
Organisation, 1996.
CiA DS-102 [1994] "CAN Physical Layer for Industrial Applications", CAN in
Automation Organisation, 1994.
CiA DS-201 [1996] "CAN Reference Model", CAN in Automation Organisation, 1996.
CiA DS-202 to DS-207 [1996] " CAN Application Layer Specification", CAN in
Automation Organisation, 1996.
CiA DS-301 [1996] "CANopen Communication Profile for Industrial Systems", CAN
in Automation Organisation, 1996.
CiA DS302 [1998] "Framework for Programmable CANopen Devices" CAN in
Automation Organisation, 1998.
CiA DS-401 to DS-406 [1996] "CANopen Device Profiles", CAN in Automation
Organisation, 1996.
Farsi M [1993] "Flexible and Reliable Robotics Cells in Factory Automation",
Proceedings of the IEEE International Conference on Systems, Man and
Cybernetics, Le Touquet, France, pp 520-525, 1993.
Farsi M [1994] "Flexible Robotics Cells in Factory Automation: Communication
Concept", 3rd IEEE Conference on Control Application, CSS 94, Glasgow, UK,
pp. 1763-1768, 1994.
Farsi M [1995] "A Production Cell Communication Model In Factory Automation
Using The Controller Area Network", Proceedings of XII International
Conference On Systems Science, Wroclaw, Poland, pp 90-95, 1995.
Farsi M [1996] "Open Communication Solutions, CANopen", Proceedings of
Fieldbuses and Communications for Drives and Motion Control, Drives and
Control 1996 Exhibition & Conference, Telford, UK, pp 27-32, 1996.
Farsi M [1997] "An introduction to CANopen and profiling", IEE Workshop on
CANopen Implementation, IEE, Savoy Place, London, UK, 1997.
Farsi M, Booth R and Ratcliff K [1994] "Device Communication For Flexible
Manufacturing: A New Concept", Ninth International Conference on System
Engineering, Coventry Poly., UK, pp 328-334, 1994.
Farsi M and Ratcliff K [1996] "CANopen, Configure Device Testing", Proceedings of
FieldComm Conference 96, Hinckley Island Hotel, Leicester, UK, 1996.
192
Farsi M and Ratcliff K [1997] "CANopen: Conformance and Device Testing" ICSE'97,
Coventry University, UK, pp 242-247, 1997.
Farsi M and Ratcliff K [1997] "Introduction to CANopen and implementation",
CANopen Workshop, IEE, Savoy Place, London, UK, 1997.
Farsi M, Ratcliff K and Barbosa M [1999] "An Overview of Controller Area Network",
Computing and Control Engineering Journal, Volume 10, Number 3, IEE, 1999.
Farsi M, Ratcliff K and Barbosa M [1999] "An Introduction to CANopen", Computing
and Control Engineering Journal, Volume 10, Number 4, IEE, 1999.
Gerhard Gruhler [1993] "Bus selection procedure", Aspic Project - Report D2, STA
Rutlingen, Germany, 1993.
Halsall F [1996] "Data Communications, Computer Networks and Open Systems", 4th
Edition, Addison-Wesley, 1996.
Hewlett Packard [1998] "HCPL-7710, HCPL-0710 40ns Propagation Delay, CMOS
Optocoupler, Datasheet", Hewlett Packard, 1998.
Intel [1995] "8x196 Microcontroller Family, Datasheet", Intel, 1995.
ISO7498 [1984] "Information Processing Systems - Open Systems Interconnection -
Basic Reference Model", ISO, 1984.
ISO 11898 [1993] "Road Vehicles, Interchange of Digital Information - Controller Area
Network (CAN) for high-speed Communication", ISO, 1993.
McLaughlin R [1997] "Introduction to CAN", CANopen Workshop, IEE, Savoy Place,
London, UK, 1997.
Monk F [1997] "Producer/Consumer the New Network Paradigm", Fieldcomms UK '97
Conference, Hanover International Hotel, Leicestershire, UK, 1997.
Motorola [1996] "MC68HC05X4, MC68HC705X4 Technical Data, Datasheet",
Motorola, 1996.
Philips [1996] "P8x592 8-bit microcontroller with on-chip CAN, Datasheet", Philips
Semiconductors, 1996.
Philips [1997] "PCA82C250 CAN Controller Interface, Datasheet", Philips, 1997.
Robert Bosch GmbH [1991] "CAN Specification 2.0", Robert Bosch GmbH,
1991.
Ratcliff K and Farsi M [1997] "A low cost configuration tool for CANopen networks",
CAN Newsletter, Department of Electrical & Electronic Engineering, University
of Newcastle upon Tyne, 1997.
Ratcliff K and Farsi M [1997] "Implementation of CANopen on Optimised Control
Motion Controller", Department of Electrical & Electronic Engineering,
University of Newcastle upon Tyne, 1997.
Ratcliff K and Farsi M [1998] "Implementation of CANopen in PCs, Nextmove on
Optimised Control Motion Controllers", Department of Electrical & Electronic
Engineering, University of Newcastle upon Tyne, 1998.
193