You dont have javascript enabled! Please enable it!

CAN-bus

Subjects:

  • Preface
  • Multiple networks in one car
  • CAN network with the nodes
  • Different types of CAN speeds
  • CAN bus signals
  • Speeds and voltage levels
  • Structure of the CAN bus message of a (standard) 11-bit identifier
  • Structure of the CAN bus message of an (extended) 28-bit identifier
  • Error recognition using Bitstuffing and CRC & ACK delimiters
  • Twisted Pair Wiring
  • Terminating resistors
  • Gateway
  • Measuring on the CAN bus

Preface:
Modern vehicles are packed with electronics. The control units collect and process data from sensors and control actuators. Often different ECUs use the same data: dThe accelerator pedal position sensor registers the position of the accelerator pedal. This signal is sent through the wiring directly to the engine-ECU. The engine ECU is not the only ECU using this signal:

  • The engine-ECU uses the signal from the accelerator pedal position sensor to actuate the throttle valve, when accelerating for acceleration enrichment by driving the injectors longer, adjusting the ignition timing and, if necessary, decelerating. control the wastegate or VGT adjustment of the turbo;
  • The automatic transmission ECU uses the accelerator pedal position to determine the shift times of the clutches in the automatic transmission. If the accelerator pedal is depressed slightly, the automatic gearbox will upshift at a lower speed than if the accelerator pedal is half depressed. By suddenly pressing the accelerator pedal quickly, the “kick down” will be activated by shifting to a lower gear and making the engine rev up;
  • The amount of accelerating in a corner can be a reason for the ESP-ECU to have the ESP intervene by reducing the engine power and, if necessary, by reducing the engine power. apply a brake on a spinning wheel.

During an intervention by the ESP, the engine power decreases by (partially) closing the throttle and injecting less fuel. An indicator light will also illuminate or flash in the instrument panel to alert the driver that the ESP is operating.

The above already shows the cooperation between different ECUs. CAN bus ensures that ECUs communicate with each other and can therefore exchange data with each other. CAN is an abbreviation of: Controller Area Network. 

Engine ECU
Built-in engine ECU in engine compartment

In the 80s, cars received more and more accessories and manufacturers began to build in control devices. Each function has a separate thread. As a result, the wire thickness and the number of plug connections increased sharply.
Thick cable harnesses have the disadvantage that concealment behind interior trim is difficult, and the risk of malfunctions increases considerably.

With CAN bus, ECUs communicate with only two wires: the CAN high and the CAN low. All communication between the ECUs is provided over these two wires. iThe following two images clearly show that the number of wires at one door already decreases considerably when using the CAN bus.

Dozens of control devices can be connected to the two CAN bus wires on the CAN bus. All the connected control devices can exchange data with each other.

 

The figure below shows a vehicle with eleven control units (indicated by the red blocks). These control devices are all connected with two wires; an orange and a green wire. These wires represent the CAN high and CAN low. Each control unit has its own function and can communicate with any other control unit in the network via CAN bus. More substantive information about the control devices can be found on the page control devices.

1. Towbar installation control unit
2. Door control unit RA
3. RV . door control unit
4.Gateway
5. Comfort control unit
6. Alarm system control unit
7. Instrument panel
8. Steering column electronics control unit
9. LV . door control unit
10. LA . door control unit
11. Park Distance Control Control Unit

With the arrival of CAN bus, it is also EOBD more comprehensive. EOBD stands for European On Board Diagnosis. EOBD has to do with emissions. Various sensors of the engine and the exhaust pass information to the ECU. If there are incorrect values ​​(because, for example, poor combustion takes place), a MIL (Motor Indication Light) lights up. That is a sign that the car needs to be read. A diagnostic tester must then be connected to the OBD plug to read out the errors. Based on the fault, the ECU has stored a hexadecimal fault code, which is displayed by the diagnostic tester as a P-code or a fault with text (the latter is more brand-specific). Click here to learn more about OBD1, OBD II and EOBD.

Multiple networks in one car:
There can be several networks in a car. The image below shows an overview with legend of control units in multiple networks of a BMW 3 Series E90.

The K-CAN, PT-CAN and F-CAN networks in the above image fall under CAN bus. The differences are the speeds, the voltage levels and the applications. Although the PowerTrain-CAN and the F-CAN have the same high-speed speed and voltage levels, the difference is that the PT-CAN is used for engine and transmission control, and the F-CAN contains the chassis control units.

CAN network with the control devices
The CAN bus network consists of control devices equipped with hardware and software to receive, process and send messages. A CAN high wire and a CAN low wire are used for data transfer. In the image below, the CAN-High is colored red and CAN-Low is colored blue.
The control devices (also called control units or nodes) are connected to these wires. All control devices can both send and receive information. An example of a network is the CAN bus system in the interior of the car; Here, various control devices can be connected to one bus system.

As an example we take a reversing camera (node ​​5) that is retrofitted. This camera is attached to the license plate holder or handle. The CAN wiring is connected anywhere in the interior. The condition is that the node of the camera contains the correct identifier (pre-programmed by the manufacturer) because the other control devices must recognize it. When the camera is registered on the supported radio, the image is immediately visible.
After programming the software, the radio receives a signal from the gearbox that reverse gear is selected. At that moment, the radio switches to the image from the rear view camera. The moment the first gear (forward) is selected, the image switches off again. All this thanks to the data transfer of the CAN bus system.

Unsupported equipment (eg with an incorrect identifier) ​​can cause problems. If it sends messages that are not recognized by other control devices, an error message will be generated. This type of equipment can also ensure that the CAN bus remains active after the ignition has been switched off. The car then does not go into “sleep mode” which would drain the battery quickly. Then there is one parasitic drain.

CAN bus signals:
The CAN bus system uses the broadcast principle; a transmitter puts a message on the CAN bus. Each node on the same bus receives the message. However, the sender indicates in the message for which nodes the message is intended. All nodes receive the message and provide their feedback (more on that later). The nodes for which the message is not intended recognize it and ignore it.

A CAN bus signal consists of a CAN high and CAN low voltage. In the image below, CAN-high is shown in red and CAN-low is shown in blue. The high and low signals are identical, but mirrored from each other. When the bus becomes dominant, the voltage of CAN high rises from 2,5 to 3,5 volts and CAN low drops from 2,5 to 1,5 volts. In recessive state (at rest) both voltages are 2,5 volts.

The image above shows an example of a measurement with an oscilloscope. It can be clearly seen that both voltages are identical to each other, only in mirror image. Finally, the voltage difference in the active (dominant) region is 2 volts. This means the difference between 1,5 and 3,5 volts. The difference of 2 volts is seen as a 0 (dominant) and the difference of 0 volts as a 1 (recessive).

If a (sending) node wants to send the binary code “0 0 1 0 1 1 0 1” it will set the stated voltages on the CAN-High and CAN-Low (see the example above). The receiving node will again see these voltages as a binary code, and then convert them into a hexadecimal code. Said binary code will be converted from hexadecimal to 2D.

To convert binary to hexadecimal it is easy to draw a table of 8 squares with a thick line in the middle. Name the boxes on the right 1, 2, 4 and 8 (see the red numbers in the picture). Then do the same on the left side. Write down the digits that have a 1 above them in the binary code. On the left it is only the 2, on the right it is 8, 4 and 1. Add everything on the right (13) and do the same with the left (2). Hexadecimal changes from 10 to A, 11 = B, 12 = C, 13 = D. So that ultimately makes 2D.

More information about converting binary to (hexa-)decimal and vice versa can be found on the page Binary, Decimal and Hexadecimal. Clear examples are described in detail here.

Speeds and voltage levels:
In vehicles we can encounter CAN bus networks with different speeds:

  • High speed: ECUs related to the drivetrain, including engine electronics, transmission, ABS/ESP, EBS (commercial vehicles);
  • Medium or low speed: interior electronics such as the instrument panel, radio, climate control, parking brake, tow bar.

The two images below show the CAN high and CAN low signals of the high speed CAN bus. At rest, the voltage of both signals is 2,5 volts. To send a message, the CAN high rises from 2,5 to 3,5 volts and the CAN low falls from 2,5 to 1,5 volts.

CAN high speed (1)

Below you can see the signal of the CAN high speed again, with zoomed in (50 microseconds per division), where the scope was set to 200 microseconds per division for the above signal.

CAN high speed (2)

In comfort electronics, the high speed of communication is less important. Typical for the medium or low speed CAN bus, the voltage levels at rest and when forming a message are as follows:

  • CAN high is 5 volts at rest and drops to 1 volt;
  • CAN low is 0 volts at rest and rises to 4 volts.

In the measurement where the zero lines of channels A and B are set at the same height, it can be seen that the voltages have shifted “into each other”. This makes it difficult to read the purity of the CAN high and low signals.

CAN low speed (1)

In order to assess the purity of the messages, it is recommended to shift the zero lines. In the image below, Channel A's zero line has shifted down and Channel B's has moved up. This means that the depicted signals have been pulled apart and a clearer course of the voltages can be seen.

CAN low speed (2)

Structure of the CAN bus message of a (standard) 11-bit identifier:
The structure of a CAN bus message is always based on the figure below. There are differences in the structure; for example, the ARB and CTRL field of an 11-bit identifier and a 29-bit identifier are different. The information below refers to the 11-bit identifier. For your information: a 29 bit identifier has room for more data than the 11 bits. More on this later.

The structure of the message is now simply summarized, and later described in detail:

SOF:
Every CAN message starts with a SOF (start of frame). When a node wants to send a message, a dominant bit is placed on the bus. The CAN bus is always recessive at rest (a 1, so both the CAN-High and the CAN-Low are 2 Volts). The dominant bit (a 0) indicates that other nodes should wait to send a message until the entire message has been posted. Only after the IFS (Interframe Space) is the next node allowed to send its message. Even if it's an important message, it can't get through.
When 2 nodes want to send a message at the same time (which they do not know about each other) and thus make the bus dominant together by placing a 0, the ARB (arbitration) determines which message takes precedence.

From here on, each section of the CAN bus message discussed will have that section added to this gray image. That way I try to keep a little overview. The message started with the SOF.

AR:
The Arbitration Field of an 11 bit identifier consists of 2 parts; the identifier and the RTR bit.
Identify:
Suppose 2 nodes simultaneously make the CAN bus dominant, then the node with the least important message will wait until the important message is posted (until after the IFS). The message identifier contains a string of ones and zeros. These numbers are intentionally assigned to a message by the programmer. The identifier with a 0 in the message (dominant) has a higher priority than the one with a 1 in the message (recessive). The message with the 0 will continue, and the message with the 1 will have to wait.

Both identifiers start posting a message of 11 bits. At the SOF, the dominant bit is placed. After that, the first 5 bits of both identifiers are equal to each other (0 1 1 0 1). The 6th bit at the identifier number 2 is a 0, and at the first identifier a 1. Dominant predominates, so identifier 2 creates the final CAN message.
Identifier 1 placed a 6 as the 1th bit. The node that sends the identifier only recognizes when another node places a 0 on the bus that 2 nodes are sending a message at the same time. At this point, identifier 1 stops transmitting and now acts as a receiver. Although the message that started with 0 1 1 0 1 was originally intended to be the message this node wanted to send, it will now consider it the received message. The node then listens to the entire message and determines whether something is done with it.

The gray image of the SOF is now extended with the ARB that consists of 2 parts, namely the identifier and the RTR bit:

RTR Bit:
The last bit of the 11-bit identifier is called an RTR; this is a Remote Transmit Request bit. This RTR bit indicates whether it is a data frame or a remote frame.
0 = Data frame
1 = Remote frame

A data frame contains data that is forwarded to the nodes that need the information. A node can also request information; e.g. what the coolant temperature is at any given time. The node will then place a 1 as the RTR bit because it asks for the data.

CTRL:
The Control Field consists of the IDE (Identifier Extension), an R-bit and the DLC. The IDE bit indicates whether it is a standard (11 bits) or an extended (29 bits) identifier:
0 = Default identifier (11 bits)
1 = Extended identifier (29 bits)

The R-bit is reserved for the future and is now always recessive.

Then the DLC follows: A CAN bus network can send a maximum of 8 bytes. There are 1 bits in 8 byte, so a total of 64 bits can be sent according to the standard protocol. The Control Field indicates how much data is being sent. It would be pointless to send a large message with all empty data fields for a confirmation bit (1 for on or 0 for off). The number of bytes is stated in the appropriate DLC (Data Length Code). The DLC is a function in the programming software and thus is predefined value by the programmer.
Suppose there is 1 byte in the DLC, then 8 bits are sent. This is sufficient for short confirmation messages.
For very extensive messages there will be a value of up to 8 data bytes in the DLC.

The example has been expanded again. The IDE, R and DLC have been added.

DATE:
The final data to be sent is placed in the data field. The size depends on the value of the DLC (Data Length Code). It has already been indicated that the DLC is a maximum of 8 bytes in size. Each byte consists of 8 bits, so in total the data field can consist of 64 bits.

CRC:
The Cyclic Redundancy Check consists of a mathematical calculation, which is sent along with the message. The sending node calculates the total CAN message to date; the SOF, ARB, CTRL and DATA. So the CRC is the calculation. When the receiving node has received the message up to the CRC, it will perform the math calculation up to the DATA and compare it with the calculation in the CRC. If it does not match (due to an incorrect bit / fault), the message is not accepted and the message is requested to be sent again (with a certain maximum number of retries). The example has been extended with the CRC.

Acknowledgment:
The Acknowledge field is used for the confirmation of receipt. When the sender has sent the message to the CRC, a kind of pause is inserted; the sender makes the bus recessive (with a 0) and waits until one or more nodes make the bus dominant (1). It does not matter whether one or more nodes have received the message, because if one node has received it, at least it has been sent successfully. After the bus is made dominant with a 1, message transmission resumes.

EDF:
The End Of Frame consists of 7 recessive bits (1 1 1 1 1 1 1). This is a sign for all Control Units that the message has ended.

IFS:
To avoid interference, an Inter Frame Space is always applied after the EDF. The IFS consists of 11 recessive bits. All nodes wait for these 11 recessive bits to pass before sending a message. After these 11 recessive bits, for example, 2 nodes can start sending a message at the same time. The ARB (Arbitration) is then looked at again to determine which message has the highest priority. The whole cycle then starts again.

Structure of the CAN bus message of an (extended) 28-bit identifier:
The 11-bit identifier was designed at a time when cars did not have so many control devices (nodes). The programmers soon found out that the 11-bit identifier was not enough. This one has only (2^11) = 2048 possibilities. Of these, 2032 unique combinations of the binary code remain. Modern cars now use much more codes thanks to the extended 28 bit identifier. This is called the extended identifier.
This means that no less than (2^29) = 536870912 combinations are possible. This is spacious enough for the future.
A number of things will change in the CAN bus message. Both identifiers (default and extended) are used interchangeably. In the CAN message, therefore, each species is indicated, after which a long message follows.
The base of the 11 bit identifier is used and also serves as a preparation before it is read through; now only the changes that the message undergoes when it is a 29 bit identifier are indicated.
The SOF (Start Of Frame) remains the same. The sending node makes it dominant when it starts sending a message.
Then follow the ARB and the CTRL where the differences are.

AR:
In the arbitration, there is first a standard 11-bit identifier (ie part of the 29 bits). The RTR bit (as it is with the 11 bits) is moved to the end of the ARB. Instead of the RTR comes the SRR: (Substitute Remote Request). This bit is always recessive (1) with an extended identifier.
After the SRR bit comes the IDE bit, which is located in the 11 bit identifier in the CTRL (Control Field). This is now removed from the control field and placed at the extended identifier after the SRR bit.

For clarity, the images below show the standard (11-bit) and extended (29-bit) identifiers.

Standard 11-bit identifier
Extended 29-bit identifier

The IDE bit stands for Identifier Extension. The IDE bit shows whether it is a standard or extended identifier.
IDE 0 = Default (11 bit ID)
IDE 1 = Extended (29 bit ID)

After the IDE bit comes the rest of the extended identifier. The 11 and 18 bits together make 29. These cannot be placed in the message as one whole, because the CAN protocol is then no longer correct. Basically the IDE bit now indicates that the message is split in two.

CTRL:
The Control Field has therefore been changed with the extended identifier. The IDE bit has been moved to the ARB.
The IDE bit is replaced by an R bit (spare). It is recessive by default. This is followed by an R bit and the DLC (Data Length Code), which indicates how many bytes the message will consist of.

Again, the control fields of both the 11-bit and 29-bit identifiers are shown.

CTRL from 11-bit IDE
CTRL from 29-bit IDE

Error recognition using Bitstuffing and CRC & ACK delimiters:
Bit stuffing:
To keep the synchronization between the sending and receiving nodes optimal, bit stuffing is applied. Bitstuffing means that after 5 identical bits, an opposite bit is added. No bit value changes to the originally sent message, but a bit is added.
The receiver recognizes this. After 5 identical bits, the receiver will erase the 6th bit (see figure below).

The original message of only ones is sent, but the sender appends a 6 every 0th bit. The message length does increase because of the zeros (but this length does not count for the DLC (Data Length Code). The receiver filters out the opposite bits (the zeros) and then reads the message again with only ones.

CRC & ACK delimiters:
Delimiters are placed after the CRC field and the ACK field. This is a bit with a known value for both the sender and the receiver. So if there is an error in the message, this value will be different. The receiver then receives a different bit value as expected and marks the message as erroneous. The sender will resend the message.

Twisted Pair Wiring:
Twisted pair cables are used as cabling for the CAN bus. The CAN-High and the CAN-Low cable are then twisted together as shown in the picture. In this way interference from external influences is avoided; if an inductance of a few tenths of a volt enters one cable, it will also enter the other. However, the voltage difference between CAN high and low remains the same. This eliminates the malfunction and does not affect the ECUs.

Terminating resistors:
Terminating resistors are used in every high speed CAN bus network. These are often located in the nodes at the end of the CAN bus line (wire) or incorporated in the wiring. These resistors each have a resistance of 120Ω (Ohm). The replacement resistance is measured as 60Ω on a resistance measurement on the wires.

These terminating resistors serve to suppress interference; if these were not there, reflection would arise. The voltage signal travels through the CAN bus wire, comes to the end and bounces back. The latter is prevented. The voltage is included in the resistor. Reflection could cause voltage signals to bounce off, affecting the messages sent and then interfering with control devices.

gateways:
The car is equipped with a network of control devices (nodes). The gateway connects various CAN bus networks (think of the interior, the engine / transmission and the chassis), the MOST bus and the LIN bus with each other, so that all networks can communicate with each other. So it is in fact a node between all networks. The differences in speed are unimportant with a gateway. Click here to go to the page where the operation and functions of the Gateway are described.

Measuring on the CAN bus:
It is often asked whether it is possible to measure the CAN bus. You can. A diagnosis can be made by measuring the voltage levels on the wires and checking the voltage image on the oscilloscope. How to measure is described on the page measuring on the CAN bus system.

Related page: