Basics of CAN-Bus
In this post I will explain the very basics of a CAN-Bus network which is used in Motorsport vehicles. This can be helpful for people who ever heard of the name, but never knew what it is or what is does. There is a lot of technical information on the internet, but my goal is to explain it in very basic language. In this post I’m taking a High-speed (1mbit/s) CAN2.0A 11-bit specification as example.
CAN stands for Controller Area Network. It is a method to allow microcontrollers to communicate with each other in a network (bus). Compare it to Ethernet (LAN), a standard to allow computers to communicate with each other as well.
The bus line is a twisted pair wire with a termination resistor (120 Ohm) on each side. One wire is called CAN High and one wire is called CAN Low. Both wires are needed for proper communication.
A device which is connected to the bus is called a ‘Node’. There are always two or more nodes required on the CAN network to communicate. In Motorsports you will usually find 3 to 10 nodes on the bus.
A node has at least a Micro Controller and a CAN Controller integrated. The CAN Controller converts digital information to messages on the bus. Compare it to Morse code. Information comes in, the CAN Controller translates it and sends out the message in a defined language, and another CAN Controller receives the information again.
A Micro Controller will process information such as sensor inputs or outputs to turn on lights or an actuator. The Micro Controller can also process information to control a dashboard or another kind of communication.
A CAN-Bus message holds all kind of data, but the basics are an ID and a message frame (8 bytes). Imagine it as a train: The train goes with a certain speed (1Mbit/s) over the rail (bus), and has several wagons (ID’s). At every train station (Node) you can put more wagons on the train, or see who’s in another wagon. The wagon (ID) with the lowest number, has the highest priority and comes first. A Node can sent multiple ID’s on the bus.
A wagon (ID) has 8 private rooms (bytes) with each 8 seats (bits). Each seat (bit) can have a value of 0 or 1. A complete private room with 8 seats can have 256 different combinations, which is the maximum value of 1 byte. In normal language; 1 ID can hold multiple signals such as RPM, Throttle, Temperature etc. If each signal is on 1 Byte (8 bits), the ID can hold 8 signals.
If you want to send out a message as ‘8000 RPM, the maximum accuracy of 1 room (byte) will be 5000 mV / 256 = 31 RPM. The signal transmitting will go in steps of 31 RPM. To get higher accuracy, it is possible to use 2 rooms (bytes) for 1 message. Two rooms can have a maximum value of 62236. If you send out a message ‘8000 RPM’ over 2 bytes, the steps will be 8000 / 65536 = 0,12 RPM.
It is important to understand why sometimes 1 bit, 1 byte or 2 bytes are used to transmit a signal.
In order to get the signal you are searching for, you need to have an ID, High Byte, Low byte and a quantification factor. The Q-factor is used to convert a message value (unit less) to an understandable value (units such as RPM, V, Bar).
How many ID’s (wagons) can be on the rails (bus) is depending on many factors. If the bus load exceeds 60-70%, you will get data losses or a crashed train. Also when the rails conditions are not good (bad wiring, no twisted wires etc.), you will get data losses or crashed trains as well. Always make sure that every node (train station) is capable of connecting to the bus (rails). A node which is created for a 500kbit/s rails, cannot be connected to a 1Mbit/s rails.
I know that not every comparison I’ve made in this post is 100% correct, but from personal experience, with explaining CAN basics to others, trying to visualize it, helped them a lot to understand the basics.