MQ-2 smoke sensor

A, MQ-2 smoke sensor Introduction

MQ-2 family are commonly used in plant and gas leak detection means adapted to detect the liquefied gas, benzene, dioxane, alcohol, hydrogen gas, smoke and the like. Thus it is, MQ-2 can be accurately is a multi gas detector.

MQ-2 detection range is extremely broad. Its advantages: high sensitivity, fast response, good stability, long life, simple drive circuit.

Second, the principle of MQ-2

MQ-2 Smoke tin dioxide semiconductor gas sensor material belongs, it belongs to the surface of the ion of formula N-type semiconductor. At 200 to 300 degrees Celsius when, tin dioxide adsorbed oxygen in the air, formation of negative ions adsorbed oxygen, the electron density of the semiconductor is reduced, so that its resistance value increases. When contacted with the smoke, if the potential barrier at the grain boundaries of the smoke density varies received, it will cause changes in surface conductivity. This can be obtained by using the existence of such information of smoke, the greater the concentration of smoke, the greater the electrical conductivity, the lower the output resistance, the output analog signal is greater .

Third, the characteristic of the MQ-2

  • MQ-2 sensor has a high sensitivity to natural gas, liquefied petroleum gas fumes, especially alkanes more sensitive to smoke, with good resistance, interference information can be accurately exclude non-flammable irritating smoke.

  • MQ-2 type sensor having good repeatability and long-term stability. The initial stability, short response time, a long time working performance. Note that: must be heated for a time before use, otherwise the output resistance and voltage inaccuracies.

  • Detecting combustible gases and smoke in the range of 100 10000ppm ~

  • (Ppm volume concentration .1ppm = 1 cc / 1 m3)

  • Circuit design wide range of voltages, 24V or less can be heated 5 ± 0.2V voltage

Note: if the heating voltage is too high, will cause the input current is too large, the internal signal wire fuse, whereby the device scrapped.

 

Four, MQ-2 Application Circuit

MQ-2, there are two commonly used circuit, using a comparator circuit using a monitor, another circuit for detecting the ADC.

1. The comparator circuit

 

MQ-2的引脚4输出随烟雾浓度变化的直流信号,被加到比较器U1A的2脚,Rp构成比较器的门槛电压。当烟雾浓度较高输出电压高于门槛电压时,比较器输出低电平(0v),此时LED亮报警;当浓度降低传感器的输出电压低于门槛电压时,比较器翻转输出高电平(Vcc),LED熄灭。调节Rp,可以调节比较器的门槛电压,从而调节报警输出的灵敏度。R1串入传感器的加热回路,可以保护加热丝免受冷上电时的冲击。

 

2. ADC转换电路

MQ-2传感器另外一个采集方法为AD信号采集,即将电压信号转化为数字信号,进而转化为精确的烟雾浓度值。

MQ-2传感器的4脚、6脚的电压为输出信号,Rs为传感器的本体电阻。其中若气体浓度上升,必导致Rs下降。而Rs的下降则会导致MQ-2的4脚、6脚对地输出的电压增大。所以气体浓度增大,其输出的电压也会增大,最终通过ADC0832转换后数值增大。

五.控制程序

1. 因为比较器电路处理的检测信号只有高和低两种状态;当浓度低于阈值时,信号为高电平;浓度高于阈值时,信号为低电平。所以单片机只需要将引脚配置为输入模式,监控该信号的高低电平即可。

2. AD信号采集程序

实现对MQ-2烟雾浓度的采集,只需实现ADC0832采集函数便可完成信号的采集。但通过ADC0832采集到的信号只为原始信号,要转换为实际的烟雾浓度,还需要根据MQ-2的特性进行校正和公式转换,最终得到实际的浓度值。

/****************************************************************************
函数功能:AD转换子程序
入口参数:channel
出口参数:dat
****************************************************************************/
unsigned char adc0832(unsigned char channel )
{
  unsigned char i,test,adval,dat;
  adval = 0x00;
  test = 0x00;
  
  Clk = 0;       //初始化
  DATI = 1;
  _nop_();
  CS = 0;
  _nop_();
  Clk = 1;
  _nop_();
  
  
  if (channel == 0x00 )      //通道选择
  {
    Clk = 0;
    DATI = 1;      //通道0的第一位
    _nop_();
    Clk = 1;
    _nop_();
    Clk = 0;
    DATI = 0;      //通道0的第二位
    _nop_();
    Clk = 1;
    _nop_();
  } 
  else
  {
    Clk = 0;
    DATI = 1;      //通道1的第一位
    _nop_();
    Clk = 1;
    _nop_();
    Clk = 0;
    DATI = 1;      //通道1的第二位
    _nop_();
    Clk = 1;
    _nop_();
  }
  
  Clk = 0;
  DATI = 1;
  for( i = 0;i < 8;i++ )      //读取前8位的值
  {
    _nop_();
    adval <<= 1;
    Clk = 1;
    _nop_();
    Clk = 0;
    if (DATO)
    adval |= 0x01;
    else
    adval |= 0x00;
  }
  for (i = 0; i < 8; i++)      //读取后8位的值
  {
    test >>= 1;
    if (DATO)
    test |= 0x80;
    else 
    test |= 0x00;
    _nop_();
    Clk = 1;
    _nop_();
    Clk = 0;
  }
  if (adval == test)      //比较前8位与后8位的值,如果不相同舍去。若一直出现显示为零,请将该行去掉
  dat = test;
  nop_();
  CS = 1;        //释放ADC0832
  DATO = 1;
  Clk = 1;
  return dat;
}

/****************************************************************************
函数功能:获取烟雾浓度
入口参数:无
出口参数:dat
****************************************************************************/
unsigned char GetYanWuValue(void)
{
    unsigned int sum=0;
    unsigned char m,value=0;
    for(m=0;m<20;m++)      //读50次AD值
      sum = adc0832(0)+sum;    //读到的AD值,将读到的数据累加到sum
    value=(unsigned char)(sum/20);        //跳出上面的for循环后,将累加的总数除以50得到平均值value
  
    if(value > ADC_Zero) 
        value = value - ADC_Zero;              //首先减去零点漂移
      else
        value = 0;
  
    return value;

}

 

发布了9 篇原创文章 · 获赞 4 · 访问量 226

Guess you like

Origin blog.csdn.net/weixin_44206126/article/details/104356094