Realization of Rail Pressure Tester Based on PIC16F876A Single Chip Microcomputer

Publisher:SerendipitySoulLatest update time:2011-12-03 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Track circuit is an important outdoor equipment for signal interlocking, which plays a role in ensuring the safety of driving and shunting operations. It can supervise and check whether there are trains running, shunting operations or vehicle occupation on the line (including station line) in a fixed section, and can show whether the rails in the section are intact. It uses the rails as conductors, and the rail seams are connected by connecting wires. One end is connected to the power supply and the other end is connected to the receiver. It works through the track current.


Whether the track circuit can work properly directly affects the safe driving of the train. Therefore, the detection of the track circuit is particularly important. At present, there are few detection equipment on the market, and they generally have shortcomings such as high power consumption, high price, and large size. To this end, this paper analyzes and studies the track circuit and designs a high-precision pressure test instrument to simulate the pressure of the train on the track, so as to verify the performance of the track circuit.

System composition and working principle
This system uses PIC16F876A microcontroller as the core, and realizes data processing and real-time system control through software programming. The system block diagram is shown in Figure 1, which consists of the main control MCU module, A/D sampling module, power management module, display module and sensor.

Figure 1 System structure diagram


The main functions of each part of this system are: the power management is mainly responsible for detecting and boosting the battery voltage. When the voltage is lower than 3V, the system stops working and issues an undervoltage alarm. The main control MCU is responsible for mathematical calculations of the collected pressure signal, converting the voltage signal into a pressure value, displaying it on the digital tube, and can perform manual zero adjustment and full-scale adjustment. The system accuracy requirement is ±0.1kN; over-range alarms and sensor disconnection alarms can be performed. In order to achieve the purpose of low power consumption, sleep and shutdown functions are implemented in the software.

System hardware design
1 Power management circuit design
Power management mainly boosts and stabilizes the battery voltage, and can also perform overvoltage protection and low voltage alarm functions. The boost circuit is composed of the TPS60230 chip. TPS60230 is a new type of charge pump DC/DC converter produced by TI. Its application principle is shown in Figure 2. The battery voltage of 2~5.4V is connected to the TPS60230 input pin IN. In the figure, C1 and C2 are charge pump capacitors, and capacitors with small equivalent resistance are used. R1 and R2 divide the voltage to determine the low voltage alarm threshold. When it is lower than the voltage division value of R1 and R2, LBO outputs a low level. After the microcontroller finds that there is a low level, it controls the analog switch to cut off the power supply of the subsequent circuit; the output 5V is connected to the analog switch and microcontroller behind.

Figure 2 Power management circuit


2 Single-chip microcomputer and sampling circuit design
According to the accuracy requirements, this system uses ADI's 16-bit A/D chip AD7705. The AD7705 chip integrates amplification, filtering and A/D conversion units. It is a low-cost, wide dynamic range, and high-resolution A/D conversion chip. AD7705 and the single-chip microcomputer communicate data through SPI. The connection is shown in Figure 3, where CH1 and CH2 are differential input channels, REF is the full-scale level, and the full-scale level is set by adjusting RP1. The single-chip microcomputer is the host and is connected to the AD7705 through a four-wire (CS, SCLK, DI, DO) SPI. DRDY is the data conversion completion signal, which is valid at low level and connected to the RC2 port of the single-chip microcomputer. When the single-chip microcomputer finds that the RC2 port has a low level, it starts to send a register read instruction to the AD7705 to obtain the AD value. CH1+ and CH1- are pressure signals from the pressure sensor, and CH2+ and CH2- are signals sent by the zero potentiometer.

Figure 3 Sampling circuit


3 Display and alarm circuit design
The display and alarm circuit is shown in Figure 4. The display part uses a 7-segment 4-bit digital tube display. The PORTB port is connected to the segment code of the digital tube. The RC0, RC1, RC6, and RC7 ports are driven by transistors to amplify and control the selection end of the digital tube. When the microcontroller detects a low-level signal at the RA1 port, it controls the analog switch to cut off the power supply of the subsequent circuit. At the same time, D1 and buzzer B send out an alarm signal. When the pressure exceeds the system range, D2 and the buzzer alarm. In order to distinguish between low-pressure alarms and over-range alarms, D1 and D2 use different colors, and the buzzer rings at different times in equal intervals.

Figure 4 Display and alarm circuit [page]

System software design
1 Sampling and data processing
① AD7705 read and write timing
AD7705 communicates with the microcontroller through a four-wire SPI. Its read and write timing diagram is shown in Figure 5 (a) and (b). During the read and write process, the high bit of the serial data comes first and the low bit comes last. DRDY is low, indicating that the A/D conversion has been completed, the data is ready, and the read and write instructions can be started. At any time to read and write the AD7705, it is necessary to check whether DRDY is low.

Figure 5 AD7705 read and write timing diagram


②AD7705 registers
The first is the communication register, which selects the acquisition channel, whether the next operation is to read or write, and which register to read or write next time.
The second is the setup register, which determines the calibration mode, gain setting, polarity setting, and buffer mode.
The third is the clock register, which sets the filter memory clock control bit.
The software programming idea is also written in this order, first setting the communication register, then writing the setup register, and finally setting the clock register. After setting, as long as DRDY is detected to be low, the clock can be started to read the converted data in the AD7705 data register.
2 Data processing algorithm ideas
Data processing mainly converts voltage signals into pressure values ​​and converts the collected data. Given that: the sensor parameter is 10mV corresponds to 30kN, the full-scale voltage of A/D is 1.5V, the collected A/D value is K, the converted pressure is X, the A/D value corresponding to 10mV is D, and the gain is 64, then the above parameters can be calculated:
(1)
(2)
Formula (2) is the relationship between the converted pressure value and the collected A/D value.
Because the microcontroller does not support floating-point operations, in order to accurately display the results, the software is used to simulate floating-point division operations. The main idea is to define an integer variable INTD and store the result of the division in INTD. Because it is an integer variable, the result of the division only takes the integer part, for example, 5/4=1. The algorithm of simulated division is mainly based on this feature.
The first step is that if the collected value K is greater than 932, K/932 is stored in the integer variable to get the integer part.
The second step is to use K to take the modulus of 932 to get R. Obviously, R is less than 932. Then get the first decimal place, and then use R×10 to take the modulus of 932 to get R1, the second decimal place , and so on, to get the third decimal place dec3.
The third step is to directly perform the second step if the collected value K is less than 932.
The fourth step is to compare with the logical zero point to get the theoretical pressure value, and perform BCD conversion to display on the digital tube.

Figure 6 Software Flowchart


3 Programming ideas and flow chart
The system software programming adopts the state machine mechanism. After power-on, each module is initialized, including I/O port initialization, timer initialization, SPI initialization, etc. After initialization, it enters the system loop, and performs task processing according to the task flag in the loop body. The main tasks are: undervoltage processing, data acquisition, sleep, shutdown, etc. When processing data, first collect the value of channel 2, and then collect channel 1. If the sensor is not connected, the collected value is zero or approximately zero, and the system alarm waits. If the collected value is greater than zero, it participates in the calculation. Calculate the theoretical value for display.

Reference address:Realization of Rail Pressure Tester Based on PIC16F876A Single Chip Microcomputer

Previous article:High-precision data acquisition device based on PIC16F87X series microcontroller
Next article:Design and application of programmable power supply based on PIC16F874 microcontroller

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号