Development and implementation of digital barometer controlled by single chip microcomputer

Publisher:superstar10Latest update time:2011-05-04 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. Introduction

A barometer is a device that uses a pressure-sensitive element to directly convert the measured air pressure into a current or voltage signal that is easy to detect and transmit, and then processes it through subsequent circuits and displays it in real time. The core component is the air pressure sensor, which plays an important role in monitoring pressure, controlling pressure changes, and measuring physical parameters. The air pressure sensors used in barometers basically rely on the changes in air pressure at different altitudes to obtain air pressure values.

Meteorological research shows that the air pressure decreases with the increase of altitude in the vertical direction. For example, in the lower layer, the air pressure decreases by 10 hPa for every 100m rise; at an altitude of 5 to 6 km, the air pressure decreases by 7 hPa for every 100m increase in altitude; and when the altitude increases further, that is, after reaching an altitude of 9 to 10 km, the air pressure decreases by 5 hPa for every 100m increase in altitude; similarly, if there is a downdraft in the air, the air pressure will increase; if there is an updraft in the air, the air pressure acting on the bottom of the air column will decrease. Generally, the weight of the air column acting on a unit area is called atmospheric pressure.

2. Structure of the barometer

The air pressure sensor is used to convert the measured air pressure into a voltage signal; a V/F converter can be used to convert the voltage signal output by the air pressure sensor into a pulse signal with a certain frequency; so that the pulse signal can be received by a single-chip microcomputer, and the corresponding air pressure value can be calculated based on the number of pulses obtained per unit time and the linear relationship between voltage and frequency, and finally displayed by an LED under the control of the single-chip microcomputer.

This barometer can accurately measure the corresponding air pressure value within the linear range of the air pressure sensor. It should be noted that its measured value is the absolute air pressure value. The technical indicators of the barometer studied in this article are as follows:

●Measurement range: 300hPa~1050hPa;

●Measurement accuracy: 0.1% FS (20℃);

●Display accuracy: 0.1%, achieved by 4 8-segment LED displays;

●Working temperature range: 0~85℃;

●Power supply voltage: 9V.

3. System Implementation

In the process of system construction, factors such as stability, complexity, cost and ease of debugging need to be considered. Each part is a unit circuit that can complete its own function. There is no complex signal transmission between modules, and there is little interference, so the overall system is relatively stable.

3.1 Air pressure sensor

The pressure sensor occupies a core position in the barometer. When designing, the pressure sensor can be selected based on several performance indicators such as measurement accuracy, measurement range, temperature compensation, and measurement of absolute pressure value.

Since the barometer displays the absolute pressure value, it is necessary to select a pressure sensor that measures the absolute pressure value. At the same time, in order to simplify the circuit and improve stability and anti-interference ability, the pressure sensor is required to have temperature compensation.

For this purpose, the author selected Motorola's MAX4100A pressure sensor to measure the absolute pressure value. The temperature compensation range of this sensor is -40~+125℃; the pressure range is 20kPa~1050kPa; the output voltage signal (Vs=5.0V) range is 0.3~4.65V; the measurement accuracy is 0.1%VFSS, and it has good linearity at 20kPa~1050kPa. The specific output relationship is as follows:

Vout=Vs(0.01059P-0.1528)±Error

Where Vs is the operating voltage, P is the atmospheric pressure, and Vout is the output voltage.

3.2 V/F conversion

The function of V/F device is to convert the amplitude of input voltage into a pulse train whose frequency is proportional to the amplitude of input voltage. Although V/F itself cannot be regarded as a quantizer, it can also realize A/D conversion after adding timer and counter. Its outstanding feature is that it converts analog voltage into a pulse train with strong anti-interference ability, which can be transmitted over long distances and directly input into the computer, thereby realizing A/D conversion function by measuring the output frequency of V/F.

Considering the difficulty of peripheral circuit implementation and the corresponding performance indicators, the author selected the LM331 voltage/frequency conversion chip. The device uses a temperature-compensated bandgap reference circuit, so it has excellent temperature stability, with a maximum temperature drift of 50ppm/℃. At the same time, the pulse output of the device is compatible with any logic form; LM331 can be powered by single or dual power supplies, with a voltage range of 5~40V; full-scale range of 1Hz~100kHz; maximum nonlinear error of 0.01%. Figure 2 shows the peripheral circuit of LM331 in this system. In this circuit, the voltage-frequency conversion relationship based on LM331 is:

fo = K Vi

Among them, K = Rs/(2.09 RtCt RL), Rs = Rs1 + Rs2

In fact, Rs in the circuit is mainly used to adjust the conversion gain of the circuit. The typical values ​​of Rt, Ct, and RL are 6.8kΩ, 0.01pF, and 100kΩ, respectively. The K value can be determined by the designer. In this design, K=2000 and Rs=28.424kΩ are taken mainly to consider that the single-chip microcomputer part uses the frequency measurement method to measure fo to ensure the measurement accuracy of the frequency signal. Since Rs, RL, Rt and capacitor Ct will directly affect the conversion result of fo. Therefore, there are certain requirements for the parameters of these components, and they should be appropriately selected according to the conversion accuracy during design. Although capacitor CL has no direct effect on the conversion result, a capacitor with small leakage current should be selected. Using resistor R1 and capacitor C1 to form a low-pass filter can reduce interference pulses in the input voltage and improve conversion accuracy.

3.3 Microcontroller

This barometer implementation requires the use of the microcontroller's P1 port and part of the P3 port, as well as an interrupt source, a timer and a counter. Therefore, the author selected ATMEL's AT89C2051 microcontroller, which is compatible with the 89C51, has 2kB of reprogrammable flash memory, a 2.7V to 6V operating voltage range, 128Byte internal RAM, two I/O ports (P1, P3), two 16-bit counters/timers and six interrupt sources, and can directly drive LED outputs, and has a programmable serial communication port. In addition, the microcontroller is also small in size and low in price.

3.4 LED Display

A single LED is a display unit composed of 7 segments of light-emitting diodes. There are 10 pins, corresponding to 7 segments, a decimal point and two common terminals. In the display circuit, these light-emitting diodes have two ways of connection: common anode connection and common cathode connection. In this design, 4 LEDs are needed to form a display unit, and a dynamic display method is adopted. Since the connection of 4 single LEDs for display is relatively complicated, and the port driving capability of the single-chip microcomputer is difficult to guarantee, a special driver chip needs to be added. Therefore, the author uses a common anode LED with 4 LEDs connected together and the corresponding segments are connected inside. It has 12 pins, including 7 segments and 4 common terminals. In order to increase the brightness of the digital tube, a transistor drive circuit can be added to the bit selection line.


The display circuit controlled by AT89C2051 is shown in Figure 3. The display circuit needs to select appropriate resistors R and Ra to ensure the brightness of the LED. Too large or too small will not allow the LED to display normally. When designing, it is ideal to take R as 4.7kΩ and Ra as 510Ω. If the convenience of printed circuit board wiring is considered, chip resistors and resistor arrays can be used to save space. In addition, 74LS244 and 74LS06 can also be used to form a driving display circuit, but current limiting resistors must also be added. Because 74LS06 is an open-drain device, a pull-up resistor needs to be added at the output.


4 Software Implementation

Through the above design, the size of P can be calculated by fo to obtain the real-time air pressure value. After the hardware circuit design is completed, it can be simulated using the simulation environment of the AEDK5196PH simulator, and the processing program can be written in C51 language.

Program setting: T0 is a timer, and the basic timing time base is 50ms. T1 is a counter. Using internal interrupt 0 can ensure that the value of the counter is read after T0 is set to 500ms to calculate the pressure value. If T1 and T0 are both working in mode 1, and the font code is sent at port P1, and P3.0~P3.3 can be used as bit selection lines, then the corresponding function is as follows:

(1) Timer T0 interrupt function:

voidtimer0(void) interrupt1 using1

{uintx,y;

uintcount_plus;

ET0=0; //Disable T/C0 interrupt

Tcount++; //interrupt times

ifTcount=== 10){

TR1=0; //Stop the counter counting

Tcount=0;

x = TH1;

y = TL1;

count_pulse=(x*256+y)*2;

ph=(uint)(10* ((float)(countpulse+1520)/105.9 //Calculate the air pressure

TH1=0x00; //Reset the initial value

TL1=0x00;

}

TH0 = -50000/256; //Reset to 50ms initial value

TL0 =-50000%256;

if(TL0!=0) TH0--;

ET0=1;

TR1=1;

return;

}

This interrupt function is mainly used to complete the reading of pulses and the calculation of air pressure values. ph is a global variable that can be used to save air pressure values.

(2) In the display function, the air pressure value is first separated by bit and saved in an array, and then the segment code and the corresponding bit selection are sent to display the corresponding air pressure value. The specific procedure is as follows:

voiddisplay(uintph_in)

{uchari=0;

ucharj=0;

uccharselect_bit=0; //bit selection

do {

cur_buff[i]=ph_in%10;

i++;

j = i;

} while (ph_in = ph_in / 10); // When the high bit is zero, the loop ends

i=0;

select_bit=0xfe;

do

{P1=tab[*p];

P3=select_bit;

dl_ms();

select_bit=(selectbit<<1)+1;

//Start displaying from the rightmost digit, circularly shift left

p++;

i++;

}while(i<j);

p = cur_buf; // pointer reset

return;}

In this way, in the main program, you only need to initialize it when the program runs for the first time, and then call the display function in a loop to achieve the real-time display function.


5. Conclusion

The author has designed a barometer using pure hardware circuits. Practice shows that due to the influence of temperature and the limitation of hardware parameters, the stability of real-time display is poor and the accuracy is not high. However, the use of V/F conversion signal and programming method to achieve the measurement completely overcomes the above shortcomings. The results show that this method has the advantages of high accuracy, good stability, and easy function expansion, which can provide a new idea for the design of instruments and electronic products.

Reference address:Development and implementation of digital barometer controlled by single chip microcomputer

Previous article:Design of Interface between ARINC429 Aviation Bus and AT89C52 Microcontroller
Next article:Design of measuring light curtain for object classification equipment using C51 series single chip microcomputer

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号