How to make 3 dimensions lookup tables
Archiver
Posts: 46,084
my question is simple, i was wondering if u can make 3d tables on a
stamp 2, i want the stamp to see two different variables and through
a 3d table find the correct coresponding value, then update the 3rd
variable with what it gathers...
the application is for a eletronic fuel injecting system working off
two input variables,1. a air presure denisty sensor (MAP Sensor) on
the intake manifold. This sensor will tell the stamp if there is a
boost in presure to enrich the fuel air ratio and also define one of
the variables in table as X, used later to be one of the dimensions
in the 3d table. 2. The second sensor is the thottle postion sensor,
this 2nd variable will be the Y of the table. The thottle sensor will
tell the stamp, if the thottle is idle / wide open or inbetween. The
3rd part of the table will be the injector pulsewidth constant. This
will be what the stamp looks up from the other X Y variables , and
then output the lookedup value to a Z variable that in which the
stamp can use later , to give the correct pulsewidth for the injector
for that one engine cycle under those differenent conditions...
i would love it if someone had a simple demostration program
outlineing the X Y Z variables... , the resolution for my thottle
postion sensor is 8 step's, and the MAP sensor has a resolution of
100 step's ( in 10 step increments)...
X VAR WORD ' MAP Sensor
Y VAR WORD ' TPS Sensor
Z VAR WORD ' Pulswidth
X 0 10 20 30 40 etc...
Y
0 100 200 300 400 500
1 200 300 400 500 600
2 300 400 500 600 700 <--- these are the pulswidth constants
3 Z Z Z once the stamp finds the correct value
4 Z Z it will then update it to the
Z variable
5 Z
etc..
as u see that would be a idea of what im trying to do if u were look
at it on a sheet of paper, just i want use stamp to see the two
different sensor input variables, then lookup the corresponding
constant and output it to a defined variable in which later i can use
the pulsout command to fire my injector under the different eninge
conditions
Sean....
stamp 2, i want the stamp to see two different variables and through
a 3d table find the correct coresponding value, then update the 3rd
variable with what it gathers...
the application is for a eletronic fuel injecting system working off
two input variables,1. a air presure denisty sensor (MAP Sensor) on
the intake manifold. This sensor will tell the stamp if there is a
boost in presure to enrich the fuel air ratio and also define one of
the variables in table as X, used later to be one of the dimensions
in the 3d table. 2. The second sensor is the thottle postion sensor,
this 2nd variable will be the Y of the table. The thottle sensor will
tell the stamp, if the thottle is idle / wide open or inbetween. The
3rd part of the table will be the injector pulsewidth constant. This
will be what the stamp looks up from the other X Y variables , and
then output the lookedup value to a Z variable that in which the
stamp can use later , to give the correct pulsewidth for the injector
for that one engine cycle under those differenent conditions...
i would love it if someone had a simple demostration program
outlineing the X Y Z variables... , the resolution for my thottle
postion sensor is 8 step's, and the MAP sensor has a resolution of
100 step's ( in 10 step increments)...
X VAR WORD ' MAP Sensor
Y VAR WORD ' TPS Sensor
Z VAR WORD ' Pulswidth
X 0 10 20 30 40 etc...
Y
0 100 200 300 400 500
1 200 300 400 500 600
2 300 400 500 600 700 <--- these are the pulswidth constants
3 Z Z Z once the stamp finds the correct value
4 Z Z it will then update it to the
Z variable
5 Z
etc..
as u see that would be a idea of what im trying to do if u were look
at it on a sheet of paper, just i want use stamp to see the two
different sensor input variables, then lookup the corresponding
constant and output it to a defined variable in which later i can use
the pulsout command to fire my injector under the different eninge
conditions
Sean....
Comments
z = 10(x + 10) + 100y
regards
Adrian
Also, the BS2 doesn't have a lot of memory, so this would be a problem.
However, two things come to mind. First, you could use LOOKUP to get you
there. This stores data in program memory. Second you could use scratch pad
memory.
Here's the deal,
Let's consider a 2x2x2 cube. You could expand for larger ones. The first
plane of the cube has:
111 112
121 122
The second plane has
211 212
221 222
Yes, I know we could get to these with a formula, but I just want something
that is easy to follow.
X var byte
Y var byte
Z var byte
Result var byte
X=0
Y=1
Z=0
Gosub Lookupxyz
Debug ?result
End
Lookupxyz:
BRANCH z,[noparse][[/noparse]z0,z1] ' keep in mind that z ranges from 0 to 1
Z0: BRANCH y,[noparse][[/noparse]y00,y01] ' ditto for y
Z1: BRANCH y,[noparse][[/noparse]y10,y11]
Y00: LOOKUP x,[noparse][[/noparse]111,112],result
Return
Y01: LOOKUP x,[noparse][[/noparse]121,122],result
Return
Y02: LOOKUP x,[noparse][[/noparse]211,212],result
Return
Y03: LOOKUP x,[noparse][[/noparse]221,222],result
Return
I didn't test this, so maybe some typos, but you get the idea.
2) The general formula for a matrix like this is to say:
index=z*xmax*ymax+y*xmax+x
So in our example above, xmax=2 and ymax=2 So:
X Y Z INDEX
0 0 0 0
1 0 0 1
0 1 0 2
1 1 0 3
0 0 1 4
1 0 1 5
0 1 1 6
1 1 1 7
(of course, this is more interesting if xmax <> ymax <> 2)
You could use this with GET or READ in a BS2P, for example.
Xmax con 2
Ymax con 2
Zmax con 2
X var byte
Y var byte
Z var byte
Result var byte
Index var byte
. . .
index= z*xmax*ymax+y*xmax+x
GET index,result ' or PUT if you want to write
If you want words, you might want something like:
Index=(z*xmax*ymax+y*xmax+x)*2
GET index,result.lowbyte
GET index,result.highbyte
Hope that helps.
Al Williams
AWC
* Floating point math for the Stamp or any micro:
http://www.al-williams.com/pak1.htm
>
Original Message
> From: djrevolution99 [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=RPMb1IgPKBPYMw3-u8WlJFHNMbUZfugy470NNuaAQ6zEfEFL2V1Xrh1dbG7TI_D4t2wG1YVLhilTOfcI749kVQfB]djrevolution99@y...[/url
> Sent: Tuesday, November 18, 2003 2:10 AM
> To: basicstamps@yahoogroups.com
> Subject: [noparse][[/noparse]basicstamps] How to make 3 dimensions lookup tables
>
>
> my question is simple, i was wondering if u can make 3d tables on a
> stamp 2, i want the stamp to see two different variables and through
> a 3d table find the correct coresponding value, then update the 3rd
> variable with what it gathers...
>
> the application is for a eletronic fuel injecting system working off
> two input variables,1. a air presure denisty sensor (MAP Sensor) on
> the intake manifold. This sensor will tell the stamp if there is a
> boost in presure to enrich the fuel air ratio and also define one of
> the variables in table as X, used later to be one of the dimensions
> in the 3d table. 2. The second sensor is the thottle postion sensor,
> this 2nd variable will be the Y of the table. The thottle sensor will
> tell the stamp, if the thottle is idle / wide open or inbetween. The
> 3rd part of the table will be the injector pulsewidth constant. This
> will be what the stamp looks up from the other X Y variables , and
> then output the lookedup value to a Z variable that in which the
> stamp can use later , to give the correct pulsewidth for the injector
> for that one engine cycle under those differenent conditions...
>
> i would love it if someone had a simple demostration program
> outlineing the X Y Z variables... , the resolution for my thottle
> postion sensor is 8 step's, and the MAP sensor has a resolution of
> 100 step's ( in 10 step increments)...
>
> X VAR WORD ' MAP Sensor
> Y VAR WORD ' TPS Sensor
> Z VAR WORD ' Pulswidth
>
> X 0 10 20 30 40 etc...
> Y
> 0 100 200 300 400 500
> 1 200 300 400 500 600
> 2 300 400 500 600 700 <--- these are the pulswidth constants
> 3 Z Z Z once the stamp finds the correct value
> 4 Z Z it will then update it to the
> Z variable
> 5 Z
> etc..
>
> as u see that would be a idea of what im trying to do if u were look
> at it on a sheet of paper, just i want use stamp to see the two
> different sensor input variables, then lookup the corresponding
> constant and output it to a defined variable in which later i can use
> the pulsout command to fire my injector under the different eninge
> conditions
>
> Sean....
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the
> Subject and Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
>
>
EEPROM memory chip to store his data. Microchip has many available
that have plenty of memory to store lookup tables.
http://www.microchip.com/1010/pline/memory/memdvice/spi/4to64/devices/
25aa640/options/
-Dave
--- In basicstamps@yahoogroups.com, "Al Williams" <alw@a...> wrote:
> As someone pointed out, you could do this with a formula instead of
a table.
> Also, the BS2 doesn't have a lot of memory, so this would be a
problem.
> However, two things come to mind. First, you could use LOOKUP to
get you
> there. This stores data in program memory. Second you could use
scratch pad
> memory.
>
> Here's the deal,
>
> Let's consider a 2x2x2 cube. You could expand for larger ones. The
first
> plane of the cube has:
>
> 111 112
> 121 122
>
> The second plane has
> 211 212
> 221 222
>
> Yes, I know we could get to these with a formula, but I just want
something
> that is easy to follow.
>
> X var byte
> Y var byte
> Z var byte
> Result var byte
>
> X=0
> Y=1
> Z=0
> Gosub Lookupxyz
> Debug ?result
> End
>
> Lookupxyz:
> BRANCH z,[noparse][[/noparse]z0,z1] ' keep in mind that z ranges from 0 to 1
> Z0: BRANCH y,[noparse][[/noparse]y00,y01] ' ditto for y
> Z1: BRANCH y,[noparse][[/noparse]y10,y11]
> Y00: LOOKUP x,[noparse][[/noparse]111,112],result
> Return
>
> Y01: LOOKUP x,[noparse][[/noparse]121,122],result
> Return
>
> Y02: LOOKUP x,[noparse][[/noparse]211,212],result
> Return
>
> Y03: LOOKUP x,[noparse][[/noparse]221,222],result
> Return
>
> I didn't test this, so maybe some typos, but you get the idea.
>
>
> 2) The general formula for a matrix like this is to say:
> index=z*xmax*ymax+y*xmax+x
>
> So in our example above, xmax=2 and ymax=2 So:
>
> X Y Z INDEX
> 0 0 0 0
> 1 0 0 1
> 0 1 0 2
> 1 1 0 3
> 0 0 1 4
> 1 0 1 5
> 0 1 1 6
> 1 1 1 7
>
> (of course, this is more interesting if xmax <> ymax <> 2)
>
> You could use this with GET or READ in a BS2P, for example.
>
> Xmax con 2
> Ymax con 2
> Zmax con 2
> X var byte
> Y var byte
> Z var byte
> Result var byte
> Index var byte
>
> . . .
> index= z*xmax*ymax+y*xmax+x
> GET index,result ' or PUT if you want to write
>
> If you want words, you might want something like:
> Index=(z*xmax*ymax+y*xmax+x)*2
> GET index,result.lowbyte
> GET index,result.highbyte
>
> Hope that helps.
>
> Al Williams
> AWC
> * Floating point math for the Stamp or any micro:
> http://www.al-williams.com/pak1.htm
>
>
>
>
> >
Original Message
> > From: djrevolution99 [noparse][[/noparse]mailto:djrevolution99@y...]
> > Sent: Tuesday, November 18, 2003 2:10 AM
> > To: basicstamps@yahoogroups.com
> > Subject: [noparse][[/noparse]basicstamps] How to make 3 dimensions lookup tables
> >
> >
> > my question is simple, i was wondering if u can make 3d tables on
a
> > stamp 2, i want the stamp to see two different variables and
through
> > a 3d table find the correct coresponding value, then update the
3rd
> > variable with what it gathers...
> >
> > the application is for a eletronic fuel injecting system working
off
> > two input variables,1. a air presure denisty sensor (MAP Sensor)
on
> > the intake manifold. This sensor will tell the stamp if there is
a
> > boost in presure to enrich the fuel air ratio and also define one
of
> > the variables in table as X, used later to be one of the
dimensions
> > in the 3d table. 2. The second sensor is the thottle postion
sensor,
> > this 2nd variable will be the Y of the table. The thottle sensor
will
> > tell the stamp, if the thottle is idle / wide open or inbetween.
The
> > 3rd part of the table will be the injector pulsewidth constant.
This
> > will be what the stamp looks up from the other X Y variables ,
and
> > then output the lookedup value to a Z variable that in which the
> > stamp can use later , to give the correct pulsewidth for the
injector
> > for that one engine cycle under those differenent conditions...
> >
> > i would love it if someone had a simple demostration program
> > outlineing the X Y Z variables... , the resolution for my thottle
> > postion sensor is 8 step's, and the MAP sensor has a resolution
of
> > 100 step's ( in 10 step increments)...
> >
> > X VAR WORD ' MAP Sensor
> > Y VAR WORD ' TPS Sensor
> > Z VAR WORD ' Pulswidth
> >
> > X 0 10 20 30 40 etc...
> > Y
> > 0 100 200 300 400 500
> > 1 200 300 400 500 600
> > 2 300 400 500 600 700 <--- these are the pulswidth constants
> > 3 Z Z Z once the stamp finds the correct
value
> > 4 Z Z it will then update it to the
> > Z variable
> > 5 Z
> > etc..
> >
> > as u see that would be a idea of what im trying to do if u were
look
> > at it on a sheet of paper, just i want use stamp to see the two
> > different sensor input variables, then lookup the corresponding
> > constant and output it to a defined variable in which later i can
use
> > the pulsout command to fire my injector under the different
eninge
> > conditions
> >
> > Sean....
> >
> >
> > To UNSUBSCRIBE, just send mail to:
> > basicstamps-unsubscribe@yahoogroups.com
> > from the same email address that you subscribed. Text in the
> > Subject and Body of the message will be ignored.
> >
> >
> > Your use of Yahoo! Groups is subject to
> > http://docs.yahoo.com/info/terms/
> >
> >
> >
> >