AWC PAK-II Math coprocessor
Archiver
Posts: 46,084
Hi, I was wondering if anyone could explain in layman's terms how to
use a PAK-II with a Basic Stamp 2. Does anyone have a simple program
that explains the code used. Thanks
use a PAK-II with a Basic Stamp 2. Does anyone have a simple program
that explains the code used. Thanks
Comments
the PAK-I (among other things) at
http://www.al-williams.com/awce/doclib.htm.
The easiest way to talk to the PAK is to use our library that does all the
SHIFTIN/SHIFTOUT commands for you. You can also do the SHIFTIN/SHIFTOUT
yourself. For now, say you will use the library.
The basic operation has three steps:
1) Get some numbers into the PAK
2) Do calculations
3) Get numbers out of the PAK
#1. If you want to handle integers (1/3=.3333) you can load them directly
and convert them to floating point. You can also use the provided FCONVERT
program to convert constants into 32-bit floats, or you can load IEEE format
floats directly. With a PAK-IX you can load the results of a A/D conversion
(averaged over several samples) directly.
#2. The PAK has X and Y registers that you load with the data you want to
work with. This is sort of like an HP calculator:
Load X
Load Y
ADD (X=X+Y)
The PAK also has several temporary registers that allow you to save and load
the X register without a round trip to the Stamp.
#3. Depending on what you want to do, you can:
a) Convert to an integer and read that
b) Dump characters out (so 3.5 is "3" and "5")
c) Read the 32-bit number in IEEE format for sending to a PC, etc.
d) Scale to an integer.
To illustrate the last item, suppose you compute a temperature between 0 and
100 degrees and you want to display it on an LCD with 1 decimal point. You
could compute X=10*X and then convert to an integer. This gives you from
0-1000. Now you could write:
SEROUT .... [noparse][[/noparse] fpx/10, ".", fpx//10 ]
Now if you don't mind using the libraries, you can stop here. If you want to
do your own, that's fine too.
Many of the PAKs use SHIFTIN/SHIFTOUT to communicate. You might think that
is more troublesome than using SERIN and SEROUT, but it is really much
better. Why?
1) Speed insensitive. You can pull data as fast you want or as slow as you
want (within limits).
2) It waits for you. All lengthy commands have a way to signal you they are
ready to be read. That means you can poll and read when you are ready. With
SERIN you'd have to wait until the PAK was ready for fear you'd miss the
result. Or you'd have to use more I/O pins.
The manual contains the function codes for all the commands. You simply
shift them out and then shift the results back in. You can look inside the
library to see how it works.
Hope that helps. If you have more specific questions, feel free to ask. I
think the documents on the PAK-I though will clear it up for you.
Regards,
Al Williams
AWC
*Connect any serial device to the Internet:
http://www.al-williams.com/awce/netporter.htm
>
Original Message
> From: rstackho@h... [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=i7h-8vJ5-_qn9v7tGc-FvHaf82nGrkJrrBFSmEVbW_ZYOWebuaULLXnV9Zs1Z6jn8doH1Lx2qFukICc]rstackho@h...[/url
> Sent: Wednesday, May 16, 2001 5:04 PM
> To: basicstamps@yahoogroups.com
> Subject: [noparse][[/noparse]basicstamps] AWC PAK-II Math coprocessor
>
>
> Hi, I was wondering if anyone could explain in layman's terms how to
> use a PAK-II with a Basic Stamp 2. Does anyone have a simple program
> that explains the code used. Thanks
>
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>