Using two Basic Stamps at the same time
terahertz
Posts: 55
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?
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?
Comments
Sid
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Don't have VGA?
Newzed@aol.com
·
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.
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 .
Hmmm I wonder if the gorilla glue is dry on my new servo webcam PTZ module