Functions: Monitor gas concentration in real time through the host computer and compare it with the alarm threshold set by the host computer. If the gas concentration exceeds the alarm value, the upper and lower computers will alarm at the same time. Change the gas alarm value in real time and transmit it to the lower computer for judgment through the host computer.
Circuit diagram: Refer to ADC0809 datasheet and MQ-2 gas sensor module parameters. The sensor outputs 0~5V analog voltage according to the gas concentration and inputs it to the analog input terminal of 0809.
Debugging: Use the serial port debugging assistant to check the correctness of data transmission.
program:
#include
#include
#include
#define uchar unsigned char
#define uint unsigned int
sbit CLK=P3^3;
sbit ST=P2^0; //Start conversion input signal
sbit OE=P2^1;
sbit EOC=P3^2;
uchar DATA; //Store A/D conversion data
sbit Beep=P2^7;
uchar aa;
void delayxms(uint x) //delay
{
uint i,j;
for(i=x;i>0;i--)
for(j=110;j>0;j--);
}
void delayxus(uint x) //delay xus
{
uint i;
for(i=x;i>0;i--)
_nop_();
}
void init(void)
{
TMOD=0x22; //Timer 0 automatically reloads 8 bits to generate CLK, and timer 1 sets serial port parameters
TH0=237; //50kHZ
TL0=237;
TL1=0xf3;
TH1=0xf3;//2400bps
TR1=1;
TR0=1;
SM0=0;
SM1=1;
EA=1;
ET0=1;
EN=1;
REN=1;
ST=0;
OE=0;
}
void ADC0809()
{
ST=0;
OE=0;
//LE=1;P0=0x00;LE=0;
delayxus(2);
ST=1;
delayxus(10);
ST=0;
delayxus(200);
while(EOC==0);
YOU=1;
DATA=P1; //DATA is the data after AD conversion
delayxus(20);
OE=0;
}
[page]
void main()
{
Beep=1;
heat();
while(1)
{
ADC0809();
if(aa==49)Beep=0;
else Beep=1;
delayxms(200);
}
}
void serial() interrupt 4
{ uint r;
RI=0;
r=SBUF;
aa=r;
if(r==48||r==49)
{
while(!IF);
IF = 0;
}
}
void T0_time() interrupt 1
{
}
Previous article:Smoke alarm system based on labview
Next article:How to generate executable files/setup files in LabVIEW
Recommended ReadingLatest update time:2024-11-16 21:40
- Popular Resources
- Popular amplifiers
- 100 Examples of Microcontroller C Language Applications (with CD-ROM, 3rd Edition) (Wang Huiliang, Wang Dongfeng, Dong Guanqiang)
- Arduino Nano collects temperature and humidity data through LabVIEW and DHT11
- Modern Testing Technology and System Integration (Liu Junhua)
- Computer Control System Analysis, Design and Implementation Technology (Edited by Li Dongsheng, Zhu Wenxing, Gao Rui)
- Keysight Technologies Helps Samsung Electronics Successfully Validate FiRa® 2.0 Safe Distance Measurement Test Case
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Seizing the Opportunities in the Chinese Application Market: NI's Challenges and Answers
- Tektronix Launches Breakthrough Power Measurement Tools to Accelerate Innovation as Global Electrification Accelerates
- Not all oscilloscopes are created equal: Why ADCs and low noise floor matter
- Enable TekHSI high-speed interface function to accelerate the remote transmission of waveform data
- How to measure the quality of soft start thyristor
- How to use a multimeter to judge whether a soft starter is good or bad
- What are the advantages and disadvantages of non-contact temperature sensors?
- 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
- [Xingkong Board Python Programming Learning Main Control Board Review 2] Mind+ Graphical Programming - Digital Clock
- Second generation Audi night vision computer disassembly
- 【Renesas CPK-RA2L1 Development Board】Review - 2: RT-Thread
- RT1052 (2) Tool Generates Code
- 【Xingkong Board Python Programming Learning Main Control Board】 4. What you see is what you get Mind+ graphical WS2812 light strip implementation
- Error when building MQTT server with apollo
- I often see people using large capacitors to make welding machines. Why don’t they explode?
- Visual wind speed ship lights
- Switching Power Converter - Principles, Simulation and Design of Switching Power Supplies (Original Book 3rd Edition)
- [Xingkong Board Python Programming Learning Main Control Board] Review 7. Xingkong Board Dedicated Python Libraries: unihiker and pingpong