Difference between revisions of "CAN Bus"

From fswiki.us
Jump to navigation Jump to search
(Add cable impedance spec, add wiring section.)
(Reorganize into layers to make more sense)
Line 1: Line 1:
 
[[Category:Electronics]]
 
[[Category:Electronics]]
 
CAN bus is a [[Communication Protocols|Communication Protocol]] and networking standard designed for communicating between devices in vehicles. Because of its versatility and relatively low complexity, it is used in the vast majority of vehicles manufactured today. By letting multiple devices communicate with each-other through a common interface, wiring harness complexity can be reduced.
 
CAN bus is a [[Communication Protocols|Communication Protocol]] and networking standard designed for communicating between devices in vehicles. Because of its versatility and relatively low complexity, it is used in the vast majority of vehicles manufactured today. By letting multiple devices communicate with each-other through a common interface, wiring harness complexity can be reduced.
==Types of CAN Bus Networks==
+
 
There are several types of CAN networks: low–speed CAN and high–speed CAN. There is also [[#CAN FD]], described below.
+
Computer networks can be thought of as having layers. CAN bus has 3 main layers:
 +
* the physical layer, which contains electrical specifications (cable impedance, voltage levels, etc.)
 +
* the data link layer, which specifies bit timing, message framing, error detection, etc.
 +
* the application layer, which specifies things like which identifier to use for what data.
 +
==CAN bus physical layer==
 +
At the physical layer, there are two types of CAN networks: low–speed CAN and high–speed CAN.
 
===High–Speed CAN===
 
===High–Speed CAN===
 
[[File:CAN ISO11898-2 Network.png|thumb|Example of a high–speed CAN network.]]
 
[[File:CAN ISO11898-2 Network.png|thumb|Example of a high–speed CAN network.]]
Line 8: Line 13:
 
===Low–Speed CAN===
 
===Low–Speed CAN===
 
[[File:CAN ISO11898-3 Network.png|thumb|Example of a low–speed CAN network.]]
 
[[File:CAN ISO11898-3 Network.png|thumb|Example of a low–speed CAN network.]]
Low speed is limited to a speed of 125 Kb/s, but it is more flexible in its routing. It can be connected as a star bus with no issues, and each device on the network has two termination resistors. Their value can be calculated based on the method described on page 4-10 of this document from National Instruments: [https://www.ni.com/docs/en-US/bundle/ni-can-hw-sw-seri/resource/370289t.pdf].
+
Low-speed CAN (ISO 11898-3) is limited to a speed of 125 Kb/s, but it is more flexible in its routing. It can be connected as a star bus with no issues, and each device on the network has two termination resistors. Their value can be calculated based on the method described on page 4-10 of this document from National Instruments: [https://www.ni.com/docs/en-US/bundle/ni-can-hw-sw-seri/resource/370289t.pdf].
===Data Format===
+
 
===History===
+
Because of its low speed it is not often used in the automotive world, but if you don't have a lot of data to send it could be useful.
==CAN FD==
+
==CAN bus data link layer==
CAN FD (Flexible Data-rate) is an extension of the original CAN protocol. It can dynamically switch between different data rates and longer or shorter messages, resulting in faster data speeds and higher data capacity.<ref>Falch, Martin. "CAN FD Explained - A Simple Intro [2022] - CSS Electronics". Retrieved 2023-01-21. https://www.csselectronics.com/pages/can-fd-flexible-data-rate-intro.</ref>
+
The CAN 2.0 protocol is specified in ISO 11898-1. It is split into CAN 2.0A and CAN 2.0B, the original 11 bit identifier version and the extended 29 bit identifier version.
===Electrical Specification===
+
===CAN 2.0A===
===Data Format===
+
CAN 2.0A is effectively the same as CAN 1.0 and 1.2. It uses 11 bit identifiers, so a maximum of 2048 devices can transmit on a network. If a device says it supports CAN, it supports this.
===History===
+
<!--insert frame format table here -->
==Wiring==
+
===CAN 2.0B===
In the wiring harness, CAN should be routed as a twisted pair.<ref>Corrigan, Steve. "Introduction to the Controller Area Network (CAN)". Retrieved 2023-01-29. https://www.ti.com/lit/an/sloa101b/sloa101b.pdf.</ref> In practice, it's probably a good idea for this to be shielded twisted pair unless you're knowledgeable about EMI. As stated above, technically High-Speed CAN needs cable with an impedance of 108-132 ohms, but in practice most twisted pair cable will be good enough.
+
CAN 2.0B builds on CAN 2.0A by allowing 29 bit identifiers.
 +
<!--insert frame format table here -->
 +
===CAN FD===
 +
CAN FD (Flexible Data-rate) is an extension of the CAN 2.0 protocol. It can dynamically switch between different data rates and longer or shorter messages, resulting in faster data speeds and higher data capacity.<ref>Falch, Martin. "CAN FD Explained - A Simple Intro [2022] - CSS Electronics". Retrieved 2023-01-21. https://www.csselectronics.com/pages/can-fd-flexible-data-rate-intro.</ref>
 +
==CAN bus application layer==
 +
===J1939===
 +
===CANopen===
  
For wire gauge, generally you can just use the smallest wire gauge the connectors will accept.
 
 
==References==
 
==References==

Revision as of 20:56, 21 June 2023

CAN bus is a Communication Protocol and networking standard designed for communicating between devices in vehicles. Because of its versatility and relatively low complexity, it is used in the vast majority of vehicles manufactured today. By letting multiple devices communicate with each-other through a common interface, wiring harness complexity can be reduced.

Computer networks can be thought of as having layers. CAN bus has 3 main layers:

  • the physical layer, which contains electrical specifications (cable impedance, voltage levels, etc.)
  • the data link layer, which specifies bit timing, message framing, error detection, etc.
  • the application layer, which specifies things like which identifier to use for what data.

CAN bus physical layer

At the physical layer, there are two types of CAN networks: low–speed CAN and high–speed CAN.

High–Speed CAN

Example of a high–speed CAN network.

High–speed CAN (ISO 11898-2) is probably the most common version of CAN. It can support speeds up to 1 Mb/s, and uses a linear bus. High–speed CAN does not work when hooked up as a star network, as star networks can lead to strange behavior at higher frequencies. The stubs coming off of the linear bus should be kept as short as possible. If you are designing a custom PCB that uses CAN, you can do this branching on the PCB instead of in the wiring harness. A 120 ohm termination resistor is required at either end of the bus, i.e. the DC resistance measurement between the 2 CAN wires should be 60 ohms when hooked up properly. The cable should theoretically have an impedance between 108 and 132 Ohms at the bus frequency, but in practice this isn't necessary and most cable will work just fine.[1]

Low–Speed CAN

Example of a low–speed CAN network.

Low-speed CAN (ISO 11898-3) is limited to a speed of 125 Kb/s, but it is more flexible in its routing. It can be connected as a star bus with no issues, and each device on the network has two termination resistors. Their value can be calculated based on the method described on page 4-10 of this document from National Instruments: [1].

Because of its low speed it is not often used in the automotive world, but if you don't have a lot of data to send it could be useful.

CAN bus data link layer

The CAN 2.0 protocol is specified in ISO 11898-1. It is split into CAN 2.0A and CAN 2.0B, the original 11 bit identifier version and the extended 29 bit identifier version.

CAN 2.0A

CAN 2.0A is effectively the same as CAN 1.0 and 1.2. It uses 11 bit identifiers, so a maximum of 2048 devices can transmit on a network. If a device says it supports CAN, it supports this.

CAN 2.0B

CAN 2.0B builds on CAN 2.0A by allowing 29 bit identifiers.

CAN FD

CAN FD (Flexible Data-rate) is an extension of the CAN 2.0 protocol. It can dynamically switch between different data rates and longer or shorter messages, resulting in faster data speeds and higher data capacity.[2]

CAN bus application layer

J1939

CANopen

References

  1. "CAN Physical Layers - Kvaser". Retrieved 2023-01-21. https://www.kvaser.com/lesson/can-physical-layers/.
  2. Falch, Martin. "CAN FD Explained - A Simple Intro [2022] - CSS Electronics". Retrieved 2023-01-21. https://www.csselectronics.com/pages/can-fd-flexible-data-rate-intro.