Design and Implementation of Vehicle Data real-time Acquisition System

Different drivers produce different characteristics of driving data, for different requirements of the vehicle reliability, safety and comfort, the driving style is analyzed according to the driving data collected by the vehicle. This paper presents and designs a platform of vehicle operation data real-time acquisition based on UDS diagnosis. The platform uses MCU and CAN controller to build communication modules, and with PC to control data collection, display and preservation. The overall design process is systematically elaborated in this paper, including the design method of vehicle embedded data acquisition terminal and PC monitoring terminal, focusing on the design of platform communication protocol. The test results show that the platform satisfies general vehicle data acquisition requirements.


Introduction
Vehicles increasingly complex system structure, function, fault types are increasingly diverse, these are for automobile fault diagnosis and monitoring technology put forward higher requirements [1,2] . In terms of automobiles, abnormal driving and vehicle maintenance can cause great losses. The claims system of countries was gradually improved, but returns and recalls is a common occurrence. The recall system has been in place in Japan since 1969. As early as the 1960s and 1970s, the United States introduced reliable technology into automobiles, power generation facilities, engines and other mechanical products. In 1965, "Quality and reliability institute" was established in China. It was not until 1980 that mechanical reliability research began to be valued in China. At present, in the process of vehicle maintenance and fault location is about 3:7. With the rapid development of automobile industry, people have put forward higher requirements for vehicle reliability [3] .
According to the statistics of Ministry of Industry and Information Technology of the People's Republic of China, the total automobile production in China in 2017 was 290.15 million, and the sales volume stood at 288.79 million, overall showing a steady growth trend. According to a research report by the state administration of safety supervision and the ministry of transport, China ranked second in the world in terms of annual deaths from road traffic accidents in 2017, with about 630,000 deaths caused by traffic accidents in the whole year. With the increase of automobile production year by year, it has become the primary issue of vehicle safety to curb the high incidence of the traffic accident and reduce traffic accident injuries [4] .
For different requirements of the vehicle reliability, safety and comfort, it is proposed to collect real-time data during vehicle operation and design the system based on unified diagnostic services (UDS) [5][6] . The current collection platform and diagnostic equipment have some deficiencies as follow: 1) It is not easy for non-professionals to understand and operate [7] ; 2) Poor compatibility; 3) High cost. This paper presents and designs a platform of vehicle operation data real-time acquisition based on UDS diagnosis. This platform has the advantage of high reliability, good reusability, reasonable cost and convenient system software upgrade, which is in line with the industrial development and market demand. At present, it has entered the stage of actual vehicle testing, providing a set of reference solution for products of the same type.

General design of system
The vehicle data real-time acquisition system based on CAN bus can be divided into two parts according to the data flow: information monitoring system and diagnostic monitoring system, which correspond to CAN communication module and PC terminal control module. The system collects the driver's driving behavior data in real time [8] , including electronic control unit (ECU) signal collection, CAN communication signal conversion, ISO protocol processing, information fusion technology and vehicle-mounted network communication technology. The overall structure of the system is shown in Fig.1. Sensors of the vehicle itself monitor various parameters in the vehicle driving, and report the monitoring results to ECU. Peripheral equipment collects ECU parameters through the diagnostic interface provided by the vehicle. PC is used as the interface between human and vehicle. The system mainly completes three functional modules: reading real-time diagnostic data steam, diagnosis data parsing and storage, and fault processing.

Diagnosis technology based on CAN bus
The ISO 15765 defines common requirements for vehicle diagnostic systems implemented on a Controller Area Network (CAN) communication link, as specified in ISO 11898 [9] . It provides diagnostic services and server programming requirements for all vehicles external test equipment which connected to CAN network server. This technology has no requirement for automobile internal CAN bus architecture. The diagnosis system is used to diagnose fault of the sensor and actuator of the control system so that maintenance personnel can find and resolve the fault accurately. With the increasingly strict regulations, the integration degree of industrial automobile technology and electronic information technology is higher and higher. The increasing number of vehicle ECU makes the vehicle network more complex. CAN network technology oriented to the vehicle network solves this problem. The CAN protocol defines the bottom two layers of the open system interconnection reference model: the data link layer and the physical layer. In order to improve the reliability of vehicle fault diagnosis, the application layer diagnosis protocol of CAN communication protocol is implemented by UDS. UDS is applicable to all ECU of the vehicle, and the design of the vehicle information acquisition system adopts the software architecture of UDS to realize diagnostic services. Based on the actual needs of different auto enterprises, the diagnosis service is selected to realize some part or to customize some private properties.
UDS is designed from the technology of CAN bus. Currently, UDS is the trend of various manufacturers. CAN bus is the physical medium of vehicle-mounted communication. It has the advantages of strong anti-interference ability and high communication rate. The transmission rate of CAN bus is as high as 1Mb/s. UDS accesses the data of electronic control unit in the form of Request and Response. UDS provides both physical and functional addressing, distinguishing functional and physical addressing requests according to CAN ID. UDS include: diagnostic and communication 3 management services, data transfer services, storage data transfer services, input-output control services, routine services, upload/download services [10] .

Design of CAN communication module
According to the functional requirements and scalability of vehicle data acquisition [11], the hardware design of embedded CAN communication module is shown in Fig.2 [12] . TJA1050 can provide differential transmission performance for the bus and differential reception performance for the CAN controller. Considering the reliability and safety design principles of the system, this module is designed with other isolation protection circuits.

Software protocol design
The data acquisition software system includes PC control software and embedded diagnostic software. The diagnostic protocols in the diagnostic system software are almost identical, and the extension of the diagnostic function is only an increase in number. Referring to the OSI seven-layer structure, the communication diagnosis stratification is shown in Fig.3 which shows the entire software protocol architecture.

Fig.3 software protocol architecture
The ISO 15765 defines the diagnostic network architecture. According to ISO 15765, the embedded software receives the request of reading variable instruction from PC terminal to determine the diagnostic strategy and function of UDS. UDS defines the meaning and instruction of each diagnostic command, and establishes A-PDU (application layer protocol data unit) to parse the command. The network layer defines such mechanisms as sending and receiving data, sequence management, error processing, etc. The network layer encapsulates application layer messages into data format suitable for CAN bus transmission, and finally realizes the communication transformation from software to hardware through the service interface of data link layer and physical layer.

Embedded system software development protocol
A CLASSICAL CAN protocol device can transmit/receive frames with payload sizes ranging from 0 bytes to 8 bytes per frame. The network layer mainly implements the network protocol data unit (N_PDU) and network timer to ensure the validity of the actual content and message in the data transmission process. The N_PDU includes three parameters: addressing information (N_AI), network protocol control information(N_PCI) and network data(N_Data). If the data to be transferred do not fit into a signal CAN frame, a segmentation method is provided in ISO 15765-2 [13][14] .

Computer data communication protocol
When the CAN communication module accesses the vehicle, it can access the device it wants to according to the different addresses of the ECU. Currently, the most commonly used is the conventional addressing mode, which is represented by an 11-bit CAN ID, and each ECU needs to support a pair of physical addressing CAN ID, one for receiving diagnostic requests and the other for sending diagnostic responses. At the same time, each ECU also supports the function addressing diagnostic request CAN identifier. The general rule is that the CAN identifier used for diagnostic messages is limited to 0x700~0x7FF, where 0x7DF~0x7EF is used only for the diagnosis of the relevant ECU.
The application layer is specified in ISO15765-3 [15] and ISO14229 [16] . The protocol described A_PDU and application layer session management timer. A_PDU is 1 byte long and stores the Service ID(SID), the RSID of the affirmative response message = SID+0x40. There are six interface service types between the network layer and the application layer. Table 1 shows the meaning of each primitive and the interface function used in this entry. PC terminal acquisition CAN message uses standard frame ID. for example ,as to EMS ,diagnosis ID is 0x7DF and response ID is 0x7E8. Table 2 describes the software communication data protocol format. PCI represents the number of bytes of protocol control information, MODE represents request mode, and PID represents parameter flag of request reading data stream. The data domain of each message is composed of PCI, MODE and PID. Table 2 shows the partial acquisition signal type, PID is used to distinguish the collected signal type, 0x04 represents the engine load value, 0x05 represents the engine cooling fluid temperature, 0x0C represents the engine speed, 0x0D represents the real-time speed of the vehicle. Analyze the signal value according to the response message, for example, the rotating speed is ((XX)1* 256) + XX2) /4rpm, travel speed is XX km/h.  Driving speed 0 x02 0 x01 0 x0d 0 x03 0 x41 0 x0d XX PC software mainly completes the request, reply, processing, record and display functions of data, which mainly includes network communication module, communication task allocation module, data analysis module, data pool interface module, log record module and main task coordination module. The modules coordinate with each other to ensure the CAN bus data and Ethernet data, system storage and directional selection, which could be flexibly extended to other related fields.

System testing and analysis
1) Road environment Considering the authenticity and reliability of the test data, the driving environment selected is the urban trunk road section. The driving environment test section of the system is the street mouth district, with a total length of 10 kilometers.
2) Data collection The CAN communication module is connected to the vehicle cabin diagnosis for engine load values (EL), engine coolant temperature (T), short-term fuel correction (STF), long fuel correction (LTF), engine Speed (RPM), Speed (Speed) and absolute throttle position (TP), and other direct reaction driving behavior data operation.
3) Analysis of the test results The PC terminal acquires the variation trend of each signal quantity within the range of test data, and makes statistical analysis of multiple driving records. For example, Fig.4 shows the curve diagram of the speed change of different drivers with time. According to the test results of the system, vehicle status and driver safety operation specifications can be analyzed in a directional manner. According to Fig.4, it can be concluded that each driving data changes within the normal data range without exceeding the parameter threshold and without obvious abnormality. According to the analysis of the variation trend of vehicle speed of driver A, driver B and driver C over time, it is concluded that the speed curve of driver C is the most frequently, followed by driver B, and driver A is the most stable. It can be reflected that the acceleration and deceleration operation of C is the most frequently, with the worst riding comfort, the most serious loss and fuel consumption on the vehicle, followed by B, of which A has the most stable driving operation. According to the speed analysis of driver B, there may be waiting for the red light or traffic jam. Other semaphore results are similar to the above analysis.

Conclusion
This paper presents and designs a platform of vehicle operation data real-time acquisition based on UDS diagnosis. With the combination of automation technology and software programming, embedded Internet technology and information integrated into industrial technology, etc., the state of the moving vehicle is collected, processed, displayed and counted. This paper introduces the method of UDS diagnosis based on CAN bus, which ensures the real-time and accuracy of data transmission and effectively controls the development cost of the system. With the development of Internet and industry 4.0, the system is not limited to the application scope of this paper, but can be extended to various industries in the automotive service. The design of the data terminal can also be modified according to different applications, which can meet a wider need of system. The realization of this system lays a foundation for driving vehicle analysis and driving behavior analysis.