CAN Bus Tutorial
CAN Bus Tutorial
CAN Bus Tutorial
Home
About us
News
FPGA Products
Microcontrollers
Biometrics
Other Products
Lab Equipment
Projects
Articles
Shop
Contact
Created by BOSCH in the 80's and primarily intended for the automotive industry, Controller Area Network (CAN)
protocol is becoming an industry standard for inter-system serial communications.
Joan C. Abelaira
Origins of CAN
Since the late 70's electronics in automobiles has been growing up to the point a medium-segment car manufactured today (2008) can
contain up to 70 ECUs (Electronic Control Units). As automotive electronic elements are physically distributed and efficient
communication between them offers a better behaviour of the car' electronics as a whole, communication plays a key role.
Existing serial protocols like RS232 and their variants (RS422, RS485, etc.), I2C or SPI did not fulfil the automotive requirements.
Bosch GmbH developed a multi-master serial bus protocol, frame-based (data organization) and message-based (opposite to addressbased architectures), the Controller Area Network or CAN. Released in 1986, first ICs were produced next year. In 1991, CAN
specification v2.0 was released. In 1994, ISO-11898 standardizes CAN protocol layers 1 and 2 (physical and data link).
The architecture is designed to support any programming language, such as C and C++. The full benefits of the instruction set may
require extensions to standard languages, libraries, or the use of assembly language. XMOS has designed XC, a version of C that
supports I/O, multi-core and precision timing.
ISO standards of CAN
There are so far four ISO standards related to CAN (see below). The first one, ISO 11898-1 describes the CAN protocol and just covers
the Data Link Layer (MAC and LLC) and the Physical Layer (PLS). This is the field of the CAN controller, with hardware-implemented
functions.
Documents ISO 11898-2 and ISO 11898-3 cover the PMA and PMS of Physical Layer, implemented by the transceivers and physical
bus medium. Two speeds (125 kbps and 1 Mbps) are standard.
For the MDI sub-layer (physical connector), no standard exists but CiA DS-102 recommends SUB-D9.
Finally, ISO 11898-4 adds time triggered communication to the event-driven communication defined in ISO 11898-1.
CAN network, bus and nodes
A CAN network consists of a number of nodes which are linked via a physical transmission medium (the bus). Typically the topology is
linear as in the picture below, but a star configuration can be used if necessary.
For Electromagnetic Immunity the bus is implemented as a symmetric differential UTP (Unshielded Twisted Pair), with termination
resistors. Line resistance should be less than 60 m. The maximum data rate is 1 Mbps with a maximum bus length of 40 meters. The
maximum number of CAN nodes is 32 according to ISO. CAN bus lines are designated as 'high' (CANH) and 'low' (CANL). For high speed
bus, characteristic bus impedance is 120 and is not specified for low speed.
Nodes and ECUs (Electronic Control Units) can somehow be seen as interchangeable terms. Primitive ECUs had simple hardware (a
transceiver and a controller) and software . Current software state-of-the-art includes RTOS (Real-Time Operating System), network
management functions and error management. As ECU software has become complex a parallel effort has been done to setup a
standardizing architecture, like AUTOSAR presented below.
AUTOSAR
AUTOSAR stands for AUTomotive Open System ARchitecture. It is a reference software architecture for automotive (ECU)
software developed by a joint of car manufacturers and related companies. The official website is www.autosar.org. Picture below
describes the software layers under its architecture.
A key of AUTOSAR is the RTE (Run Time Environment) that decouples the ECU software components from the network
management functions. The RTE automatically provides each software component with the required network information.
The transceiver interfaces the controller (logical signals) to the bus (differential) with a general schematic shown below. If a logical
'1' is set through TxD, both transistors are cut off and both CANH and CANL voltages are 0,5Vcc via de pull up resistors. If a logical
'0' is set, CANH voltage raises and CANL lowers thus appearing a differential voltage, detected by all the Receivers in the network.
Note that if bus drivers set different logical values, the bus will be in the logical '0' state (CANH > CANL). Therefore the logical '0' is
called dominant (gains) and the logical '1' recessive (looses). This is used for bus arbitration. High-speed transceivers (up to 1 Mbps)
are different from Low-speed transceivers (125 kbps). The latter are fault-tolerant and a bus failure of one wire does not lead to a total
communication failure, therefore being reserved for safety signals. CAN transceivers offer very low EMI and a large common mode
operating range. For added noise immunity and EMI, common mode chokes (CMC) can be connected to each node (ECU) bus lines.
CAN communication principles
For improved reliability in critical applications, CAN bus protocol is decentralized. This means there is no master node and each node
can access the bus to send messages when it is free. An ECU (node) can fail without severely affecting the network.
Bus access is also event-driven, that is a node broadcasts a message whenever there is a new data for other nodes. There is no time
schedule or fixed data rates.
CAN bus is also said to have a broadcasting scheme, so a message sent by a node is received by all the other nodes in the network.
Each receiving node selects whether to accept or discard it by the message identifier (MID) included in the frame.
CAN bus is also quick. Frames are short and last for hundreds of microseconds. So the latency for a node until the bus is free to
broadcast a message is of that order.
go to part II
http://www.jcelectronica.com/articles/CAN%20bus%20tutorial.htm (7 of 8)05/04/2011 23:03:09
Home | About | News | FPGA| Microcontroller | Biometrics | Other Products | Lab Equipment | Projects | Articles | Shop | Contact