Datasheets and documents for CAN based microcontrollers might make them seem complicated to use. Thankfully, MCU manufacturers provide code libraries and examples that can get you off to a good start. You need not
understand every aspect of the CAN bus and CAN controllers to
communicate between devices. This article will help you learn enough
to use basic bus communications in projects. Later articles will supply
more details of CAN signals and protocols.
People who use RS-232 type communications understand how
positive and negative voltages represent logic 1s or 0s. The CAN bus,
on the other hand, uses the voltage difference between two wires —
labeled CANH and CANL — to represent logic levels. The
SN65HVD251 bus driver, for example, includes a differential driver and
a differential receiver (Figure 1).
When you apply a logic 1 to the driver input (D) on an
SN65HVD251 IC, the CANH and CANL outputs will have the same
voltage level; about 2.5V for a 5V supply. We call this a recessive state
on the bus. A differential receiver — including the one in the
SN65HVD251 — would detect no voltage difference between CANH
and CANL, so its receiver output (R) would give us a logic 1. Apply a
logic 0 to the D input and the CANH output rises to about 4V, while
the CANL output drops to about 1.4V to create a 2.6V difference
between the two signals as shown in Figure 2. We call this the
dominant state, and all differential receivers would produce a logic 0 at
their R output.
Even if all other drivers produce recessive signals, a logic 0 input to
The Controller Area Network (CAN) began as a communication path for
electronic equipment in vehicles. Unlike the RS-232 or RS-485 standards,
the CAN standard (ISO 11898) provides electrical specifications and a format
for information exchanges. Many newer microcontrollers include one or two
CAN controllers that properly format data, set device addresses, provide
hardware error detection, and identify communication errors if any. As a
bonus, CAN based devices may operate in a multi-master network that uses
more than one controller to supervise operations.
Take a CAN Bus
for a Spin
By Jon Titus KZ1G
Post comments on this article and find any associated files and/or
downloads at www.nutsvolts.com/magazine/article/
December2016_CAN-Bus-Basics-Propeller-MCU.
FIGURE 1. An SN65HVD251 provides a bus
driver (top) and a bus receiver (bottom). The
receiver output always indicates the state of the
CAN bus. Ground the Rs input on this device, and
do not make a connection to the reference-voltage output on pin 5 (not shown). A CAN bus
does not need a common ground between
devices (pin numbers for an eight-pin DIP).
December 2016 29
Learn how to use
a CAN bus with a
Propeller MCU
Part 1