CAN is extensively used in automobiles and trucks but has found
applications everywhere. There are many "application"
layers available for CAN such as ISO 15765 (cars), J1939 (trucks) and
CANopen (factory automation) but it is very easy to
develop your own protocol that will fit and simplify your needs. Modern
CAN transceivers provide a stable and reliable
CAN physical environment without the need for expensive coaxial cables.
Most of the mystery of CAN has dissipated over
the years. There is plenty of example CAN software available to help
you quickly develop your own network.
A CAN controller is a sophisticated device. Nearly all the features of
the CAN protocol described below are automatically
handled by the controller with almost no intervention by the host
processor. All you need to do is configure the controller by
writing to its registers, write data to the controller and the
controller then does all the housekeeping work to get your message
on the bus. The controller will also read any frames it sees on the bus
and hold them in a small FIFO memory. It will notify
the host processor that this data is available which you then read from
the controller. The controller also contains a hardware
filter mechanism that can be programmed to ignore those CAN frames you
do not want passed to the processor.
For the purposes of this article; we will assume a CAN network consists
of the physical layer (the voltages and the wires) and
a frame consisting of an ID and a varying number of data bytes. CAN has
the following general attributes:
11 or 29 bit ID and from zero to 8 data bytes. TIP: These
dynamically changed "on the fly".
Peer to Peer network. Every node can see all messages from
nodes. A node can't read its own messages.
Nodes are really easy to add. Just attach one to the
two wires plus a ground.
Higher priority messages are sent first depending on the
the ID. A lower ID has the higher priority.
Automatic retransmission of defective frames. A node will
if it causes too many errors.
Speeds from approximately 10 Kbps to 1 Mbps. TIP: All nodes
operate at the same frequency.
The twisted differential pair provides excellent noise
some decent bus fault protection.
The CAN system will work with the ground connection at
levels. TIP: Or no ground at all.
Click here for the rest of the
paper that includes: the theory and implementation of the CAN
interface, a practical example using the STM32
microcontroller, and links to further documentation and
Join our online Radio Show on Friday 11th July starting at 2:00pm Eastern, when EETimes editor of all things fun and interesting, Max Maxfield, and embedded systems expert, Jack Ganssle, will debate as to just what is, and is not, and embedded system.