2
\$\begingroup\$

I'm using this sensor AIR FLOW METER, but I see on page 11 that the 0-10 V output is not linear, how can I linearize that output?

\$\endgroup\$
  • 7
    \$\begingroup\$ Software. Or a lookup table, possibly with interpolation. It entirely depends on what you are trying to do and what your ultimate output should be, or could be if you re-consider the entire system. \$\endgroup\$ – Chris Stratton Dec 17 '18 at 19:55
  • \$\begingroup\$ Thanks, i'm just trying to calculate more precisely the air flow speed via software \$\endgroup\$ – VirtApp Dec 17 '18 at 20:34
  • 1
    \$\begingroup\$ If you're doing it in software, then make a calibration table. If you were trained as an engineer then somewhere on the back shelves of your brain should be the procedure for doing linear interpolation. So you can make a look up table with as few entries as you can get away with, and use linear interpolation to go from the measured sensor value to the actual air flow value. \$\endgroup\$ – TimWescott Dec 17 '18 at 20:45
  • \$\begingroup\$ Note to OP - The calibration table consists of pairs of numbers of sensor reading paired with actual air flow for that reading. During run time you take a sensor reading and find which pair of table entries the reading is in between. Then linear interpolate between those two points to get a corresponding air flow value. You are basically solving the straight line equation with (x1,y1) and (x2,y2) being the bounding entries in the table with x being the sensor reading and solving for y the corresponding air flow value. \$\endgroup\$ – Michael Karas Dec 17 '18 at 21:32
  • \$\begingroup\$ @MichaelKaras Or the OP can use exponential interpolation between points in the table, as well. It may be more accurate to do so than to use a piece-wise linear approach. Exponential interpolation merely assumes a multiplicative relationship throughout the range. \$\endgroup\$ – jonk Dec 17 '18 at 21:47
1
\$\begingroup\$

Let me provide more detailed information regarding piece wise linear interpolation than I was able to supply in comments beforehand.

Copy from comments:

The calibration table consists of pairs of numbers of sensor reading paired with actual air flow for that reading. During run time you take a sensor reading and find which pair of table entries the reading is in between. Then linear interpolate between those two points to get a corresponding air flow value. You are basically solving the straight line equation with (x1,y1) and (x2,y2) being the bounding entries in the table with x being the sensor reading and solving for y the corresponding air flow value.

Here is a graphic representation:

enter image description here

The blue line represents the nonlinear behavior of between an x value and a y value from some real world sensor. Calibrated data points represented by the circles are measured at particular values of X to capture the corresponding real accurate value for Y. If the CAL points lie in the right places along the non-linear curve then straight line segments between them can provide a close approximation of the actual curve. The job of the engineer is to learn enough about her sensor to be able to understand where to make CAL measurements. The more CAL points the closer to the curve you get and the less the error in the interpolated values. Two other jobs for the engineer are to to determine the acceptable level of error and to determine if a fixed table can be used across all products using a particular sensor or if each and every product needs to be calibrated and a separate table of CAL points loaded into each product.

Added Edit:

Following from the OP in comments I show how you can extract data points from the typical curve in the sensor data sheet. Do please keep in mind that the accuracy of the data sheet graph, its repeatability from unit to unit, and its variance at temperatures away from 20C is up for debate. So in absence the following example gives some sample points that could be used. In an actual linear interpolation process where some data acquisition system is reading the voltage out of the sensor the V values in the coordinates become the X values as described above. The Y interpolated values would become the values along the bottom of the graph.

enter image description here

The interpolation table could look something like this:

enter image description here

If you measured a value of voltage say 4.5V then that would fall into the range between the second and third row of the table. Then the following values would be plugged into the above equation to derive the corresponding Y airflow rate.

enter image description here

Do note that the above example is not intended to imply the optimum selection of the "sample points". It is up to the user to select the number of points to approximate the curve to the acceptable error band.

| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ The OP's datasheet has a curve that "looks" exponential in nature. Not s-shaped or otherwise spline-like. The OP admits using software in a comment (not the question, sadly.) So I think should be pretty easy to work out a curve-fit from just three points taken from the desired chart curve in order to solve for \$y=A\:e^{k\cdot x}+C\$. Using a math model closer to the underlying process can be a good way to go, at times. \$\endgroup\$ – jonk Dec 18 '18 at 3:37
  • \$\begingroup\$ @jonk - Using a curve fit solution may be realistic if there is plenty of processing power available. It is my experience however that for some system designs linear interpolation is a lot more practical, especially on low throughput 8-bit systems, even if one has to calibrate to additional data points. For well behaved sensors where curve shape stays the same but may just see an offset it is often still more efficient to use a fixed lookup table with linear interpolation after adjusting with a single CAL offset value. The key is to study the real world data and understand your device. \$\endgroup\$ – Michael Karas Dec 18 '18 at 8:57
  • \$\begingroup\$ @MichaelKaras, i can't understand how to linearize this sensor, via software, given the voltage readed from the sensor, how i can calculate the respective speed? \$\endgroup\$ – VirtApp Feb 24 '19 at 10:53
  • \$\begingroup\$ @VirtApp - Did you do some calibration? If not that is the first step. This will consist of measuring the Y results for a few X values using separate reference standard equipment. \$\endgroup\$ – Michael Karas Feb 24 '19 at 11:28
  • \$\begingroup\$ @MichaelKaras Unfortunately the sensor it has been installed some years ago and actually i can't do any kind of calibration. I mean, there is some other road to follow? \$\endgroup\$ – VirtApp Feb 24 '19 at 12:34
0
\$\begingroup\$

The easiest way (given that there is no equation given) is to extract the data from the published data sheet using software such as Webplotdigitizer then fit a curve to the data. That will get you a matrix of data.

If you have MATLAB there is a curve fit tool that let you try different equations. But for such a crude curve you could also use linear interpolation with many segments or splines. Or just do a lot of points in Webplotdigitizer and interpolate between them. You can even try using the solver in Excel if you must (it's an optional install) to minimize the absolute or least squares error. Scilab and Octave (both free) are MATLAB options but I'm not sure if they have tools that make it as easy as MATLAB.

Note that most likely the linearized value is less and less accurate as you approach a couple m/s, until it's totally meaningless. You may wish to indicate that in some way, depending on what you are doing with the linearized data. There's no point in displaying something to 3 significant digits when it might be off by 2:1.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.