Design scheme based on vehicle CAN bus fault diagnosis instrument

This paper presents a design scheme based on the vehicle CAN bus fault diagnosis instrument. The solution is low in cost, convenient to carry, and has strong flexibility and adaptability.

1 program design

The overall design block diagram of the system is shown in Figure 1. The system is divided into two parts: the transmitting end and the receiving end.



Due to the adoption of radio frequency technology, the data acquisition part of the CAN bus and the data diagnosis part of the CAN bus can be separated, no wiring is required, and it is not limited by the space space, and the installation and carrying are convenient. According to the relevant ISO standards, the CAN bus transmission rate can be up to 1 Mbps; however, due to the special environment inside the car, the on-board CAN bus speed is generally 250 kbps. The radio frequency rate in this system can reach up to 1 Mbps, which can meet the data transmission requirements.

The transmitter uses USB as the receiving module and PC interface. Compared with RS232 or PCI interface, USB has the advantages of convenient user use, automatic identification of devices, automatic installation of drivers and configurations, support for dynamic access and dynamic configuration, etc.; its transmission rate can reach tens of Mbps, and supports synchronous and asynchronous transmission. The way, the bandwidth is guaranteed, and the transmission distortion is small.

The PC-side application layer software integrates the application layer protocol of KWP2000. KWP2000 is an in-vehicle fault diagnosis protocol developed by Sweden. It has been widely used in microcomputer-controlled automatic transmissions, anti-lock braking systems, airbags and cruise systems. It is based on the OSI seven-layer protocol and conforms to the IS07498 standard. Among them, the first to sixth layers implement the function of the communication service, and the seventh layer realizes the function of the diagnostic service. The application layer proposes a complete and standardized diagnostic code. The system uses the application layer protocol of KWP2000 to analyze the collected CAN bus data to realize the function of fault diagnosis.

2 hardware implementation

2.1 Introduction to the chip used in the system

2.1.1 nRF2401 chip

nRF240l is a single-chip RF transceiver chip, working in the 2.4 ~ 2.5GHz ISM band; built-in frequency synthesizer, power amplifier, crystal oscillator, modulator and standard SPI and other functional modules; output power and communication channel can be done by software Configuration, a total of 125 channels are available, and the maximum rate is up to 1 Mbps. The chip has a wide operating voltage of 1.9 to 3.6 V and has a very low operating energy consumption. When transmitting at a power of 5 dBm, the operating current is only 10.5 mA; when receiving, the operating current is only 18 mA.

The nRF240l has four working modes: transceiver mode, configuration mode, idle mode, and shutdown mode. Its working mode is determined by the three pins PWR_UP, CE, CS and the lowest byte TX_EN of the configuration byte.

The transceiver mode is divided into DirectMode and ShockBurst. The former does not add any processing to the signal on-chip, the same as other RF transceivers. The latter uses an on-chip FIFO stack, where data is sent from the MCU at low speed, but at high speed, and all high-speed signal processing associated with the RF protocol is done on-chip. For example, the nRF240l automatically processes the header and CRC check code in the ShockBurst transceiver mode, and automatically removes the header and CRC check code when receiving; automatically adds the header and CRC check code when transmitting data.

2.1.2 TMU3100 chip

The TMU3100 is a microcontroller for the RISC core introduced by Tenx Corporation in Taiwan in 2005. It is embedded in a fully compatible USBl. 1 protocol USB controller, and provides a low-speed USB interface and 3 endpoints, 1 of which controls the input/output endpoint and 2 interrupt input endpoints.

The TMU3100 can be configured as a standard HID class and can use the HID class driver that comes with the Windows operating system. This saves the development of device drivers and shortens the development cycle. The structure of the TMU3100 chip is shown in Figure 2.



2.1.3 PICl8F2682 chip

PICl8F2682 is Microchip's new 8-bit low-power CAN microcontroller. The main resources are: built-in standard CAN module, 80KB flash program memory, 1 KB data E2PROM, 3.3 KB RAM memory, 8-channel ADC, 1 8 Bit and three 16-bit T1MER, one SPI and I2C serial communication port and programmable brown-out reset function and low-voltage detection circuit.

The PIC18F2682 includes an enhanced CAN bus module that includes the CAN protocol engine, information buffering, and information control. The CAN protocol engine automatically processes all received and transmitted messages on the CAN bus, which can parse data frames as they are received or transmitted. It is only necessary to first set the appropriate register to send the information, and the status of the information transmission can be obtained through the relevant registers.

2.2 hardware circuit

2.2.1 Transmitter circuit principle

Figure 3 shows the circuit principle of the system transmitter. The CAN bus interface uses the PIC18F2682 microcontroller with Microchip's built-in CAN module, and is bus-isolated by the optocoupler 6N137; the CAN bus transceiver uses the MCP2551.



The PIC18F2682 and the RF chip nRF2401 are connected via the standard SPI interfaces SCK, SDI, SDO, which can greatly increase the transmission rate. The nRF2401 configuration control enable CS and the receive and transmit enable CE are controlled by RB4 and RB5, respectively. When the nRF2401 receives the data packet, DR1 will be set high, so the PICl8F2682 can judge whether the data is received by querying the state of INT0.

2.2.2 Receiver circuit principle

Figure 4 shows the circuit principle of the system receiving end. Since the TMU3100 is powered by the PC, and the voltage VDD interference provided by the USB interface of the PC is large, VDD is filtered by VDD.



Since the TMU3100 does not have an SPI module, it can communicate with the SPI port of the nRF2401 via PB[1] and PB[0] according to the SPI protocol. The nRF2401 configuration control enable CS and the receive and transmit enable CE are controlled by KSO[3] and KSO[13], respectively. After the nRF2401 receives the data packet, DR1 will be set high. Therefore, the TMU3100 can judge whether the data is received by querying the state of KSl6.

3 software design

The software design of the system includes transmitter software design, receiver software design and PC software design.

3.1 Transmitter software design

The transmitter process is shown in Figure 5. The software design mainly realizes two functions: the first is to realize the data acquisition on the CAN bus; the second is to realize the data after the acquisition is transmitted through the radio frequency.

This article refers to the address: http://





After power-on, the CAN module is first initialized. Then initialize nRF2101 and establish a connection with the receiving end. When the ACK signal is not received after the CAN data is transmitted, the frequency hopping is performed; then the transmitting end is notified to receive the retransmitted CAN data until the ACK signal is received.

In order to prevent air interference, an automatic frequency hopping air protocol is adopted, that is, frequency hopping is performed regardless of whether an ACK signal is received, so that strong interference in a certain frequency band can be prevented, thereby reducing the bit error rate.

3.2 Receiver software design

The receiving end software flow is shown in Figure 6. The software design mainly implements two functions: the first is to implement enumeration; the second is to realize uploading the received data to the PC via USB. After power-on, first configure the TMU3100 and enumerate it with the PC; after the enumeration is successful, configure the nRF2401 and establish a connection with the transmitter. When a packet is received, it is first determined whether it is a CAN data or a retransmit data command. If it is a CAN data packet, it returns an ACK signal to the transmitting end and hops the frequency, and then transmits the received data to the PC through the USB; if it is a retransmission command, it first hops the frequency, and then sets the retransmission flag to indicate the next data. A packet is a retransmitted packet.

The TMU3100 is configured as a standard HID class so that instead of developing drivers for the device, the standard HID class driver provided by Windows is used.

3.3 PC software design

The PC side software consists of an application and a device driver. Windows provides a complete built-in driver for standard USB. The system uses the HID class driver that comes with Windows. As long as the TMU3100 is configured as a HID class, communication with the PC can be completed. This eliminates the need to develop device drivers, greatly simplifying the development of PC software.

The primary function of the upper computer application is to realize the reading and writing of the TUM3100 endpoint, written in VC++ language, and the USB device can be operated as a file. Use the CreateFiile() function to get the USB handle and open the specified endpoint for read access or write access. Use DeviceControl() to control operations, ReadFile() to read data from the specified endpoint, and WriteFile() to write data to the endpoint.

When the data on the CAN bus is collected to the PC, the fault diagnosis can be performed. The fault diagnosis code is designed according to the fault code specified by the KWP2000 application layer. It is currently used internationally and is now applied to the CAN application layer. It can be replaced with the new CAN upper layer protocol in the future. The diagnostic trouble code is defined in the SSF14230. In SAE J1979, the different ranges of service identifier values ​​defined by the vehicle manufacturer or system supplier are listed in Table 1.

The service identifier represented by a hexadecimal number in this table corresponds to the SID service identification byte in the data byte in the data link layer. Different SID values ​​represent different service requests, and the fault diagnostic program must conform to this application layer standard in order to identify different fault information represented by different hex codes.



4 Conclusion

The 2.4G wireless car CAN bus fault diagnosis instrument designed in this paper adopts the automatic frequency hopping air protocol, so the bit error rate is almost close to zero, and reliable work can still be performed within 14 m. The system uses the internationally accepted diagnostic code to make the program universal and practical. With the PC as the hardware platform, there is no need to develop a hardware platform specifically, which can greatly reduce the development cost and facilitate the upgrade and maintenance of the device; use the USB interface and 2. 4G wireless communication, with plug-and-play, no space constraints, and strong real-time data transmission.

12V Power Battery

12V Power Battery,Electric Car Battery,Lithium Ion Battery,Lithium Rechargeable Battery

Sichuan Liwang New Energy Technology Co. , https://www.myliwang.com

Posted on