Interpolation
>I want to do the following
> ADRPM/520 * X
>where adrpm is 300 to 1100 and x a vule from
>1 to 120.
>The stamp does not seem to like fractions.
result=ADRPM**12603*X
gives the result to two decimal places. For example, if ADRPM=1100 and
X=120, then result=25384. While on a calculator the result is
1100/520*120=253.85.
To round off to integer:
result=(ADRPM**12603*X+50)/100
For more explanation on fractions in the Stamp, visit:
http://www.emesystems.com/BS2math1.htm
best regards,
-- Tracy Allen
http://www.emesystems.com
> ADRPM/520 * X
>where adrpm is 300 to 1100 and x a vule from
>1 to 120.
>The stamp does not seem to like fractions.
result=ADRPM**12603*X
gives the result to two decimal places. For example, if ADRPM=1100 and
X=120, then result=25384. While on a calculator the result is
1100/520*120=253.85.
To round off to integer:
result=(ADRPM**12603*X+50)/100
For more explanation on fractions in the Stamp, visit:
http://www.emesystems.com/BS2math1.htm
best regards,
-- Tracy Allen
http://www.emesystems.com
Comments
I want to do the following
ADRPM/520 * X
where adrpm is 300 to 1100 and x a vule from
1 to 120.
The stamp does not seem to like fractions.
What can I do.
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
Share information about yourself, create your own public profile at
http://profiles.msn.com.
You the HTML page seems to complicate the issue.
A liitle bit of reading should clear it up.
I have built a Fuel Injector controller for a Turbocharged.
It reads engine RPM and Boost and lookup a fuel table to decide
how long the injectors should stay open. The firing of the injector
is sychronized with the induction strokes. The duration of the injector
can therefore be changed by changing values in the fuel map.
There is a fuel table for each 1000rpm. The tabe has eight entries
representing pressure from 1psi to 8psi. The entries in the table
represent pulse widths. These are fed to the 8254 interval timer.
Interpolation is required when the engine speed is between the RPM values
for example 2500rpm. The pulse value retrieved from the table
should be portion of the actual value. E.g 2500/3000 * Pulsval.
My next step would be to change the fuel map using a hand held
device with a LCD Display. is this possible?
>From: Tracy Allen <emesys@c...>
>Reply-To: basicstamps@egroups.com
>To: "INTERNET:basicstamps@egroups.com" <basicstamps@egroups.com>
>Subject: Re: [noparse][[/noparse]basicstamps] Re: Interpolation
>Date: Mon, 11 Sep 2000 18:27:39 -0400
>
> >I want to do the following
> > ADRPM/520 * X
> >where adrpm is 300 to 1100 and x a vule from
> >1 to 120.
> >The stamp does not seem to like fractions.
>
> result=ADRPM**12603*X
>gives the result to two decimal places. For example, if ADRPM=1100 and
>X=120, then result=25384. While on a calculator the result is
>1100/520*120=253.85.
>
>To round off to integer:
> result=(ADRPM**12603*X+50)/100
>
>For more explanation on fractions in the Stamp, visit:
>
> http://www.emesystems.com/BS2math1.htm
>
> best regards,
> -- Tracy Allen
> http://www.emesystems.com
>
>
>
>
>
>
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
Share information about yourself, create your own public profile at
http://profiles.msn.com.
>representing pressure from 1psi to 8psi. The entries in the table
>represent pulse widths. These are fed to the 8254 interval timer.
>Interpolation is required when the engine speed is between the RPM values
>for example 2500rpm. The pulse value retrieved from the table
>should be portion of the actual value. E.g 2500/3000 * Pulsval.
Hi Fernando,
I do not quite picture this table. It sounds like injection pulse width
depends on both pressure and rpm--two independent variables and one
dependent variable?
There is an example of interpolation on the Stamp at:
http://www.emesystems.com/BS2math3.htm#tables and interpolation
-- Tracy Allen
Electronically Monitored Ecosystems
http://www.emesystems.com
Fuel Injected is dependent on Boost and RPM.
LOOKDOWN ADpsi,<=[noparse][[/noparse]1280,1354,1438,1522,1606,1690,1774,2400],psiidx
' debug "psiidx ",DEC psiidx,cr ' Display data.
tabled:
IF ADrpm > 550 then tablee
LOOKUP psiidx,[noparse][[/noparse]12,15,30,35,40,45,50,55],pulsval '3000rpm table
pulsval = (adrpm**11915*pulsval+50)/100
goto done
tablee:
IF ADrpm > 720 then tablef
LOOKUP psiidx,[noparse][[/noparse]15,25,35,45,55,65,75,85],pulsval '4000rpm table
pulsval = (adrpm**9102*pulsval+50)/100
goto done
>From: Tracy Allen <emesys@c...>
>Reply-To: basicstamps@egroups.com
>To: "INTERNET:basicstamps@egroups.com" <basicstamps@egroups.com>
>Subject: Re: [noparse][[/noparse]basicstamps] Re: Interpolation
>Date: Wed, 13 Sep 2000 12:06:26 -0400
>
> >There is a fuel table for each 1000rpm. The tabe has eight entries
> >representing pressure from 1psi to 8psi. The entries in the table
> >represent pulse widths. These are fed to the 8254 interval timer.
>
> >Interpolation is required when the engine speed is between the RPM values
> >for example 2500rpm. The pulse value retrieved from the table
> >should be portion of the actual value. E.g 2500/3000 * Pulsval.
>
>Hi Fernando,
>
>I do not quite picture this table. It sounds like injection pulse width
>depends on both pressure and rpm--two independent variables and one
>dependent variable?
>
>There is an example of interpolation on the Stamp at:
> http://www.emesystems.com/BS2math3.htm#tables and interpolation
>
>
> -- Tracy Allen
> Electronically Monitored Ecosystems
> http://www.emesystems.com
>
>
>
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
Share information about yourself, create your own public profile at
http://profiles.msn.com.
>Fuel Injected is dependent on Boost and RPM.
>
> LOOKDOWN ADpsi,<=[noparse][[/noparse]1280,1354,1438,1522,1606,1690,1774,2400],psiidx
> ' debug "psiidx ",DEC psiidx,cr ' Display data.
> tabled:
> IF ADrpm > 550 then tablee
> LOOKUP psiidx,[noparse][[/noparse]12,15,30,35,40,45,50,55],pulsval
'3000rpm table
> pulsval = (adrpm**11915*pulsval+50)/100
> goto done
> tablee:
> IF ADrpm > 720 then tablef
> LOOKUP psiidx,[noparse][[/noparse]15,25,35,45,55,65,75,85],pulsval '4000rpm
table
> pulsval = (adrpm**9102*pulsval+50)/100
> goto done
I think for it to be interpolation, the end points should match up. For
example, say psiidx=6, in "tablee" with 550<ADrpm<720. Plug ADrpm=550 into
the tablee formula:
by calculator: 550/720*75=57
by stamp math: 550**9102*75+50/100=57
But instead of =57, shouldn't it to come out =50, which is the psiidx=6
value from "tabled"?
It seems to me that a proper linear interpolation formula is:
(this example for tablee, with psiidx=6)
by calculator: pulsval = (ADrpm-550)/(720-550)*(75-50)+50
This interpolates pulseval from 50 to 75, as ADrpm goes from 550 to 720.
The formula needs the two rpm values that bracket the range in which the
current ADrpm falls, and the corresponding two pulsevals.
Maybe the algorithm should also account for two ADpsi values, the ones that
bracket the current ADpsi reading. Interpolate on both ADrpm and ADpsi?
Geometrically the pulsvals represent a surface above the ADrpm,ADpsi plane.
The following is an alternative program fragment. The pulse values are
entered in contiguous DATA statements to set up a calculated READ: You
mentioned in an earlier message that you might want to change these values
on the fly using a hand-held LCD terminal of some sort. Having the values
in DATA statements makes that a lot more feasible. You cannot monkey with
the values in a LOOKUP or LOOKDOWN command on the fly. The boost and rpm
values might also have to be in DATA statements, if you want to change
those on the fly too. It appears that the numbers (differences) in the
interpolation formula will be small enough to avoid special math tricks,
except multiply before divide. This is just interpolation on ADrpm.
tablea data ...
...
tabled data 12,15,30,35,40,45,50,55
tablee data 15,25,35,45,55,65,75,85
tablef data .....
LOOKDOWN ADpsi,<=[noparse][[/noparse]1280,1354,1438,1522,1606,1690,1774,2400],psiidx
LOOKDOWN ADrpm,<[noparse][[/noparse]0,..,....,550,720,..],rpmidx ' minimum value 1
LOOKUP rpmidx-1,[noparse][[/noparse]0,..,....,550,720,..],rpm0
LOOKUP rpmidx,[noparse][[/noparse]0,..,....,550,720,..],rpm1
READ tablea+(rpmidx-1*8)+psiidx,pulseval0
READ tablea+(rpmidx*8)+psiidx,pulseval1
pulseval=(ADrpm-rpm0)*(pulseval1-pulseval0)/(rpm1-rpm0)+pulseval0
goto done
regards,
-- Tracy Allen
Electronically Monitored Ecosystems
http://www.emesystems.com/BS2math3.htm <--- more interpolation stuff
your repsonse. Please bear with me.
>From: Tracy Allen <emesys@c...>
>Reply-To: basicstamps@egroups.com
>To: "INTERNET:basicstamps@egroups.com" <basicstamps@egroups.com>
>Subject: Re: [noparse][[/noparse]basicstamps] Re: Interpolation
>Date: Thu, 14 Sep 2000 11:41:55 -0400
>
> >Here is a sample of the program. You can see where I embeded your code.
> >Fuel Injected is dependent on Boost and RPM.
> >
> > LOOKDOWN ADpsi,<=[noparse][[/noparse]1280,1354,1438,1522,1606,1690,1774,2400],psiidx
> > ' debug "psiidx ",DEC psiidx,cr ' Display data.
> > tabled:
> > IF ADrpm > 550 then tablee
> > LOOKUP psiidx,[noparse][[/noparse]12,15,30,35,40,45,50,55],pulsval
>'3000rpm table
> > pulsval = (adrpm**11915*pulsval+50)/100
> > goto done
> > tablee:
> > IF ADrpm > 720 then tablef
> > LOOKUP psiidx,[noparse][[/noparse]15,25,35,45,55,65,75,85],pulsval '4000rpm
>table
> > pulsval = (adrpm**9102*pulsval+50)/100
> > goto done
>
>I think for it to be interpolation, the end points should match up. For
>example, say psiidx=6, in "tablee" with 550<ADrpm<720. Plug ADrpm=550 into
>the tablee formula:
> by calculator: 550/720*75=57
> by stamp math: 550**9102*75+50/100=57
>But instead of =57, shouldn't it to come out =50, which is the psiidx=6
>value from "tabled"?
>
>It seems to me that a proper linear interpolation formula is:
> (this example for tablee, with psiidx=6)
>
> by calculator: pulsval = (ADrpm-550)/(720-550)*(75-50)+50
>
>This interpolates pulseval from 50 to 75, as ADrpm goes from 550 to 720.
>The formula needs the two rpm values that bracket the range in which the
>current ADrpm falls, and the corresponding two pulsevals.
>
>Maybe the algorithm should also account for two ADpsi values, the ones that
>bracket the current ADpsi reading. Interpolate on both ADrpm and ADpsi?
>Geometrically the pulsvals represent a surface above the ADrpm,ADpsi plane.
>
>The following is an alternative program fragment. The pulse values are
>entered in contiguous DATA statements to set up a calculated READ: You
>mentioned in an earlier message that you might want to change these values
>on the fly using a hand-held LCD terminal of some sort. Having the values
>in DATA statements makes that a lot more feasible. You cannot monkey with
>the values in a LOOKUP or LOOKDOWN command on the fly. The boost and rpm
>values might also have to be in DATA statements, if you want to change
>those on the fly too. It appears that the numbers (differences) in the
>interpolation formula will be small enough to avoid special math tricks,
>except multiply before divide. This is just interpolation on ADrpm.
>
> tablea data ...
> ...
> tabled data 12,15,30,35,40,45,50,55
> tablee data 15,25,35,45,55,65,75,85
> tablef data .....
> LOOKDOWN ADpsi,<=[noparse][[/noparse]1280,1354,1438,1522,1606,1690,1774,2400],psiidx
> LOOKDOWN ADrpm,<[noparse][[/noparse]0,..,....,550,720,..],rpmidx ' minimum value 1
> LOOKUP rpmidx-1,[noparse][[/noparse]0,..,....,550,720,..],rpm0
> LOOKUP rpmidx,[noparse][[/noparse]0,..,....,550,720,..],rpm1
> READ tablea+(rpmidx-1*8)+psiidx,pulseval0
> READ tablea+(rpmidx*8)+psiidx,pulseval1
> pulseval=(ADrpm-rpm0)*(pulseval1-pulseval0)/(rpm1-rpm0)+pulseval0
> goto done
>
>
>
> regards,
> -- Tracy Allen
> Electronically Monitored Ecosystems
> http://www.emesystems.com/BS2math3.htm <--- more interpolation stuff
>
>
>
>
>
>
>
>
>
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
Share information about yourself, create your own public profile at
http://profiles.msn.com.
>From: Tracy Allen <emesys@c...>
>Reply-To: basicstamps@egroups.com
>To: "INTERNET:basicstamps@egroups.com" <basicstamps@egroups.com>
>Subject: Re: [noparse][[/noparse]basicstamps] Re: Interpolation
>Date: Thu, 14 Sep 2000 11:41:55 -0400
>
> >Here is a sample of the program. You can see where I embeded your code.
> >Fuel Injected is dependent on Boost and RPM.
> >
> > LOOKDOWN ADpsi,<=[noparse][[/noparse]1280,1354,1438,1522,1606,1690,1774,2400],psiidx
> > ' debug "psiidx ",DEC psiidx,cr ' Display data.
> > tabled:
> > IF ADrpm > 550 then tablee
> > LOOKUP psiidx,[noparse][[/noparse]12,15,30,35,40,45,50,55],pulsval
>'3000rpm table
> > pulsval = (adrpm**11915*pulsval+50)/100
> > goto done
> > tablee:
> > IF ADrpm > 720 then tablef
> > LOOKUP psiidx,[noparse][[/noparse]15,25,35,45,55,65,75,85],pulsval '4000rpm
>table
> > pulsval = (adrpm**9102*pulsval+50)/100
> > goto done
>
>I think for it to be interpolation, the end points should match up. For
>example, say psiidx=6, in "tablee" with 550<ADrpm<720. Plug ADrpm=550 into
>the tablee formula:
> by calculator: 550/720*75=57
> by stamp math: 550**9102*75+50/100=57
>But instead of =57, shouldn't it to come out =50, which is the psiidx=6
>value from "tabled"?
>
>It seems to me that a proper linear interpolation formula is:
> (this example for tablee, with psiidx=6)
>
> by calculator: pulsval = (ADrpm-550)/(720-550)*(75-50)+50
>
>This interpolates pulseval from 50 to 75, as ADrpm goes from 550 to 720.
>The formula needs the two rpm values that bracket the range in which the
>current ADrpm falls, and the corresponding two pulsevals.
>
>Maybe the algorithm should also account for two ADpsi values, the ones that
>bracket the current ADpsi reading. Interpolate on both ADrpm and ADpsi?
>Geometrically the pulsvals represent a surface above the ADrpm,ADpsi plane.
>
>The following is an alternative program fragment. The pulse values are
>entered in contiguous DATA statements to set up a calculated READ: You
>mentioned in an earlier message that you might want to change these values
>on the fly using a hand-held LCD terminal of some sort. Having the values
>in DATA statements makes that a lot more feasible. You cannot monkey with
>the values in a LOOKUP or LOOKDOWN command on the fly. The boost and rpm
>values might also have to be in DATA statements, if you want to change
>those on the fly too. It appears that the numbers (differences) in the
>interpolation formula will be small enough to avoid special math tricks,
>except multiply before divide. This is just interpolation on ADrpm.
>
> tablea data ...
> ...
> tabled data 12,15,30,35,40,45,50,55
> tablee data 15,25,35,45,55,65,75,85
> tablef data .....
> LOOKDOWN ADpsi,<=[noparse][[/noparse]1280,1354,1438,1522,1606,1690,1774,2400],psiidx
> LOOKDOWN ADrpm,<[noparse][[/noparse]0,..,....,550,720,..],rpmidx ' minimum value 1
> LOOKUP rpmidx-1,[noparse][[/noparse]0,..,....,550,720,..],rpm0
> LOOKUP rpmidx,[noparse][[/noparse]0,..,....,550,720,..],rpm1
> READ tablea+(rpmidx-1*8)+psiidx,pulseval0
> READ tablea+(rpmidx*8)+psiidx,pulseval1
> pulseval=(ADrpm-rpm0)*(pulseval1-pulseval0)/(rpm1-rpm0)+pulseval0
> goto done
>
>
>
> regards,
> -- Tracy Allen
> Electronically Monitored Ecosystems
> http://www.emesystems.com/BS2math3.htm <--- more interpolation stuff
>
>
>
>
>
>
>
>
>
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
Share information about yourself, create your own public profile at
http://profiles.msn.com.
will be used.
The pulsval is indeed on another plane. In the Automive feild what I
am trying create is a 3 dimensional fuel map.
>From: Tracy Allen <emesys@c...>
>Reply-To: basicstamps@egroups.com
>To: "INTERNET:basicstamps@egroups.com" <basicstamps@egroups.com>
>Subject: Re: [noparse][[/noparse]basicstamps] Re: Interpolation
>Date: Thu, 14 Sep 2000 11:41:55 -0400
>
> >Here is a sample of the program. You can see where I embeded your code.
> >Fuel Injected is dependent on Boost and RPM.
> >
> > LOOKDOWN ADpsi,<=[noparse][[/noparse]1280,1354,1438,1522,1606,1690,1774,2400],psiidx
> > ' debug "psiidx ",DEC psiidx,cr ' Display data.
> > tabled:
> > IF ADrpm > 550 then tablee
> > LOOKUP psiidx,[noparse][[/noparse]12,15,30,35,40,45,50,55],pulsval
>'3000rpm table
> > pulsval = (adrpm**11915*pulsval+50)/100
> > goto done
> > tablee:
> > IF ADrpm > 720 then tablef
> > LOOKUP psiidx,[noparse][[/noparse]15,25,35,45,55,65,75,85],pulsval '4000rpm
>table
> > pulsval = (adrpm**9102*pulsval+50)/100
> > goto done
>
>I think for it to be interpolation, the end points should match up. For
>example, say psiidx=6, in "tablee" with 550<ADrpm<720. Plug ADrpm=550 into
>the tablee formula:
> by calculator: 550/720*75=57
> by stamp math: 550**9102*75+50/100=57
>But instead of =57, shouldn't it to come out =50, which is the psiidx=6
>value from "tabled"?
>
>It seems to me that a proper linear interpolation formula is:
> (this example for tablee, with psiidx=6)
>
> by calculator: pulsval = (ADrpm-550)/(720-550)*(75-50)+50
>
>This interpolates pulseval from 50 to 75, as ADrpm goes from 550 to 720.
>The formula needs the two rpm values that bracket the range in which the
>current ADrpm falls, and the corresponding two pulsevals.
>
>Maybe the algorithm should also account for two ADpsi values, the ones that
>bracket the current ADpsi reading. Interpolate on both ADrpm and ADpsi?
>Geometrically the pulsvals represent a surface above the ADrpm,ADpsi plane.
>
>The following is an alternative program fragment. The pulse values are
>entered in contiguous DATA statements to set up a calculated READ: You
>mentioned in an earlier message that you might want to change these values
>on the fly using a hand-held LCD terminal of some sort. Having the values
>in DATA statements makes that a lot more feasible. You cannot monkey with
>the values in a LOOKUP or LOOKDOWN command on the fly. The boost and rpm
>values might also have to be in DATA statements, if you want to change
>those on the fly too. It appears that the numbers (differences) in the
>interpolation formula will be small enough to avoid special math tricks,
>except multiply before divide. This is just interpolation on ADrpm.
>
> tablea data ...
> ...
> tabled data 12,15,30,35,40,45,50,55
> tablee data 15,25,35,45,55,65,75,85
> tablef data .....
> LOOKDOWN ADpsi,<=[noparse][[/noparse]1280,1354,1438,1522,1606,1690,1774,2400],psiidx
> LOOKDOWN ADrpm,<[noparse][[/noparse]0,..,....,550,720,..],rpmidx ' minimum value 1
> LOOKUP rpmidx-1,[noparse][[/noparse]0,..,....,550,720,..],rpm0
> LOOKUP rpmidx,[noparse][[/noparse]0,..,....,550,720,..],rpm1
> READ tablea+(rpmidx-1*8)+psiidx,pulseval0
> READ tablea+(rpmidx*8)+psiidx,pulseval1
> pulseval=(ADrpm-rpm0)*(pulseval1-pulseval0)/(rpm1-rpm0)+pulseval0
> goto done
>
>
>
> regards,
> -- Tracy Allen
> Electronically Monitored Ecosystems
> http://www.emesystems.com/BS2math3.htm <--- more interpolation stuff
>
>
>
>
>
>
>
>
>
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
Share information about yourself, create your own public profile at
http://profiles.msn.com.