Shop OBEX P1 Docs P2 Docs Learn Events
Merging Programs or Multiple Stamps???? — Parallax Forums

Merging Programs or Multiple Stamps????

Scott PortocarreroScott Portocarrero Posts: 72
edited 2009-07-29 02:14 in BASIC Stamp
I am trying to merge several programs together onto one stamp. In order to do this do I declare my variables and just stack the programs together or is there more involved. Do I need another stamp to do different tasks? I know what people are going to say....buy a propeller....unfortunately I don't know how to program them and I am just getting comfortable using the stamp.

So what I am trying to do is automous robot control with other subsystem control such as a moving spine / panning head.

I remember somebody told me it was pretty easy to like stamps and have them talk but is this necessary? Can I do it all with one stamp as long as I don't run out of IOs? HELP! freaked.gif

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-07-25 22:21
    All Stamps have a limited variable space. It's 26 bytes divided up into 16-bit words, 8-bit bytes, 4-bit nibbles, and individual bits. If your several programs' variables all fit in this limited space, you should be able to "stack" the programs together. If there are too many variables, you'll have to share the space by declaring some variables as aliases for others that are not used at the same time. Look up "aliases" in the Stamp Manual or the help file for the Stamp Editor.

    If the programs have to somehow work at the same time, you'll have to spend a lot of time figuring out when one program is waiting for something or idle and parts of another program could be called (as subroutines) to do something useful during that time. For example, there's a pause needed between control pulses to a servo (about 20ms). There are lots of examples in "Robotics with the BoeBot" of reading some sensors during this pause time.

    If you're going to use several (more than 2 or 3) servos, you should consider using a Parallax Servo Controller. This offloads the task of issuing control pulses every 20ms to a coprocessor that takes care of ramping position or speed, making the pulses, etc. for up to 16 servos.
  • EmilyPEmilyP Posts: 21
    edited 2009-07-28 12:07
    Hello,

    My project seems similar to yours. I am using two stamps. However, be forewarned. The more stamps you use does not necessarily mean faster processing. I thought that if I used two stamps, one stamp could control motors and read some sensors while the other stamp could read some more sensors and operate bluetooth. Turns out that while using two stamps allows you to do simultaneous processes, it can kill overall efficiency. If the stamps need to communicate, one stamp has to wait for the other stamp to give it a serial message. You will run into timing issues which are okay if you like to debug code and have development boards to do so. I suggest you use one stamp and slap on a motor controller. A good motor controller will take up less i/0. You still might have to do subroutines but you won't have to deal with timing issues.

    Emily
  • Bill ChennaultBill Chennault Posts: 1,198
    edited 2009-07-29 01:45
    Emily and Scott--

    Regarding multiple Stamps: Contemplate a "master" Stamp and independent "slave" Stamps dedicated to actuators and sensors. All the master would do is look for a bit to be raised by a "sensor" Stamp. The master would then make a decision (or not) and send an instruction to a slave actuator Stamp. Slave actuators and slave sensors are merely smart peripheals. They are vastly over-powered even by Stamp standards. But, Stamps are cheap and you don't want to miss a sensor·event.

    The communication between master and slave(s) is not serial. Just have the slave raise a bit on·the master. This hardware intensive configuration pretty much ensures that all code, even on the master, is very short and sweet. Therefore, even without interrupts and the terrible inherent delays of serial communication among Stamps, the master never misses a beat or a bit. The master is also responsible for implementing some kind of "personality" that determines machine behavior. (Obstacle avoidance, encoder event counting, whatever.)

    This configuration worked very well for me. I used a BS2p40 as the master and four OEM-BS2s as slaves. If I did it over again, I would use BS2 modules in place of the OEM versions. They are a bit cheaper and save real estate.

    Of course, you could also switch to an SX and cut SX/B code, even lacking complete documentation. My current machine is based on an SX48 module designed and built by Robert Doerr. (The SX48 module is a drop-in replacement for a BS2p40 . . . only a LOT faster and with an interrupt structure.) It runs at 20MHz and easily handles Bluetooth. (Not hard, anyway. That is, AFTER you finally get Bluetooth up and running.) Its next life will drop the Bluetooth and use Ping and perhaps some other stuff (maybe, maybe not) to implement an obstacle avoidance personality.

    I really liked the multiple Stamp machine. It consisted of the BS2p40 and four OEM-BS2s. Although I dedicated five pins of the BS2p40 to each BS2, I probably could have got by with three. Therefore, there were far more pins left over for other things. The BS2p40 received simple data (a bit) from the smart sensors and then instructed the smart periphereals using the five bits . . . meaning a five bit instruction set was necessary. (Like 00001 means send a stop signal to the HB-25 and 00002 means send a dead slow signal to the HB-25 and so forth.)

    This same idea would work perfectly well with the SX48 module, too.

    --Bill



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You are what you write.
  • Scott PortocarreroScott Portocarrero Posts: 72
    edited 2009-07-29 02:14
    Hello Bill

    Thank you for the excellent reply! I agree with everything you said. Why didn't I think of that? In fact I plan on using one BS2 as a master, one for the motion control and sensing of the platform movement, one to control the spine (still in planning stage), and one for interaction such as sound, motion, and lighting.
Sign In or Register to comment.