Skip to content

Commit ab9ffb3

Browse files
committedAug 19, 2024·
styling fixes
1 parent 795a876 commit ab9ffb3

File tree

1 file changed

+47
-13
lines changed
  • content/learn/05.communication/10.can

1 file changed

+47
-13
lines changed
 

‎content/learn/05.communication/10.can/can.md

Lines changed: 47 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ If you want to jump straight to the examples click here or go to the end of this
5252

5353
#### Origin and Purpose
5454
The CAN bus, or Controller Area Network, was developed by the German company Bosch in the 1980s. Its primary purpose was to streamline communication within vehicles, enabling various microcontrollers and devices to communicate with each other without the need for a central host computer. This innovation significantly enhanced the efficiency and reliability of automotive systems, allowing for real-time data exchange and coordinated control across different vehicle components. The robustness and noise immunity of CAN made it particularly suitable for the harsh environments typical of automotive applications.
55+
5556
| Name | Year | Speed |
5657
|-----------------------------|------------|-------------------------------------------------------|
5758
| CAN 1.0 | 1986 | Up to 125 kilobits per second |
@@ -62,27 +63,33 @@ The CAN bus, or Controller Area Network, was developed by the German company Bos
6263

6364
#### Timeline of Standards
6465

65-
- **1986: CAN 1.0**
66-
- The first version of the CAN protocol was released in 1986, supporting a bit rate of up to 125 kilobits per second. Initially, it was used primarily for diagnostic communication within vehicles.
66+
**1986: CAN 1.0**
67+
68+
The first version of the CAN protocol was released in 1986, supporting a bit rate of up to 125 kilobits per second. Initially, it was used primarily for diagnostic communication within vehicles.
6769

68-
- **1991: CAN 2.0**
69-
- The influential CAN 2.0 standard was released, introducing significant advancements. This version supported bit rates of up to 1 megabit per second and introduced two frame formats: the standard 11-bit identifier and the extended 29-bit identifier. CAN 2.0 became widely adopted not just in automotive applications but also in industrial and other embedded systems. When using an Arduino, this is the version that is as of today (08.15.2024) supported by the [Arduino_CAN]() library.
70+
**1991: CAN 2.0**
71+
72+
The influential CAN 2.0 standard was released, introducing significant advancements. This version supported bit rates of up to 1 megabit per second and introduced two frame formats: the standard 11-bit identifier and the extended 29-bit identifier. CAN 2.0 became widely adopted not just in automotive applications but also in industrial and other embedded systems. When using an Arduino, this is the version that is as of today (08.15.2024) supported by the [Arduino_CAN](https://github.com/arduino/ArduinoCore-renesas/tree/main/libraries/Arduino_CAN) library.
73+
74+
**2003: ISO Standardization**
75+
76+
CAN technology was standardized under the International Organization for Standardization (ISO) as ISO 11898-1. This helped in formalizing the protocol and ensuring compatibility and reliability across different implementations.
77+
78+
**2011: CAN FD (Flexible Data Rate)**
79+
80+
CAN FD was introduced to meet modern demands for higher data rates and larger payloads. CAN FD supported bit rates of up to 1 megabit per second for the arbitration phase and up to 8 megabits per second for the data phase. It also allowed for payload sizes up to 64 bytes, compared to the 8-byte limit of CAN 2.0.
7081

71-
- **2003: ISO Standardization**
72-
- CAN technology was standardized under the International Organization for Standardization (ISO) as ISO 11898-1. This helped in formalizing the protocol and ensuring compatibility and reliability across different implementations.
82+
**2015: ISO 11898-1:2015**
7383

74-
- **2011: CAN FD (Flexible Data Rate)**
75-
- CAN FD was introduced to meet modern demands for higher data rates and larger payloads. CAN FD supported bit rates of up to 1 megabit per second for the arbitration phase and up to 8 megabits per second for the data phase. It also allowed for payload sizes up to 64 bytes, compared to the 8-byte limit of CAN 2.0.
84+
The latest revision of the ISO standard incorporated CAN FD, making it an integral part of the international standard for CAN.
7685

77-
- **2015: ISO 11898-1:2015**
78-
- The latest revision of the ISO standard incorporated CAN FD, making it an integral part of the international standard for CAN.
86+
**Ongoing: CAN XL (Extra Large)**
7987

80-
- **Ongoing: CAN XL (Extra Large)**
81-
- Currently in development, CAN XL aims to further enhance the capabilities of the CAN protocol, offering even higher bit rates and larger payloads. This ongoing evolution is driven by the need to compete with Ethernet and other high-speed communication protocols in automotive and industrial applications.
88+
Currently in development, CAN XL aims to further enhance the capabilities of the CAN protocol, offering even higher bit rates and larger payloads. This ongoing evolution is driven by the need to compete with Ethernet and other high-speed communication protocols in automotive and industrial applications.
8289

8390
## How CAN Works
8491

85-
CAN (Controller Area Network) operates by transmitting data through a structured series of bits called frames. These frames ensure reliable and efficient communication between nodes on a network by encapsulating various fields that serve specific purposes such as message identification, data transmission, and error checking.
92+
CAN operates by transmitting data through a structured series of bits called frames. These frames ensure reliable and efficient communication between nodes on a network by encapsulating various fields that serve specific purposes such as message identification, data transmission, and error checking.
8693

8794
### Shared Bus and Absence of a Central Master Node
8895

@@ -93,7 +100,9 @@ One of the unique features of a CAN bus system is its use of a shared communicat
93100
![Differential Signal](./assets/differential_signal.png)
94101

95102
CAN uses a differential signal scheme, meaning data bits are represented by the difference in voltage between two wires: CAN_H (CAN High) and CAN_L (CAN Low). This differential nature makes CAN highly resistant to electrical noise, ensuring robust communication over long distances and in noisy environments typical of automotive and industrial applications.
103+
96104
#### Practical Example: CAN in Automotive Systems
105+
97106
Imagine a modern car where multiple sensors and actuators are connected throughout the vehicle. These include components such as the Anti-lock Braking System (ABS), Engine Control Unit (ECU), and various sensors for monitoring engine performance or temperature. To connect all these devices, a significant number of wires run across the car, often in close proximity to high-power electrical systems like the ignition system or the alternator.
98107
In such an environment, electrical noise is a common issue. Traditional serial communication protocols, which rely on single-ended signaling (measuring voltage relative to a common ground), can be significantly affected by this noise. The noise can induce erroneous signals, leading to data corruption and malfunctioning of the system.
99108
However, the CAN protocol uses differential signaling, which measures the difference in voltage between the CAN_H and CAN_L lines rather than referencing a predefined voltage level. This differential voltage measurement ensures that the data being transmitted is accurately received, regardless of common-mode noise. Even if the CAN signal is increased, decreased, or corrupted by external noise, the difference between CAN_H and CAN_L remains the same, preserving the integrity of the communication.
@@ -102,7 +111,9 @@ However, the CAN protocol uses differential signaling, which measures the differ
102111

103112
#### Ground Wire Considerations
104113
Technically, CAN's differential nature means that a ground wire is not strictly necessary for data transmission, as the data is conveyed through the voltage difference between CAN_H and CAN_L. However, in practical applications, it is advisable to include a ground wire for the following reasons:
114+
105115
- **Common Ground Potential:** Including a ground wire helps keep all nodes in the CAN network at a similar ground potential, reducing the risk of large ground potential differences, which can cause issues with the physical layer transceivers.
116+
106117
- **Safety and Reliability:** In an automobile, the chassis often serves as the common ground, ensuring that all devices operate at compatible voltage levels, reducing the chance of communication errors and improving overall system stability.
107118

108119
#### Example of Collision and How CAN Handles Bus Arbitration
@@ -125,26 +136,43 @@ Each CAN message is encapsulated in a frame made up of several fields:
125136
CAN frames come in two formats: Standard and Extended. The primary difference between these two formats is the length of the identifier field.
126137

127138
- **Standard CAN ID:** Uses an 11-bit identifier, allowing for 2,048 unique message IDs.
139+
128140
- **Extended CAN ID:** Uses a 29-bit identifier, offering a significantly larger address space with 536,870,912 unique message IDs.
129141

130142
A typical CAN frame consists of the following fields:
131143

132144
1. **Start of Frame (SOF):** Marks the beginning of the frame with a dominant bit, synchronizing all nodes to the start of the message.
145+
133146
2. **Arbitration Field:**
147+
134148
- **Identifier:** A unique value used to identify the message and determine its priority during arbitration.
149+
135150
- **RTR (Remote Transmission Request):** Differentiates between data frames and remote frames (requests data).
151+
136152
3. **Control Field:**
153+
137154
- **IDE (Identifier Extension):** Indicates whether the identifier field is standard (11 bits) or extended (29 bits).
155+
138156
- **r (Reserved bit):** Reserved for future use, should always be dominant.
157+
139158
- **DLC (Data Length Code):** Specifies the number of bytes of data (0 to 8 bytes).
159+
140160
4. **Data Field:** Contains the actual payload data, from 0 to 8 bytes.
161+
141162
5. **CRC Field:**
163+
142164
- **CRC Sequence:** Holds the Cyclic Redundancy Check value for error detection.
165+
143166
- **CRC Delimiter (DEL):** A single recessive bit separating the CRC field from the acknowledgment field.
167+
144168
6. **ACK Field:**
169+
145170
- **ACK Slot:** Indicates successful receipt of the message by setting a dominant bit.
171+
146172
- **ACK Delimiter (DEL):** Follows the acknowledgment bit and is recessive.
173+
147174
7. **End of Frame (EOF):** Consists of seven recessive bits marking the end of the frame.
175+
148176
8. **Interframe Space (ITM):** A period of bus inactivity between consecutive data frames ensuring the bus is idle before the next message.
149177

150178
These structured fields enable CAN to provide robust and error-resilient communication, making it highly suitable for automotive and industrial applications where reliability is crucial.
@@ -158,8 +186,11 @@ Timing and synchronization are crucial aspects of CAN communication. Unlike sync
158186
Despite being asynchronous, CAN ensures precise timing synchronization between nodes through a mechanism called **bit timing**, which consists of the following phases:
159187

160188
- **Sync Segment:** Used for synchronizing nodes. All nodes recognize the start of a message by identifying the transition from a recessive to a dominant bit.
189+
161190
- **Propagation Segment:** Accounts for physical delay times within the network.
191+
162192
- **Phase Segment 1 (PS1):** Helps compensate for phase edge errors.
193+
163194
- **Phase Segment 2 (PS2):** Provides further compensation for phase errors.
164195

165196
Bit timing is divided into **Time Quanta (TQ)**, which are the smallest units of time in CAN communication. The total number of TQ in a bit period defines the bit timing, adjusted to ensure high reliability in communication.
@@ -184,8 +215,11 @@ With the CAN class, you can send and receive data over a Controller Area Network
184215
The CAN class has several essential methods:
185216

186217
- `begin(CanBitRate rate)` - Initializes the CAN bus with a specified bit rate (e.g., `CanBitRate::BR_250k` for 250 kbps).
218+
187219
- `available()` - Checks if there are any incoming CAN messages available to read.
220+
188221
- `read()` - Reads a CAN message from the bus and returns it as a `CanMsg` object.
222+
189223
- `write(const CanMsg& msg)` - Writes a CAN message to the bus. The message is encapsulated in a `CanMsg` object, which includes the CAN ID, data length, and the data payload.
190224

191225
These methods provide the core functionality for sending and receiving messages over the CAN bus, allowing efficient and reliable communication across multiple devices in a network. For example, these methods can be used to monitor vehicle sensors or control industrial machines.

0 commit comments

Comments
 (0)
Please sign in to comment.