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
#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
}
Previous article:Single chip microcomputer controlled stepper motor system
Next article:Design of digital barometer based on MPX4105
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Design of overvoltage protection circuit in TI chip Buck-Boost circuit
- Sharing the OS transplantation and application of Lingdongwei MM32 MCU--Based on I2C interface control of AMetal platform
- What do you think of the official open source of Huawei's Ark Compiler?
- [New version of Zhongke Bluexun AB32VG1 RISC-V development board] - 5: Enhanced version of Blink
- Current Status and Future Development of Satellite Mobile Communications
- Intelligently Connected World—Application of Internet of Vehicles and Future Development of Digitalization
- Motor drive circuit design 1
- Free Review - Topmicro Intelligent Display Module (5) Touch Screen
- How to deal with the acidic wastewater from acid salt spray testing of metal electronic products and devices?
- Summary: annysky2012's practical journey of motor development based on "STM32F746ZG+IHM07M1"