Pages: [1]   Go Down
Author Topic: MQ-7 gas sensor  (Read 2759 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all!I have been reading a lot about this sensor in internet and in the forum, but in fact, I still cannot make it work properly. After readint his webpage:
http://forum.sparkfun.com/viewtopic.php?f=14&t=18447
I decided to supply 5V during 120sec and 0V during 180 sec. Then I take readings during the last 20 sec of the 0V period and average them. I use a 10K RL, my problem is that I get pretty stable readings around 400 (can read from 0-4095), which is too low and results in Rs of aprox 90k, and plus, as I do more readings this values go decreasing, so Rs go increasing. During the 5V period I get higher readings, around 1200, but not so stabel. Plus, just by reading the satasheet I have no clue how to conevrt this tho ppm, asit says 100ppm for CO in the clean air, and as I was reading in wikipedia and other sites, limit of safety is 50ppm. Also, I do not understand if which values can get the Rs. The 20-200k is for 100ppm or is from 10-10000ppm? I hope someone can help me with this. My code is as follows, thanks!
Code:
 if (cont_GasV==120){           //PUT GAS INPUT TO 1.4V DURING18sec
        Gas_val=0.0;
      P4OUT&=~BIT6;             //SETTING OUT AS 1 MAKES TRANSISTOR GIVE 0V        
    //  P7OUT&=~0x08;
     }
      else if (cont_GasV>=280&&cont_GasV<=299){
      ADC12IE = 0x01;                           // Enable ADC12IFG.3
      halAdcStartRead();
      Gas_val=SavedADC12MEM0+Gas_val;        // Store the sampled data
      }
     else if (cont_GasV==300){    //PUT GAS INPUT TO 5.0V DURING 120sec
       cont_GasV=0;
        P4OUT|=BIT6;                  //SETTING OUT AS 0 MAKES TRANSISTOR GIVE +5V
        Gas_val=Gas_val/20.0;
         Gas_val=(5.0*Gas_val)/4095.0;    //COMPUTE VRL
        Gas_val=10.0*((5.0-Gas_val)/Gas_val);               //COMPUTE RS
       char gas[20];
      sprintf(gas,"GAS: %.4f ",Gas_val);
      HalLcdWriteString(gas,8);
     }
« Last Edit: April 14, 2011, 05:42:30 am by Virginia » Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 227
Posts: 14026
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Please modify your post, select the code and press the # button. Also post the whole code if possible.


Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thnaks! I did not know how to do that, so is done!
Regarding the previous results, I realized that I was in fact NOT using a 10K resistor, but now I modified it and I am getting more logic results. Anyway, my ADC output in the 0V phaseis around 1000, that gives me about 27k of Rs. Anyway, this seems to be increasing with time (ADC decreasing). Still no idea why and also how to convert to ppm
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 227
Posts: 14026
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks,

Could you please post the whole sketch as this snippet makes too little sense for me, sorry ;(
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry, in fcat my code is quite huge with several libraries, as is part of a bigger project. I am in fcat developing it with a texas chip, so it may differ a bit. What I do is basically each second (and taking into account that VH=5V at the beggining):

Code:
read adc input
cont++
if cont=60sec {
  VH=0V;
}
else if cont >140 and cont<149  //store data at the end of the 90 sec cool period
  {store ADC;
}
else if cont=150sec (this is 60+90)
 { VH=5V;
  averagesamples=store ADC/10;
  Gas_val=(5.0*Gas_val)/4095.0;    //COMPUTE VRL
   Gas_val=10.0*((5.0-Gas_val)/Gas_val);               //COMPU
}

hope this can help to understand




Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 227
Posts: 14026
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

averagesamples=store ADC/10;

where do you make the ten samples in the code?
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The 10 samples I make them from 140 to 140, I go on storing them (summing ) in the same variable
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 227
Posts: 14026
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

if i understand the code it is this part:
Code:
if cont >140 and cont<149  //store data at the end of the 90 sec cool period
  {store ADC;
}
assuming that store ADC does the summing it will be called when cont = { 141,142,143,144,145,146,147,148 } so eight times. and a bit later you divide it by ten. that will make your outcome lets say 20% smaller than it should be, or said differently, the real average is 25% greater.
Code:
if cont > 139 and cont < 150  //store data at the end of the 90 sec cool period
{
  store ADC;
}
That 20% smaller value goes into the rest of your formula so it will be incorrect too


Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi guys..
can somebody help me how to convert the analog out to ppm values?
Logged

Pages: [1]   Go Up
Jump to: