Design of digital barometer based on MPX4105

Publisher:LogicLeaperLatest update time:2016-09-07 Source: eefocusKeywords:MPX4105 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
The microcontroller can not only be used to measure temperature, but also to measure non-electrical signals such as air pressure, which requires the use of air pressure sensors. The principle of the air pressure sensor is to convert air pressure information into current or voltage output. The converted voltage or current is often an analog signal, so A/D conversion must also be performed to meet the interface requirements of the microcontroller. After learning the use of temperature sensors, combined with the MPX4105 air pressure sensor, we learned the design of a digital air compressor.

 

Main components:

1. AT89C52 single-chip microcomputer chip collects, controls and processes the air pressure information of the sensor.

2. MPX4105 integrated pressure sensor.

3. The voltage/frequency converter is LM331 high-precision V/F conversion chip.

4. The three-terminal low current linear voltage regulator chip MC78L05 outputs a stable +5v voltage.

 

Test flow chart: 
 

Test circuit diagram: 
 

Test program code:

//DigAirPress.h program

#ifndef _DIGAIRPRESS_H // Prevent DigAirPress.h from being referenced repeatedly

 

#define _DIGAIRPRESS_H

 

#include // Reference the header file of the standard library

#include

#include

#include

 

#define uchar unsigned char

#define uint unsigned int

 

#define K 2000 // K is the V/F conversion gain constant

 

uchar PressVal; // pressure value

uchar count; // counter

 

#endif

 

// DigAirPress.c program

#include "DigAirPress.h"

 

void display();

 

/* Timer 0 interrupt */

void timer0() interrupt 1 using 1

{

       uint x,y;

       uint fo;

 

       ET0 = 0; // Disable timer 0 interrupt

       count++;

       if (count == 10) // 500ms

       {

              TR1 = 0; // Stop counter 1

              count = 0;

              x = TH1;

              y = TL1;

             

              /* Calculate the frequency value. Since it is 500ms, multiply it by 2 */

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

             

              /* Calculate the air pressure value according to the calculated formula P=20fo/K+9 */

              PressVal = (uint)(20*(float)(fo)/K+9);     

 

              /* Display function, display the calculated PressVal value through a 5-digit digital tube (4 digits and 1 decimal point)

              Displayed, the display precision is 0.1, that is, retain one decimal place. This function is omitted in this example. */     

              display();

             

              /* Clear counter 1 to 0 */

              TH1 = 0;

              TL1 = 0;          

    }

 

       /* Reset TH0 and TL0 */

       TH0 = -50000/256;

       TL0 = -50000%256;

 

       ET0 = 1; // Enable timer 0 interrupt

       TR1 = 1; // Start counter 1

 

       return;

}

 

/* Main program */

void main(void)

{

       EA = 1;

       ET0 = 1; // Enable timer 0 interrupt

      

       /* Set T1 to 16-bit counter and T0 to 16-bit timer */

       TMOD = 0x51;

      

       /* Timer 0 is 50ms timing */

       TH0 = -50000/256;

       TL0 = -50000%256;

      

       /* Timer 1 starts counting from 0 */

       TH1 = 0;

       TL1 = 0;

 

       TR0 = 1; // Start timer 0

       TR1 = 1; // Start counter 1

 

       count = 0;

      

       /* Start an infinite loop and wait for an interrupt to arrive */

       while (1);             

 

}

 

void display(void)

{

       //Omitted in this example

}

Keywords:MPX4105 Reference address:Design of digital barometer based on MPX4105

Previous article:Single chip microcomputer controlled stepper motor system
Next article:Design of digital barometer based on MPX4105

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号