Design and Implementation of Rapid Prototyping for Automotive CAN Bus Network
2026-04-06 08:50:20··#1
Abstract: This paper analyzes the characteristics of vehicle CAN bus, then designs and implements a rapid prototyping system for vehicle CAN bus. It solves the problem of combining module-based embedded software development with network simulation-based system analysis. Finally, the effectiveness of the system design is verified by using an experimental environment composed of the THECU-2003 hardware platform and control models built in Simulink. Key words:CAN bus; rapid prototyping; electric control unit 1Introduction With the increasing number of controlled nodes and control complexity in vehicle networks, in order to meet control requirements and reduce the development cost of control systems, automobile manufacturers and automobile design units have increasingly higher requirements for automotive embedded software development tools. At present, there are some software development technologies and software development tools for this application area, such as software design technology based on rapid prototyping and MATLAB/Simulink and dSPACE development tools. Software design technology based on rapid prototyping refers to the software development method in which software designers describe software functions by creating and maintaining functional models of embedded software and use microprocessor-oriented automatic code generation technology to realize the rapid generation of lower-level machine code. Using this technology can improve the development efficiency of embedded software and reduce development costs. However, current software development tools focus on single electronic control unit (ECU) modeling and verification of the execution efficiency and performance of software in a single ECU environment; they have limited support for the robustness and feature analysis of control strategies in network scenarios. On the other hand, network protocol simulation and analysis tools, such as OPNET, can provide analysis of protocol performance in network scenarios [6], but because the simulation code developed on OPNET cannot be directly ported to the controller, the development work cannot be easily reused for the target system. If we combine embedded software design based on rapid prototyping and analysis based on network simulation for the application scenario of automotive CAN bus network, we can realize rapid prototyping of automotive CAN bus network. In the early stages of design, virtual hardware defined by the model is used to replace the actual hardware that is not yet designed or is too expensive, for initial system design analysis. Once the corresponding hardware is available, the virtual hardware is replaced, and the model code is converted into target code for the target system, for verification analysis that is closer to the actual system. Finally, when all actual control software, controller hardware, and controlled hardware are completed, an integrated real-time simulation of the entire system is performed. This solves the problems of using independent tools to develop models and perform simulation verification. This paper provides a system for designing, simulating, and analyzing the performance of an automotive CAN bus network by designing and implementing a rapid prototype of an automotive CAN bus network. The system uses a virtual hardware method, constructing controller models and controlled object models related to typical automotive environments in Simulink, and constructing the CAN card simulation program TH-CAN-Vcard and the CAN bus analysis tool TH-CAN_Scope in the Windows environment. For the automotive CAN bus network scenario, it realizes the organic combination of control strategy simulation analysis and control code generation in the CAN bus network environment. 2 System Design and Implementation 2.1 Characteristic Analysis of Automotive CAN Bus Network The CAN bus is a serial communication bus. Carrier Sense Multiple Access with Collision Detection (CSMA/CD) is used for bus arbitration and control. In order to standardize the performance of automotive CAN bus in network scenarios, the International Organization for Standardization (ISO) and the Society of Automotive Engineers (SAE) have developed relevant international standards for the benchmark environment of CAN communication diagnostics. These standards define benchmark test requirements from different levels according to the layered structure of the CAN protocol. For example, SAE J2012 and ISO/DIS 15031-6 correspond to the definition of application layer fault diagnosis;[3] [7] ISO/DIS15765-2 corresponds to the network layer communication protocol, which provides long message data segmentation/reassembly, data transmission with flow control, and timeout processing control of messages between the on-board control unit and the off-board test tool by defining the Unacknowledged Segmented Data Transmission Protocol (USDT).[2] On the other hand, various automobile manufacturers have also developed their own corporate standards based on these international standards to standardize the products of ECU product suppliers. For example, the CAN communication standard software model of DaimlerChrysler-Benz Group is divided into two parts: vehicle diagnostic-related modules and modules unrelated to vehicle diagnostics. The vehicle diagnostics-related modules are divided into diagnostic protocol services (KWP2000) and network transmission protocol services (ISO-15765-2), which correspond to the functional descriptions of application layer services and network layer services, respectively, and define the relevant baseline environment parameters and test message sequences. [2] These standards provide detailed definitions of the content of diagnostic services based on CAN bus in the automotive environment, the logical relationship between network transmission message sequences and the latency requirements. Based on these requirements, the core technical work of this design is to provide a rapid prototype of a CAN bus network, realistically simulate message sequences and data flows with given characteristics, and reproduce possible interference and bit error signals. This work can provide the function of analyzing the relationship between network traffic, network efficiency and network response, and simulate and verify the robustness and real-time performance of ECU control code in the automotive CAN network environment. 2.2 Structure and Implementation of Rapid Prototype System The rapid prototype system has three types of nodes: actual CAN nodes with physical CAN hardware interfaces, virtual CAN nodes composed of TH-CAN-Vcard and Simulink models, and monitoring nodes running the TH-CAN-Scope analysis tool. In designing simulation experiments, the number of nodes is not limited, only affected by the specific addressing scheme of the CAN application layer. The first type of node is the CAN node we usually use; here, we focus on describing the implementation of the latter two types of nodes. 2.2.1 Virtual CAN Node A virtual CAN node consists of a TH-CAN-Vcard and a Simulink model, and the node implementation is shown in Figure 1. When the physical CAN card does not exist, virtual hardware technology is used. By selecting the virtual CAN channel provided by the CAN card driver library and instantiating the developed VCANCtrl control object as a COM server, a connection can be established between the COM server and the model in MATLAB (as a COM client) on a single machine. The process of virtually receiving/sending CAN messages to the CAN bus provides basic CAN communication testing functions for the model built in Simulink. When the physical CAN card exists, the target CAN channel in the model can be directly modified, so that the model in MATLAB has the function of communicating with other physical CAN nodes. At this time, multiple models located on different PCs and controller code on multiple ECU hardware can establish a vehicle CAN network simulation analysis environment through the CAN bus. [align=center]Figure 1 Implementation of Virtual CAN Node[/align] TH-CAN-Vcard is a CAN card simulation program developed in the Windows environment using Visual Studio .NET and KVASER's CAN card driver library. We developed the VCANCtrl control object using ActiveX technology and implemented the following internal functions in VCANCtrl: VCAN_Read Message receiving function; the input parameter is the CAN channel handle, and the return parameter is the ID, data packet, length, identifier, and timestamp of the CAN message in the receive buffer. VCAN_Write Message sending function; the input parameter is the CAN channel handle, and the ID, data packet, length, and identifier of the CAN message to be sent. VCAN_Start CAN card initialization function; the input parameters are the selected CAN channel number, baud rate, channel open mode, synchronization mode, synchronization segment, and CAN controller working mode. VCAN_Close CAN card closing function; the input parameter is the handle returned when the CAN card initialization is successful. 2.2.2 Monitoring Node The monitoring node is the node that performs CAN bus message sequence monitoring and control, running the TH-CAN-Scope - CAN message simulation analysis tool. TH-CAN-Scope is a tool for simulating CAN message sequences and recording and analyzing simulation results. It's a Windows application developed using KVASER's CANLIB SDK. TH-CAN-Scope's CAN message processing functions include: creating/editing message stream sequences, CAN communication management, CAN message sequence tracking, a console HMI, and database maintenance for message sequence management. The creation/editing of message stream sequences, CAN message sequence tracking, console HMI, and message sequence management related to database operations all use user threads. CAN communication management, which has high real-time requirements, uses a separate worker thread, and the two threads communicate with each other using Windows' message processing mechanism. Additionally, TH-CAN-Scope provides analysis functions including: online display of CAN messages, online statistics of CAN bus usage, recording CAN messages on the bus, and actively/cyclically sending CAN disturbance messages. And the CAN messages collected over a period of time are recorded in the database, which can be used for more detailed and in-depth performance analysis. By using the CAN message editing tool, the monitoring node can be specified to send trigger messages under the time trigger (send a certain CAN message/group of CAN messages at a specified relative time) and event trigger (send a specified CAN message sequence when a certain CAN message or a certain type of CAN message is received) mechanism to examine the performance of the CAN bus. 2.3 System Implementation Technology 2.3.1 Implementation of MATLAB External Program Interface TH-CAN-Vcard provides CAN communication function for the controller model and the controlled model under MATLAB, and adopts COM technology. Compared with the Matlab external communication method implemented by DDE technology [4], COM technology has better performance. In the test conducted by Emanuele Ruffaldi et al., COM improved the write performance by 10 times and the read performance by more than 30 times compared with DDE [5]. In addition, MATHWORKS no longer continues to develop the DDE interface, but recommends the use of the COM interface. In practical use, we first construct the VCAN transmitting and receiving modules in Simulink. We then instantiate the VCANCtrl COM object using the `actxcontrol` command in the M language to obtain its handle. We can then use this instantiated handle to call the corresponding `VCAN_Write` and `VCAN_Read` functions in the COM object, thus enabling CAN communication support in the Matlab control model. In use, this is equivalent to using a device with a handle. 2.3.2 Data Flow Simulation and Node Synchronization Implementation To generate a specified CAN message sequence on the CAN bus, we define the required message sequence using TH-CAN-Scope. Then, we define the response operations to CAN messages on the bus using a combination of time-triggered and event-triggered methods. The corresponding control logic is implemented through the Simulink model. Therefore, the actual control strategy is similar to being distributed across various CAN nodes. Node synchronization means that all CAN nodes on the bus should be able to simultaneously generate their respective specified message sequences at a certain time. Using TH-CAN-Scope to broadcast a custom CAN synchronization message and start timers on each node, a certain degree of node synchronization precision can be achieved. 2.3.3 Implementation of CAN Bus Performance Analysis In performing CAN bus performance analysis, we implemented the following analysis functions: examining the impact of bus load (including the number of nodes, the amount of information per node, and the bus rate set for each node); examining the impact of node priority strategies; examining the impact of fault tolerance strategies (e.g., nodes with excessively high transmit/receive error rates should actively exit the CAN bus network); and examining the real-time performance of the CAN network, mainly including the range of network message delay and the variation of message delay. The delay magnitude describes the static characteristics of message delay, while the delay variation describes the dynamic characteristics of message delay. 3 System Functional Testing and Analysis To verify the rapid prototyping system's support for mixed simulation of virtual and actual hardware under multiple ECUs, we designed the system functional testing experimental platform shown in Figure 2: ECU-A and ECU-B are two independent hardware ECUs, using the TH-ECU2003 controller developed in the laboratory; ECU-C and ECU-D are two independent control models developed in Simulink, implementing software simulation of CAN card functions through VCAN transmit and VCAN receive modules, which are virtual hardware. In the test, the communication flow was controlled by filtering the received CAN messages at each node, as shown in Figure 2: ECU-A -> ECU-B -> ECU-C -> ECD-D -> ECU-A. This verified all scenarios under the hybrid simulation of virtual and actual hardware. [align=center] Figure 2 Experimental platform for functional testing of the rapid prototyping system[/align] In the experiment, TH-CAN-Scope was used as the monitoring software to collect data on the CAN bus for 5 seconds. The mean and standard deviation of the delay of more than 2,000 CAN message messages between nodes were analyzed (the delay here includes the processing delay of the node and the transmission delay between the nodes). The analysis results are shown in Table 1. The experiment proves that normal communication can be carried out between any two nodes in the system, meeting the test requirements and verifying the effectiveness of the system design. Table 1 CAN message delay analysis in the experiment 4 Conclusion This paper addresses the problem that existing ECU software development tools focus on single ECU modeling and that it is difficult to reuse the development code in existing network simulation tools on the target system. A rapid prototyping system for automotive CAN bus networks was designed and implemented. Finally, the effectiveness of the rapid prototyping system design was verified through a simulation environment consisting of the THEC003 hardware platform and the control model in Simulink. References: [1] Anthony M. Phillips, Functional Decomposition in a Vehicle Control System. Proceedings of the American Control Conference, Anchorage, AK May 8-10, 2002, P3713-3718. [2] Daimler Chrysler Cop. Network Transport Protocol Requirement Definition, R1.1. May 9, 2000. [3] Holger Zeltwanger. CAN Standard Review: Change and Enhancements of the ISO11898 [S]. 2000. [4] Li Changhong, Using Multithreading to Implement Remote Simulation of MATLAB, Computer Engineering and Applications, 2003, 17. [5] Emanuele Ruffaldi, 1.2.3 ways of integrating MATLAB with the .NET. http://www.codeproject.com, 2005. [6] Liu Heng, Yang Jie, An Jianping, Qing Min, Application of Network Simulation Technology in CAN Bus Protocol Analysis, Proceedings of the 2003 National Conference on Simulation Technology, 2003. [7] SAE Standard, Recommended Practice for a Serial Control and Communication Vehicle Network J1939 (Draft) [S]. 1997.