In today's high-end cars, CAN bus technology is used. The failure of the car CAN bus will appear. Combined with the advantages of radio frequency and USB, rely on the fault code specified by the KWP2000 application layer, this paper proposes a design plan based on the vehicle CAN bus fault diagnosis. This program is low in cost, easy to carry, and has strong flexibility and adaptability.
1, program design
Due to the use of RF technologies, the automotive CAN bus data acquisition portion and the CAN bus data diagnostic portion are separated, no need to connect, is not subject to spatial venue, and is convenient to carry. According to ISO-related standards, the CAN bus transmission rate is up to 1 Mbps; but due to the special environment inside the car, the car CAN bus rate is generally 250 kbps. The maximum rate of frequency rate in this system is up to L MBPS, which can meet the data transmission requirements well.
The transmit terminal uses USB as the receiving module and the PC interface. Compared to the RS232 or PCI interface, the USB has the advantages of user easy, device automatic identification, automatic installation driver, and configuration, support for dynamic access and dynamic configuration; its transmission rate can reach tens of Mbps, and support synchronous and asynchronous transmission Way, guarantee bandwidth, transmission distortion.
PC side application layer software integrates the application layer protocol of KWP2000. KWP2000 is a wide application in a car fault diagnosis agreement developed by Sweden, has been widely used in microcomputer controlled automatic transmission, anti-lock brake system, airbag, cruise system. It is based on the OSI seven-layer protocol, which is in line with the IS07498 standard. The first to sixth floors implement the function of communication services, and the seventh layer realizes the function of diagnostic services. Its application layer proposes a complete and standardized diagnostic code. This system utilizes the KWP2000 application layer protocol to analyze the acquired CAN bus data to achieve fault diagnosis.
2, hardware implementation
2.1 Introduction to the chip used by the system
2.1.1 NRF2401 chip
The NRF240L is a single-chip radio frequency transceiver chip, working in a 2.4-2.5GHz ISM band; built-in frequency synthesizer, power amplifier, crystal oscillator, modulator, and standard SPI function modules; output power and communication channels can be performed by software Configuration, a total of 125 channels can be used, and the maximum rate can reach the L Mbps. The chip has 1.9 ~ 3.6 V wide operating voltage, and the work energy is very low. When transmitting at a 5 DBM power, the operating current is only 10.5 mA; when receiving, the operating current is only 18 mA.
NRF240L has four working modes: transceiver mode, configuration mode, idle mode, shutdown mode. Its working mode is determined by the three pins and configuration bytes of PWR_UP, CE, CS.
The transceiver mode is divided into DirectMode and Shockburst. The former does not add any processing in the film, the same as other radio frequency transceivers. The latter uses the on-chip FIFO stack, data from the MCU low speed, but high-speed transmitting, and all high-speed signal processing related to the RF protocol is performed in the tablets. For example, NRF240L automatically handles the head and CRC check code in ShockBurst transceiver mode, and automatically shifts the header and CRC check code when receiving; automatically add the character and CRC check code when transmitting data.
2.1.2 TMU3100 chip
TMU3100 is a single-chip microcontroller in the RISC kernel launched by Taiwan's 2005. It is embedded in fully compatible USBL. 1 The USB controller of the protocol, and provides a low speed USB interface and 3 endpoints, one of which control input / output endpoints and 2 interrupt input endpoints.
The TMU 3100 can be configured as a standard HID class that can use the HID class driver with the Windows operating system. This will save the work of the development device driver and shorten the development cycle. The TMU3100 chip structure frame is shown in Figure 2.
2.1.3 PICL8F2682 chip
PICL8F2682 is a new 8-bit low-power CAN microcontroller, which Microchip, has been introduced. The main resources are: built-in standard CAN module, 80KB flash program memory, 1 KB data E2PROM, 3.3 KBRAM memory, 8 channel ADC, 1 8 Bits and 3 16-bit T1MER, 1 SPI and I2C serial communication ports and programmable undervoltage reset function and low voltage detection circuits.
The PIC18F2682 built-in enhanced CAN bus module contains the CAN protocol engine, information buffer, and information control. The CAN protocol engine automatically processes all receiving and transmitted messages on the CAN bus, which can parse the data frame when receiving or transmitting information. You can only send information to you first set the appropriate registers, and the status of the information transmission can be obtained by the relevant registers.
2.2 Hardware Circuit
2.2.1 Principle of Launch Direction
Is the principle of system transmit terminal circuitry. The CAN bus interface uses Microchip's PIC18F2682 microcontroller for the Built-in CAN module, and bus isolation is performed by optocoupler 6N137; the CAN bus transceiver uses MCP2551.
The PIC18F2682 and the radio frequency chip NRF2401 are completed by standard SPI interfaces SCK, SDI, SDO, which greatly increases the transmission rate. Configure the control of the NRF2401 to enable CS and reception, and the transmit enable CE is controlled by RB4 and RB5, respectively. When the NRF240L receives the packet, the DRL will be high level, so the PICL8F2682 can determine whether or not data is received by querying the state of INT0.
2.2.2 Connection Direction Circuit Principle
Since the TMU 3100 is powered by the PC, the voltage VDD provided by the PC USB interface is large, and the VDD is π filtering.
Since the TMU 3100 does not have an SPI module, it can be communicated in accordance with the SPI protocol and the SPI port of the NRF2401 by PB [1], PB [0]. Configure the control of the NRF2401 to enable CS and reception, and the transmission enable CE is controlled by KSO [3] and KSO [13], respectively. After the NRF2401 receives the packet, the DRL will be high level, so the TMU 3100 can determine whether the data is received by querying the state of the KSL6.
3, software design
The software design of the system includes the design of the transmitter software, receiving software design and PC-side software design.
3.1 Launch Software Design
The transmitting terminal is shown in Figure 5. The software design mainly implements two functions: the first is to achieve acquisition of data on the CAN bus; the second is to achieve the acquisition data by radio frequency.
After power-on, the CAN module is first initialized. Then, the NRF2101 is then initialized and a connection is established with the receiving end. When the ACK signal is not received after the CAN data is transmitted, it is hopped; then the sender is notified to prepare the CAN data that receives the retransmit until the ACK signal is received.
In order to prevent air interference, automatic frequency hopping air protocols, that is, if you receive the ACK signal, it is possible to prevent the strong interference of a frequency band, thereby reducing the bit error rate.
3.2 Receiving Software Design
The receiving end software flow is shown in Figure 6. The software design mainly implements two functions: the first is to achieve enumeration; the second is to implement the received data to upload to the PC via USB. After power-on, the configuration of the TMU 3100 is first complete, and enumerate with the PC; the NRF2401 is configured after the enumeration is successful, and the connection is established with the transmitting end. When the packet is received, first determined whether the CAN data or retransmit the data command. If it is a CAN packet, return the ACK signal to the transmit terminal and frequency hop, and then pass the received data to the PC by USB; if it is a retransmission command, first frequency hop, then return the biography, indicate the next data The package is a retransmission packet.
The TMU 3100 is configured as a standard HID class so that it is not necessary to develop drivers for the device, but use the standard HID class driver provided by Windows.
3.3 PC end software design
The PC end software consists of an application and device driver. Windows provides comprehensive built-in drivers for standard USBs. This system uses Windows's own HID class driver, as long as the TMU 3100 is configured as the HID class, communication with the PC can be completed. This saves the driver of the development equipment, which greatly simplifies the development of the upper computer software.
The function of the primary machine's application is the functionality to implement read and write to TMU3100 endpoints. Writes in VC ++, you can operate the USB device as a file. Use the CreateFiile () function to obtain a USB handle, open the specified endpoint for read access or write access. Use deviceControl () to perform control operations, read data from the specified endpoint with readfile () to write data to the endpoint.
When the data on the CAN bus is collected into the PC, it can be diagnosed. The fault diagnosis code is based on the fault code specified by the KWP2000 application layer, which is currently internationally used, and it is now applied to the application layer of CAN, and it can be replaced with a new CAN upper protocol in the future. The fault diagnostic code is defined in the SSF14230. In SAE J1979, the number of service marker values defined by the vehicle manufacturer or system supplier is listed in Table 1.
This table corresponds to the service marker represented by hexadecimal number, corresponds to the SID service identifier byte in the data byte in the data link layer. Different SID values represent different service requests, the fault diagnostics must meet this application layer standard to identify different fault information represented by different hexadecimal code.
4, conclusion
This article is designed 2.4G wireless car CAN bus fault diagnostic, since automatic frequency hopping aerial protocol, the error rate is almost close to zero, and reliable work can be carried out in 14 m. The system uses internationally universal diagnostic code to make the program generic and practical; as a hardware platform, it is necessary to develop hardware platforms, which can greatly reduce development costs and easy to implement upgrade and maintenance of devices; use USB interfaces and 2. 4G wireless communication, with plug-and-play, no spatial restriction, data transmission real-time strength.
Our other product: