As I mentioned in Detecting LPG, it occurred to me that we can use the Figaro LPM2610 module to not just detect the presence of LPG when it's >= 10% of its lower explosive limit (LEL), we may also be able to use its analog outputs to measure the amount of gas in the air.

Before we jump in, a couple of caveats relevant to measuring gas levels. The TGS2610 datasheet says the sensor's typical detection range is between 500 to 10,000 ppm. Given butane LEL = 18,000 ppm, the sensor's detection range translates to 2.8% to 55.5% LEL. I want to be able to measure all the way down to 1% but it looks like this may be asking too much from this sensor. Then again we can take our chances.

Secondly, the sensor is hardly accurate as can be seen in this Figaro diagram of the module's expected performance:

The note below the chart says

When using LPM2610, typical alarm tolerances for 10% LEL of LP gas such as those shown in the figure above can be expected. However, in actual usage, alarm thresholds may vary since the threshold is also affected by such factors as the tolerances of test conditions and heat generation inside the gas detection enclosure.The tolerances are pretty wide: 5 to 20% LEL. Not at all encouraging.

Given these characteristics, using the LPM2610 to measure gas levels seems almost foolhardy. But in quixotic fashion we shall nevertheless proceed--if only as a mathematical exercise.

To start off here's a list of definitions of terms and variables we'll be using:

*Standard*values are sensor resistance and output voltage at an ambient temperature of 20°C. To*standardize*a voltage is to apply a corrective factor provided by V_{REF}so that the voltage value becomes that which would be expected if ambient = 20°C.

*Actual*values are LPM2610 resistance and output voltage values without consideration to ambient temperature.

- V
_{REF}is the output of the LPM2610 voltage divider consisting of a thermistor and various fixed-value resistors. V_{REF}is theoretically = V_{DD}/2 when ambient temperature = 20°C.

- V
_{OUT(act)}= actual output of the LPM2610 voltage divider consisting of (1) the TGS2610 sensor whose resistance varies with amount of LPG present and (2) a fixed value load resistor R_{L}.

- R
_{S(act)}= actual sensor resistance in the LPM2610

- R
_{S(std)}= standard sensor resistance

- V
_{OUT(std)}= standard voltage output given R_{S(std) }

- R
_{L}= load resistance in series with R_{S}

#### Preliminary equations

Take a look at the LPM2610 circuit diagram above. Given the voltage divider R_{S}and R

_{L}, output voltage V

_{OUT}is given by the equation below. V

_{OUT}in this case is the actual V

_{OUT}and R

_{S}is the actual R

_{S}.

Given our definitions of standard sensor resistance and output voltage it follows that:

The LPM2610 module is calibrated at an ambient temperature of 20°C where V

_{REF}= V

_{DD}/2. As ambient temperature deviates from 20°C, V

_{REF}is adjusted by the module's thermistor. In our equations we will need to determine V

_{OUT(std)}. And so we need to adjust V

_{OUT(act)}by a certain factor. This correction factor is as follows:

####
Derivation of R_{S(std)} Equation

We need to find an equation that describes sensor resistance in terms of % LEL. Since Figaro provides no equation we need to derive it from sensor data. Fortunately, Application Note for LP Gas Detectors using TGS2610
lists R_{L}= R

_{S}for various %LEL and TGS2610 ID numbers (ID# corresponds to specific sensor resistances). For example the Figaro LPM2610 modules that I got have sensors with ID#15. From the AN here are its characteristics:

% LEL | R_{S(std)} in ohms |
---|---|

5 | 3830 |

10 | 2740 |

15 | 2260 |

20 | 2000 |

To transform that table of data into a formula we perform regression analysis. If we plot the above we end up with a nonlinear curve, one which shows the characteristics of a power law curve where y = ax

^{b}. Unfortunately, the spreadsheet I'm using can only do linear regression. Fortunately, we can work around this limitation. If we plot the values in the above table on a log-log paper (where x and y axes are graduated in a logarithmic scale), we get a nearly straight line and not a curve. Therefore, we can take the log(x) and log(y) and plug those in the linear regression equations. Solving for the log of both x and y, i.e., of %LEL and R

_{S(std)}, we obtain the following:

log(%LEL) | log(R_{S(std)}) |
---|---|

0.698970004336019 | 3.58319877396862 |

1 | 3.43775056282039 |

1.17609125905568 | 3.3541084391474 |

1.30102999566398 | 3.30102999566398 |

We let the spreadsheet perform a linear regression using the above logarithmic data and it magically spews out the following:

b = x coefficient = -0.471269891979091

c = constant = 3.91103846203761

r squared = 0.999483957661255

r

^{2}is the square of the correlation coefficient. Since it's practically = 1 it implies that the correlation between data and the equation is extremely high. Keeping in mind that we had used the logarithms of x and y, the regression equation is:

log(y) = b*log(x) + c

Here's a plot of both the datasheet values (red points) and computed line using an online linear regression calculator:

Taking the antilog of both sides of the equation above gives us:

y = 10

^{[b*log(x) + c]}

Table below shows the computed R

_{S(std)}and the %error from values given in the datasheet.

% LEL | R_{S(std)} in ohms |
error in % |
---|---|---|

5 | 3816 | -0.36 |

10 | 2753 | 0.47 |

15 | 2274 | 0.62 |

20 | 1986 | -0.72 |

Recall that I performed a linear regression because my spreadsheet does not have the capability of doing a power regression. However, there are various online resources that we can use, obviating the need to get the logarithms of x and y. Plugging the data from the very first table above into a power regression calculator gives us the following results:

a = 8147.7643914991

b = -0.471269892

correlation coefficient = 0.9998059883

So the power equation is

y = 8147.7643914991x

^{-0.471269892}

Now, since both the linear and power equations yield the same y we can equate the two:

ax

^{b}= 10

^{[b*log(x) + c]}

Taking the log of both sides we obtain:

log(a) + b*log(x) = b*log(x) + c

log(a) = c

Indeed, if we take the log of 8147.76 we get 3.911

Bear in mind that the above equations apply only to TGS2610 ID#15. Nevertheless, upon subjecting ID#10 and #20 to power regression and computing for V

_{OUT(std)}as a percentage of V

_{DD}I obtained results which confirmed the guess that they'd all show practically the same characteristic voltage outputs given their respective voltage divider resistor values. Click the "Vout as %Vdd" tab at the bottom of the following spreadsheet to see the computed values. Take a look at the columns with blue headers. The percentages for each of the three ID# are practically the same for every %LEL.

### Determining % LEL

There's at least two ways--when using a microcontroller--to determine the % LEL: direct computation and use of a look-up table.

#### I. Direct Computation

The direct way is to derive a formula which the microcontroller can use to calculate the amount of gas detected (as % LEL).Given the voltage divider in the TGS2610 sensor and from our definition of standard values we infer that:

From the above power regression we have:

Therefore:

Given V

_{OUT(act)}we can obtain V

_{OUT(std)}by applying the corrective factor:

Rearranging the terms, substituting and solving for x:

R

_{L}is a constant and will be contingent upon the particular TGS2610 unit being used (its ID# will determine what R

_{L}will be).

#### II. Look-up Table

The other method--which is less CPU intensive--would be to compare the standardized V_{OUT}as a fraction of V

_{DD}with the values in a look-up table to determine % LEL (eg., to the nearest %). The look-up table is populated with values computed using the following formula, where x = %LEL and

*a*and

*b*derived from power regression:

As we already obtained in the direct computation method:

We then divide V

_{OUT(std)}by V

_{DD}to obtain a unitless fraction:

So all the MCU has to do is evaluate the relatively simply equation on the right and then look for the closest value in the table to determine %LEL.

## No comments:

## Post a Comment