Abstract: This paper introduces a car driving recorder based on LPC2104 CPU. The recorder uses a large-capacity flash memory as a storage medium, uses a timer interrupt method to realize data acquisition and storage at second intervals, and uses a serial port interrupt method to realize data communication with a microcomputer. Keywords: car driving recorder; LPC2104; flash memory introduction As the number of cars increases, the probability of traffic accidents also increases. It is difficult to analyze, judge and repair the accident using traditional methods. This raises a question for people: how to analyze the existence of faults in a timely and prepared manner and objectively analyze the responsibility of the accident. This is related to the "black box" installed on the plane. Once the plane crashes, the information in the "black box" is an important basis for judging the cause of the crash. Because of its high cost and complex technology, it is difficult to use it on ordinary cars. This article introduces a low-priced, fully functional and expandable car driving recorder. This recorder uses LPC2104 CPU with ARM7 core as the main control machine, large-capacity flash memory as the storage medium, with accurate clock circuit, high-precision A/D converter to collect analog quantity converted by automobile sensors, and directly record various switch quantities of automobile signal lights, etc. At the same time, it uses serial port to realize data communication with microcomputer, and stores the low-level information of automobile driving record in the form of binary file on the hard disk.
1 Hardware design of the system The overall framework of the system is shown in Figure 1. The LPC2104 CPU with ARM7 core is the core of the car driving recorder. The whole system consists of information acquisition module, information processing and storage module and serial communication module. LPC2104 is an ARM7TDMI-S CPU produced by Philips that supports real-time simulation and tracing. It integrates the ARM7 local bus that interfaces with the on-chip memory controller, the AMBA high-performance bus (AHB) that interfaces with the interrupt controller, and the VLSI peripheral bus (VPB, ARM, AMBA bus compatible VLSI) that connects the on-chip peripheral functions, and embeds 128KB high-speed Flash memory. LPC2104 configures ARM7TDMI-S as little-endian byte order, with the advantages of small package, low power consumption, multiple 32-bit timers, multiple bus interfaces and up to 9 external interrupts, making it very suitable as the main control CPU of the car driving recorder. At the same time, LPC2104 also has a 128-bit memory interface and a unique acceleration structure, so that 32-bit code can run at the maximum clock frequency. 2 Information Collection Module Design The vehicle driving recorder requires real-time recording of various vehicle driving status information, so this system divides the information acquisition module into switch data acquisition module, analog data acquisition module, and clock data acquisition module. 2.1 Switch data acquisition module
This module uses 74LS165 parallel input 8-bit shift register to expand 16-bit parallel input port, and its hardware circuit is shown in Figure 2. Among them, 3 I/O port lines of LPC2104 are used to expand into 16-bit input port lines. In the figure, 2 74LS165 are connected in series to expand 16-bit input lines. CLK is the clock pulse input terminal, D0-D7 is the parallel input terminal, and the data output terminal QH of the previous stage is connected to the signal input terminal SIN of the next stage. When S/L is low level, parallel data placement is allowed, and when S/L is high level, serial shifting is allowed. In this way, 16 switch quantities such as left and right turn signals, front lights, door opening signals, brake light signals, etc. are isolated by photoelectric couplers and input into 2 74LS165 in parallel. After conversion by 74LS165, they are serially output to LPC2104 for processing. 2.2 Analog data acquisition module When performing analog data acquisition, the signals collected by 8 sensors such as water temperature and water level first pass through the analog signal conditioning link to adjust them within the full-scale input voltage signal determined by the reference voltage Vref of the A/D converter, and then pass through the A/D converter for A/D conversion. This module uses the TLC0838 8-channel 8-bit successive approximation analog-to-digital converter launched by Texas Instruments, USA, with a sampling frequency of 100kHz and an SPI bus interface for external communication. LPC2104 communicates with TLC0838 through its embedded SPI bus interface, and its hardware circuit is shown in Figure 3. Among them, SCK is the clock input by the SPI host or slave, MOSI is the data transmission from the SPI host to the slave, MISO is the data transmission from the SPI slave to the host, and SSEL is the SPI slave selection. The measurement of the car speed is realized by counting the pulse signal generated by the speed sensor. This system uses the AT89C2051 microcontroller to count the speed pulse signal. The microcontroller can set a guard to count the speed pulse signal and convert it into the actual range of the car. At the same time, the speed of the car can be calculated based on the travel and time, and the data can be transmitted to LPC2104 through the serial port UART0. 2.3 Clock Data Acquisition Module In order to record the driving time and enable the driving recorder to record the car status in real time, a special clock module is used to provide the time signal. This system uses the DS12887 clock circuit. DS12887 is a clock circuit that spans the year 2000 and uses a 4-digit calendar system to represent the year. The crystal oscillator, oscillation circuit, charging circuit and rechargeable lithium battery of the circuit are packaged together on the chip to form a thickened integrated circuit module. DS12887 can automatically access and update the current time. LPC2104 can obtain the current time and calendar by reading the internal time register of DS12887, and can also initialize the 10 time registers of the circuit by selecting binary code or BCD code. 3 Information processing and storage module design Since the storage structure of Flash is suitable for solid-state storage and the storage structure of EPROM is suitable for dynamic storage, this system uses a combination of Flash solid-state storage and EPROM dynamic storage to store and memorize data according to actual needs, that is, the collected car status data is stored in Flash solid-state storage, and the latest sector number and storage address of Flash is dynamically stored in EPROM. The flash memory uses the MX29F800BTC produced by Maxim, and the EPROM uses the 24C32 produced by Microchip. At the same time, the I2C bus interface embedded in LPC2104 is used to communicate with 24C32. When the system is working, the LPC2104 main control CPU first reads the sector number and storage address of the most recent storage of the Flash from the 24C32, and then uses this address as a reference, takes one address value of this address as the starting address of the Flash, and takes the next address value of this address as the starting address of the Flash, and stores them in sequence. The data that the Flash needs to store include 16-way switch quantity information, 8-way analog quantity information and clock information. The system uses two bytes (a total of 16 bits) to store 16-way switch quantity information, and uses 8 bytes of storage space to store 8-way analog quantity information. In order to save storage space, the system does not store time stamps every time it stores collected data. Since data collection is performed at fixed second intervals, the system only collects and stores clock signals as time stamps at the beginning of operation and at the starting position of each sector, and the collection time of subsequent data is referenced by these time stamps. The software flow of system storage is shown in Figure 4. When the system is reinstalled and powered on, it is necessary to record the time information of the start of collection. Since the system power is provided by the car power supply, the time of starting collection is also the time when the car starts, which is used as the time stamp of the car starting to drive. During program operation, the main program sets a car start flag. The car start flag is valid before the first data is written. Then, it is first determined whether the current storage address has the first address of a sector. If so, the current clock signal is stored at the beginning of the seventh byte according to the requirements of the write sector. Otherwise, 10 bytes are used to store the current clock signal at the current storage address, and the start time of the car is recorded. Then the car start flag is cleared. Whether the time information recorded at the start address of the sector is the start time of the car can be determined based on the time information recorded in the previous sector. If the data recorded in the two sectors before and after are continuous, the time information recorded in the header of the latter sector does not indicate the start time of the car. Otherwise, the situation is the opposite.
4 Serial communication module design The computer can read the data stored in the driving recorder at any time through the serial port. The serial communication between the driving recorder and the computer follows the RS232 protocol. During serial communication, LPC2104 reads the data stored in the Flash in turn and sends it through the UART0 serial port, then sends it to the computer through the MAX232 level converter, and then the computer receives the data through the serial port.
Figure 5
5 Conclusion The car driving recorder uses a microcomputer to receive the car driving data through the serial port and analyzes and processes the data; Visual C++ 6.0 is used as a development tool to write a microcomputer data analysis and processing program to simulate and display the state of the car when it is running; and the waveform of each component is displayed using graphics, such as the forward light switch status, the left and right direction light switch status, the door opening information, the brake signal, the water temperature change (range 0℃~100℃), etc. The driving recorder was installed on the car for testing, and the results were also ideal and met the design requirements. The test results are shown in Figure 5.
|