Pressure data acquisition based on LM331 and single chip microcomputer

Publisher:SereneVoyageLatest update time:2011-08-17 Keywords:LM331 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
1 Introduction

A/D converters are widely used in analog signal conversion for single-chip microcomputer controlled data acquisition. However, for long-distance data transmission and high-precision applications, the use of general A/D converters has many disadvantages. V/F converters can be used instead of A/D converters. The interface between the V/F converter and the single-chip microcomputer only requires one I/O port to input the frequency signal, and the interface is simple and occupies less hardware resources. The data acquisition system with the single-chip microcomputer and V/F converter as the core can measure the pressure detected by the sensor in real time and meet the system measurement accuracy requirements.

2 Basic principle structure of the system

The pressure sensor converts the measured pressure into a voltage signal, and the voltage signal output by the sensor is converted into a corresponding frequency signal through the V/F converter. The frequency signal is transmitted to the single-chip microcomputer using an optocoupler, and the signal frequency is measured using the timer/counter inside the single-chip microcomputer. The pressure value is calculated based on the linear relationship between voltage and frequency using the strong computing function of the single-chip microcomputer. Figure 1 is a system structure diagram.


3 System Hardware Design

3.1 Pressure Sensor MPXV50014G Module

In addition to the sensing unit, the integrated silicon pressure sensor MPXV5004G also contains a signal conditioner, a temperature compensator and a pressure correction circuit, which is particularly suitable for detection systems composed of single-chip machines. The MPXV5004G pressure sensor uses a rated 5 V power supply voltage, a maximum measured pressure difference of 3.92 kPa, a maximum withstand pressure of 16 kPa, and a temperature compensation range of -30℃ to 100℃. When the operating temperature is 10℃~60℃ and the pressure range is 0~4 kPa, the pressure sensor has good linearity, and the output relationship is:



Where: VOUT is the output voltage, VS is the operating voltage, P is the pressure value, and the error is 0.045 V.

When using this sensor, add a decoupling capacitor between the power supply and the ground to filter out the high-frequency signal interference generated by the device itself and contained in the power supply; add a decoupling capacitor between the signal output and the ground to filter out the noise component of the output signal. Figure 2 shows the decoupling capacitor configuration.



In applications, considering the zero drift of the pressure sensor due to temperature changes or device aging, it is necessary to correct the zero point and correct the output value so that the output value can maintain sufficient correctness and accuracy over a long working time.

3.2 V/F converter LM331 module

LM331 is a general-purpose V/F converter with a frequency range of 1 to 100 kHz, a maximum nonlinear error of 0.01%, a maximum temperature drift of 50 ppm/℃, a power supply range of 4 to 40 V, and an input voltage range of -2.0V~VS. When 4.5 V≤VS≤10 V, the power supply voltage has an effect of 0.1%V on the gain; when 10 V≤VS≤40 V, the power supply voltage has an effect of 0.06%V on the gain. The external circuit of LM331's V/F conversion is shown in Figure 3.



In Figure 3, the output frequency fout=KVIN, where K=Rs/(2.09RtCtRL). The typical values ​​Rt=6.8 kΩ, RL=100 kΩ, and Ct=0.01μF are selected. In the system, K=1000, so Rs=14.212 kΩ. In the circuit, Rs is composed of a 12 kΩ fixed resistor and a 5 kΩ adjustable resistor in series, which is used to adjust the gain deviation of LM33l and the deviation caused by RL, Rt, and Ct. CIN is a filter capacitor, which is generally taken in the range of 0.01~0.1μF. In the case of better filtering effect, CIN uses a 1μF capacitor. In order to improve accuracy and stability, the above resistors and capacitors use low temperature coefficient devices, preferably metal film resistors and polystyrene or polypropylene capacitors.

3.3 Interface between V/F converter and microcontroller (photocoupler 6N137)

In the detection or control system with more than two grounding points, in order to suppress the interference caused by the ground potential difference, it is very effective to use isolation technology to cut off the loop current. In principle, isolation technology can be divided into electromagnetic isolation and photoelectric isolation. Photoelectric isolation is to add a photocoupler between two circuits. The linear range of the photocoupler is limited and it is used for digital signal transmission. At the same time, the photocoupler is small in size and fast in conversion speed, so it is widely used in detection or control systems composed of microcomputers. The photocoupler is used to isolate the V/F converter from the microcontroller to enhance the system's anti-interference ability, prevent the microcontroller from freezing or the program running away due to the harsh external environment, and also play an electrical protection role for the microcontroller. Here, TOSHIBA's 6N137 photocoupler is selected. Figure 4 is a typical application circuit of 6N137.



Pin 2 of 6N137 is the signal input terminal. When the input signal is high, the light-emitting diode emits light, and the reverse-biased photosensitive tube is turned on after being illuminated. After current-to-voltage conversion, it is sent to the AND gate. The other input terminal of the AND gate (pin 7) is the enable terminal. When the enable terminal is high, the signal output terminal (pin 6) outputs a low level. When the input signal is low, the output is high. A 0.1μF capacitor with good high-frequency characteristics must be connected between Vcc (pin 8) and ground (pin 5), and it should be placed as close to pin 8 and pin 5 as possible. The forward voltage drop of the light-emitting diode is 1.2~1.7 V, and the forward current is 6.5~15 mA, so a 470Ω current limiting resistor must be added between pin 3 and ground.

3.4 MCU AT89C51 module

This system design requires an interrupt of the MCU. A timer. A counter. Here, AT89C51 is selected, which contains 2 16-bit timers/counters and 5 interrupts. When the internal timer/counter of MCS-51 is selected as the timing mode, the counting input signal is the internal clock pulse, and each machine cycle generates a pulse to increase the counter by 1; one machine cycle is 1/12 of the external clock oscillation frequency, and a 12 MHz crystal oscillator is used, and the machine cycle is 1μs. When the internal timer/counter is selected as the counting mode, the counting pulse comes from the external input pin P3.4 (T0) or P3.5 (T1). When the input signal generates a negative jump from 1 to 0, the counter increases by 1. Since a negative jump takes two machine cycles, when a 12MHz crystal oscillator is selected, in order to ensure that the level is sampled once before the change, the external counting input signal cannot exceed 500 kHz. The maximum count value of the 16-bit timer/counter is 65,535, which meets the design requirements here. The system sets T0 of AT89C51 as a timer and T1 as a counter. When the microcontroller receives an interrupt signal, timing and counting start at the same time, and when timing ends, counting also ends. Then, by using the calculation function of the single-chip computer to divide the count value by the timing value, the frequency of the measured signal can be obtained. Through the linear relationship between frequency and voltage, and voltage and measured pressure, the corresponding pressure value can be obtained.

4 System software design

The system software design is written in Keil C51 language and applies modular design, mainly including measurement function, interrupt subroutine, and control function. The main program flow chart is shown in Figure 5.



Set TO as the timer, the basic timing time is 50 ms, and Tl as the counter. IE=Ox8a, TMOD=Ox51. When the P3.2 port is at a low level, the status flag becomes 0, and the measurement starts. By using the interrupt, every time the timing reaches 500 ms, the counter stops counting and the measurement is completed. The status flag becomes 1, and the count value is read to calculate the frequency, and the pressure is obtained through the frequency. When the P3.2 port is at a high level, the control stage of the sensor monitoring object is entered according to the measured pressure value. The program code of the measurement function and the T0 interrupt subroutine are given below:



5 Conclusion

This measurement system is widely used in automotive electronic control, industrial production monitoring, safety protection, and household appliances. It has a simple structure, high accuracy, and stable performance. It is suitable for those occasions that require accurate measurement accuracy and have a certain anti-interference ability.
Keywords:LM331 Reference address:Pressure data acquisition based on LM331 and single chip microcomputer

Previous article:Application of automotive FPGA in racing car engine control unit
Next article:Application of CPCI single board computer in in-flight entertainment system

Recommended ReadingLatest update time:2024-11-17 04:42

Connection and drive of LM331 and PIC16F73 microcontroller
This paper introduces an AD conversion circuit composed of VF converter LM331 chip. It has the characteristics of simple wiring, low price, high conversion accuracy, etc. Moreover, LM331 chip does not need software program drive during the conversion process. Compared with AD conversion circuits such as AD574 that
[Microcontroller]
Connection and drive of LM331 and PIC16F73 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号