CAN Bus Basics - MyLab-odyssey/ED4scan GitHub Wiki
Find useful information about the CAN bus and tools.
Most microcontrollers needs a special CAN controller and CAN transceiver for CAN bus communication. When you use an Arduino UNO you need a CAN bus shield for this purpose. Other microcontrollers like Teensy or Particle Photon include the CAN controller. Then you will only need a additional CAN transceiver for the bus connection.
A very common CAN controller is the MicroChip MCP2515. This one is used in the ED BMSdiag project. On some CAN shields the MCP2551 transceiver is used. Modern designs will use a ESD hardened type: MCP2561 or MCP2562.
The MCP2515 CAN controller uses a SPI bus for communication with the microcontroller (MCU). Four signal lines are used as follows:
Signal | Purpose |
---|---|
SCLK | Serial Clock |
MOSI | Master Out Slave In: data from MCU to device |
MISO | Master In Slave Out: data from device to MCU |
CS | Chip Select: select active device |
Sometimes CS is called Slave Select (SS). Find addidtional information about the SPI bus @Wikipedia.
The ED BMSdiag software will use a CS signal on the Arduino UNO on pin 10 as default. If you use a CAN-Shield with another CS pin for the MCP2515, please change the default definition in the ED_BMSdiag.h
file to the correct CS pin:
#define CS 10 //!< chip select pin of MCP2515 CAN-Controller
Shield / Vendor | GPIO voltage | CS Pin | ESD protection | Termination | Remark |
---|---|---|---|---|---|
Sparkfun v1.3 (my personal choice) | 5V | 10 | ESD diode | active | w/o included headers |
CANdiy v2.0 | 5V or 3.3V | 10 | in transceiver | jumper | headers to be soldered, SPI only on ICSP header |
Seeedstudio v2.0 (also recommended) | 5V | 9 | ESD diode | switch | headers fitted |
Seeedstudio v1.2 | 5V | 9 | - | switch | headers fitted |
MakerHawk CAN-BUS | 5V | 10 ? | - | switch | headers fitted, SPI only on ICSP header |
elecfreaks.com | 5V | 10 | - | switch | headers to be soldered, SPI only on ICSP header |
Recommended is a shield with a ESD diode or with a modern transceiver!
Newer microcontroller boards often have 3.3V GPIO voltage. Please then use the CANdiy shield and configure it to 3.3V (cut a bridge and solder a jumper).
For some boards - like CANdiy shield - make sure to fit the ICSP connector for the SPI bus:
The CAN bus is a realtime bus system which enables multiple network nodes to communicate over a parallel bus without a host controller. It is used mainly as a vehicle bus. Because of the robustness modified versions are also common in aerospace industries, medical and manufacturing installations.
On the physical layer the bus uses two wires (CAN-High and CAN-Low) with a differential signal. Base level is 2.5V representing a logical (recessive) high. The high and low signal have ±1.0V offset from the base level and signal so a logical low as dominant data.
Often the bus needs an additional ground reference for the transceivers to work. Long bus systems - like in a car - will separate chassis ground from signal ground for better noise performance. Keep this in mind if you tab into the active car bus.
When connecting to the OBD port of the car both ground signals are tight together in the diagnostics gateway (the OBD connector is part of). So don´t bother about the correct ground signal ;-)
The bus must be terminated for signal integrity - to avoid signal refections. Commonly 120 Ohm resistors are used at both ends of the bus. The nodes in between may not use a termination!
Overview of the CAN topology and the used components:
The diagnostics gateway acts as a bridge between the car bus and the outside world. You can safely enable the termination if you connect the CAN shield (e.g. ECU2) to the diagnostics gateway (e.g. ECU1) as they are the only active nodes in this part of the vehicle.
Find additional information about the CAN bus @Wikipedia.