CAN Bus
CAN Bus, stand for Controller Area Network, is one type of serial communication that usually
used in industrial and automotive environments. The real example of CAN Bus application can
be found in speed car data sensor that can be transferred to the rpm indicator.
CAN Bus is a message based protocol that can be used for multiple device communication. The
figure below represents that when several CAN devices are connected together like a network,
each device can communicate with other devices in the node. In general, CAN communication
range is in range 50Kbps to 1Mbps, with the distance range is 40 meters (at 1 Mbps) to 1000
meters (at 50 kbps).
In this communication, data is transferred in a certain message format. Each message consists
of many segments, but there are two main segments: Identifier and Data. Identifier or CAN ID,
or known as Parameter Group Number (PGN) is used to identify the CAN device in the CAN
network, usually in 11 (Standard CAN) or 29 bit (Extended CAN) length, based on the CAN
protocol. While Data is the message content to be sent, usually in 0 to 8 bytes length.
CAN Protocol consists of two wires : CAN_H and CAN_L to send and receive the message.
This two wires act as a differential line where CAN signal is represented with the potential
difference between them. If the difference is positive and larger than a certain minimum voltage,
then the signal is 1, and if the difference between them is negative, it will be 0.
Usually, in CAN communication, twisted pair cable is used. And at the ends of the CAN
networks, a single 120-ohm resistor is used. It is because the line should be balanced and tied
to the same potential.
In this project,
Getting started with CAN bus and an
Arduino Uno
In order to talk to CAN bus devices relatively using an Arduino Uno. we need the
following:
• An Arduino Uno R3 board
• An MCP2515-based Arduino CAN shield
EF02037 style MCP2515 Arduino Uno CAN bus shield
• Connector to vehicle.
Here are the steps:
Arduino IDE Configuration:
Configure Arduino IDE
1. Download and install the Arduino IDE on your computer
2. Connect your Arduino board with a USB cable
Tools -> Port make sure your Arduino board is selected
File -> Examples -> [Link] -> Blink
Sketch -> Upload
Having a blinking light on your Arduino board. This means your IDE is working.
Configure CAN bus shield
CAN bus shield fitted to Arduino Uno
• Disconnect the Arduino board, assemble CAN shield and fit it to the Arduino
• Connect your Arduino board with a USB cable
• Download the CAN library ZIP file from here [Link]
Studio/CAN_BUS_Shield
Sketch -> Include Library -> Add .ZIP Library... & choose the ZIP file you just
downloaded
File -> Examples -> CAN-BUS Shield -> receive_check
Tools -> Serial Monitor change the baud rate to 115200
Sketch -> Upload
• Hopefully you will see the following on the Serial Monitor:
Enter setting mode success
set rate success!!
Enter Normal Mode Success!!
CAN BUS Shield init ok!
Talk to your device over CAN
Arduino CAN bus shield on the serial is shown as: