CAN Bus: How It Works, Advantages, and Disadvantages

2023-06-06 01:35:51
关注

Illustration: © IoT For All

Control Area Network (CAN) bus is a serial communication protocol that allows devices to exchange data reliably and efficiently. It is widely used in vehicles, working like a nervous system to connect ECUs in the vehicle.

CAN bus was originally designed for automotive applications by Bosch in the 1980s. It is a multi-master, multi-slave, half-duplex, and fault-tolerant protocol that fits well with the requirements of automotive applications. It is simple, low-cost, and reliable and can be used in harsh environments. The CAN bus provides one point of entry for all the ECUs in the vehicle, which makes it easy to connect and diagnose.

CAN bus data can provide valuable insights into the performance and status of the connected devices. However, collecting and processing CAN bus data can be challenging due to the high data rate, low bandwidth, and variable network conditions. One possible solution to overcome these challenges is to use MQTT, enabling timely data transmission from cars to the cloud even with weak network conditions.

“The CAN bus provides one point of entry for all the ECUs in the vehicle, which makes it easy to connect and diagnose.”

EMQ Technologies Inc.

A Brief History of CAN Bus

The primary purpose of the CAN bus was to establish an effective communication system for automotive applications, specifically to decrease the complexity of wiring harnesses in vehicles.

In 1986, Bosch introduced their initial CAN protocol, which quickly gained momentum among automakers due to its reliability and robustness. By 1993, it became an international standard under ISO-11898. To summarize the evolution of the protocol:

  • 1991: Mercedes-Benz becomes one of the first automobile manufacturers to implement CAN bus in their W140 S-Class model.

  • 2004: The introduction of CAN FD (Flexible Data Rate), providing higher data rates and larger payloads than traditional CAN networks.

  • 2015: Adoption of ISO-16845:2015 as a conformance test plan for devices implementing both classic CAN and CAN FD protocols.

Apart from automotive applications, other industries have embraced this versatile network protocol over time. Today, it is used in industrial automation systems (CANopen) and marine electronics (NMEA 2000). Its widespread adoption is mainly attributed to its ability to operate reliably even under harsh conditions while maintaining low-cost implementation requirements.

How Does a CAN Bus Work?

The CAN bus is a decentralized communication protocol. Its decentralized approach makes it ideal for applications in automotive and industrial systems where reliability and real-time performance are essential.

In a CAN network, all nodes are connected via twisted-pair wiring or optical fiber cables. Each node has its microcontroller responsible for processing incoming messages and sending outgoing ones. Data is broadcasted by a node on the shared bus, allowing all other nodes to receive it. The primary stages of the communication process are:

  1. Arbitration: To prevent collisions when multiple nodes attempt to transmit simultaneously, CAN uses an arbitration process based on message priority. The lower the identifier value of a message, the higher its priority.

  2. Error detection: Built-in error detection mechanisms ensure data integrity within CAN networks. These include cyclic redundancy checks (CRC), frame check sequences (FCS), and acknowledgment bits from receiving nodes.

  3. Fault confinement: If any node detects an error or malfunctions during transmission, it will enter an “error passive” state until proper operation resumes. This prevents faulty transmissions from affecting overall system functionality.

This combination of features allows CAN buses to maintain high levels of efficiency while ensuring reliable communication between different components in complex systems like vehicles or factory automation equipment.

Message Structure in the CAN Protocol

The message structure in a CAN bus system is crucial for efficient communication between devices. The protocol uses a data frame format that consists of several fields, including an identifier, control field, data field, and error detection mechanism.

  • Identifier: This unique value determines the priority of each message on the network. In standard 11-bit identifiers (CAN 2.0A), there are up to 2048 different priorities available. Extended 29-bit identifiers (CAN 2.0B) provide even more options with over half a billion distinct values.

  • Data Length Code (DLC): Located within the control field, this code specifies how many bytes are present in the data field – ranging from zero to eight bytes.

  • Data Field: Contains actual information being transmitted across nodes in byte-sized segments.

  • Cyclic Redundancy Check (CRC): A built-in error detection mechanism that ensures reliable communication by detecting transmission errors and requesting retransmission if necessary.

  • Acknowledgment Slot: A single bit used by receiving nodes to acknowledge the successful receipt of messages or indicate errors requiring retransmission.

  • Error Frame: An optional part of CAN messaging that allows nodes to signal when they detect an issue with their own transmissions or received messages from other devices on the network.

Types of CAN

Here are the three main types of CAN:

#1: Low-Speed CAN

Low-Speed CAN, also known as fault-tolerant or ISO 11898-3, operates at speeds up to 125 kbps. It is designed for less critical systems like body control modules, door locks, window controls, etc., where data transmission speed isn’t vital. Its key feature is the ability to continue functioning even when one wire in the bus fails.

#2: High-Speed CAN

High-Speed CAN, or ISO 11898-2, can reach speeds up to 1 Mbps. This type of network is suitable for more time-sensitive applications such as engine management systems and electronic braking systems due to its faster data transfer rates compared to low-speed counterparts. However, it lacks fault tolerance capabilities found in low-speed networks.

#3: CAN FD (Flexible Data Rate)

CAN FD, introduced by Bosch in 2012, is an extension of high-speed networks with increased data rates—up to 5 Mbps—while maintaining backward compatibility with existing high-speed devices. The primary advantage of this technology lies in its ability to transmit larger payloads more efficiently than traditional CAN, making it ideal for modern vehicles with increasingly complex electronic systems.

CAN Bus: Advantages and Challenges

Advantages

The CAN bus data can provide valuable insights into the performance, health, and behavior of a vehicle. Collecting CAN bus data to the cloud is a powerful way to leverage the potential of vehicle data through big data analysis.

By applying machine learning, artificial intelligence, or other analytical tools to the collected data from a large number of vehicles, vehicle manufacturers can gain valuable insights and leverage them to optimize vehicle performance.

  • Detecting, troubleshooting, and predicting faults: By analyzing the CAN bus data, one can identify any abnormal or erroneous signals from the devices and sensors. This can help diagnose the root cause of a problem and fix it before it leads to more damage or safety issues. Manufacturers can also train machine learning models to predict faults by feeding the collected data to the model.

  • Visualizing vehicle data: With the collected data, users can develop a system to display the aggregated data on a dashboard that allows users to filter, sort, and compare different vehicles and metrics. The dashboard also provides alerts and recommendations based on the data analysis. The system enables users to gain insights into their performance.

  • Vehicle road coordination: The collected data can be calculated together with the road infrastructure data to build a vehicle road coordination system.

In the AI era, data is the most valuable property. By collecting data from cars to the cloud and then distributing it to all kinds of data infrastructure like databases, and data lakes, users can leverage the data for nearly all kinds of applications.

Challenges

Collecting CAN bus data locally on the vehicle is pretty mature. However, it can be challenging to collect and process the CAN bus data and transfer the insight to the cloud in real time due to the high data rate, low bandwidth, and variable network conditions. Thus, transferring all the CAN bus data to the cloud for processing is impractical. Instead, one can collect and process the CAN bus data locally on the edge side to reduce the data volume and transfer the insight to the cloud in real time.

You’ll need at least two components to build such a solution:

  1. Edge computing engine: An edge computing engine can collect only the needed CAN bus signals, flexibly process them and trigger MQTT transfer actions in real time. 
  2. MQTT broker in the cloud: An MQTT broker can help transfer the processed CAN bus data to the cloud in real time.

Tweet

Share

Share

Email

  • Cloud Software
  • Data Analytics
  • Network and Protocols
  • Vehicle Tracking

  • Cloud Software
  • Data Analytics
  • Network and Protocols
  • Vehicle Tracking

参考译文
CAN总线:工作原理、优点与缺点# 示例输入与输出 **输入** 人工智能(AI)是计算机科学的一个分支,旨在开发表现出人类智能的软件或机器。这包括从经验中学习、理解自然语言、解决问题以及识别模式。 **输出** 人工智能(AI)是计算机科学的一个分支,旨在开发表现出人类智能的软件或机器。这包括从经验中学习、理解自然语言、解决问题以及识别模式。
插图:© IoT For All --> 控制区域网络(CAN)总线是一种串行通信协议,使设备能够可靠高效地交换数据。它被广泛用于车辆中,就像神经网络一样连接车辆中的各个电子控制单元(ECU)。CAN总线由博世公司在20世纪80年代为汽车应用而设计。它是一种多主多从、半双工、具有容错能力的协议,非常符合汽车应用的需求。它结构简单、成本低、可靠性高,适用于恶劣环境。CAN总线为车辆中的所有ECU提供了一个统一的接入点,从而便于连接和诊断。CAN总线的数据可以为连接的设备性能和状态提供有价值的洞察信息。然而,由于高数据速率、低带宽和网络条件变化,收集和处理CAN总线数据可能会面临挑战。一种可能的解决方案是使用MQTT,即使在网络条件较差的情况下,也能实现汽车数据及时传送到云端。“CAN总线为车辆中的所有ECU提供了一个统一的接入点,从而便于连接和诊断。”EMQ Technologies Inc.CAN总线的简要历史CAN总线的主要目的是为汽车应用建立一个高效的通信系统,具体来说就是减少车辆中线束的复杂性。1986年,博世推出了最初的CAN协议,由于其可靠性和稳定性,迅速在汽车制造商中流行起来。到1993年,它成为ISO-11898国际标准。总结一下该协议的发展历程:1991年:梅赛德斯-奔驰成为首批在其W140 S级车型中采用CAN总线的汽车制造商之一。2004年:引入CAN FD(灵活数据速率),提供比传统CAN网络更高的数据速率和更大的数据载荷。2015年:采用ISO-16845:2015作为经典CAN和CAN FD设备的一致性测试计划。除了汽车应用,随着时间的推移,其他行业也逐渐采纳了这一灵活的网络协议。如今,它被用于工业自动化系统(CANopen)和航海电子(NMEA 2000)。其广泛采用主要归功于其即使在恶劣条件下也能可靠运行,同时保持低成本的实现要求。CAN总线是如何工作的?CAN总线是一种去中心化的通信协议。其去中心化的方式使其非常适合需要可靠性和实时性能的汽车和工业系统应用。在CAN网络中,所有节点通过双绞线或光纤电缆连接。每个节点都有一个微控制器,负责处理接收到的消息并发送消息。数据由一个节点在共享总线上广播,允许所有其他节点接收。通信的主要阶段包括:仲裁:为防止多个节点同时传输导致冲突,CAN使用基于消息优先级的仲裁机制。消息标识符值越低,其优先级越高。错误检测:内置的错误检测机制确保CAN网络中的数据完整性。这些机制包括循环冗余校验(CRC)、帧校验序列(FCS)和接收节点的确认位。故障隔离:如果任何一个节点检测到错误或在传输过程中发生故障,它将进入“错误被动”状态,直到恢复正常运行。这可以防止故障传输影响整个系统功能。这些特性组合在一起,使CAN总线在复杂系统(如车辆或工厂自动化设备)中保持高效率的同时,确保不同组件之间的可靠通信。CAN协议中的消息结构CAN总线系统中的消息结构对于设备之间的高效通信至关重要。该协议使用一种数据帧格式,包括标识符、控制字段、数据字段和错误检测机制。标识符:这个唯一值决定了网络中每条消息的优先级。在标准11位标识符(CAN 2.0A)中,最多有2048个不同的优先级可用。扩展的29位标识符(CAN 2.0B)提供了更多的选择,超过五亿个不同的值。数据长度码(DLC):位于控制字段中,该代码规定数据字段中有多少字节,范围从0到8字节。数据字段:包含在节点之间以字节大小分段传输的实际信息。循环冗余校验(CRC):一种内置的错误检测机制,通过检测传输错误并根据需要请求重传,以确保可靠通信。确认槽:接收节点用一个比特来确认消息成功接收或指出需要重传的错误。错误帧:CAN消息的可选部分,允许节点在网络检测到其自身传输问题或接收其他设备的消息出现问题时发出信号。CAN的类型以下是三种主要的CAN类型:#1:低速CAN低速CAN,也称为容错CAN或ISO 11898-3,运行速度最高可达125 kbps。它适用于车身控制模块、车门锁、车窗控制等对数据传输速度不重要的非关键系统。其主要特点是在总线中的某一根导线发生故障时仍能继续运行。#2:高速CAN高速CAN,即ISO 11898-2,运行速度最高可达1 Mbps。这种类型的网络适用于发动机管理系统和电子制动系统等对时间要求更严格的应用,因为其数据传输速度比低速CAN快。然而,它缺乏低速网络中具有的容错能力。#3:CAN FD(灵活数据速率)CAN FD由博世于2012年推出,是高速网络的扩展,数据速率提高至最高5 Mbps,同时与现有高速设备向后兼容。该技术的主要优势在于其能够比传统CAN更高效地传输更大的数据载荷,因此非常适合现代车辆中日益复杂的电子系统。CAN总线:优势与挑战优势CAN总线数据可以为车辆的性能、健康状况和行为提供有价值的洞察信息。将CAN总线数据收集到云端,是通过大数据分析发挥车辆数据潜力的强大方式。通过将机器学习、人工智能或其他分析工具应用于从大量车辆收集到的数据,汽车制造商可以获得有价值的洞察信息,并用于优化车辆性能。检测、诊断和预测故障:通过分析CAN总线数据,可以识别来自设备和传感器的任何异常或错误信号。这有助于诊断问题的根源,并在导致更多损坏或安全问题之前进行修复。制造商还可以通过将收集的数据输入模型中,训练机器学习模型以预测故障。可视化车辆数据:通过收集到的数据,用户可以开发一个系统,将汇总数据显示在仪表盘上,允许用户筛选、排序和比较不同的车辆和指标。仪表盘还可基于数据分析提供警报和建议。该系统使用户能够深入了解其性能。车辆道路协调:收集到的数据可以与道路基础设施数据结合计算,构建车辆道路协调系统。在人工智能时代,数据是最宝贵的资产。通过将数据从车辆收集到云端,并将其分发到各类数据基础设施,如数据库和数据湖,用户可以利用这些数据进行几乎所有的应用。挑战在车辆上本地收集CAN总线数据已经相当成熟。然而,由于高数据速率、低带宽和不断变化的网络条件,收集和处理CAN总线数据并实时将洞察信息传输到云端可能会面临挑战。因此,将所有的CAN总线数据传输到云端进行处理是不现实的。相反,可以在边缘侧收集和处理CAN总线数据,以减少数据量,并实时将洞察信息传输到云端。要构建这样的解决方案,至少需要两个组件:边缘计算引擎:边缘计算引擎可以仅收集所需的CAN总线信号,灵活地进行处理,并实时触发MQTT传输动作。云端MQTT代理:云端的MQTT代理可以帮助实时将处理后的CAN总线数据传输到云端。TweetShareShareEmail 云软件 数据分析 网络与协议 车辆追踪 --> 云软件 数据分析 网络与协议 车辆追踪
您觉得本篇内容如何
评分

评论

您需要登录才可以回复|注册

提交评论

广告

iotforall

这家伙很懒,什么描述也没留下

关注

点击进入下一篇

小电阻之大作用——CAN终端电阻

提取码
复制提取码
点击跳转至百度网盘