Date post: | 18-Jul-2016 |
Category: |
Documents |
Upload: | sm-ferdous |
View: | 10 times |
Download: | 0 times |
Lesson : Controller Area Network (CAN)
Semester 3 – Power Systems in hybrid (HEVs) and electric (EV) vehicles
Lecturer: F.F.Linera
EECPS/STEPS Universidad de Oviedo
2
Controller Area Network (CAN)
• developed by Robert Bosch GmbH, Germany in 1987
• Products available from all microcontroller manufacturers
• International Standards: ISO11898 (Europe), SAE J2284 (US) for
“high – speed” CAN; ISO 11519-2 for “fault-tolerant low speed”
CAN
• backbone serial bus system for automotive applications, but also
used in industrial automation & control
• Event triggered Serial Bus System; Self-Synchronisation
More Features :
multi master bus access
random access with collision avoidance (CSMA / CA )
short message length , at max. 8 Bytes per message
data rates 100KBPS to 1MBPS
short bus length, physical length depends on data rate
self-synchronised bit coding technology
Robust EMC - behaviour
build in fault tolerance
3
Main Features :
• CAN is a priority-based-on-message bus with multi-master access.
• It allows to provide a bounded communication delay for each
message priority.
• The MAC (Medium Access Control) protocol of CAN uses
CSMA/CA (Carrier Sense Multiple Access with Colission
Avoidance)
• The bus arbitration is non-destructive and is realized over a part of
the frame called the ID (Identifier).
• The identifier is coded using 11 bits (CAN2.0A) or 29 bits
(CAN2.0B) and it also serves as priority.
• Short message length. Up to 8 Bytes of data per message can be
carried by one CAN frame.
• A CRC (Cyclic Redundancy Code) is added as part of the frame for
transmission error detection.
• Robust EMC - behaviour
Controller Area Network (CAN)
4
Main Features :
• CAN uses a NRZ bit encoding scheme for making possible the bit
by bit arbitration with a logical bit arbitration
• But, the bit-by-bit arbitration limits the bit rate of CAN as the bit
time must be long enough to cover the propagation delay on the
whole network
• A maximum of 1Mbps is specified to a CAN bus not exceeding
25m. Physical length depends on data rate.
• Recommended Guidelines for Cable length according to CANopen
DS 102 V2.0 Physical Layer for Industrial applications (appendix):
Controller Area Network (CAN)
5
Main Features :
• Maximum message transmission time include the worst-case bit
stuffing number and is:
Tframemax = 44 + 8 DLC +34 + 8 DLC
4 𝑥 𝑇𝑏𝑖𝑡,
𝑤ℎ𝑒𝑟𝑒 𝐷𝐿𝐶 𝑖𝑠 𝑑𝑎𝑡𝑎 𝑙𝑒𝑛𝑔𝑡ℎ & 𝑇𝑏𝑖𝑡 𝑖𝑠 𝑡ℎ𝑒 𝑏𝑖𝑡 𝑡𝑖𝑚𝑒
The fraction represent the overhead due to the bit stuffing
• Bit stuffing is a technique implemented by CAN for bit
synchronization which consists in inserting an opposite bit every
time five consecutive bits of the same polarity are encountered.
Controller Area Network (CAN)
6
The Standardization of CAN
• CAN is an open system and has been standardized by
ISO
CAN follows the ISO - OSI seven layer model for open
system interconnections
CAN implements layer 1, 2 and 7 only
However, Layer 7 is not standardised
Physical Layer Type Europe
www.iso.org
North America
www.sae.org
Single – Wire CAN n/a SAE J2411
Single Wire CAN for Vehicle
Applications
Low-Speed Fault Tolerant
CAN
ISO 11519 - 2
ISO 11898 - 3
n/a.
High-Speed CAN ISO 11898 SAEJ2284
7
Open Systems Interconnection (OSI)
ISO Reference Model:
Layer 7
Layer 6
Layer 5
Layer 4
Layer 3
Layer 2
Layer 1
Application Layer
Presentation Layer
Session Layer
Transport Layer
Network Layer
Data LInk Layer
Physical Layer
void
void
void
void
Layer 1: transmission line(s)
differential two-wire-line, twisted
pair with/without shield
Transceiver Integrated Circuit
Optional: fibre optical lines (passive
coupled star, carbon )
Optional: Coding as PWM, NRZ,
Manchester Code
ISO 11898
Layer 2: Data Link Layer
message format and transmission
protocol
ISO 11898
CSMA/CA access protocol
Layer 7: Application Layer
different standards in industry, not
standardized in automotive
The Standardization of CAN
8
• ISO11898 is the standarized version of the CAN protocol as it
was originally defined by Bosch
• It only defines the layers1 (physical) and 2 (Data Link) of the
ISO/OSI model.
• Layer 2 (Data Link) is the most complete defined.
• Layer 2 defines message framing, arbitration, acknowledgement,
error detection and error signalling in the Medium Access
Control (MAC) sublayer.
• Layer 2 defines how message filtering, overload notification or
the error recovery procedure must be realized.
• Layer 2 can not be modified by any given protocol based on
CAN.
The Standardization of CAN
9
• Layer 1 is not completely defined by ISO11898
• The Bosch Reference document describes only the
detailed bit representation (Physical Signalling
Sublayer).
• But the driver/receiver characteristics of the
physical layer are not defined and so, the transport
medium and the signal levels can be optimized for
any given application.
The Standardization of CAN
10
So, Layer 1 allows wire media of all kinds:
• Single wire, simple and asymmetrical.
• Two-wire in differential mode, with/without galvanic
isolation using optocouplers or transformers.
• Optical media using optical fibers
• Electromagnetic media: using ASK and FSK
modulated radio-frequency waves or infrared
waves.
Single wire and two-wires in differential mode are used
in the automotive sector
The Standardization of CAN
11
Practical implementations of CAN Practical implementations of differential wires CAN
• Two differential wires medium is very widespread in
industry and so, ISO has standarized the use of CAN in
this particular medium.
• Two main ISO Standards:
• ISO11898-2 – High Speed CAN (125Kbps to 1Mbps)
• ISO11898-3 – Low Speed CAN (10Kbps to 125Kbps)
• ISO defines the operation and electrical characteristics of
the transmission media, i.e. the electrical levels, but do not
cover the mechanical aspects (forms of connector) or any
of the problems of the other layers.
12
Practical implementations of CAN
• It is defined for use in applications with bit rates from
125Kbps to 1Mbps
• It is implemented using a simple differential wire pair
• It is the most widespread implementation used in vehicle
(power train domain) and industry applications
• The following figure shows the electrical levels adopted for
the dominant (nom.2V) and recessive bits (nom. 0V)
High Speed CAN – ISO11898-2
13
Practical implementations of CAN
Real HS CAN Waveform: CANH, CANL and the difference
High Speed CAN – ISO11898-2 – Real Frame Waveform
14
Practical implementations of CAN High Speed CAN – ISO11898-2
Typical High Speed node implementation
• Normally the uC has an integrated CAN
controller
• ISO defines a characteristic line
impedance of 60 ohm.
• This impedance can be obtained as it is
shown in the figure. This implementation
reduces EMC pollution.
• Other impedance implementations are:
2x120 ohmios, 3x180ohmios.
• Normally these resistances must be
situated at the end of the lines and can be
measured with a polymeter.
• Normally the termination resistances are
included as part of the CAN devices with
the possibility to connect it between CANH
and CANL using a jumper or a switch
15
Practical implementations of CAN High Speed CAN – ISO11898-2 – Typical Driver ICs
PCA82C250/251 from NXP TJA 1050 from NXP
This resistance
reduces slew-rate
in transition an so,
EMC pollution.
Depending of the
speed, a double
choke to reduce
EMC can be
neccesary.
16
Practical implementations of CAN High Speed CAN – ISO11898-2 – Typical Driver ICs
TJA 1040 from NXP
TJA1040 has a
split voltage Vcc/2
drawn from the IC,
to avoid some
error reads during
wake-ups for a
sleep-node
17
Practical implementations of CAN High Speed CAN with diagnosis of the physical layer –
ISO11898-5 – Typical Driver ICs
TJA 1041/43 from NXP
Pin compatible
with ISO11898-
2 drivers
The driver detects some type of failures on the CAN bus
and send this information to the microcontroller using
the ERR signal.
Normally, the microcontroller disconnects the node from
the CAN bus.
Typical failures are: TXD dominant (low level) clamping
detection, RXD recessive (high level) clamping
detection, TXD-to-RXD short circuit detection, Bus
dominant clamping detection or overtemperature
detection
Typical application
with 3V
microcontroller
18
Practical implementations of CAN Partial Network systems
• In automotive systems, some nodes have to remain live for functional
reasons while the contact is off (clamp-30).
• Others are deliberately disconnected from the battery when the contact
is off because they need to save power (clamp-15).
• Others can also be put in standby mode or sleep mode By the
microcontroller
• The key point is that nodes which are in sleep mode or switched off do
not disturb the communication between the ones which remain awake
19
Practical implementations of CAN High Speed CAN – ISO11898-2 &ISO11898-5 Typical Driver ICs
High Speed CAN NXP transceivers High Speed CAN TI transceivers
Practical implementations of CAN
• It is defined for use in applications with bit rates up to 125Kbps
• It is implemented using a simple differential wire pair
• It is the most widespread implementation used in vehicle (body/confort
domain) and industry applications
• The transmission is yet maintained, in degraded mode, even in sever
conditions of physical disturbances
FT Low Speed CAN – ISO11898-3 -
20
21
Practical implementations of CAN FT Low Speed CAN – ISO11898-3 –
Electrical levels of the FT Low Speed physical layer
Main characteristics
• Maximum speed: 125 Kbps
• From 2 to 20 nodes
• Differential (twisted) pair with groun
return
• A distributes termination network
through the bus.
• Low EMC radiation
Nominal Values Recessive Dominant
VCANH 0V 3.6V VCANL 5V 1.4V VCANH – VCANL -5V 2.2V
3.6V
1.4V
22
Practical implementations of CAN FT Low Speed CAN – ISO11898-3 –
• The main advantage to use a slower speed is that the communication distance
can be increased without problems of EMC pollution.
• Some applications do not require long distances and the communication
speed can be below 125 Kbps. In this case, this low speed CAN network can
be implemented using the same ISO11898-2 drivers shown in the previous
slides. The main difference with ISO 11898-3 is the electrical levels on the
physical layers.
• It will found that as the length of the network increases, it is more likely that it
will suffer of various kinds of electromechanical disturbances due to short
circuits and/or open circuits (wires isolated or cut).
• If a CAN communication must be reliable, it must be capable of being
maintained even in severe conditions of physical disturbances, continuing to
transmit, even in “degraded mode” and signalling and/or indicating any faults
that ocurre.
• This is the reason to define a Fault Tolerant Low Speed CAN (FT LS CAN).
• This CAN network is not very usual in medium-end cars. It is more usual in
high-end cars used in body applications like roof, seat, windows where a short-
circuit or cut wires can be more likely.
23
Practical implementations of CAN FT Low Speed CAN – ISO11898-3 –
• Principle of FT LS CAN: If there are any faults on the bus, they must be
detected, signalled and repaired as well as possible.
24
Practical implementations of CAN FT Low Speed CAN – ISO11898-3 –
• All nodes continue communicating at least with reduced signal and noise ratio.
25
Practical implementations of CAN FT Low Speed CAN – ISO11898-3 –
Typical implementation of a FT-CAN node
• It is based in a distributed termination
resistance philosophy to avoid
communication problems if some
wire/node is broken
• The device provides differential transmit
capability but will switch in error
conditions to a single-wire transmitter
and/or receiver.
• In the supported failure cases all nodes
continue communication with reduced
signal-to-noise ratio. Once the wire
corruption is removed, the fault-tolerant
transceiver automatically resumes
differential signal transmission
26
Practical implementations of CAN FT Low Speed CAN – ISO11898-3 – Typical Driver ICs
FT LS CAN NXP transceivers
27
Practical implementations of CAN Single-Wire CAN – SAE J2411
• Leaving aside any standarization of the physical layer for differential wires, a single-wire
solution (plus ground, of course) was developed several years ago for economical
reasons.
• Drivers for this implementation only use one pin, normally called CANH. High Level on
this pin can be achieved with 5V (normal mode)/12V (wake-up mode) with respect to
GND.
• Due to a high RF radiation, this bus is only used at low speeds. Typical values are 33,3
Kbps (normal/wake-up mode) and 83,3Kbps (high speed mode)
• Failures of the short circuit and opencircuit types are theoretically insoluble and so, it is
only used for non-critical solutions intended to use and comply with the CAN protocol,
benefit from its advantages and the cost must be reduced.
• Examples of application: GMLAN /SAE J2411 specification by OPEL/GM for body
system.
• SW-CAN and LIN physical layers are very similar. SW-CAN has the main advantage of
maintaining consistency and performance of the CAN protocol throughout the network,
thus avoiding the need of gateways between protocols or between a protocol and a
“sub-protocol”, such as LIN.
28
Practical implementations of CAN Single-Wire CAN – SAE J2411
29
Practical implementations of CAN Single-Wire CAN – SAE J2411
• There are not many single-wire transceiver manufaturer in the market: NXP AU5790,
Infineon TLE6255, Melexis TH8055/56, Freescale 33897 and ONSemi NCV7356.
GMLAN operation
During Wake-up mode (Mode0 = 0 & Mode1 =
1) the nominal CAN bus electrical levels used
are 12V (high) and 0V (low).
After wake-up, normal mode is activated
(Mode0 = 1 & Mode1 = 1) the nominal CAN
bus electrical levels used are 4V (high) and 0V
(low)
30
Practical implementations of CAN Galvanic Isolated CAN wire links
By optical coupling Every optocoupler delays the signal 20 ms
(equivalent to 200ns)
By isolation transformer Every optocoupler delays the signal 20 ms
(equivalent to 200ns)
31
Connectors
Practical implementations of CAN
RJ-45 Connector
32
CAN Frame Structure
32
Courtesy of Vector Informatik GmbH
• All fields in a CAN frame have a bit length defined with the exception of the arbitration
field.
• The arbitration field has a length of 12 bits if the CAN frame corresponds to CAN-
Version 2.0A (Standard), where the messages uses a 11-bit standard identifier and no-
stuffing bits must be added.
• The arbitration field has a length of 32 bits if the CAN frame corresponds to CAN-
Version 2.0B (Extended), where the messages uses a 29-bit standard identifier and no-
stuffing bits must be added.
• If stuffing bits must be added, the arbitration field length can be different to 12 or 32 bits.
• CAN-Standard 2.0A messages and CAN-Extended 2.0B messages can share the same
CAN physical network
33
CAN-Version 2.0A
messages with 11-bit -identifiers
CAN-Version 2.0B
messages with 29-bit-identifiers
==> Suitably configured, each implementation ( BASIC or FULL)
can handle both standard and extended data formats.
Standard
Extended
CAN Frame Structure
34
CAN Frame Structure
34
ISO11898 distinguishes four types of frames in CAN networks:
• Data Frame: Data is transmitted form a transmitter to one or several receivers upon the
initiative of the source (transmitter). Normally, the frame has all fields, but the data field
is optional.
• Remote Frame: A bus node (receiver) can request the transmissión of a data frame of
the same frame identifier by a source. It has not data field.
• Error Frame: It is used to signal an error detected by a bus node (transmitter or receiver)
and to destroy the frame.
• Overload Frame: It is used to provide for an extra delay between a preceding and a
succeeding data or remote request frame or to signal a specific error condition.
REMOTE FRAME ESCENARIO:
35
CAN Access Procedure: CSMA/CA
CSMA/ CA: “Carrier Sense Multiple Access with Collision
Avoidance” • access-control with non
destructive bit-wide
arbitration
• if there is a collision , the
“winner” continues
• the message with higher
priority is not delayed!
• real-time capability for high
prioritised messages
• the lower the identifier, the
higher the priority
• Controllers losing
arbitration will wait until
bus-idle before reattempting
transmission
CAN Frame Structure
36
CSMA / CA =
"bit - wide arbitration during transmission with simultaneous
receiving and comparing of the transmitted message"
means :
• if there is a collision within the arbitration-field, only the
nodes with lower priorities cancel transmission.
• The node with the highest priority continues with the
transmission of the message.
node 1 node 2 node 3
high : reccessive
low : dominant
node 1 node 2 node 3 bus
high high high high high low high low low low high low
Vcc
R
CAN Frame Structure
37
(1) arbitration-field :
denote the priority of the message
logical address of the message (identifier)
Standard frame, CAN 2.0A: 11 bit-identifier
Extended frame, CAN 2.0B: 29 bit-identifier
CAN Frame Structure
38
CAN Frame Structure
Courtesy of Vector Informatik GmbH
• Because dominant (logic “0”) wins over recessive (logic “1”), low-valued identifiers always
have higher priority to access the bus.
• If Std IDs and Ext IDs are involved, the Std IDs compete with the 11 most significant bits
(b28…b18) of the Ext IDs.
• If all 11 first bits are identical, the Std ID wins if it is a data frame because of the
dominant RTR bit (SRR is always recessive)
• If all 11 first bits are identical, the Std ID wins if it is a remote frame because of the
dominant IDE bit (the IDE bit belongs to the arbitration field in the Extended frame and
belongs to the control field in the standard frame)
39
(3) control-field :
Transmit the number of bytes in the data-field (DLC – From 0 to 8)
CAN Frame Structure
40
(3) data field :
up to 8 bytes per message ,
a 0 byte message is also permitted
CAN Frame Structure
41
(4) CRC field:
cyclic redundancy check ; contains a checksum generated by a CRC-
polynomial
CAN Frame Structure
42
(5) ACK field:
• The ACK Field is two bits long and contains the ACK Slot and the ACK Delimiter (always
recessive).
• The transmitter of a frame transmits both bits fo the ACK Field recessive.
• Every CAN node that receives any error-free transfer (from SOF to CRC) reports this to
the transmitter by sending a dominant bit during the ACK slot – regardless of whether the
message was intended for that node.
• If the transmitter detects a positive acknowledge, that is a dominant ACK slot, the
transmitter knows that in minimum one node has got his message.
• If no one receives the message correctly the ACK Slot stays recessive.
CAN Frame Structure
43
(6) End Of Frame Field:
• Seven Recessive bits
If a dominant level occurs in bit number:
• [1..6] A form error is detected by the receiver and the transmitter. The frame is discarded
and an error flag is started. The transmitter repeats the transmission.
• [7] The frame is valid for the receiver but not for the transmitter. The tranmitter repeats
the transmission, that frame is received twice. A higher layer protocol must handle this
situation.
CAN Frame Structure
44
EOF + IFS
10 bits
ACK
2 bits
CRC
15 bits
data
0...8 byte
DLC
4 bits
r0
1 bit
IDE
1 bit
RTR
1bit
Identifier
11 bits
start
1 bit
Identifier
11 bits
start
1 bitEOF + IFS
10 bits
ACK
2 bits
CRC
15 bits
data
0...8 byte
DLC
4 bits
r0
1 bit
r1
1bit
RTR
1bitSRR
1bit
IDE
1bit
Identifier
18bit
DATA-Frame CAN 2.0A (11-bit-identifier)
DATA-Frame CAN 2.0B (29-bit-identifier)
CAN Frame Structure
45
start bit (1 bit - dominant): beginning of a message; after idle-time falling-edge to
synchronize all transmitters
identifier (11 bit): mark the name of the message and its priority ;the lower the value
the higher the priority
RTR (1 bit): remote transmission request; if RTR=1 (recessive) no valid data inside
the frame - it is a request for receivers to send their messages
IDE (1 bit): Identifier Extension; if IDE=1 then extended CAN-frame
r0 (1 bit): reserved
CDL (4 bit): data length code in byte (0...8)
data (0...8 byte): the data of the message
CRC (15 bit): cyclic redundancy code for error detection, no correction; hamming-
distance 6 (up to 6 single bit errors can be detected)
ACK (2 bit): acknowledge; if a receiving node has received a valid message, it
must transmit an dominant acknowledge – bit
EOF (7 bit = 1, recessive): end of frame; intentional violation of the bit-stuff-rule ;
normally after five recessive bits one stuff-bit follows automatically
IFS (3 bit = 1, recessive): inter frame space; time space to copy a received
message from bus-handler into buffer
Extended Frame only : SRR (1 bit = recessive): substitute remote request ; substitution of the RTR-bit in
standard frames r1 (1 bit ): reserved
CAN Frame Structure
46
Remote Frames
RTR bit = 1 No Data Field
CAN Frame Structure
47
INTERFRAME SPACE: SEPARATES A FRAME (of whatever type) FROM A DATA O REMOTE FRAME:
• Data frames and remote frames are separated from preceding frames whatever type
they are (Data, remote, error or overload) by a field called INTERFRAME SPACE.
• In contrast, Overload and error frames are not preceded by an Interframe space and also
if multiple Overload frames has to be transmitted.
• Interframe Space constains two parts: INTERMISSION and BUS IDLE.
• INTERMISSION consists of 3 recessive bits. During Intermission the only action to be
taken is signalling an OVERLOAD condition and no station is allowed to actively start a
transmission of a data or remote frame
• BUS IDLE may be of arbitrary length. The bus is recognized to be free and any node
having something to trnsmit can access the bus. Even if a message is pending of
transmission during a previous one, it will be started in the first bit following
INTERMISSION.
CAN Frame Structure
48
Overload Frames
USED TO DELAY NEXT CAN MESSAGE:
A node can generate a maximum of 2 sequential overload frames to delay the start of the next data or remote frame
CAN Frame Structure
49
CAN Error Frame
• any node that detects a bus error generates an error - frame
• an error frame is transmitted as soon as an error has been
detected, e.g. inside a data frame
• consists of two fields: Error Flag Field; Error Delimiter Field
• Error Delimiter Field:
• 8 recessive bits
• allow bus nodes to restart bus communication after an error
• Error Flag Field:
Type depends on the error-state of the node:
• error active: 6 consecutive dominant error bits; all other
nodes will respond to this violation with their own error
frames Error Flag Field = 6…12 dominant bits
• error passive: 6 consecutive recessive bits plus 8 error
delimiter bits = 14 recessive bits • receiver: does not corrupt the message • transmitter: other nodes may respond with active error frames
CAN Frame Structure
50
data error frame Inter frame space
6 bit error flag
6..12 bit error overlay 8 bit error delimiter
Active error frame
Example1: Active error frame
CAN Frame Structure
CAN Error Frame
51
data error frame Inter frame space
6 bit error flag 8 bit error delimiter
passive error frame from a receiver
data error frame Inter frame space
6 bit passive error flag
6 bit active error overlay
from another active node
8 bit error delimiter
passive error frame from a transmitter
CAN Frame Structure
CAN Error Frame
52
data
Transmitter X
CAN - Tx
Example: active error frame
Receiver Y
CAN - Tx
Receiver Z
CAN - Tx
CAN
Bus - level
1
2
3
4
4
5
6 6 8 3
6
CAN Frame Structure
CAN Error Frame
53
1 Node X sees a bit error
2 Node X generates an active error flag field
3 Nodes Y, Z realize a stuff bit error after bit 6 of the active error flag field
(note: if the corrupted data frame had dominant bits, the stuff bit error is
detected earlier)
4 Nodes Y,Z transmit their own active error flag field of 6 dominant bits
5 All nodes transmit the recessive error delimiter field. Node Y and Z see
no difference @ bus level, but node X detects a delay of 6 bits
between bus level and its own output First node to message error
6 After the last 8 recessive error delimiter bits @ CAN-bus and 3 bit of
inter frame space a new arbitration is entered by node X, e.g. it has to
compete again with other nodes
CAN Frame Structure
CAN Error Frame
54
1. Bit-Error
the transmitted bit doesn’t read back with the same digital
level (except arbitration and acknowledge- slot ) 2. Bit-Stuff-Error
more than 5 continuous bits read back with the same digital
level (except ‘end of frame’-part of the message ) 3. CRC-Error
the received CRC-sum doesn’t match with the calculated sum 4. Format-Error
Violation of the data-format of the message , e.g.: CRC-
delimiter is not recessive or violation of the ‘end -of-frame’-
field 5. Acknowledgement-Error
transmitter receives no dominant bit during the
acknowledgement slot, i.e. the message was not received by
another node.
CAN Frame Structure
CAN Error Frame
55
error
handling
error
detection
error
managing
error
limitation
error
active
error
passive
bus
off
Purpose: avoid persistent disturbances
of the CAN by switching off defective
nodes three Error States :
Error Active: normal mode, messages will be received and
transmitted. In case of error an active error frame will be transmitted.
Error Passive: after detection of a certain number of errors, the node
reaches this state. Messages will be received and transmitted but in
case of an error the node sends a passive error frame.
Bus Off: the node is separated from CAN, neither transmission nor
receive of messages is allowed and the node is no longer able to
transmit error frames.
CAN Frame Structure
CAN Error STATUS
56
error passive
error active
bus off
REC <127
and
TEC <=127
REC >127 or
127<TEC<255
TEC > 255
'reset' or 'init
node'
• transitions will be carried out automatically by
the CAN-chip
• states are managed by 2 Error Counters :
Receive Error Counter (REC)
Transmit Error Counter (TEC)
• Possible situations :
a) a transmitter recognises an error:
TEC:=TEC + 8
b) a receiver sees an error : REC:=REC + 1
c) a receiver sees an error, after transmitting an
error frame: REC:=REC + 8
d) if an ‘error active’-node find’s a bit-stuff-error
during transmission of an error frame:
TEC:=TEC+ 1
e) successful transmission:
TEC:=TEC - 1
f) successful receive:
REC:=REC - 1
State - Diagram:
CAN Frame Structure
CAN Error Counter
57
• The data transmission via CAN network is based on the principle of message
broadcasting.
• This means that all messages transmitted on the bus are accessible to all nodes and
received by the CAN controllers.
• In many cases a certain node will only be interested in a few messages intended for it.
For this reason it is very appropriate to implement an additional message filtering
mechanism which ensures that a host controller is only informed of the reception of a
new message is actually relevant for it
• For the implementation of this filtering mechanism, the CAN controllers has several
internal registers normally called: mask registers and filter register
• The mask registers are formed, at least, by the same number of bits than an identifier in
a CAN frame (29). Every bit in this register indicates if the corresponding bit in the
received frame is relevant or not to inform to the controller core about its reception.
• The filter register are also formed, at least, by the same number of bits than an identifier
(29). A received message is relevant for this node if the corresponding identifier bit has
the same value in the filter register.
• Normally, a CAN controller has several filter register and several mask register. The
same CAN register can be combined with several filter register
• The filter and/or mask registers has normally extra bits in order to define if the filtering
process is only applicable to standard messages, extended messages or both of them
Message Filtering
58
• To explain the filtering main principle, we are going to suppose that the identifiers are
formed by only 4 bits
• Mask bit = 1 means that this bit is relevant for recepetion
• Mask bit = 0 means that this bit is not relevant for reception. It can be 1 or 0.
Message Filtering
Transmitter ID: 1001b
Receiver1 Mask: 1001b Filter: 1111b
Receiver2 Mask: 0000b Filter: 0110b
Receiver3 Mask: 1000b Filter: 1110b
Receiver4 Mask: 1000b Filter: 0001b
X
Main Principle
• Receiver1 relevant messages: ID=1xx1b Receiver2 relevant messages: ID=xxxxb (all)
• Receiver 3 relevant messages: ID=1xxxb Receiver4 relevant messages: ID=0xxxb
• Relevant means that the microcontroller must expend some time to extract the message
from the CAN buffer and decode the data
59
Message Filtering
Transmitter ID: 1000b
Receiver1 Mask: 1001b Filter: 1111b
Receiver3 Mask: 0000b Filter: 0110b
Receiver2 Mask: 1000b Filter: 1110b
Receiver4 Mask: 1000b Filter: 0001b
X
Main Principle
X
Transmitter ID: 1110b
Receiver1 Mask: 1001b Filter: 1111b
Receiver3 Mask: 0000b Filter: 0110b
Receiver2 Mask: 1111b Filter: 1110b
Receiver4 Mask: 1000b Filter: 0001b
X
X
60
CAN Useful Links
Videos
• Youtube - Controller Area Network(CAN)]-Introduction CAN Bus
Technology.flv by SaidyNguyen. http://www.youtube.com/watch?v=YKWrlsu2IXc
• Youtube – CAN Seminar Part 1/2/3/4 of 4 by Wilfried Voss (esd-electronics) http://www.youtube.com/watch?v=m8HTVlEC7Lg
Web Resources
• CAN-CiA Organization. http://www.can-cia.org/index.php?id=can