Professional Documents
Culture Documents
Controller Area Network (CAN) is bus standard for automotive applications, originally developed in
the 1980s by Robert Bosch GmbH, for connecting electronic control units (ECUs):
asynchronous;
bidirectional half duplex;
linear;
with protocol: address + data + data check + signal information;
multi-master: every node can start communication.
Transmission Active
control Suspension Power Seats Power
windows
CiA
DIN
SW
People Presentation Layer
CAN Controller
Processing Physical Layer
HW
CAN Transceiver
CAN bus
~ ~~
120 Ω 120 Ω
CAN-L
RT = 180 Ω RT = 180 Ω
RT = 180 Ω
The multiple termination concept is used when network architecture differs from linear
structure e.g. the cable drop length of a few meters is needed. For such a topology a
multiple termination concept with three branches needs about three times the total
termination resistance: 180 Ω .
T T
r CAN_H r
a 30 Ω a
n n
CAN s 10 Ω s CAN
node c c
e e node
i i
v 30 Ω v
e CAN_L e
r r
2 mH
ferrite bead: 44 Ω
10 pF
Daimler-Chrysler have patented a star topology with a common termination. This topology
avoids resonance problems, undesired harmonics and it's insensitive to incoming noise. All
noise traveling towards the termination point will be absorbed there and never reflected.
Volts
CAN-H
3.5
2.5
CAN-L
1.5
Time
Volts
CAN-H
4.0
3.25
1.75
CAN-L
1.0
Time
PCA82C250
The CAN controller may be a different chip or be integrated into the microcontroller:
Microcontroller Microcontroller
CAN controller
CAN controller
Transceiver Transceiver
CAN Bus
Problem:
Frequencies of the quartz oscillators of the CAN nodes usually differ;
Re-synchronization of nodes during transmission is necessary;
Bit time
Synch Propagation Phase Buffer Segment 1 Phase Buffer Segment 2
Segm Time Segment
tq
sample point
V+ 1 (high) V+
recessive dominant recessive
0 (low)
Bus Line
Idle Start
Node B Bit listening only
recessive
Idle dominant
Bus Level
Global Faults: lead to a breakdown of the system wide communication (e.g. short circuits or
interrupts of the line, deadlock of the bus due to a permanent transmitting node;
Local Faults: are limited to malfunctions of a node ore node components (e.g. interrupts in a bus
connector, transmit problems of a transmitter, etc.);
Temporary Faults: disturb the CAN bus system for a limited time;
Permanent Faults: disturb the CAN bus system all the time, they are not reversible.
IFS/IDLE SOF Message ID Control Data CRC ACK EOF IFS IDLE /SOF
29 / Basica Liviu / 2009 © Continental AG For Internal Use Only
Data Link Layer:
Error Frame – Status of the node
The error management unit uses two error counters:
a receive error counter REC
a transmit error counter TEC If to many errors are
CAN node status after reset: TEC = REC = 0.
detected by one node, this
node is automatically
Error active node : disconnected from the bus.
For each6detected
dominant
error there is
generated an active error flag Error
bits
(queue of six consecutive dominant Active
bits)
Error condition REC > 127 or
TEC > 127 REC < 128 and HW reset
Error passive node : TEC < 128
For each detected error there is
generated an passive error flag
(queue of six consecutive Error Bus
recessive6 bits)
recessiv bits Passive TEC > 255 Off
Error condition
In the case of one node detects a local error it will send an error flag. Other nodes may detect an
error because of this error flag. They send also an error flag;
After receiving/sending an error flag all nodes cancel the message;
Each node which detects an error increments its error counters;
Overlapping error flags result in a queue of 6 up to 12 active error bits followed by an error delimiter
(queue of 8 recessive bits)
Error condition
Superposition
Error Flag of Error Flags 8 Bit Error Delimiter IFS SOF / Idle
recessive
Bus Idle 6 dominant bits 8 recessive bits 3 bits Bus Idle
dominant
Unit sends Overload Frame when at present it cannot receive frames any more due to high workload;
Transmission of an Overload Frame is started during the first two bits of the Interframe Space (IFS) of the
preceding frame;
Other units react immediately by also transmitting Overload Frames Overload Flags overlap, resulting in
up to 12 consecutive dominant bits;
Implemented in very few (mostly older) controllers, though controllers must still be able to interpret
correctly Overload Frames they receive;
Overload Frames do not influence the error counters (TEC and REC)
A unit originating a message is called “TRANSMITTER” of that message. The unit stays
TRANSMITTER until the bus is idle or the unit loses ARBITRATION.
A unit is called “RECEIVER” of a message, if it is not TRANSMITTER of that message and the bus is
not idle.
The message is valid for the transmitter, if there is no error until the end of END OF FRAME. If a
message is corrupted, retransmission will follow automatically and according to prioritization. In order
to be able to compete for bus access with other messages, retransmission has to start as soon as the
bus is idle.
The message is valid for the receivers, if there is no error until the last but one bit of END OF
FRAME.
Session Layer
IL
CCL
Transport Layer
TP GENy
Calibr Tool
NM Network Layer
CAN Controller
Physical Layer
CAN Transceiver
CAN bus
Functional scope:
Initialize the CAN controller;
Transmit a single CAN message: CanTransmit(<MsgHandle>);
Receive a single CAN message; A CAN controller is said to be in
Handle Bus-Off; "bus off" state if it's not
Support sleep mode;
participating in the bus traffic
Support special services. Some CAN Controller are supporting a
so called sleep mode with reduced
power consumption.
1. Interrupt control;
2. Assertions;
3. Support OSEK;
4. Multiple channels;
5. ...
36 / Basica Liviu / 2009 © Continental AG For Internal Use Only
Data Link Layer: CAN driver – Rx
CAN BUS
CAN message received
HW Acceptance Filters
For a Basic-CAN Controller or the Basic-CAN object of a
Normally,
The function
Full-CAN the CAN theDriver
ApplCanMsgReceived()
Controller hardware is informed
is calledby
acceptance bythethe CAN
filtering
Driver
CAN
providedon by
every
the reception
Controller of a CAN
via interrupt
CAN Controller of message
the
is not after
reception
sufficient. the
of a
Therefore
hardware
CAN acceptance
message.
a software filter is passed.
acceptance filtering has to be supported by
Receive Function
comparing the incoming message identifier
Thatthemeans
with completethelist
received CANmessage
of all relevant identifieridentifier.
has If a
SW Acceptance Filters passed the hardware
CAN message has passed acceptance
the hardware filtering of the
acceptance
CAN Controller
filtering and the
but is rejected by theentire message
software is stored
acceptance filtering
in a receive register.
(in case of a Basic CAN receive object) a special callback
DLC Check Generic
function precopy means
will be called that a common function
(if configured).
CAN ISR In case of a Basic-CANisobject,
ApplCanGenericPrecopy() the
called for all message
identifiers. has
Generic PreCopy Function toInbe retrieved
case and processed
IL component as fastprecopy
is used the generic as possible.
is
mandatory and it will be: IlCanGenericPrecopy()
PreCopy Function
After the generic precopy (if configured) a precopy
function separate for each message according to the entry
Copy DATA in Rx Reg. in the
In the description data
next step the is is
data called.
copied to the global data
buffer.
Indication Flag
Then the indication actions defined for this message are
performed. This means the indication flag is set and/or the
Indication Function indication function is called. The Application has to reset
the indication flag before or after data processing.
End Rx
Start Tx
First the CAN Driver checks whether the transmit path is
SW Appl: CanTransmit(msg)
switched to online state. If not the function returns with an
no error code.
CAN online ?
CAN Driver checks the availability of a hardware transmit
object. If no object is available the transmit request is
Queue Message stored in the transmit queue.
Within this user specific function the Application may
PreTransmit Function
copy the data to be transmitted directly to the CAN
Controller hardware registers.
Copy DATA in Tx Reg.
This functionality is used to check the transmit path of the
CAN Driver.The prototypes for the functions
Tx Observe 'ApplCanTxObjStart', 'ApplCanTxObjConfirmed',
CAN BUS 'ApplCanInit' are generated.
logical predecessor
message
D1 -> E1 E1 -> A A -> B2
Node A
Node D1 Node E1 Node B2
- two logical nodes -
CAN 0 CAN 1
A -> B1 B2 -> C2
logical successor
C1 -> D1 message
Node C1 Node B1 Node C2
C2 -> A
B1 -> C1
40 / Basica Liviu / 2009 © Continental AG For Internal Use Only
Transport Layer:
Transport Protocol (TP)
A TP is needed if the data length exceeds 8 bytes. In this case, the sender must divide
up the data into a number of CAN messages with the same identifier. Additional
information is necessary for the recipient to put the data back together again.
In a Single TPCAN
The classIDonly one connection
contains is addressing information (to each
the complete
possible, source
which isand
using the only available
target address combination a unique CAN ID is assigned)
Functional scope: TpChannel.
Now the application has a simplified and smaller API to handle the CANbedded
components (e.g. initialization, task handling, transceiver handling, network management
handling etc.).
main integration interface
Rez
Prio Data page PDU Format PDU Specific Source Address
1 bit
3 bits 1 bit 8 bits 8 bits 8 bits
0x0
Parameter groups
Parameter groups combine similar or associated signals. In the specification SAE J1939-71 the
parameter groups are defined with the signals they contain.
GlobalSample
PGNs for
of aparameter groups
parameter group that are sent to all (broadcast). Here all 16 bits of the PGN
definition:
are used; the
Name: value of the upper 8 bits (PDU format) must be greater than 239 (0xF0);
Engine temperature
Transmission rate: 1s
Data length: 8 bytes
Data
Specific page:for parameter groups
PGNs 0 that are sent to particular devices (peer-to-peer). With these
PDU format: 254
PGNs, only the higher-value 8 bits (PDU format) are valid and the value must be smaller than
PDUlower
240. The specific: 238specific) is always 0.
value byte (PDU
Default priority: 6
PG Number: 65262 (FEEE16 )
Description of data:
Each parameter
Byte: group is addressed
1 uniquely viacoolant
Engine a number (Parameter Group Number): PGN =
temperature
DP + PDUF + PDUS 2 Fuel temperature
3,4 Engine oil temperature
5,6 Turbo oil temperature
7 Engine intercooler temperature
8 Not defined
On a J1939 network, each device has a unique address. Each message that is sent by a device
contains this source address. There are 255 possible addresses:
Network Node:
- can be programmed in CAPL
language in order to interact in all
aspects with the CAN bus
- can interact with the CAN data
base
Generator Block:
- can output frames: data, remote, error
- can be triggered via key press, time
arrival of another message
- can interact with the CAN data base
Replay Block:
- can output messages
Interactive Generator Block: that are stored in a log
- can output frames: data, remote, error file ( e.g.: CANOE.asc
- can be triggered via key press, time file)
- can manipulate during simulation runtime
- can display and manipulate signals
inside message
Trace window:
- shows the content of the bus: timing,
channels, message ID, name, direction,
length and data field
Data window:
- shows the values of various CAN
signals in raw value or/and physical
value
Graphics window:
- shows graphically the values of various
CAN signals in raw value or/and
physical value
Logging window:
- allows the user to record the content of
the CAN bus into a log file
54 / Basica Liviu / 2009 © Continental AG For Internal Use Only
ECU configuration:
CAN data base -source address;
CAN channel -received and transmitted messages
name and signals
Message configuration:
- ID, name, length, receiving and
transmitting ECU, signal layout,
transmission type and cycle time
- etc;
Signal configuration:
- length, bit ordering, unit, factor,
offset, min and max, send type,
timeout time, receiving ECUs,
- etc.
message list
signal list