Maker Pro
Maker Pro

Non-linear functions ...

F

Fred Bartoli

Rich Grise a écrit :
.-----. .-----. .-----.
| | | | | |
problem o---->| ADC |----->| LUT |----->| DAC |-----> answer
| | | | | |
'-----' '-----' '-----'

.-----. .-----. .-----. .-----. .-----.
| | | OPE | | ABA | | OPE | | | slow
problem o---->| ADC |-->| RA |-->| CUS |-->| RA |-->| DAC |-->answer
| | | TOR | | | | TOR | | |
'-----' '-----' '-----' '-----' '-----'
 
K

krw

LUT best implemented with an FPGA ??

Not necessary if there's no other control to be done. As described
above all that's needed is a ROM of some description. Of course if
the ADC and DAC have some sort of funky interface (I2C and SPI are
popular) an FPGA makes the work simpler, though a uC will be cheaper.
Cheap FPGAs tend not to have much, if any, memory.
 
J

Jon Kirwan

Richard Rasker a écrit :

OK, then instead of using your log approach, one could notice the
extreme similarity between your sensor response Vout=c1*(1-e^(-F/c2))+1
and an RC step response Vout=Vo*(1-e^(-t/tau)) which only differs from
your sensor response by a 1 constant. You can easily put this to work,
without having to bother with the inherent log amp thermal problems, and
use feedback to recover the flow value...


R C RC = C2
___ ||
-1 >----. C1 >--|___|--+--||---.
| | || |
.---. | ===
Vout >--| + |---. .--------+ GND
'---' | | |
.-----. |
\+ -/ +-||
comparator \ / ->||
V +-||---.
| | |
| === |
.--o--. GND |
GND -|D S Q|-------------'
| |
Clk >---|> -| ___
| R Q|---|___|--+-----> Flow
'--o--' |
---
---
|
===
GND


Note that this will be a sampled system, so you have to adapt the clock
frequency to your wanted frequency bandwidth.

Yes, I was imagining the RC response when I'd earlier responded. And
this approach, though not so cleanly.

Jon
 
S

Spehro Pefhany

LUT best implemented with an FPGA ??

...Jim Thompson

If speed isn't important, a micro is cheaper, will use less power, and
will be pretty much self-contained (maybe just an external bypass
capacitor). ROM in a FPGA uses a lot of internal resources. But if you
need the answer FAST it might be the answer.
 
T

Tim Williams

Fred Bartoli said:
.-----. .-----. .-----. .-----. .-----.
| | | OPE | | ABA | | OPE | | | slow
problem o---->| ADC |-->| RA |-->| CUS |-->| RA |-->| DAC |-->answer
| | | TOR | | | | TOR | | |
'-----' '-----' '-----' '-----' '-----'

problem o----

.--------------------. .--------------------.
| | | |
| 10 kilomonkeys |--->| 10 kilotypewriters |---> answer
| | | | (eventually)
'--------------------' '--------------------'

Tim
 
S

Spehro Pefhany

Hmmm, even simpler...
You could use the 555 with an external mos switch with it's source
shifted, say 1V (guess why) and omit the constant subtraction from your
Vout input.


R C RC = C2
___ ||
C1 >--|___|--+--||---.
| || |
| ===
Vout >----------. .--------+ GND
| | |
.-----. |
\+ -/ +-||
comparator \ / ->||
V +-||---.
| | |
| +1V |
.--o--. |
GND -|D S Q|-------------'
| |
Clk >---|> -| ___
| R Q|---|___|--+-----> Flow
'--o--' |
---

Very nice, Fred!

These should be very close to practical values:

24K9 10n
___ ||
6.02V >--|___|--+--||---.
| || |
| ===
Vout >---------. .--------+ GND
| | |
.-----. |
\+ -/ +-||
comparator \ / ->||
V +-||---.
| | |
| 1V |
.--o--. |
GND -|D S Q|-------------'
| |
100Hz Clk >---|> -| ___
| R Q|---|___|--+-----> Flow
'--o--' | 200mV full scale
 
T

Tim Williams

Bill Sloman said:
In a related circuit I used a thick film platinum resistance sensor to
compensate for the change in the therma voltage - kT/h which is
proportional to absolute temperature and about 26mV at 300C (room
temperature).

Er, KbT/q is volts. And it's 300K. Lead melts at 300C.

Just how long have you been unemployed, Bill? Ordinarily you're just a
sourpuss, but when you start reporting incorrect facts, you're actively
sabotaging things.

Tim
 
P

Przemek Klosowski

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.

A second degree polynomial fit is not too bad either.

V = -7.6087e-05*F^2 + 3.4724e-02 *F + 1.0566

BTW, your c1/c2 didn't work for me; shouldn't it be
128,125 rather than 5,125?
 
F

Fred Bartoli

Spehro Pefhany a écrit :
Very nice, Fred!

These should be very close to practical values:

24K9 10n
___ ||
6.02V >--|___|--+--||---.
| || |
| ===
Vout >---------. .--------+ GND
| | |
.-----. |
\+ -/ +-||
comparator \ / ->||
V +-||---.
| | |
| 1V |
.--o--. |
GND -|D S Q|-------------'
| |
100Hz Clk >---|> -| ___
| R Q|---|___|--+-----> Flow
'--o--' | 200mV full scale
---

Thanks for calculating the values I was to lazy to compute.

Now I can reveal the whole world the last simplification bit (ahem) :
that is, if you make sure the duty cycle is far enough from 100%, which
sure would be with a 100Hz clock, then you can just delete the 1V
reference and make it a simple resistor (with a small bypass cap) so
that the 6.02V reference with the 24K9/Rsource divider just gives you
the wanted 1V at the capacitor top.
Adjust the source bypass cap to optimize the circuit behavior WRT the
mosfet charges. A value from the low tens of pF to maybe 1nF.

Also, please applause the effort I made in disclosing the resistor's
secret value (just had a cup of coffee :).

That would be:
24K9 10n
___ ||
6.02V >--|___|--+--||---.
| || |
| ===
Vout >---------. .--------+ GND
| | |
.-----. |
\+ -/ +-||
comparator \ / ->|| optim.
V +-||---. .---||-----.

| | | | ___ |
| '--------+--|___|---+

.--o--. | 4K96 |
GND -|D S Q|-------------' ===
| | GND
100Hz Clk >---|> -| ___
| R Q|---|___|--+-----> Flow
'--o--' | 200mV full scale
 
R

Richard Rasker

Fred Bartoli said:
Spehro Pefhany a écrit :

[snip great, simple antilog circuit]
Thanks for calculating the values I was to lazy to compute.

Now I can reveal the whole world the last simplification bit (ahem) :
that is, if you make sure the duty cycle is far enough from 100%, which
sure would be with a 100Hz clock, then you can just delete the 1V
reference and make it a simple resistor (with a small bypass cap) so
that the 6.02V reference with the 24K9/Rsource divider just gives you
the wanted 1V at the capacitor top.
Adjust the source bypass cap to optimize the circuit behavior WRT the
mosfet charges. A value from the low tens of pF to maybe 1nF.

Also, please applause the effort I made in disclosing the resistor's
secret value (just had a cup of coffee :).

That would be:
24K9 10n
___ ||
6.02V >--|___|--+--||---.
| || |
| ===
Vout >---------. .--------+ GND
| | |
.-----. |
\+ -/ +-||
comparator \ / ->|| optim.
V +-||---. .---||-----.

| | | | ___ |
| '--------+--|___|---+

.--o--. | 4K96 |
GND -|D S Q|-------------' ===
| | GND
100Hz Clk >---|> -| ___
| R Q|---|___|--+-----> Flow
'--o--' | 200mV full scale
---


Absolutely wonderful, I'm truly amazed how even elegant, simple circuits can
often be optimized and refined even further!
Now talking about optimization: from this design, it would appear that one
could swap the MOSFET and 4K96 resistor -- which would mean that the
internal discharge FET (using an ICM7555) can be used, doing away with an
external MOSFET altogether.

I'll build this beastie tomorrow, and I'm sure to let you know how it turns
out!

Thanks once again, best regards,

Richard Rasker
 
R

Richard Rasker

Przemek said:
A second degree polynomial fit is not too bad either.

V = -7.6087e-05*F^2 + 3.4724e-02 *F + 1.0566

BTW, your c1/c2 didn't work for me; shouldn't it be
128,125 rather than 5,125?

I think you made a miscalculation then, or misinterpreted the formula; the
sensor's Vout exhibits an e-power curve which asymptotically approaches
+6 volts, which means that c1 must be 5. An example with F=75ccm:
Vout = 5(1-e^(-75/125))+1 ~= 5(1-0.55)+1 = 5*0.45+1 = 3.25V

Richard Rasker
 
F

Fred Bartoli

Richard Rasker a écrit :
Fred Bartoli said:
Spehro Pefhany a écrit :

[snip great, simple antilog circuit]
Thanks for calculating the values I was to lazy to compute.

Now I can reveal the whole world the last simplification bit (ahem) :
that is, if you make sure the duty cycle is far enough from 100%, which
sure would be with a 100Hz clock, then you can just delete the 1V
reference and make it a simple resistor (with a small bypass cap) so
that the 6.02V reference with the 24K9/Rsource divider just gives you
the wanted 1V at the capacitor top.
Adjust the source bypass cap to optimize the circuit behavior WRT the
mosfet charges. A value from the low tens of pF to maybe 1nF.

Also, please applause the effort I made in disclosing the resistor's
secret value (just had a cup of coffee :).

That would be:
24K9 10n
___ ||
6.02V >--|___|--+--||---.
| || |
| ===
Vout >---------. .--------+ GND
| | |
.-----. |
\+ -/ +-||
comparator \ / ->|| optim.
V +-||---. .---||-----.

| | | | ___ |
| '--------+--|___|---+

.--o--. | 4K96 |
GND -|D S Q|-------------' ===
| | GND
100Hz Clk >---|> -| ___
| R Q|---|___|--+-----> Flow
'--o--' | 200mV full scale
---


Absolutely wonderful, I'm truly amazed how even elegant, simple circuits can
often be optimized and refined even further!
Now talking about optimization: from this design, it would appear that one
could swap the MOSFET and 4K96 resistor -- which would mean that the
internal discharge FET (using an ICM7555) can be used, doing away with an
external MOSFET altogether.

Of course you're absolutely right (I guess one cup of coffee wasn't
enough this morning).
Now you've really squizzed the last remaining bit of optimization out of
this.
 
U

Uwe Hercksen

Rich said:
.-----. .-----. .-----.
| | | | | |
problem o---->| ADC |----->| LUT |----->| DAC |-----> answer
| | | | | |
'-----' '-----' '-----'

Hello,

works well for 8 bit ADCs, also for 10 or 12 bits. With large EPROMs
also for 14 or 16 bits.

Bye
 
K

krw

Hello,

works well for 8 bit ADCs, also for 10 or 12 bits. With large EPROMs
also for 14 or 16 bits.

These days it works for any A/D or D/A you can find.
 
N

Nico Coesel

Richard Rasker said:
Hi all,

I'm currently working with a mass air flow sensor (a Honeywell AWM3100V, see
http://datasheet.octopart.com/AWM3100V-Honeywell-datasheet-57019.pdf), 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 use Excel for that purpose. If you choose an X-Y graph you can
choose to show a math approximation.
 
F

Fred Bartoli

Fred Bartoli a écrit :
Richard Rasker a écrit :
Fred Bartoli said:
Spehro Pefhany a écrit :
On Wed, 25 Nov 2009 16:10:31 +0100, Fred Bartoli <" "> wrote:

Hmmm, even simpler...

[snip great, simple antilog circuit]
Thanks for calculating the values I was to lazy to compute.

Now I can reveal the whole world the last simplification bit (ahem) :
that is, if you make sure the duty cycle is far enough from 100%, which
sure would be with a 100Hz clock, then you can just delete the 1V
reference and make it a simple resistor (with a small bypass cap) so
that the 6.02V reference with the 24K9/Rsource divider just gives you
the wanted 1V at the capacitor top.
Adjust the source bypass cap to optimize the circuit behavior WRT the
mosfet charges. A value from the low tens of pF to maybe 1nF.

Also, please applause the effort I made in disclosing the resistor's
secret value (just had a cup of coffee :).

That would be:
24K9 10n
___ ||
6.02V >--|___|--+--||---.
| || |
| ===
Vout >---------. .--------+ GND
| | |
.-----. |
\+ -/ +-||
comparator \ / ->|| optim.
V +-||---. .---||-----.

| | | | ___ |
| '--------+--|___|---+

.--o--. | 4K96 |
GND -|D S Q|-------------' ===
| | GND
100Hz Clk >---|> -| ___
| R Q|---|___|--+-----> Flow
'--o--' | 200mV full scale
---


Absolutely wonderful, I'm truly amazed how even elegant, simple
circuits can
often be optimized and refined even further!
Now talking about optimization: from this design, it would appear that
one
could swap the MOSFET and 4K96 resistor -- which would mean that the
internal discharge FET (using an ICM7555) can be used, doing away with an
external MOSFET altogether.

Of course you're absolutely right (I guess one cup of coffee wasn't
enough this morning).
Now you've really squizzed the last remaining bit of optimization out of
this.

Argh... And also don't forget to shift the 6.02V by one volt too and
make it 7.02V, which makes the resistor's secret value 4K14
 
S

Spehro Pefhany

I use Excel for that purpose. If you choose an X-Y graph you can
choose to show a math approximation.

Matlab etc. (if you have it) or Excel can help with this kind of
design. I took the solution to the diffeq for capacitor charging from
an intial voltage

v(t) = Vf * (1- exp(-(t-a)/tau))

and fit that to the data points to find a, Vf so as to minimize the
sum of errors squared from each data point.

With Excel 2003+ I think solver is not loaded by default, just a less
powerful function that will only change a single variable.
 
S

Spehro Pefhany

Fred Bartoli a écrit :
Richard Rasker a écrit :
Fred Bartoli <" "> wrote:

Spehro Pefhany a écrit :
On Wed, 25 Nov 2009 16:10:31 +0100, Fred Bartoli <" "> wrote:

Hmmm, even simpler...

[snip great, simple antilog circuit]

Thanks for calculating the values I was to lazy to compute.

Now I can reveal the whole world the last simplification bit (ahem) :
that is, if you make sure the duty cycle is far enough from 100%, which
sure would be with a 100Hz clock, then you can just delete the 1V
reference and make it a simple resistor (with a small bypass cap) so
that the 6.02V reference with the 24K9/Rsource divider just gives you
the wanted 1V at the capacitor top.
Adjust the source bypass cap to optimize the circuit behavior WRT the
mosfet charges. A value from the low tens of pF to maybe 1nF.

Also, please applause the effort I made in disclosing the resistor's
secret value (just had a cup of coffee :).

That would be:
24K9 10n
___ ||
6.02V >--|___|--+--||---.
| || |
| ===
Vout >---------. .--------+ GND
| | |
.-----. |
\+ -/ +-||
comparator \ / ->|| optim.
V +-||---. .---||-----.

| | | | ___ |
| '--------+--|___|---+

.--o--. | 4K96 |
GND -|D S Q|-------------' ===
| | GND
100Hz Clk >---|> -| ___
| R Q|---|___|--+-----> Flow
'--o--' | 200mV full scale
---
---
|
===
GND



Absolutely wonderful, I'm truly amazed how even elegant, simple
circuits can
often be optimized and refined even further!
Now talking about optimization: from this design, it would appear that
one
could swap the MOSFET and 4K96 resistor -- which would mean that the
internal discharge FET (using an ICM7555) can be used, doing away with an
external MOSFET altogether.

Of course you're absolutely right (I guess one cup of coffee wasn't
enough this morning).
Now you've really squizzed the last remaining bit of optimization out of
this.

Argh... And also don't forget to shift the 6.02V by one volt too and
make it 7.02V, which makes the resistor's secret value 4K14

It might be worth dividing down the input voltage to allow the 6.02V
reference to be the same as the output reference (eg. FF power supply)
which I assumed to be 5.00V). Then a series 5V 0.1% reference like the
ADR395 could be used and a 1% NP0 cap. Stray capacitance would require
a bit of fiddling to compensate for, but it should be pretty darn
stable.
 
R

Richard Rasker

Fred Bartoli said:
Fred Bartoli a écrit :
Richard Rasker a écrit :
Fred Bartoli <" "> wrote:

Spehro Pefhany a écrit :
On Wed, 25 Nov 2009 16:10:31 +0100, Fred Bartoli <" "> wrote:

Hmmm, even simpler...

[snip great, simple antilog circuit]

[snip schematic]
Argh... And also don't forget to shift the 6.02V by one volt too and
make it 7.02V, which makes the resistor's secret value 4K14

OK, I've been doing some experimenting, and the 555 (or ICM7555) isn't
suitable after all. The Vcontrol range doesn't extend down to 1V, and the
flip-flop is set directly, instead of being edge-triggered (which would
require a clock pulse with a shorter duration than the output pulse).

So I'd still have to use a separate D-flip-flop, comparator and clock pulse
generator, requiring at least two separate devices.

But as it turns out, there is a solution with just one comparator or opamp:

o +10.0V
|
| ________
| | flow |
|--| sensor |--.
| |________| |
R1| | | | |10K
| | === | |
| gnd | |\
.-----+-------------(---|-\ ___
| | | | | >--|___|-----> Vout
R3| | R2| | ---C |--|+/ 100K |
| | | | --- | |/ ---1uF
| | | | ---
| === === | |
||--' gnd gnd ||--' ===
||<-. ||<-. gnd
.--||--|Q1 .--||--|Q2
| | | |
| === | ===
| gnd | gnd
-----------------------'
clock
__ __
_| |__| |__


This works fine; the only requirement here is that the clock signal has a
longer duty cycle than the maximum output pulse width.
The clock signal itself can be RC-generated, using a second comparator/opamp
and an identical capacitor to C, which may further diminish any temperature
drift.

Richard Rasker
 
Top