7 Automotive CAN

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 82

CAN

Controller Area Network


 CAN is a Asynchronous , Half Duplex Protocol
 CAN Uses TWO Wires CAN_H and CAN_L
 CAN is a High Speed Protocol , Operates at 1MBPS to
10MBPS.
 1 byes to 8 Bytes information can transmits in a single
Transmission.
 Error Detection, Error Notification and Error Confinement.
 Long Distance communication up to 40meter @ the speed
of 1MBPS
 Up to 500 meter @128kbps
 CAN is not a Master Slave Protocol,
 CAN is a Message Based Protocol
 CAN is a Address (Device Address ) Based Protocol
 CAN Uses 11bit Addressing or 29 Bit Addressing
 CAN has Data Frame, Extended Frame, Remote
Frame, Error Frame
 CAN Uses NRZ coding, Bit Stuffing
 CAN Uses Wired And Logic
 CAN Uses Differential Voltage Technique
 CAN uses CSMA/CD: Carrier Sense multiple Access
and collision detection.
 CAN uses Arbitration method
CAN :Control Area Network
LIN: Local Interconnect Network

RKE: Remote Keyless Entry


TPMS: Tyre Pressure Monitoring System
Typical n/w of devices in an automobile

• Need
– Reduce wiring
– Transfer large amount of data at high speed
– Need for multi cast
– Robust error checking
– Fault tolerance
– Flexibility …
CAN Network

CAN Protocol : Set of rules for transmitting and receiving


messages in a network of electronic devices.
Need of CAN
Reducing the number of wire harnesses
Transferring large amount of data at high
speed via multiple LAN’s and so on
 The idea initiated by Robert Bosch in 1983
to improve the quality of automobiles there
by making them more reliable, safe and fuel
efficient
 CAN Released in 1986
Basic Definition
• CAN Protocol is a Asynchronous method of
communication b/w various electronics devices like
 Engine management System,
 Active Suspension,
 ABS,
 Gear Control,
 Lighting Control,
 Air Conditioning,
 Airbags,
 Centre Locking etc
Applications of CAN
ECUs inside a CAR
• Electronic Fuel Injection ECU
• Gear Box Control
• Air Bags ECU
• Anti Lock Breaking System
• Hand Break ECU
• Door Monitoring
• Seat Belt Monitoring
• Anti Theft Vehicles
CAN Standards

• CAN ISO Standards


– ISO 11898 -2 (High speed networking)
•0 bps to 1 Mbps

– -Revised to ISO 11898 -3


(ISO 11519 Low speed networking)
•upto 125 Kbps
CAN layered architecture
•As we know that the OSI model partitions the communication
system into 7 different layers.
•But the CAN layered architecture consists of two layers,
i.e., data-link layer and physical layer.
CAN Bus Standards
• CAN 2.0 A – Standard CAN
– 11 bit message identifiers
• CAN 2.0 B – Extended CAN
– 29 bit message identifiers
• CAN FD (Flexible Data rate )
– Released by Bosch in 2012
– Flexible data length
– Capable of switching to faster bit rate after arbitration
– Compatible with CAN 2.0
CAN speeds
• CAN 2.0 A
– Speed upto 125 Kbps.
– Low speed CAN (ISO - 11898-3 )
– Distance : 500 mtrs
• CAN 2.0B
– Speed up to 1 Mbps
– High speed CAN (ISO – 11898-2)
– Distance : 40 mtrs
• CAN FD
– Upto 15 Mbps
– Distance : 10 meters
Physical Layer
Signal Mechanism , Wired AND Logic, Message Coding
A physical layer defines the electrical levels and signaling
scheme on the bus, the cable impedance and similar things.
CAN bus :
• There are two different signaling states: dominant (logically
0) and recessive (logically 1).
• Logic 0 and Logic 1 correspond to certain electrical levels
which depend on the physical layer used
• The bus uses Non-Return To Zero (NRZ) with bit-stuffing.
• The modules are connected to the bus in a wired-and fashion:
– if just one node is driving the bus to a logical 0, then the
whole bus is in that state regardless of the number of
nodes transmitting a logical 1.
NRZ coding
• A non-return-to-zero (NRZ) line code is a binary code in which
ones are represented by one significant condition, usually a
positive voltage, while zeros are represented by some other
significant condition, usually a negative voltage
• No other neutral or rest condition.
• RZ code also has an additional rest state beside the
conditions for ones and zeros
• The pulses in NRZ have more energy than a return-to-
zero (RZ) code

NRZ Coding RZ Coding


• CAN uses NRZ encoding with bit stuffing after
5 consecutive bits
• In NRZ encoding voltage level remain constant
during bit interval
Problem With NRZ
• As we know in NRZ encoding voltage level remain
constant during bit interval
• If we are sending long sequence of bits, No
voltage changes for longer duration
• For longer unchanged sequence Rx loose the
synchronization with Tx
• Misinterpretation of data can be happen

Bit stuffing is used to ensure the synchronization


of all nodes
Bit Stuffing
• A bit of reverse polarity is inserted after 5
consecutive bits of same polarity ( because of
NRZ coding)
• Bit stuffing is done for synchronization of all
nodes
• 6 consecutive bits of same polarity indicates error
• Not applicable to ACK, delimiters, EOF
• The receiver also checks the number of bits of
same polarity and removes the stuff bits again
from the bits stream, this called “de-stuffing”
CAN network
Host
A host is a microcontroller or microprocessor which is running some
application to do a specific job. A host decides what the received
message means and what message it should send next.

CAN Controller
CAN controller deals with the communication functions described by
the CAN protocol. It also triggers the transmission, or the reception of
the CAN messages.

CAN Transceiver
CAN transceiver is responsible for the transmission or the reception of
the data on the CAN bus. It converts the data signal into the stream of
data collected from the CAN bus that the CAN controller can
understand.
CAN uses unshielded twisted pair cable is used to transmit or
receive the data.

It is also known as CAN bus, and CAN bus consists of two lines,
i.e., CAN low line and CAN high line, which are also known as
CANH and CANL, respectively.

The transmission occurs due to the differential voltage applied to


these lines.

 The CAN uses twisted pair cable and differential voltage because
of its environment.

For example, in a car, motor, ignition system, and many other


devices can cause data loss and data corruption due to noise.
CAN bus Signaling Mechanism

• Differential Voltage of 2v -> Logic 0 (Dominant)


• Differential Voltage of 0v -> Logic 1 (Recessive)
• Both wires are driven while transmitting a ‘0’
• Neither wire is driven while transmitting a ‘1’
Termination resistors
• It is device attached to the end points of a bus
network

• Signal Reflection
 When a signal is transmitted along a
transmission medium, such as a twisted pair
cable or an optical fiber, some of the signal
power may be reflected back to its origin
rather than being carried all the way along the
cable to the far end
 This happens because imperfections in the
cable cause impedance mismatch & changes
in the cable characteristics
• Thus, for impedance matching we are using
120 ohm resister
2

HOST CONTROLLER – Responsible for the functioning of NODE


CAN CONTROLLER- Responsible for convert the msg of nodes according
to CAN protocol
CAN TRANSRECEIVER- Converted msg tx/rx by transreceiver
In general terms…

Protocol Types

ADDRESS BASED MESSAGE BASED

Data Packet contain address Every Msg is identified by the


of the destination predefined unique id
4

CAN is MSG based Protocol

8 BYTES
5. Error Handling
• CAN protocol provides mechanisms for
– Error detection
– Error Notification
– Error Recovery
CAN Media Access

• CSMA/ CD  NDBA(Non destructible Bus Arb)


• All nodes must sense bus before
transmission(CS) Carrier sense
• Equal Access opportunity for all nodes(MA)
• Must detect collision during transmission(CD)
• Once collision detected, distributed
arbitration applied
CSMA/ CD
Arbitration

• Any node may transmit when bus is idle


• The node which begins first gets the bus.
• If multiple nodes start sending simultaneously
– The node whose message has highest priority gets the bus.
– Other nodes trying to transmit become receivers
– Nodes which loose arbitration will automatically re-
transmit
Types of Frame
1. Data frame: Used to transmit up to 8 bytes of
data
2. Remote frame: Used to request a data frame
3. Error frame: Used to indicate error to the
entire network
4. Overload frame: Used to create an extra
delay between frames
5. Inter-frame space: separate different data
frames
The SRR bit is the Substitute Remote Request, which in case of, standard data frame
and extended data frame, when both messages have equal base identifier, then
standard data frame has higher priority and hence it indicates the bit is always a
recessive bit.
Remote frames

• The purpose of the remote frame is to seek


permission for the transmission of data from
another node.
• This is similar to data frame without data field
and RTR bit is recessive.
RTR=0

RTR=1
• SOF - Start of Frame bit.
It indicates start of message and used to
synchronize the nodes on a bus. A dominant
bit in the field marks the start of frame.
• IDENTIFIER - It serves dual purpose one, to
determine which node has access to the bus
and second to identify the type of message.
(Arbitration field)
This field indicates the priority of data. The
structure of this field differs between the
standard and extended formats. 11 or 29 bits
• Control field: This 6-bit field indicates the number of
data bytes in a message to be transmitted. The
structure of this field differs between the standard
and extended formats.
RTR: Remote Transmission Request.
It identifies whether it’s a data frame or a remote
frame .RTR is dominant when it is a data frame and
recessive when it is a remote frame.
0 = Data frame (Write)
1 = Remote Frame (Read)
IDE: Identifier Extension
It is used to specify the frame format. Dominant bit is
for standard frame and recessive for extended frame.
IDE bit
0 = Standard ID (11 bit)
1 = Extended ID (29 bit)

R0 - Reserved bit. Not used currently and


kept for future use

DLC: Data Length Code.


It is 4 bit data length code that contains the
number of bytes being transmitted.
Data field

• Data field: This field indicates the content of


data. Zero to 8 bytes of data set in the control
field can be transmitted. The data is output
beginning with the MSB side. Contains
information/set of information like Engine
Speed, Torque and Vehicle Speed etc.
Acknowledge Field:

• This field indicates a signal for confirmation


that the frame has been received normally. It
consists of 2 bits, one for ACK slot and one for
ACK delimiter.
• The "recessive" delimiter bits ensure that
there are bit transitions in the fields that do
not have bit-stuffing applied.
• EOF: End of Frame (EOF). The 7-bit field
marks the end of a CAN frame (message)
(7 consecutive Ones)
• IFS: Inter Frame Space that specifies
minimum number of bits separating
consecutive messages. It provides the
intermission between two frames and consists
of three recessive bits known as intermission
bits. This time allows nodes for internal
processing before the start of next frame.
CRC-15

The polynomial for CRC-15 is:

(x15 + x14 + x10 + x8 + x7 +x4 +x3 +


x0).

1100 0101 1001 1001  div


Types Of Errors
• Bit Error: Detected by transmitter transmits dominant
and monitors recessive on the bus and vice versa
• Stuff Error: Detected if the stuff bit rule is violated. If 6
consecutive bits of same polarity is received
• Form Error: Detected if the fixed format in the frame is
violated
• CRC Error: Detected if the checksum mismatch
between transmitter and receiver
• Acknowledgement Error: Detected by transmitter if it
finds no acknowledgement ( Not finding dominant “Ack
Slot” field )
Error frames
• If transmitting or receiving node detects an
error, it will immediately abort transmission
and send error frame consisting of an error
flag made up of
• six dominant bits and
• error flag delimiter made up of eight
recessive bits.
• The CAN controller ensures that a node
cannot tie up a bus by repeatedly transmitting
error frame.
(1) Error flag
There are two types of error flags: active-error flag
and passive-error flag.
Active-error flag: Transmitted by Active Error Node,
consists of 6 dominant bits
Passive-error flag: Transmitted by Passive Error
Node, consists 6 recessive bits

(2) Error delimiter


The error delimiter consists of 8 recessive bits.
Overload Frame
The overload frame is used by the receive unit to notify
that it has not been prepared to receive frames yet. Not
used by many controllers
It consists of an overload flag and an overload delimiter.
(1) Overload flag
It consists of 6 dominant bits. The overload flag is
structured the same way as the active-error flag of the
error frame.
(2) Overload delimiter
It consists of 8 recessive bits. The overload delimiter is
structured the same way as the error delimiter of the
error frame.
CAN bit timing

• Nominal Bit Rate (NBR):


• No. of bits transmitted per second, CAN
Protocol configured at 500Kbps
– Egs : 500Kbps (CAN bit rate)
• Nominal Bit Time(NBT) : 1/ NBR
– 1 /500Kbps = 2 usecs.
Time Quantum
• Fosc : Clock supplied to CAN
peripheral
– Egs : 20 Mhz

• CAN Clock : Fosc / BRP


– BRP -> Bit Rate Prescalar =02
– Egs : CAN clk = 20Mhz/2 = 10 Mhz
• Time Quantum
– 1/CAN Clock
– Egs 1/10Mhz = .1 usec = 100 nsec
• Sync Segment :
– Used to synchronize the various nodes on the bus. An edge is expected to lie
in this segment
• Propagation segment :
– To compensate for the physical delay times in the network
• Phase segments 1 and 2:
– To compensate for edge phase errors,
– Can be shortened and lengthened
• Sample Point :
– Point of time when bus level is read and interpreted.
– Use Sample points of 80 to 90 %
– At end of PS1.
• Sample Mode:
a) Single sample point in Bit period
b) 2 of 3 samples in a Bit period (Majority Rule)
CAN1CMR- Command register

You might also like