Non-linear functions ...

Hi all,

I'm currently working with a mass air flow sensor (a Honeywell AWM3100V, see

formatting link
and I would like to convert the rather non-linear response curve of this device into a voltage which bears a linear relationship to the actual air flow. Ideally, I would like to see the air flow converted in millivolts, so that it can be fed into a 3.5 digit voltmeter directly.

These are the values (F=flow): F (ccm) Vout (V)

0 1.00 25 1.90 50 2.67 75 3.27 100 3.75 125 4.17 150 4.50 175 4.80 200 5.00

The first problem was simple: finding a suitable mathematical function which fits the curve; I looked at something along the lines of Vout=c1*(1-e^(-F/c2))+1, and it turns out that c1=5 and c2=125 provides a near-perfect fit. The second problem was to find an inverse function -- no problem there either: F=-c2*ln(1-(Vout-1)/c1) -- leading to the third and rather trickier problem, which of course is to implement that inverse function in an actual circuit.

I've been doing some trial-and-error experimenting with a simple circuit, based on a simple Si-diode with some bypass and series resistors in several configurations, but that doesn't produce satisfactory results -- the best curve I get is easily 10% off at the extremes, and that's even without temperature instability. All this is of course no surprise, as the exponential function of a forward-biased diode is something different than a logarithmic function, and a simple PN junction has a temperature coefficient of approximately 2 mV per degree Celsius.

Does anyone know of designs which provide a better fit for this type of logarithmic function, and preferably a better temperature stability?

Thanks in advance, best regards,

Richard Rasker

--
http://www.linetec.nl
Reply to
Richard Rasker
Loading thread data ...

.-----. .----. .-----. | | | | | | problem o---->| ADC |----->| uP |----->| DAC |-----> answer | | | | | | '-----' '----' '-----'

--
www.wescottdesign.com
Reply to
Tim Wescott

Or a piece-wise linear circuit using lots of diodes and op-amps -- but a microprocessor-based solution is smaller and probably more accurate.

--
www.wescottdesign.com
Reply to
Tim Wescott

I'll second that. Being an analog guy this was hard to write but we've got to know when to fold'em.

The MSP430F2003 has the ADC part built in. Somehow DVM tells me it's slow so you could get by with the el-cheapo MSP430F2001 or an even cheaper PIC. The MSP can work sans crystal. Program it to do dual slope conversion for the ADC and PWM the output, then RC filter that. The math goes in between where the code is :-)

Piecewise linear can be ok but with diodes it's temperature-sensitive and with comparators it's expensive.

--
Regards, Joerg

http://www.analogconsultants.com/

"gmail" domain blocked because of excessive spam.
Use another domain or send PM.
Reply to
Joerg

see

formatting link
a= nd

ce

t

ich

ides a

o

nd

al

n

A few side questions: how do those voltages look when performed at different ambient temperatures, and at different elevations (air pressures)? You might have a few more equations to play with in those cases...

Michael

Reply to
Michael

You were looking for an inverse function of something with an offset built into it. Sometimes, it helps to first subtract the offset (the

1V) before feeding it to an inverse function to linearize. That was my first thought. Second, was to wonder if you might instead focus on a function block that replicates the exponential behavior of the sensor but is _driven_ by a linear parameter (such as time or frequency, for example) and then arrange things to adjust the linear control so that the two outputs match and then read off the control parameter value, instead. Third was to consider recommending a micro, which is a rather common approach to conditioning sensors these days.

Jon

Reply to
Jon Kirwan

I assumed that this step could be considered trivial -- in my measuring setup, I have a +1.00V reference voltage for this exact purpose.

Well, of course that would provide a limited (in time and range) solution, but I'm rather more interested in a direct transfer function without translating the nonlinearity into another domain first.

I know. But I'm one of those old school die-hards who prefers hooking up a dozen or so components to a meter in an hour or so instead of spending a multiple of that time programming a controller to do the same.

Richard Rasker

--
http://www.linetec.nl
Reply to
Richard Rasker

[snip]

Good questions. I varied the temperature of the air input to the sensor between 15 and 60 degrees Celsius, and found no significant differences. I didn't vary the air pressure, but the setup is intended for use in normal atmospheric pressure at sea level, so this latter parameter is not important. Also, the gas measured is air with only very low traces (< 100ppm) of contaminants, so I don't have to take differences in gas parameters into account.

Richard Rasker

--
http://www.linetec.nl
Reply to
Richard Rasker

see

formatting link
a= nd

ce

t

ich

ides a

o

nd

al

n

It's been awhile since I've done this, but why not simply graph flowrate vs. voltage using Excel and take a 4th-order polynomial best- fit curve?

y =3D 0.6869x^4 - 6.0407x^3 + 23.423x^2 - 10.814x - 7.138 R^2 =3D 0.9998

where y=3Dflowrate (in cc/min?) and x=3Dvoltage

Are these deviations from v acceptable?

v f v, calc

1 0 0.1 1.9 25 24.4 2.67 50 50.9 3.27 75 75.3 3.75 100 99.0 4.17 125 124.7 4.5 150 149.7 4.8 175 177.2 5 200 198.6

Regards,

Michael

Reply to
Michael

, see

formatting link
and

vice

.

hat

which

ovides a

no

and

t,

eral

st

han

Sorry, 3rd column should read (f, calc) instead of (v, calc).

M
Reply to
Michael

Definitely use a micro-- you can implement your equation (in a very straightforward manner if you use C) and/or do a polynomial fit to squeeze out the last bit of error.

For example:

Flow (ccm) = 0.6629*v^5 - 9.5389*v^4 + 53.6729*v^3 - 139.4424*v^2 +

192.9420 *v -98.3132

... which can be evaluated with only five multiplies and no transcendental operations.

You *could* go looking up how to design analog log/antilog amplifiers with matched transistors and thermistors for temperature compensation, but AFICR this is not 1980 and a suitable micro is going to be cheaper, simpler and much more stable.

Reply to
Spehro Pefhany

That's the solution to life, the universe and everything, if you have the correct coefficient.

One more advantage to this approach is that one can add an SPI/I2C output and use lots of stuff other then DVMs downstream.

--
Paul Hovnanian     mailto:Paul@Hovnanian.com
------------------------------------------------------------------
"Grant me the strength to change what I can, the ability to accept
what I can\'t, and the incapacity to tell the difference."
        -- Calvin (of Calvin and Hobbes)
Reply to
Paul Hovnanian P.E.

And way smaller.

You still get the challenge of making the innies and outies good to whatever your desired precision is -- 3-1/2 digits is about 12 bits, which is quite doable but still not something that you can just do without double-checking your work.

--
www.wescottdesign.com
Reply to
Tim Wescott

It is trivial. But I didn't see you mention it and it's hard to know what to assume, from my end. I just documented by early thoughts upon reading.

I'm worried about what appears to be an open-loop approach you are taking.

Well, I'm not going to argue with you about that. You know your situation and desires better than I do. However, ... you may find yourself buffeted by practical forces to head this way, all the same.

Jon

Reply to
Jon Kirwan

With dual-slope conversion at the input and a PWM at the output that should be quite easy. The 3-1/2 digite DVM probably doesn't read more than a few times per second anyhow.

--
Regards, Joerg

http://www.analogconsultants.com/

"gmail" domain blocked because of excessive spam.
Use another domain or send PM.
Reply to
Joerg

Combine this one:

formatting link

with some of the C code from this one:

formatting link

and you're done, in less than an hour :-)

The function is already known, or you can use a simple piecewise linear approximation with your measured values. Another idea would be to use a slightly more powerful PIC and a realtime spline interpolation:

formatting link

I guess it would fit in an PIC16F628 and even with small PICs this would be much faster than you can see the changes on your voltmeter. But I would use a 7 segment display anyway, driven by the microcontroller, or with a MAX7221, which is really nice for this, if price doesn't matter.

--
Frank Buss, fb@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
Reply to
Frank Buss

...

.-----. .-----. .-----. | | | | | | problem o---->| ADC |----->| LUT |----->| DAC |-----> answer | | | | | | '-----' '-----' '-----'

;-) Rich

Reply to
Rich Grise

On a sunny day (Wed, 25 Nov 2009 00:06:16 +0100) it happened Frank Buss wrote in :

Is not a 74HC4046 a much simpler VCO with a lot bigger range? hehe

Reply to
Jan Panteltje

Comedy gold right there!

Reply to
a7yvm109gf5d1

But the requirements were lower limit and upper limit for the voltage, which would require more parts.

BTW: The new ATtiny10, mentioned in comp.arch.embedded, is interesting for such applications, because it has some interesting PWM modes and other timer goodies, which makes it even more trivial to solve such problems.

--
Frank Buss, fb@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
Reply to
Frank Buss

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.