View Full Version : Using two Basic Stamps at the same time

12-05-2006, 10:41 PM
Hi all,

Since I ran out of variable space on my BS2 I had considered switching to a different ucontroller. However, someone just gave me their BS2-BOE carrier board (still need the Stamp) so now I will have two, which will be enough.

My project requires a constant connection to A PC, the ucontrollers will never stand alone. I will obviously be using 2 ports for comms, and have two debug windows open. I would like both boards to be capable of accepting ASCII characters as subroutine commands. I already have the code written and it works great on the single board.

I am curious as to what will happen when I am pressing keyboard keys with two boards connected, will the ASCII be sent to both ucontrollers, or just one? Will I be able to choose on the fly which board gets the ASCII?

Mike Green
12-05-2006, 10:46 PM
Only one debug window is active at a time and that is the one that will respond to the keyboard press. This is true of pretty much all windowing systems (Mac, Windows, Linux, etc.) You have to do a mouse click in a window to activate it or use some special key to shift the "active" window (usually Alt-Tab).

12-05-2006, 10:46 PM
Simplify things.· Let one Stamp talk to the PC and have it relay applicable info to the second Stamp via serin/serout.· If the second Stamp needs to display something, the data can be relayed tp the other Stamp for display on the debug screen.· I am doing just that with three Stamps.


Sid Weaver
Don't have VGA?

Newzed@aol.com (mailto:Module?Newzed@aol.com)

12-05-2006, 11:32 PM
Before you spend money on another stamp (though there's no such thing as too many processors), see if it's possible to optimize your code.

First, are you sure your variables are as small as they can be? Using a full word for a counter that only goes to 7 is overkill. If you can spare the execution speed, can any of your variables be calculated as needed, rather than being stored? Can two variables be calculated by adding nibbles to a single base word?

If you have two variables that aren't used at the same time, see if they can overlap and use the same place in RAM.

Can counters (like a FOR loop) be removed by just copying the code?

If you have a variable that only gets reset once in a while, and reading speed isn't critical, maybe it can be written to the EEPROM rather than wasting space in RAM.

I'm not sure (I haven't tried it yet) but I think the DIRS bit for spare I/O pins can be used as storage if you need bits, and I suspect it may be possible to, on the BS2p24, BS2pe, and BS2px, use the whole DIRS and OUTS registers for the auxilary I/O (which is disconnected) to store four more bytes.

If I remember correctly, GOSUB uses the last word to store the return address. If your program used GOSUB, can it be rewritten so it does not?

There are many ways to optimize for variable space. For me, part of the fun of robotics is the challenge of programming, and working around the hardware limitations.

12-06-2006, 12:25 AM
Thanks Mike, I thought that's the way it would work, that will be fine,·I was hoping to have the ability to toggle between windows.

I don't want one Stamp to pass the data to the other one, there's too much info going back and forth, it'll be too hard for me to visualy keep track of if it in only one window. One window for sensor data displays and requests,·and the other for commands and confirmations.

Believe me, I've optimized the variables as much as I know how to. All the words need to be words, bytes need to be bytes etc., and sharing where possible. Just·my sensor display program alone uses every last byte of variable space.·And there's more I'd like to add if I have the space left over in the command and confirmation program.

Another thing I'm curious about, I've used all the variable space but the program itself isn't very long. (thinking out loud here) Is it possible (if they fit) to have both programs on both boards, and be able to call the second program from the first in an emergency? I would imagine not because it would need to be compiled first and the variables wouldn't fit....unless the second program used the same names for the variables as the first program http://forums.parallax.com/images/smilies/freaked.gif .

Hmmm I wonder if the gorilla glue is dry on my new servo webcam PTZ module http://forums.parallax.com/images/smilies/turn.gif