Overview of The CAN Bus Protocol - Embedded - Electronic Compone
Overview of The CAN Bus Protocol - Embedded - Electronic Compone
Have a suggestion or comment on our Forum? Stop by the Site Help, Information and
Feedback category and let us know how we can improve the forum.
CAN stands for Controller Area Network. This type of communication is inside several
types of systems, the most common is automotive. These systems consists of typically
wired controllers (microprocessors/microcontrollers) that talk to each other. There are
protocols and methods to allow wireless communication, but wired is far more
common. Unlike SPI, I2C, USB, and other similar formats, CAN Bus uses a much
different format for data communication. CAN Bus is based off of differential voltage
levels:
There are two wires used for communication that transmit data at the same time. They
are called CAN Hi (High) and CAN Lo (Low) and have different voltage levels that are
interpreted by each controller (called CAN Nodes). CAN Hi usually measures from 2.5V
to 3.75V while CAN Lo measures from 2.5V to 1.25V. When both lines read 2.5V the
signal is called “Recessive” which would be equivalent to a binary value of 1. When CAN
Skip to main content
Hi goes to 3.75V and CAN Lo goes to 1.25V the signal is called “Dominant” which would
be equivalent to a binary value of 0. Conceptually, this may not make sense when talking
about digital logic where 0 is Low and 1 is High, but the protocol is looking for the 0
values over the 1 values. So the driver logic is inverse from typical digital logic
interpretation.
The wiring has some peculiar aspects that are unique to the protocol. One advantage
CAN Bus has over single wire protocols is the ability of nodes to be disconnected
without other nodes failing. If CAN Hi or CAN Lo was cut to a particular node, the rest of
the system would not care and still send data to the other nodes. Some systems may be
capable of transmitting data along one line if the main one went down, but this depends
on the company (not all systems can work with a down CAN Hi or CAN Lo line).
Performance gets hit on systems that can handle a line being cut though because the
120 ohm resistors have two purposes. They first provide the differential between Hi and
Lo along with matching impedance for systems that have higher frequencies. The
protocol works best with the differential voltages. The crossed wires also have two
purposes (twisted pair). First, they help block EMI emissions from outside sources.
Second, they also help with EMI issues when the protocol transmits with faster
frequencies.
Notice that there are no other lines, this means that packets (messages) are sent to all
nodes at the same time. There is no “address” in a CAN message data frame, but there
are methods in the data frame to determine what is accepted or rejected by each node
along with priority with certain messages defined by the user. The data has to have bits
set in order to avoid collision with other messages, so priority is key for CAN Bus to
avoid that problem.
SOF (Start of Frame): this marks the beginning of a new CAN message, lets the other
nodes on the bus synchronize.
The arbitration field is the identifier which contains an 11 Bit ID and a bit for RTR (remote
transit request) which is set to dominant if requesting info from another node. The ID is
what other nodes care about as they are the context for whether or not if each node
cares about that message. Think of the ID as a pseudo-address that behaves like a
"topic". If other nodes don't care about the "topic" they will ignore the message. Not only
that, the ID determines priority too for collision avoidance. If communication happens at
the same time, the nodes first wait for the lines to be idle (recessive). If one node
outputs a recessive level and the other outputs a dominant level, the dominant voltage is
always higher priority. An example is shown below.
Example:
From right to left, the fourth bit on the message from Node2 would send first because a
dominant ‘0’ on bit 4 occurs. Node 1 senses this and quits sending the message and
waits for the line to become idle.
There are 5 mechanisms of error correction in a CAN Message frame. 2 are at the bit
level and 3 are message level. Bit monitoring and bit stuffing are bit level. Bit monitoring
is done by each node and monitors to see if there is an error somewhere (done in the
arbitration field), error is flagged in a specific manner. The other bit level error correction
is bit stuffing. This adds a sixth bit of an opposite level (R or D) if 5 bits of the same level
are sent in a message, this allows synchronizing with the transmitter. This is easily
removed by the receiver as each node expects this extra bit.
The two message level mechanisms are frame checking and the CRC/ACK fields. Frame
checking verifies that all CAN parts exist and if there is a recessive bit after ACK and
CRC. When there is error, there are two thresholds. When the first error occurs, one bit is
set to dominant as a flag which increments a counter for a node. If the counter is only at
1, recessive error flags are sent and traffic continues as normal on the bus. However, if
the counter reaches 2, this indicates a serious error and that node will shut off. The
counters do go down if messages are sent successfully without error.
If you want to experiment with CAN bus on your own, there are a few evaluation boards
that can be used:
1. https://www.digikey.com/short/mjbmpb2b
2. https://www.digikey.com/short/0m2rd48h
https://www.digikey.com/short/8rwhnb24
CANバスプロトコルの概要
CAN 버스 프로토콜 개요
STEVAL-MKI123V1 3
Sep 2023