You are on page 1of 34

Introduction to CAN

Introduction to CAN

3,75
V CAN High
2,5
V
CAN Low
1,25
V 0 0 1 0 1 0 1 0 0 1 1 0 1 0

120Ω 120Ω

INTRODUCTION TO CAN........................................................................................................................ 1
1. CAN....................................................................................................................................................... 2
1.1 Preface ............................................................................................................................................ 2
1.2 Abreviations .................................................................................................................................... 3
1.3 CAN milestones............................................................................................................................... 4
1.4 Essentials ........................................................................................................................................ 5
1.5 CAN bus .......................................................................................................................................... 9
1.6 Nodes ............................................................................................................................................ 17
1.7 I/O units ........................................................................................................................................ 20
1.8 CAN protocol ................................................................................................................................ 21
1.9 Response times .............................................................................................................................. 24
2. APPLICATION LAYER PROTOCOLS ......................................................................................................... 25
3. HMI...................................................................................................................................................... 27
4. CAN OR CAN NOT ................................................................................................................................. 29
4.1 Breaking the machine or rules ...................................................................................................... 29
4.2 checking the CAN-cable................................................................................................................ 31
4.3 Oscilloskope.................................................................................................................................. 32
MORE INFORMATION ................................................................................................................................ 34

1
Introduction to CAN

1. CAN

1.1 Preface

CAN (Control Area Network) was originally designed for data transfer in distributed
systems in vehicles, for the communication between the ABS-braking system, the gear
control system, and the engine control system, for example. The development of CAN
was initiated by the Robert Bosch corporation. ISO (International Organization for
Standardization) has released several CAN related standards.

In principle, CAN is a network of processors that enables the state variables of nodes to
be accessible throughout the network. A CAN-system is applicable in any device that
requires almost simultaneous data transfer between devices and uses relatively short data
transfer distances and simple messages. Due to CAN’s error handling and correction
capabilities the system is generally considered reliable.

A CAN-bus only enables the data transfer in a system. Practical applications require more
complex solutions which are implemented with software on the so-called application
layer.

2
Introduction to CAN

1.2 Abbreviations

AI Analog Input
CAL CAN Application Layer
CAN Control Area Network
CAN_L CAN Low
CAN_H CAN High
CAN_GND CAN Ground
CAN_SHLD CAN Shield
CAN_V CAN supply current
CANKingdom Upper level communication protocol which determines the
format of how control commands are transferred in CAN
bus.
CANopen Upper level communication protocol which determines the
format of how control commands are transferred in CAN
bus.
CiA CAN in Automation
CPU Central Processing Unit
DI Digital Input
DO Digital Output
EMCY Emergency object
FB Feedback
HLP Higher Layer Protocol
HMI Human – Machine Interface
I/O Input/Output
ISO International Standardization Organisation
J1939 Specification of a CAN driven application for
telecommunications in truck vehicles by SAE
Kbit Kilobyte
Mbit Megabyte
MMI Man – Machine Interface
OSI Open Systems Interconnection
PWM Pulse Width Modulation
SAE Society of Automotive Engineers
TCS Tamrock Control System

3
Introduction to CAN

1.3 CAN milestones

Start of the Bosch internal project to develop an in-vehicle


network

Official introduction of CAN protocol

First CAN controller chips from Intel and Philips Semiconductors

Bosch’s CAN specification 2.0 published

CAN Kingdom, a CAN-based higher-layer protocol introduced by


Kvaser

CAN in Automation (CiA), an international users’ and


manufacturers’ group, established

CAN Application Layer (CAL) protocol published by CiA

First cars from Mercedes-Benz use CAN network

ISO 11898 standard published

1st international CAN Conference (iCC), organized by CiA

DeviceNet protocol introduction by Allen-Bradley

ISO 11898 amendment (extended frame format) published

CANopen protocol published by CiA

Development of the time-triggered communication protocol for


CAN (TTCAN)

4
Introduction to CAN

1.4 Essentials

The number of electronic appliances in vehicles has multiplied within recent decades.
The CAN system was developed to reduce wiring.

5
Introduction to CAN

Conventionally one Central Processing Unit (CPU) controls and monitors the connected
devices in automation. The ’intelligence’ of the device is located in a single unit.

In a decentralized automation system, the system has several independent processing


units which share monitoring and controlling information throughout the system.

A1 & A2 - CAN-nodes (transceiver, CAN-controller, microcontroller)

6
Introduction to CAN

A CAN bus consists of CAN-nodes and the twin cable connecting them. Actuators and
sensors are connected to nodes. The node controls and monitors the connected devices.
Data transfer between nodes is carried out digitally, that is, in ones and zeroes.

CAN_H

120Ω 120Ω

CAN_L

Solmu 1 Solmu 2 Solmu 3 Solmu 4

The nodes ’talk’ to each other by causing voltage variations in the cable. E.g. when the
cable has a 3.5V voltage it implies a 1. If the voltage is 2.5 a 0 is implied. Zeroes and
ones are called bits.
CAN uses a twin cable where the other conductor is CAN_H (high) and the other
CAN_L (low). The same signal is transmitted simultaneously in both cables but each
cable uses different voltages.

3,75
V

2,5
V

1,25
V 0 0 1 0 1 0 1 0 0 1 1 0 1 0

A bit has two values: either 1 or 0. It forms binary numbers. To express larger numbers
we need to use multiple bits. Three bits are needed to express the first eight digits:

0 = 000 1 = 001 2 = 010 3 = 011 4 = 100 5 = 101 6 = 110 7 = 111

A binary number is converted to a decimal number by multiplying all the bits with 2
raised to the power of the bits’ ordinal number (from right to left) and adding the
products.

7
Introduction to CAN

E.g. number 11010:

A lock knob is pressed on a car door. The door node monitors the knob and generates a
digital message by causing voltage variations in the CAN-cable. The node in the control
panel reads the message and lights up an indicator light on the panel.

When the knob is up a simplified CAN message looks like this:

150 1 0
Identifier Length of message State variable

When the knob is down the state variable changes:

150 1 1
Identifier Length of message State variable

The content of the message could be described as: The state of device 150 is now 1.

The message is not sent to a specific target. It is sent to the CAN bus and is read by all
the connected nodes.

8
Introduction to CAN

1.5 CAN bus

The CAN bus goes through each node and it is terminated with termination resistors.

A twisted pair cable with two signal transmitting conductors is used: CAN_H which uses
a voltage range of 3.5 V- 2.5 V for signal transmission and CAN-L which uses a voltage
range of 1.5 V – 2.5 V for transmitting the same signal simultaneously.

9
Introduction to CAN

An oscilloscope image of a sound CAN bus.


The graphs are mirror images of each other.

The cables are twisted to minimize electromagnetic interference.

10
Introduction to CAN

Besides CAN_H and CAN_L the cable


bundle has grounding ( CAN_GND ),
supply current ( CAN_V+) and shield
(CAN_SHLD ).

CAN_H (white)

CAN_L (brown)

CAN_GND (green)

CAN_V+ (yellow)

CAN_SHLD (screen)

Tamrock uses 5-pin model M12 connectors.

11
Introduction to CAN

Pin array and cable colors used by Tamrock:

Male Female

Pin Signal Colour


1 CAN_SHLD Screen
2 CAN_V+ Yellow
3 CAN_GND Green
4 CAN_H White
5 CAN_L Brown

The connector and the cable dismantled. Notice the dirt and moisture proofing (A).
12
Introduction to CAN

For sufficient protection against harsh conditions the CAN-cable is threaded through a
hydraulic hose in mobile equipment.

13
Introduction to CAN

Terminating the CAN-bus is essential. This can be done using 120 Ω resistors between
CAN_H and CAN_L on both ends.

Split termination, where two 62 Ω resistors are placed between both CAN-H and CAN_L
and CAN_GND improves symmetry. The joint resistance is ca. 120 Ω. A capacitor
connected to CAN_GND from between the two resistors conducts any high frequency
interference to the grounding.

14
Introduction to CAN

The outermost node on the CAN-bus and a terminator plug.

Terminator pieces used by Tamrock.

15
Introduction to CAN

Oscilloscope images of a sound and a faulty CAN_H and CAN_L signal show how slow
recovery voltage may cause a misinterpretation.

SOUND FAULTY

The bit arbitration scheme between the nodes necessitates that the wave front of the
signal can propagate to the most remote node and back again before the bit is sampled.
This limits the maximum length of the CAN-cable according to used data transfer rate. At
1Mb/s the maximum length is 25 metres and at 500 Kb/s the maximum length is 100
metres, etc.

Max. cable length Transfer rate Kb/s Nominal time/bit µs


25 m 1000 1
50 m 800 1.25
100 m 500 2
250 m 250 4
500 m 125 8
650 m 100 10
1 km 50 20
2.5 km 20 50

5 km 10 100

16
Introduction to CAN

1.6 Nodes

Nodes connected via CAN bus have a CAN-compliant transceiver and a CAN controller,
which can be integrated with a microcontroller.

This circuit card has the connection sockets on the top face. A micro controller is located
on the other side.

Encapsulated CAN node TCS module

17
Introduction to CAN

Sensors and actuators are connected to nodes. Nodes monitor the status information of
the sensors. E.g. Is the door closed? What is the current engine temperature? Etc. The
node controls actuators which control e.g. the behavior of valves. A node can monitor
one or several sensors and control one or multiple actuators.

18
Introduction to CAN

Image 1 Image 2

Image 1: Axera’s SLU node


Image2: A TCS module from Toro 0011. Sensors and actuators connect
to sockets 1-3. Socket 4 is for the CAN bus.

Bus interface control unit connects I/O units (sensors & actuators) to the CAN bus.
This control unit can be connected with up to 64 digital inputs (DI), 64 digital outputs
(DO), 12 analog inputs (AI), and 12 analog outputs (AO).

19
Introduction to CAN

1.7 I/O units

Angle sensor Electromotor

Different types of signals are used to control actuators and monitor sensors. Signal types
used by the TCS are presented below:

Lyhenne Selvitys
PWM Pulse Width Modulation, output signal

FB Feedback, the control signal is read back to module from the proportional
valve
DO Digital Output, 24 V
DI Digital Input, used to read signal from a switch (24 VDC or 0 VDC)
AI Analog Input, is used to read the analog input from sensors

20
Introduction to CAN

A signal type is set for each pin in a TCS module.

1.8 CAN protocol

The nodes communicate digitally with ‘ones and zeroes’ which are called bits. Only one
node at a time can be transmitting on the CAN bus. Others have to wait their turn
according to a preordained protocol. The nodes must have information about which of the
nodes is transmitting, when the message is over, etc. The way, timing, and order this
information is passed in the message is called protocol.

Every message must include certain basic information to make the send/receive action
possible. E.g. writing a letter is not adequate to get a message through. One needs an
envelope, an address, a stamp, etc. A CAN message that includes information required by
the protocol and the message it self (e.g. engine temperature) is called a frame.

The CAN protocol defines four different frames: Data frame, Remote frame, Error frame,
and Overload frame. The frame consists of fields. The main fields of a data frame are
Arbitration field which holds the identifier, Data Length Code field which indicates the
amount of bits reserved for the oncoming Data field, and the Data field which contains
the actual information e.g. engine temperature.

21
Introduction to CAN

SOF Start of Frame


ARBITRATION contains the identifier number
RTR Remote Transmission Request. If this is a request frame, then the
RTR bit is marked as 1, otherwise it is 0.
IDE Identifier Extension. If this is a basic CAN message, then the IDE
bit is marked as 0. An extended CAN message is marked as 1.
DLC Data Length Code. Number of bits preserved for the Data field.
CRC Cyclic Redundant Check.
ACK Acknowledge field
EOF End of Frame
INT (IFS) Intermission Frame Space. 3 recessive bits.
SRR replaces the RTR-bit

In Can protocol the transceivers have no addresses and the messages are transmitted to
the bus and can be received by all nodes. Respectively all the nodes can start transmitting
at the same time when the bus is available. Message priority is set by the identifier
number, the smaller the number the higher the priority. In case several nodes start
transmitting at the same time, the nodes with higher identifier numbers will stop
transmitting as they encounter a dominant bit sent by a node with a smaller identifier. The
dominant bit is 0 and the recessive bit is 1. The message priority is illustrated in the
following graphics.

22
Introduction to CAN

Three nodes start transmitting at the same time.

Node 813 tries to send the first recessive bit. The bit is overrun by dominant 0. Node 813
aborts transmitting and shifts to receive only. Other two nodes continue transmitting.

On the fifth bit node 218 sends a recessive bit. Transmitting is aborted and the node shifts
to receive only.

Message from node 177 is sent on the bus.

23
Introduction to CAN

A cyclic redundant check (CRC) is used to detect errors. Other error handling methods
are also applied: bit-stuffing, acknowledgment, and frame check and bit monitoring.

The ins and outs of the CAN protocol are not presented here in detail. In short:

Transceivers have no addresses. The messages have identifier numbers and the messages
are sent to the bus for all the nodes.
Information is sent using frames.
Error checking and error handling methods ensure that the listening nodes have received
the transmitted message correctly.

Notice that an error that occurs when a node does not receive a message at all (e.g. due to
a loose socket) will be undetected. Such error conditions require network management
procedures. Network Management (NMT) is not a part of the CAN protocol. NMT is
implemented by an application.

1.9 Response times

The duration of the send/receive action of frames (messages) vary depending on message
priority, length of message, transmission rate, and the bus load.

The shortest possible response time occurs when a message has a 0 bit data field and it is
transmitted on to the bus immediately. In this case the bus is available (no bus load), and
the message’s identifier number (priority) is smaller than any other message’s. The length
of the frame is 47 bits. E.g. at transmission rate of 1 000 000 bit/s the response time
would be 47µs.

Highest response time would occur with a message that has poor priority while the bus
load is 100%. In such case the message would not be transmitted at all.

24
Introduction to CAN

2. Application layer protocols

Besides the services provided by the data link layer (CAN) a number of higher layer
services that are implemented by an application are required. ISO (International
Standardization Organization) has released a 7-layer OSI model (Open Systems
Interconnection) for standardizing data communications. CAN hardware implementations
cover the lower two levels of the OSI reference model.

OSI –reference model

With an application it is possible to manage the network, configure nodes, move larger
data packets than fit into one CAN data frame, etc. Applications can be self-generated or
it’s possible to use internationally released specifications. In the early 90's, the SAE
(Society of Automotive Engineers) Truck and Bus Control and Communications Sub-
committee started the development of a CAN-based application profile for in-vehicle
communication in trucks. 1998 SAE released the J1939 specification that was a basis for
several other application layer specifications.

CiA’s (CAN in Automation) CANOpen and the Swedish Kvaser AB’s CAN Kingdom
are examples of commonly used general purpose specifications. There are several more
pinpointed specifications and standards being developed by different standardization
organizations for demands such as fork-lifters, ships, bus service signs, etc.

25
Introduction to CAN

The application layer communication operates with application layer data objects. E.g. A
100 bit long application data packet that is being sent from node to node needs to be
chopped into slices small enough to fit into a CAN data field and then transmitted piece
by piece. Protocols used on application layer are called HLP (Higher layer Protocol)

An example of a higher layer service is the EMCY (Emergency object) of CANOpen.


With EMCY the nodes can report their internal states of emergencies such as overheating
or low voltage.

Network Management protocol features node boot up, shut down, and network
monitoring. Network monitoring ensures that all the wanted nodes are operational and
connected to the bus. Nodes can be configured by the application. The application can
change e.g. identifiers, transfer rates, and transceiver settings.

CANopen protocol compatible Bus interface unit

26
Introduction to CAN

3. HMI

It’s not of much use to read the CAN bus with a multimeter. To translate the information
a CAN-compatible diagnostics device is needed. Then again it’s not of much use to see
the can messages and their identifiers without profound understanding of the system.
Manufacturers develop system specific diagnostics devices which endeavor to illustrate
the function of the application and the whole system to the user.

Screenshot from Axera’s monitoring display

27
Introduction to CAN

Through a user interface the system functions can be controlled and monitored with a
joystick, monitor, keyboard, etc. The interface is called HMI (Human-Machine Interface)
or MMI (Man-Machine Interface).

Maintenance personnel can configure the system by changing the node settings and
installing new software.

Käyttöliittymän komponentit

CAN
BACKBONE
HMI IO-slave module / left

HMI PC BNET
CAN HM I SU 15”
Monitor

VGA

CA N
HM I
S UB N
ET
US

Ethernet
B

switch USB HUB

HMI IO-slave module / right


ETH
ER

Keyboard
NE
T

System Master

Another User
Interface

In this illustration the monitor and the control units are connected to a PC. The HMI PC
is connected to the CAN bus and transmits the driver’s commands to the nodes.
Information from nodes is assorted and delivered to the monitor.

28
Introduction to CAN

4. CAN or can not

4.1 Breaking the machine or rules

Computerized control and monitoring enables the system designers to set conditions for
the machine’s behaviour. E.g.:

- If the cabin door is open, the engine is not allowed to start.


- If the engine revolutions exceed 3000 rpm, the cooler circulation increases.

A function can have a list of conditions that have to be met before the function is allowed
to be executed. E.g.:

The boom cannot be lifted if: The remote control is activated or the load is too heavy or
the drill is activated, etc.

Recognizing the rules is essential in troubleshooting.

A list of conditions that have to be met to allow boom lift with TORO 0011:

POS FUNCTION STATUS MODULE PIN SIGNAL


1 Joystick deviated to right: Joystick Chair XM3, 5 0–5V
deviated
2 Boom up control signal from module Active Frame XM1, 3 PWM
3 Boom joystick direction switch (X- Active Chair XM2, 6 24 V
direction, pos)
4 Boom joystick direction switch (X- Passive Chair XM2, 5 0V
direction, neg.)
5 Parking brake Released Frame XM2, 19 24 V
6 Door status Closed Frame XM3, 21 24 V
7 Remote control Not on Frame XM2, 20 0V
8* Pump control signal from module Active Frame XM2, 1 PWM
9 RPM > engine speed minimum RPM > 500 Frame XM3,16 Pulse
(parameter, set normally 500)
10 E-stop Not Frame XM3, 20 24 V
activated

29
Introduction to CAN

Let’s take a closer look at condition 5

5 Parking brake Released Frame XM2, 19 24 V

The parking brake must be released. Information about the parking brake status is read
onto to the CANbus via the FRAME module socket XM2 pin 19. When the break is
released a 24V current is conducted to pin 19. The FRAME module sends the data to the
CAN bus and the message is read by the module controlling the boom.

If the hand brake is on, no voltage is conducted to pin 19. The FRAME module transmits
the information and the boom lifting is prohibited. A faulty wire or sensor could cause a
misinterpretation. In case the hand break is released but due to a broken wire or a faulty
sensor no current is conducted to the pin, the boom lifting is prohibited.

PO FUNCTION STATUS MODUL PIN SIGN


S E AL

1 Joystic deviated to right: Joystick Chair XM3, 5 0–5V


deviated

2 Boom up control signal Active Frame XM1, 3 PWM


from module

3 Boom joystick direction Active Chair XM2, 6 24 V


switch (X-direction, pos)

4 Boom joystick direction Passive Chair XM2, 5 0V


switch (X-direction, neg)

5 Parking brake Released Frame XM2, 24 V


19

6 Door status Closed Frame XM3, 24 V


21
7 Remote control Not on Frame XM2, 0V
20

8* Pump control signal from Active Frame XM2, 1 PWM


module

9 RPM RPM > Frame XM3,1 Pulse


500 6

10 E-stop Not Frame XM3, 24 V


activated 20

30
Introduction to CAN

4.2 checking the CAN cable

The cable is sound if any of the CAN-controlled functions work. In case there is reason to
believe that the cable is damaged, check the joints and tighten them if necessary, or
replace the joints with new ones.

Checking the conductors and the resistors by measuring the resistance between CAN_H
and CAN_L:

The cable is sound. The resistors on both ends of the bus are connected in series. Their
joint resistance is 124 Ω. When measured between the conductors they are connected in
parallel and the resistance is 62 Ω. If the measurement result is below 52Ω the bus has
probably short circuited.

There is a break in the CAN_L conductor. Only resistors on the other end influence the
measurement result. Therefore the resistance is 124 Ω.

31
Introduction to CAN

4.3 Oscilloscope

1Mbps CAN signal from a 22 metre cable (close to the 25 metre maximum length).
Signal quality is good, edges are steep and there are only faint reflections. There is only
minor asymmetry which does not cause interference.

32
Introduction to CAN

Spikes at recessive levels caused by wrong termination.

Sloping edges caused by wrong bus structure.

33
Introduction to CAN

More Information

CiA : CAN in Automation.


http://www.can-cia.org/

Kvaser AB
http://www.kvaser.com

M J Schofieldin CAN –database


http://www.mjschofield.com

Boschin CAN –pages


http://www.semiconductors.bosch.de/de/20/can/index.asp

Embedded Systems Academy – demand registration, free


www.esacademy.com/myacademy/classes/descriptions/canopen.htm

EN 13149 -standardin sovellusohje


Ohjeita liikennöijälaitteiden väliseen väyläpohjaiseen
tiedonsiirtoon joukkoliikennevälineissä.(Finnish)
Liitteenä CAN-väylä ja CANopen perusteet (Finnish)
http://www.vtt.fi/rte/projects/fits/julkaisut/hanke1/fits33_2004.pdf

Työkoneiden ja automaation CAN-väyläsovellusten turvallisuus,


VTT:n tutkimus (Finnish)
www.vtt.fi/inf/pdf/tiedotteet/2000/T2036.pdf

34

You might also like