Table look up
Archiver
Posts: 46,084
Hi everyone, I am brand new to stamps and electronics in general. I
am hoping that someone can help me. I want to program my stamp to
receive an analog voltage signal, then have the program look in a
table for an analog voltage to output that corresponds to the input
voltage. The table is of course modifiable and the transfer function
between the two voltages is completely random.
How do I program the stamp to do that?
Thanks for all of the help!!
am hoping that someone can help me. I want to program my stamp to
receive an analog voltage signal, then have the program look in a
table for an analog voltage to output that corresponds to the input
voltage. The table is of course modifiable and the transfer function
between the two voltages is completely random.
How do I program the stamp to do that?
Thanks for all of the help!!
Comments
you don't want to do it. The Stamp (and most other processors) are not
fast enough to do a conversion, look up the result you want, and
generate a voltage fast enough to do what you want to do (which I assume
would be some sort of digital signal processing). You would want a
special DSP chip that is designed for this sort of thing. Also, since
you are digitizing, there are special concerns about spectrum noise,
aliasing, and satisfying the nyquist limit that you need to worry about.
There is a very good book on DSP at www.dspguide.com (free download as
PDF).
To answer your question directly:
1) Use an A/D converter to read the voltage.
2) Look up a number using some simple Stamp code
3) Use a D/A converter to generate the new voltage
Your total speed will be limited by the speeds of the A/D and D/A plus
the Stamp's actual speed. It won't be fast enough to handle audio or
even close to that without some very tricky techniques (and probably not
even then).
If you really have a need to do this slowly, let us know and someone
will elaborate.
Al Williams
AWC
* Easy RS-232 Prototyping
http://www.al-williams.com/awce/rs1.htm
>
Original Message
> From: mkii91 [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=iqoSMExyvdDIFJYT9sru4qZny8-jHj197urwaHeVB0Z-akP8EyOVg8yGjfzKrRfQb2kNu-1FbA]mkii91@y...[/url
> Sent: Sunday, March 10, 2002 9:41 PM
> To: basicstamps@yahoogroups.com
> Subject: [noparse][[/noparse]basicstamps] Table look up
>
>
> Hi everyone, I am brand new to stamps and electronics in general. I
> am hoping that someone can help me. I want to program my stamp to
> receive an analog voltage signal, then have the program look in a
> table for an analog voltage to output that corresponds to the input
> voltage. The table is of course modifiable and the transfer function
> between the two voltages is completely random.
>
> How do I program the stamp to do that?
>
> Thanks for all of the help!!
>
>
> 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/
>
you taking time to help me out, I will download that book and see
what I can find out.
When you say slowly, how slow do you mean? If I use a BS2p and an
average A/D and D/A what would be my total conversion time? What if
I use high speed ADC (do they make those)?
I'm using this for an automotive application, basically taking the
transfer function from one sensor and making it look like the
transfer function from the stock sensor in order to not "confuse" the
car's computer. Do you think that this will require the high speed
DSP chip that you spoke of?
Thanks again for the help!!
Tony
--- In basicstamps@y..., "Al Williams" <alw@a...> wrote:
> The short answer is that this is not hard to do. The long answer is
that
> you don't want to do it. The Stamp (and most other processors) are
not
> fast enough to do a conversion, look up the result you want, and
> generate a voltage fast enough to do what you want to do (which I
assume
> would be some sort of digital signal processing). You would want a
> special DSP chip that is designed for this sort of thing. Also,
since
> you are digitizing, there are special concerns about spectrum noise,
> aliasing, and satisfying the nyquist limit that you need to worry
about.
>
>
> There is a very good book on DSP at www.dspguide.com (free download
as
> PDF).
>
> To answer your question directly:
> 1) Use an A/D converter to read the voltage.
> 2) Look up a number using some simple Stamp code
> 3) Use a D/A converter to generate the new voltage
>
> Your total speed will be limited by the speeds of the A/D and D/A
plus
> the Stamp's actual speed. It won't be fast enough to handle audio or
> even close to that without some very tricky techniques (and
probably not
> even then).
>
> If you really have a need to do this slowly, let us know and someone
> will elaborate.
>
> Al Williams
> AWC
> * Easy RS-232 Prototyping
> http://www.al-williams.com/awce/rs1.htm
>
>
> >
Original Message
> > From: mkii91 [noparse][[/noparse]mailto:mkii91@y...]
> > Sent: Sunday, March 10, 2002 9:41 PM
> > To: basicstamps@y...
> > Subject: [noparse][[/noparse]basicstamps] Table look up
> >
> >
> > Hi everyone, I am brand new to stamps and electronics in
general. I
> > am hoping that someone can help me. I want to program my stamp
to
> > receive an analog voltage signal, then have the program look in a
> > table for an analog voltage to output that corresponds to the
input
> > voltage. The table is of course modifiable and the transfer
function
> > between the two voltages is completely random.
> >
> > How do I program the stamp to do that?
> >
> > Thanks for all of the help!!
> >
> >
> > To UNSUBSCRIBE, just send mail to:
> > basicstamps-unsubscribe@y...
> > 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/
> >
takes to transfer the data and the processing time. Not a simple answer
-- it will depend on the parts you use. But even the fastest A/D will
only be able to transfer data to the Stamp at a certain rate. Usually
with the Stamp, you'll use a serial A/D to save pins but that is a slow
way to transfer data. A parallel interface A/D would be faster, but eat
up pins. Same for the DAC. You can use a R/2R network and as many output
bits as you want to get a very fast A/D. However, this eats up pins too.
Like anything else, you will be limited by one piece, so even if you use
a flash or half flash A/D, that will just move the bottleneck from one
place to another.
Do you have any idea how fast you need to process? If the transfer
function is simple enough why not do it with analog circuitry? You can
do lots of math with op amps -- averaging, square roots -- you'd be
surprised.
Al Williams
AWC
* Easy RS-232 Prototyping
http://www.al-williams.com/awce/rs1.htm
>
Original Message
> From: mkii91 [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=ns3kjKFyHpua2V508SAjV6H3zc_A__tSmNI-OVCgalKCHeNcSzvT9eu939xcDxDjqilifpP3RCQt]mkii91@y...[/url
> Sent: Tuesday, March 12, 2002 8:26 PM
> To: basicstamps@yahoogroups.com
> Subject: [noparse][[/noparse]basicstamps] Re: Table look up
>
>
> Al, Let me first start off by saying thanks!! I really appreciate
> you taking time to help me out, I will download that book and see
> what I can find out.
>
> When you say slowly, how slow do you mean? If I use a BS2p and an
> average A/D and D/A what would be my total conversion time? What if
> I use high speed ADC (do they make those)?
>
> I'm using this for an automotive application, basically taking the
> transfer function from one sensor and making it look like the
> transfer function from the stock sensor in order to not "confuse" the
> car's computer. Do you think that this will require the high speed
> DSP chip that you spoke of?
>
> Thanks again for the help!!
> Tony
>
> --- In basicstamps@y..., "Al Williams" <alw@a...> wrote:
> > The short answer is that this is not hard to do. The long answer is
> that
> > you don't want to do it. The Stamp (and most other processors) are
> not
> > fast enough to do a conversion, look up the result you want, and
> > generate a voltage fast enough to do what you want to do (which I
> assume
> > would be some sort of digital signal processing). You would want a
> > special DSP chip that is designed for this sort of thing. Also,
> since
> > you are digitizing, there are special concerns about
> spectrum noise,
> > aliasing, and satisfying the nyquist limit that you need to worry
> about.
> >
> >
> > There is a very good book on DSP at www.dspguide.com (free download
> as
> > PDF).
> >
> > To answer your question directly:
> > 1) Use an A/D converter to read the voltage.
> > 2) Look up a number using some simple Stamp code
> > 3) Use a D/A converter to generate the new voltage
> >
> > Your total speed will be limited by the speeds of the A/D and D/A
> plus
> > the Stamp's actual speed. It won't be fast enough to handle
> audio or
> > even close to that without some very tricky techniques (and
> probably not
> > even then).
> >
> > If you really have a need to do this slowly, let us know
> and someone
> > will elaborate.
> >
> > Al Williams
> > AWC
> > * Easy RS-232 Prototyping http://www.al-williams.com/awce/rs1.htm
> >
> >
> > >
Original Message
> > > From: mkii91 [noparse][[/noparse]mailto:mkii91@y...]
> > > Sent: Sunday, March 10, 2002 9:41 PM
> > > To: basicstamps@y...
> > > Subject: [noparse][[/noparse]basicstamps] Table look up
> > >
> > >
> > > Hi everyone, I am brand new to stamps and electronics in
> general. I
> > > am hoping that someone can help me. I want to program my stamp
> to
> > > receive an analog voltage signal, then have the program look in a
> > > table for an analog voltage to output that corresponds to the
> input
> > > voltage. The table is of course modifiable and the transfer
> function
> > > between the two voltages is completely random.
> > >
> > > How do I program the stamp to do that?
> > >
> > > Thanks for all of the help!!
> > >
> > >
> > > To UNSUBSCRIBE, just send mail to:
> > > basicstamps-unsubscribe@y...
> > > 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/
> > >
>
>
> 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/
beginning to think that speed is not an issue. The ADC they listed
had a maximum conversion time of 4.4 microseconds I don't know how
fast the BS2p is or how fast the d/a is but if it can be measured on
the microsecond scale I think that is plenty fast!! I think that
anything faster than 10 millisecond would be more than up to the
task.
However, I do plan on using this same stamp to also do some
datalogging of about 8 thermocouples plus the voltage from the O2
sensor, as well as display some data on an LCD mounted in my
dashboard. Possibly even run a couple of additional injectors. As I
add more programs to the same stamp, how much slower does it become?
Well I'll worry about the additional features later, so now my
question is how do I program the stamp to do table look up?
The reason why I'm not going to do this with an analog circuit is
that the conversion transfer function is rather complex. I'm sure it
is possible but I aslo want to be able to adjust certain areas of the
transfer function in order to tune the engine. This on the fly
tuning would more than likely be rather comples for me if I tried to
do it with only an analog circuit. Plus I want to be able to datalog
this information as well.
thanks again for all of the help!!
Tony
--- In basicstamps@y..., "Al Williams" <alw@a...> wrote:
> It will depend on the speed of the A/D and D/A you use plus the
time it
> takes to transfer the data and the processing time. Not a simple
answer
> -- it will depend on the parts you use. But even the fastest A/D
will
> only be able to transfer data to the Stamp at a certain rate.
Usually
> with the Stamp, you'll use a serial A/D to save pins but that is a
slow
> way to transfer data. A parallel interface A/D would be faster, but
eat
> up pins. Same for the DAC. You can use a R/2R network and as many
output
> bits as you want to get a very fast A/D. However, this eats up pins
too.
>
> Like anything else, you will be limited by one piece, so even if
you use
> a flash or half flash A/D, that will just move the bottleneck from
one
> place to another.
>
> Do you have any idea how fast you need to process? If the transfer
> function is simple enough why not do it with analog circuitry? You
can
> do lots of math with op amps -- averaging, square roots -- you'd be
> surprised.
>
> Al Williams
> AWC
> * Easy RS-232 Prototyping
> http://www.al-williams.com/awce/rs1.htm
>
>
>
> >
Original Message
> > From: mkii91 [noparse][[/noparse]mailto:mkii91@y...]
> > Sent: Tuesday, March 12, 2002 8:26 PM
> > To: basicstamps@y...
> > Subject: [noparse][[/noparse]basicstamps] Re: Table look up
> >
> >
> > Al, Let me first start off by saying thanks!! I really appreciate
> > you taking time to help me out, I will download that book and see
> > what I can find out.
> >
> > When you say slowly, how slow do you mean? If I use a BS2p and an
> > average A/D and D/A what would be my total conversion time? What
if
> > I use high speed ADC (do they make those)?
> >
> > I'm using this for an automotive application, basically taking the
> > transfer function from one sensor and making it look like the
> > transfer function from the stock sensor in order to not "confuse"
the
> > car's computer. Do you think that this will require the high
speed
> > DSP chip that you spoke of?
> >
> > Thanks again for the help!!
> > Tony
> >
> > --- In basicstamps@y..., "Al Williams" <alw@a...> wrote:
> > > The short answer is that this is not hard to do. The long
answer is
> > that
> > > you don't want to do it. The Stamp (and most other processors)
are
> > not
> > > fast enough to do a conversion, look up the result you want, and
> > > generate a voltage fast enough to do what you want to do (which
I
> > assume
> > > would be some sort of digital signal processing). You would
want a
> > > special DSP chip that is designed for this sort of thing. Also,
> > since
> > > you are digitizing, there are special concerns about
> > spectrum noise,
> > > aliasing, and satisfying the nyquist limit that you need to
worry
> > about.
> > >
> > >
> > > There is a very good book on DSP at www.dspguide.com (free
download
> > as
> > > PDF).
> > >
> > > To answer your question directly:
> > > 1) Use an A/D converter to read the voltage.
> > > 2) Look up a number using some simple Stamp code
> > > 3) Use a D/A converter to generate the new voltage
> > >
> > > Your total speed will be limited by the speeds of the A/D and
D/A
> > plus
> > > the Stamp's actual speed. It won't be fast enough to handle
> > audio or
> > > even close to that without some very tricky techniques (and
> > probably not
> > > even then).
> > >
> > > If you really have a need to do this slowly, let us know
> > and someone
> > > will elaborate.
> > >
> > > Al Williams
> > > AWC
> > > * Easy RS-232 Prototyping http://www.al-
williams.com/awce/rs1.htm
> > >
> > >
> > > >
Original Message
> > > > From: mkii91 [noparse][[/noparse]mailto:mkii91@y...]
> > > > Sent: Sunday, March 10, 2002 9:41 PM
> > > > To: basicstamps@y...
> > > > Subject: [noparse][[/noparse]basicstamps] Table look up
> > > >
> > > >
> > > > Hi everyone, I am brand new to stamps and electronics in
> > general. I
> > > > am hoping that someone can help me. I want to program my
stamp
> > to
> > > > receive an analog voltage signal, then have the program look
in a
> > > > table for an analog voltage to output that corresponds to the
> > input
> > > > voltage. The table is of course modifiable and the transfer
> > function
> > > > between the two voltages is completely random.
> > > >
> > > > How do I program the stamp to do that?
> > > >
> > > > Thanks for all of the help!!
> > > >
> > > >
> > > > To UNSUBSCRIBE, just send mail to:
> > > > basicstamps-unsubscribe@y...
> > > > 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/
> > > >
> >
> >
> > To UNSUBSCRIBE, just send mail to:
> > basicstamps-unsubscribe@y...
> > 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/
>had a maximum conversion time of 4.4 microseconds I don't know how
>fast the BS2p is or how fast the d/a is but if it can be measured on
>the microsecond scale I think that is plenty fast!! I think that
>anything faster than 10 millisecond would be more than up to the
>task.
Milliseconds, yes, microseconds no. The BS2p takes about 100
microseconds for each instruction. Some complex instructions take
much longer than that. I could imagine you doing a table lookup and
transfer function alone in a loop that takes maybe 4 to 5
milliseconds per sample. Is 8 bits enough resolution? The ADC and
DAC are not going to be the major limiting factors for speed.
>However, I do plan on using this same stamp to also do some
>datalogging of about 8 thermocouples plus the voltage from the O2
>sensor, as well as display some data on an LCD mounted in my
>dashboard. Possibly even run a couple of additional injectors. As I
>add more programs to the same stamp, how much slower does it become?
Add a couple of milliseconds for each analog channel, more if you
need to do math on the results. Add lots of time for the LCD, more
if it is serial, less if it is parallel interfaced. You can optimize
by only updating the display occasionally. Three or four
milliseconds for the injectors. Wild guess, 30 milliseconds per loop
through the tasks.
>
>Well I'll worry about the additional features later, so now my
>question is how do I program the stamp to do table look up?
The best way to do table lookup is to use DATA statements.
value var byte 'input reading from ADC
xvalue var byte 'transformed value from lookup
table data xvalue0,xvalue1,xvalue2,xvalue3,xvalue4,....
data ... ' compile-time constants
data xvalue253,xvalue254,xvalue255
' have value from ADC, 8 bits.
read value,xvalue ' one of 256 in --> one of 256 out
' now output xvalue
It is also possible to use a smaller table and interpolation, but
that takes a time hit because of the math.
<http://www.emesystems.com/BS2math3.htm#interpolation>
>
>The reason why I'm not going to do this with an analog circuit is
>that the conversion transfer function is rather complex. I'm sure it
>is possible but I aslo want to be able to adjust certain areas of the
>transfer function in order to tune the engine. This on the fly
>tuning would more than likely be rather comples for me if I tried to
>do it with only an analog circuit. Plus I want to be able to datalog
>this information as well.
>
>thanks again for all of the help!!
>Tony
-- regards,
Tracy Allen
electronically monitored ecosystems
mailto:tracy@e...
http://www.emesystems.com