Share this

Design of C8051F320 Train Safety Inspection Instrument

2026-04-06 03:59:41 · · #1
1. Introduction With the development of science and technology, train travel and tourism have become one of the main modes of transportation. To ensure the safe operation of trains, regular or irregular safety inspections are crucial. Train inspectors need to conduct safety inspections when trains arrive at stations. General inspection management systems struggle to verify fixed train numbers, stations, and times, making it difficult to achieve reasonable and standardized management. To address this need, a train safety inspection instrument based on the ultra-low-power microcontroller C8051F320 is proposed. Combined with computer application software management programs, this makes railway train inspection management more standardized and scientific. 2. Introduction to the C8051F320 Microcontroller The C8051F320 is a system-on-a-chip MCU fully integrated on a mixed-signal chip. Its core adopts a high-speed, pipelined architecture, and its instruction set is fully compatible with the standard 8051. 70% of the instructions have an execution time of 1 or 2 system clock cycles, and only 4 instructions have an execution time greater than 4 system clock cycles. Peripherals include a power supply regulator (5–3 V); two on-chip voltage comparators; a full-speed, non-intrusive in-system debug interface; a Universal Serial Bus (USB) function controller (8 flexible endpoint pipes, integrated transceiver and 1 kB FIFO RAM); a 10-bit 200 Ks/s 17-channel single-ended/differential ADC (with analog multiplexer); on-chip voltage reference and temperature sensor; on-chip voltage comparators; a high-precision programmable 12 MHz internal oscillator and a 4x clock multiplier; hardware implementation of SMBus/I2C, enhanced UART, and enhanced SPI serial interfaces; four general-purpose 16-bit timers; a programmable counter/timer array (PCA) with five capture/compare modules and a watchdog timer; on-chip power-on reset, VDD monitor, and clock loss detector. Memory includes 16 KB of in-system programmable Flash memory and 2,304 bytes of on-chip RAM (256 bytes internal RAM + 1 KB external RAM + 1 KB USB FIFO). 3. System Design Scheme 3.1 System Scheme Description To determine whether train inspection personnel have arrived at the designated location for safety inspection, this system design utilizes an i-Button information button as an external information carrier, working in conjunction with a PCF8563 high-precision clock device to accurately record the inspection location (replaced by a unique registration code) and time. The time and registration code are displayed on an SD35TR LCD module. Inspection personnel can use a TN9 infrared temperature measurement module to measure axle temperature. To facilitate nighttime work for inspection personnel, this inspection device also features high-brightness LED lighting and a reserved USB interface for easy data transfer to a PC for future data processing and retrieval. Based on the functions of the inspection device, a system structure block diagram has been designed, as shown in Figure 1, mainly including modules such as the main circuit, information acquisition, temperature acquisition, LCD display, and lighting circuit. [img=450,250]http://image.mcuol.com/News/081106164609880.jpg[/img] The main circuit module is shown in Figure 2. This module uses the C805lF320 microcontroller as its core, employs the PCF8563 to provide the system's real-time clock, and expands with an external 512 KB E2PROM memory 24LC512 to store the collected information, temperature, and time. A mini USB female connector is connected to the C805lF320's on-chip USB controller as the data transfer interface between the instrument and the PC. Two buttons serve as external interrupt inputs, initiating information acquisition and temperature acquisition respectively. A buzzer provides prompt and alarm outputs. The main circuit also includes battery voltage detection to monitor battery saturation. [img=450,400]http://image.mcuol.com/News/081106164610131.jpg[/img] 3.2 i-Button Information Button Interface Circuit The i-Button information button is a robust data carrier. Its internal photolithographic ROM contains a unique 64-bit registration code. It has a stainless steel button-shaped shell, making it dustproof, moisture-proof, and shockproof. Signals are transmitted via the 1-Wire bus protocol. The i-Button information button acquisition module of this system mainly consists of two parts: the DS1990A information button and the DS9092 information button reading probe. As shown in Figure 3, the button shape of the DS1990A information button is divided into two parts for signal connections: the center is the I/O connection of the 1-Wire bus, and the surrounding area is the signal ground connection. The DS9092 reading probe has a cup-shaped shape, with the center being the I/O connection of the 1-Wire bus and the surrounding area being the signal ground connection, achieving full contact with the button shape. Two leads are drawn from the back of the DS9092. One is an I/O line for the 1-Wire bus connected to the C8051F320 microcontroller, and the other is signal ground. Since the 1-Wire bus uses pull-up transmission, its I/O bus must be connected to the power supply with a pull-up resistor. Because information acquisition is initiated by a low-level button interrupt, another button is connected to the microcontroller to provide the information acquisition interrupt signal. [img=450,400]http://image.mcuol.com/News/081106164610222.jpg[/img] 3.3 TN9 Temperature Measurement Module Interface Circuit The TN9 infrared temperature measurement module uses infrared non-contact temperature measurement, and its temperature measurement principle applies the Stefan-Boltzmann law and Wien's displacement law. The TN9 module has five leads, in the following order: power (V), SPI data (D), SPI clock (C), ground (G), and test pin (A). The SPI data (D) and SPI clock (C) pins are used to transmit temperature information and are connected to the P0.4 and P0.2 pins of the C8051F320 microcontroller as the MOSI and SCK pins of the SPI bus, respectively. The test pin (A) is the start signal for the TN9 temperature measurement module, active low. Therefore, it is pulled up to 3.3V through a 1kΩ resistor, grounded via a button, and then connected to the P0.5 pin of the C8051F320 microcontroller as an interrupt signal for temperature acquisition. When the button is pressed, the test pin (A) is set low, starting the TN9 temperature measurement and simultaneously notifying the C8051F320 to prepare to receive temperature data. When the button is released, the test pin is pulled high and temperature measurement stops. The circuit is shown in Figure 4. [img=450,350]http://image.mcuol.com/News/081106164610853.jpg[/img] 3.4 SD35TR LCD Module Interface Circuit The SD35TR LCD module uses the HT1621 as the display driver. The full display has 4 digits, 1 colon, and 1 decimal point. Brightness adjustment is divided into 4 levels, and 4 LEDs are used as the backlight source. The LCD module interface has 6 leads, in the following order: LED backlight positive terminal (Vcc), power supply positive terminal (Vdd), ground (Vss), serial data input (DATA), write signal (WR), and chip select signal (CS). The three-wire serial interface, serial data input (DATA), write signal (WR), and chip select signal (CS), are connected to the P2.7, P2.6, and P2.5 pins of the C8051F320 microcontroller, respectively, directly controlling the SD35TR LCD module using the microcontroller's analog bus. Its circuit is shown in Figure 5. [img=450,350]http://image.mcuol.com/News/081106164611134.jpg[/img] 4 System Software Design [align=left] 4.1 System Main Flowchart[/align][align=left] The main functions of this system software design are to read data (from DS19-90A), measure temperature (train bearing temperature), store data, and display data. After system initialization, the battery voltage is detected first, and then the buttons are detected. If no button is pressed or the button is invalid, the time is read and displayed once; if a button is pressed and is valid, the corresponding button subroutine is executed, and the time is read and displayed once after the subroutine is executed. After that, the program enters standby mode, waiting for an interrupt to wake it up, and returns to the battery voltage detection loop. In this system design, the interrupt only performs the wake-up function. The software design flowchart of this system is shown in Figure 6. [img=450,700]http://image.mcuol.com/News/081106164611335.jpg[/img] 4.2 Information Acquisition Module When entering the information button information acquisition subroutine, all interrupts are first disabled, and then an initialization pulse is sent. After successful initialization, the microcontroller sends a read ROM command to the DS1990A. Its 64-bit registration number is read bit by bit and verified. If successful, the microcontroller will display "PASS" for 5 seconds and the buzzer will sound a short beep, indicating that the registration code of the information button has been successfully read. Simultaneously, the acquisition time is read and stored in the E2PROM along with the acquired information. Throughout the process, if initialization or verification fails, the program will display "Err" for 5 seconds and the buzzer will sound a long beep, indicating that the information button reading has failed. The information button information acquisition process is shown in Figure 7. [img=250,450]http://image.mcuol.com/News/081106164611536.jpg[/img]  4.3 After the infrared temperature measurement module enters the temperature measurement subroutine, it disables all interrupts, then enables the SPI function of the C8051F320, reads one byte of data, and then disables the SPI function to reset the counter. It checks if the data is 0DH; if not, it returns to SPI enable for a loop; if so, it performs data verification. If the verification passes, it calculates the actual temperature value and displays it for 5 seconds, followed by a short beep from the buzzer, indicating successful temperature acquisition. Simultaneously, it reads the temperature measurement time and stores it along with the temperature data in the EEPROM. If the verification fails, the program displays "Err" for 5 seconds and a long beep from the buzzer, indicating temperature acquisition failure. The flowchart is shown in Figure 8. [img=450,700]http://image.mcuol.com/News/081106164611747.jpg[/img] [align=left] 5 Conclusion [/align] [align=left]The train safety inspection instrument, based on the C8051F320 microcontroller, realizes offline information acquisition, axle temperature detection, and lighting functions, effectively supervising the safety of railway trains. This inspection instrument has advantages such as simple structure, low cost, small size, low power consumption, and reliable performance. Experiments have shown that the inspection instrument is stable in operation, has strong anti-interference ability, and is easy to operate, thus demonstrating that its hardware and software design is reasonable and has broad application prospects.[/align]
Read next

CATDOLL 135CM Laura

Crafted with attention to detail, this 135cm doll offers a well-balanced and realistic body shape that feels natural in...

Articles 2026-02-22
CATDOLL 133CM Kiki Shota Doll

CATDOLL 133CM Kiki Shota Doll

Articles
2026-02-22
CATDOLL Yuan Soft Silicone Head

CATDOLL Yuan Soft Silicone Head

Articles
2026-02-22
CATDOLL EQ (Sleepy Q) 108CM

CATDOLL EQ (Sleepy Q) 108CM

Articles
2026-02-22