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!
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);
}
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
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):
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
}
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.
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