Sei sulla pagina 1di 8

CAN FOR CRITICAL EMBEDDED

AUTOMOTIVE NETWORKS
THE CONTROLLER AREA NETWORK PROTOCOL OFFERS FLEXIBILITY IN SAFETY-

CRITICAL AUTOMOTIVE SYSTEM DESIGN. THE BENEFITS OF USING ALREADY

ESTABLISHED SPECIFICATIONS WILL AID AUTOMOTIVE SYSTEM DESIGNERS IN

X-BY-WIRE DEVELOPMENT.

Over the past decade, electronic sys- bus guardians, the industry has looked at
tems have gradually replaced mechanical ones other protocols such as the time-triggered pro-
in cars and trucks. The forces driving this tocol (TTP)3 and FlexRay.4
replacement have mainly included environ- However, a better solution might be to use
mental demands that require advanced elec- CAN as a base and then add missing facilities
tronic engine and driveline control in addition as needed. This technique, in contrast to tra-
to reduction of wire-harness size. In the mid- ditional layered communication services,
1980s, Bosch and Intel developed a serial net- would lead to a more flexible architecture in
work protocol, called controller area network which the communication would be inte-
(CAN),1 and implemented this in silicon grated into the control system. Then the vast
chips for supporting hardware. The CAN pro- practical experience gained from using the
tocol transfers information between electron- CAN protocol for more than a decade in dif-
ic control units (ECUs) in vehicles. In the ferent environments and applications could
early 1990s, Mercedes was the first company be leveraged to provide better services.
Lars-Berno to introduce CAN in standard cars. Since
then, the CAN protocol has proved to be an General concept
Fredriksson inexpensive, robust solution for automotive The starting point for discussing the com-
control networks and is now well established munication between ECUs in a distributed
Kvaser and used in all types of vehicles. embedded control system (DECS) must be
So far, however, only non-safety-critical sys- the system architecture. Predicting response
tems, with few exceptions, use CAN. Now, time from an event detected in one module
the automotive industry intends to use net- until the response action in another module is
work technologies for safety-critical tasks such an important requirement in safety-critical
as steer-by-wire and brake-by-wire, often sum- systems. Thus, ECU communication is not a
marized as X-by-wire. It is a common opinion stand-alone entity but an integrated part of a
among controller network specialists that such real-time operating system at the system level.
systems should be time-triggered rather than For the solution proposed in this article, I have
event-triggered and that ECU access to the made some assumptions about features need-
communication bus must be supervised and ed to meet these requirements:
controlled by specific entities, called bus
guardians.2 Because CAN does not offer sup- • Any communication in the system must
port for time-triggered message transfer or for be predefined.

28 0272-1732/02/$17.00  2002 IEEE


• The communication must be time sched- chance of meeting the dependability require-
uled during normal conditions. ments of safety-critical systems.
• The time schedule must accept event-
triggered emergency messages. Event-triggered emergency messages
• The communication must have an event- The time schedule must accept event-trig-
triggered schedule as a backup. gered emergency messages, which are a big
• There must be a clear separation between problem in time-scheduled systems. Emer-
the system level and the module level gency messages do not typically appear during
regarding failure detection and actions normal conditions, but when they must be
on failures. transmitted, their latency time must be short.
• It must be possible to update the proto- If they are a part of the schedule, they occupy
col at any time during the system’s life a substantial portion of the bandwidth that
cycle. could be more effectively used. A much more
efficient approach is to transmit regular mes-
Predefined communication sages on time schedules and emergency mes-
In a DECS, unlike a LAN or telecommu- sages on events. CAN makes such an
nication system, any need for communication approach possible.
must be known and defined a priori. Differ-
ent ECUs can respond only to known mes- Event-triggered schedule as a backup
sages and can transmit only those messages The weakness of a pure time-scheduled sys-
that they are programmed to transmit, and tem is the clock. If one node is not time syn-
the system uses the message contents. LAN or chronized with the other nodes in the system,
telecom systems do not know any communi- the system behavior is unpredictable. It is easy
cation and any message contents in advance to detect a time-keeping failure, but such fail-
of system design, and the system does not use ures are not always easy to rectify. A more
these contents. In these systems, in which robust approach when trying to fix a time-
communication functions as a service of the keeping problem is to switch to graceful
different network nodes, the communication degradation by changing from the time-trig-
service might not be available sometimes gered schedule to an event-triggered backup
because the demand is stochastic. A DECS schedule.
must be designed in accordance with the
worst-case reaction times for different events, System and module separation
at least for safety-related operations. Although CAN itself and some current
CAN-based protocols, including SAE J19395
Time-scheduled communication and NMEA 2000,6 were initially developed to
The timing of the actions in collaborating be system independent and should not require
ECUs depends on message delays. Although any system designer, in practice, there are sev-
it is possible to calculate the maximum delay eral reasons to have a system designer. Before
for any message in an event-triggered CAN a communication scheme with predictable
system, it soon becomes obvious that an latency can be designed, the number of nodes
event-triggered approach can be difficult to and their interactions has to be known, that
design if correctness, failure detection, and is, a system designer is required for any real-
maximum reaction time must be verified. time system. Furthermore, designers can
Only a few messages can have a short, guar- enhance and simplify failure detection by using
anteed maximum latency, and a lot of the both a system level and a module level. Some
bandwidth must be assigned to ensure system failures can only be detected when you com-
integrity. Systems with time-scheduled trans- pare the responses of multiple modules to an
missions are much simpler to design, under- event. In other cases, designers can make error
stand, analyze, and verify. It is important, detections redundant using mechanisms at
especially for safety-critical systems, that sys- both system and module levels. A system
tem behavior during any conditions is under- designer has complete knowledge of the sys-
standable. System architectures based on tem and can design a node capable of super-
time-scheduled communication have the best vising the system. By separating the design task

JULY–AUGUST 2002 29
CAN FOR EMBEDDED NETWORKS

into one system level and one module level, time-scheduled solutions, which would be an
module designers can concentrate on the per- ideal starting point for generations of embed-
formance of their modules and leave system ded automotive network designs.
problems to the system designer.
CAN: Not an event-triggered protocol
Protocol update Designers often rule out CAN outright
Ideally, designers would solve all problems because many falsely regard the protocol as
at a project’s specification phase. When the event-triggered. CAN uses an efficient process
team then approves the specification, it should to resolve message collisions when they occur
be simple to get it implemented, verified, and on the bus. But the protocol does not require
validated. In the real world, however, design- collisions. Nothing prevents CAN from being
ers usually detect some shortcomings of the used for time-scheduled protocols. In fact,
specification long before the verification designers have successfully used it for several
phase. Other shortcomings remain hidden years in protocols such as CDA 101.8 A great
until the product is far into its life cycle. advantage of using CAN in time-scheduled
Almost any change in a DECS will affect protocols is that clock failures can easily be
desired protocol properties, so the system detected and efficiently handled.
must allow updating. Time-scheduled communication requires
that each node rely on the same notion of time.
Ideal building block A straightforward solution is to have local
In 1988, Intel brought the first CAN chip clocks in each node, synchronized to one of
into the market. Since then, several manufac- them by time messages; software achieves this
turers have designed and produced different in current CAN applications. Although an
types of CAN chips in large numbers, and accuracy of 10 microseconds is possible, pro-
many market segments, with varying gramming software in this way is often difficult
demands, have used CAN chips. CAN has because any change in a module’s software
proved itself to be a solid base for different might influence its clock performance. A stan-
kinds of protocols in a great variety of DECSs. dardized solution implemented directly in the
Integrating different CAN controllers in a sys- CAN controller would be a better alternative.
tem has most often been a simple task.
Because CAN is a low-level protocol, sys- Global clock support
tems require a higher-layer protocol (HLP) CAN relies on time measurement for its bit
built on top of CAN. It is the quality of the encoding. The non-return-to-zero (NRZ)
applied HLP that makes some CAN systems concept encodes the bits in CAN and thus the
dependable and others not. The requirements bus level does not change when transmitting
of a dependable system relate to the system adjacent bits of the same value. In these cases,
itself and to how the system resolves critical the system calculates the number of bits by
situations (see http://www.sp.se/electronics/ dead reckoning. Thus, a CAN controller
RnD/palbus/eng/report.htm), which is why already has the basic features for an integrat-
it is almost impossible to create one and only ed clock. According to the CAN standard, a
one HLP for all critical, embedded automo- bit can be divided into at least 25-bit time
tive networks. quanta, and each bit can be as low as 1 micro-
A different approach is to make the com- second. The falling edge (the start of a frame)
munication an integrated part of the control hard synchronizes a system’s CAN controllers
system. For this approach, as mentioned pre- at the beginning of each message on the bus.
viously, CAN is an excellent basic building Thus, a time resolution of 40 nanoseconds
block. Over the years, this technique has proved and an already used synchronizing flank are
to be a robust way to convey information with- available, up-front. Only a counter has to be
in control systems. The next step is to add new added to implement a local clock. However, to
standardized support for global clocks, open- support a global clock, the local time must be
ing new opportunities for designing depend- synchronized to a system-wide notion of time,
able systems. Developers could then combine which requires a few more counters and reg-
well-proven CAN solutions with well-proven isters. But the problem is well known and was

30 IEEE MICRO
3 ECU connection

CAN
Memory RedCAN
transceiver
2 4 CAN bus CAN bus

CPU CAN controller

(a) (b )

Figure 1. Wiring harness for a distributed embedded network with four nodes. The RedCAN units labeled 1 and 4 disconnect
the bus. The section between 1 and 4 is disconnected. In case of a short or a break in another section, for example, between
the units labeled 2 and 3, the 2 and 3 units terminate the bus and units 1 and 4 connect the section between 1 and 4 to the
bus (a). Detail of a connection point. The RedCAN unit can either connect to the section or terminate the bus (b).

solved long ago in the telecom industry. Thus, A common communication problem occurs
a chip designer could add an accurate and when several nodes simultaneously detect an
adjustable clock to a CAN controller without alarm-causing event and each of them trans-
much extra cost.8 mits alarm messages, resulting in a saturated
bus. Designers can solve this problem with
Required bandwidth CAN by assigning the same identifier for an
A common claim from proponents of alter- empty alarm message to all nodes capable of
native standards to CAN is that an X-by-wire detecting the same failure. On the triggering
system requires a bit rate of at least 5 Mbps and event, they transmit the alarm message unless
that because CAN provides a bit rate of only 1 they just received the very same alarm. The
Mbps, its bandwidth is too limited. This might result is only one message on the bus, regard-
be true if you consider communication as a less of how many modules detected the fail-
stand-alone entity. But the picture is quite dif- ure. CAN’s address-less concept, in which
ferent if you regard the communication and every node receives every message, can resolve
the global clock as integrated parts of the sys- message collisions with no loss of bandwidth.
tem control. By using the global clock for time
stamping, designers can dramatically reduce Building CANs for ECUs
the need for communication bandwidth by The first step in building a CAN network
applying feedback loop control theories using for critical embedded automotive networks is
known time jitter.9 wiring, which must be robust. Each ECU
CAN’s collision resolution mechanism oper- must connect at the right spot. Figure 1a
ates according to a bitwise arbitration of the first shows a proposed physical architecture pre-
part of the message, called the identifier field. pared with connection points for four mod-
One and only one node can transmit the same ules. Each connection point has a unit that
bit pattern in the identifier field unless the rest contains memory, a CAN transceiver, a Red-
of the message contains no data or exactly the CAN device, a CAN controller, and a small
same data. Thus, any message addressing must CPU, shown in Figure 1b.
be implemented in a higher protocol layer. In RedCAN helps obtain redundancy effi-
scrutinizing the CAN standard, it seems that ciently.10 A RedCAN device can detect phys-
this offers features for efficient message trans- ical defects as shortcuts or breakups in the
ceiving of up to 94 bits of data on a bus. The wires and can terminate the bus. At startup,
so-called CAN identifier need not be an iden- RedCAN singles out one section as a redun-
tifier at all, it can be the message itself. dant sector. If one sector fails during runtime,

JULY–AUGUST 2002 31
CAN FOR EMBEDDED NETWORKS

designer can program the connection units


with communication rules that act as bus
System
module guardians optimized for the system. Thus, the
connection unit can physically disconnect an
attached module if it does not behave accord-
ing to the rules, either automatically or by
command from another module.
Connection
points
ECU 1 ECU 3 Modules
Figure 2 shows the system with modules
CAN attached. The system module (SM), created
controller
by the designer, has a supervising role because
it receives every message on the bus and has
complete knowledge of expected system
behavior on the bus. It can have the capabili-
ECU 2
ty of detecting almost any serious ECU mal-
function. When a module connects to the
access point unit, a point-to-point CAN com-
Figure 2. Architecture for dependable system with three munication runs between the module and the
electronic control units and one system module. The CAN unit. The access point unit can then interro-
controllers support global time. The system module con- gate the module and find out whether it is of
trols the connection points. the right kind and can correctly set the mod-
ule before it is connected directly to the bus.
The module can also check that it is correct-
the modules at each side automatically dis- ly connected to an approved system before it
connect this sector, and the redundant sector turns into an active mode.
becomes active. Adjacent modules can also To make the modules as system indepen-
disconnect a malfunctioning module. Red- dent as possible, they must be configurable
CAN not only provides efficient bus redun- by some kind of a tool. The SM can act as
dancy but also solves the problem of a such a tool during setup. The CanKingdom
completely crushed node. In many other sys- (http://www.cankingdom.org/) standard pro-
tems, a crushed module might ruin the ordi- vides a set of command messages to configure
nary bus and the redundant ones because they and control modules.11 A module supporting
all are connected to the module. CanKingdom lets the system designer assign
The memory in the connection-point CAN identifiers to messages, construct mes-
device contains, at a minimum, information sages from internal signals, select responses
about what kind of ECU should be connect- on events or received messages from a list of
ed to this point but can include other essen- alternatives, set the bit rate, set the periodic-
tial information such as bit rate, setup ity of messages, and adjust the local clock to
parameters, serial number of the ECU last global time. With this flexibility, the system
attached, and time schedules that otherwise designer can create a CAN higher-layer pro-
must be communicated by a tool or across the tocol and integrate the control schemes with
bus during setup. By reading the memory the communication.
before going active, the ECU can make sure The property of allowing integration of new
that it is correctly attached in the system. modules into a system is often called compos-
With a CPU at each connection point, the ability. Composability requires a clear and sta-
system designer can implement several tasks ble interface specification in a module’s value
for supervising and controlling the system and time domains. Traditionally, this require-
independently of the ECU designs. Because ment can lead to inflexible systems because
the CAN transceiver belongs to the wiring sys- the system requirements must be known when
tem, the designer can choose the bus levels (or the module is designed. But with CanKing-
even an optical alternative) while still using dom, which provides well-defined interface
ECUs with standard CAN controllers. The building blocks rather than complete inter-

32 IEEE MICRO
faces, designers can build flexible interfaces in
any module, which the SM can modify to
match current system needs—not only at
startup but also during runtime.
(a) (b) (c) (d)
Time schedules
Only the system designer knows how the dif- Figure 3. Messages can be scheduled in different ways to
ferent ECUs interact, how faults are detected, accommodate different scenarios. Tight time slot for a
and how to correct those faults when failures message from a module with a high accuracy rate: retrans-
happen. The combination of CAN and time- mission is not allowed (a). Time slot for a message from a
scheduled communication create new possibil- module with a low-quality clock: the clock allows for a big
ities, especially in contrast to classical time- jitter (b). Tight time slot for a critical message: two retrans-
scheduling techniques. Any time-scheduled sys- missions are allowed. This slot is shared by a slot for non-
tem must anticipate message loss due to elec- critical messages that start slightly later than the critical
tromagnetic disturbances. To cope with this message. CAN priority controls bus access (c). Time slot
problem, the system must retransmit the mes- where the first message is from a module with a high-
sage one or more times in the same time slot, or quality clock. The following messages are from modules
the time slot must reappear often enough so the with no clocks: These will transmit when the system
system can survive one or two lost slots. detects the first message’s CAN identifier (d).
CAN’s collision resolution feature allows a
more efficient use of bandwidth because crit-
ical messages can share the same time slot as other modules in the system.
noncritical messages. In these cases, the CAN The SM—or any module that knows the
system makes the time slot for a critical mes- schedule of other modules—can immediate-
sage long enough to allow message retrans- ly detect a module not synchronized to glob-
mission if the critical message gets corrupted. al time. If it detects that all other modules have
The system designer assigns a slot-sharing lost synchronization, then the detecting mod-
noncritical message to a CAN identifier with ule itself is unsynchronized. Because most
a lower priority, and its time slot starts slight- transmitted CAN identifiers relate to specific
ly later than the critical message. If the criti- modules, the SM knows the source of a mes-
cal message successfully transmits, the sage appearing on the bus at the wrong time.
noncritical message automatically transmits By carefully selecting the message priorities,
immediately thereafter. If not, the system will designers can create a system to be fully func-
retransmit the critical message and the non- tional for a long time even if the global time
critical message will lose the time slot. fails. The nondestructive message-priority col-
Not all modules must support a global lision-resolution mechanism provides a grace-
clock in a time-scheduled system. Some of ful degradation of the time schedule. When
them can piggyback on messages transmitted the clocks in the modules drift from global
by modules that support the global clock by time, messages will gradually start to collide
using CanKingdom’s action-reaction feature. but will appear back-to-back on the bus. Even
A module supporting the action-reaction con- when the clock in a module gets out of phase,
cept has a list of tasks and events that other the system handles this problem safely and
tasks or events can evoke. A command mes- predictably. Figure 3 shows some different
sage establishes the action-reaction relation- ways to schedule messages.
ship. By setting up the reception of a message
with a certain CAN identifier as the action TTCAN standard
event and the transmission of a certain mes- Ongoing work within ISO on a time-trig-
sage as the reaction task, designers can use any gered CAN has reached committee draft sta-
message appearing on the bus as a trigger for tus.12 The draft focuses on standardizing how
message transmission from other modules. to schedule messages and how to get a global
The designer can then use time-scheduled system clock. In the standard, messages oper-
messages from modules that support a global ate in a matrix in which each column repre-
clock to trigger message transmission from sents a time slot. The system transmits

JULY–AUGUST 2002 33
CAN FOR EMBEDDED NETWORKS

messages row by row. Time messages, from a By applying an architecture with a clear divi-
time master, occupy the first column in the sion between the system and module levels,
matrix to synchronize the module clocks. designers can simplify failure detection. A sys-
The advantages of the ISO proposal are that tem node can supervise communication and
it is easy to comprehend and easy to create a check that it is running according to current
schedule by hand. However, there are some rules and that the modules are responding to
disadvantages: actions within reasonable limits. Using the
proven CanKingdom tool, designers can flex-
• The time resynchronization messages ibly implement system communication and
appear according to a schedule pattern control rules. The wiring could include active
rather than when needed, possibly wast- connection points to the modules so that the
ing bandwidth. SM can ensure that the right modules connect
• The column width governs the time slots, at the right places at startup and during run-
which are equal for all messages in the time. This technique could make time-trig-
same column and cannot be optimized. gered CANs an excellent choice for critical
• Because the standard will be implement- embedded automotive networks. MICRO
ed in silicon, it might be difficult to have
built-in support for a global clock if References
designers use a nonmatrix method for 1. ISO 11898, Road Vehicles: Interchange of
creating the schedule. Digital Information–Controller Area Network
• The matrix only helps create a schedule, (CAN) for High-speed Communication, Int’l
which means that, in practice, it will Organization for Standardization, Geneva.
unfold into a timeline when executed, 2. H. Kopetz, Real-Time Systems Design
making the columns only a restriction Principles for Distributed Embedded
and reducing the possibility of making Applications, Kluwer Academic, Boston,
more efficient schedules. 1997.
• Some details make it difficult to harmo- 3. Time-Triggered Protocol (TTP/C), Version 1.0,
nize a CAN clock with other clocks— TTA Group, Vienna; http://www.ttagroup.org/
such as GPS, GSM, or Bluetooth ttp/specification.htm.
clocks—possibly making it hard to build 4. R. Belschner et al., FlexRay Requirements
efficient gateways to other networks. Specification (draft), version 1.9.7, FlexRay
Consortium, 2001; http://www.flexray-
The common denominator in any time- group.com/.
triggered system is the notion of time, which 5. SAE J1939, Recommended Practice for
means you can use a global clock not only for Truck and Bus Control and Communications
assisting communication but also for syn- Network, Soc. of Automotive Engineers,
chronizing tasks. Time synchronization would Warrendale, Pa., 2000; http://www.sae.org/
then operate independently of the scheduling products/j1939.htm.
method. The ISO proposal could be restruc- 6. NMEA 2000 Standard for Serial-Data
tured to fulfill this requirement. Alternative- Networking of Marine Electronic Devices,
ly, a chip manufacturer could decouple the Nat’l Marine Electronics Assoc., Severna
schedule and the clock parts in an imple- Park, Md., 2002; http://www.nmea.org/pub/
mentation. 2000/index.html.
7. D. Purdy, CDA 101, Common Digital

A n ISO standard for establishing a global


clock on top of CAN is already in prepa-
ration. Designers could use such a global clock
Architecture, Naval Air Warfare Center
Weapons Division (NAWCWD), Point Mugu,
Calif.; http://www.cankingdom.org/download/
for establishing time-controlled message trans- Download%20files/CDA101/cda_101.htm.
mission and synchronizing tasks in different 8. L-B. Fredriksson and J. Österling, An Outline
nodes. The combination of CAN’s collision for a CAN Global Clock, Kvaser, Kinnahult,
resolution features with message scheduling Sweden, 2000; http://www.cankingdom.
opens up several possibilities for critical auto- org/download/Download%20files/Time%20
motive network designs. Triggered%20Systems/tts.htm.

34 IEEE MICRO
9. J.H. Nilsson, Real-Time Control Systems Lars-Berno Fredriksson is president and
with Delays, doctoral dissertation, ISRN cofounder of Kvaser. His research interests
LUTFD2/TFRT–1049–SE, Dept. Automatic include distributed embedded control systems
Control, Lund Inst. of Technology, Lund, and advanced real-time systems, especially
Sweden, 1998. architectures. Fredriksson has an MSc in
10. H. Sivencrona et al., “A Novel Distributed Add- mechanics from the Chalmers University of
on Concept to Detect and Recover from Bus Technology in Gothenburg, Sweden. He
Failures in Controller Area Networks using holds the appointed position of the Swedish
REDCAN,” Proc. 8th Int’l CAN Conf., CiA-Can expert for TTCAN in ISO/TC22/SC3.
in Automation Int’l Users and Manufacturers
Group, Erlangen, Germany, 2002. Direct questions and comments about this
11. CANKingdom specification, ver. 3.01, article to Lars-Berno Fredriksson, Kvaser AB,
CanKingdom Int’l, Port Hueneme, Calif., Box 4076, SE 51104, Kinnahult, Sweden;
1996; http://www.cankingdom.org. lbf@kvaser.se.
12. Road Vehicles—Controller Area Network
(CAN)—Part 4: Time Triggered Communica-
tion, committee draft standard CD 11898-4 For further information on this or any other
(N1147), ISO/TC 22/SC3/WG1, Int’l Organi- computing topic, visit our Digital Library at
zation for Standardization, Geneva, 2000. http://computer.org/publications/dlib.

Let your e-mail address


show your professional
commitment.
An IEEE Computer Society e-mail alias
forwards e-mail to you, even if you change
companies or ISPs.

you@computer.org
The e-mail address
of computing professionals

JULY–AUGUST 2002 35

Potrebbero piacerti anche