Shop OBEX P1 Docs P2 Docs Learn Events
Communication between BS2p24 to BS2p24 — Parallax Forums

Communication between BS2p24 to BS2p24

pathikgohil85pathikgohil85 Posts: 21
edited 2011-11-05 05:30 in BASIC Stamp
Hello Guys,

I am looking for some help or guidance to set up communication between BS2p24 to BS2p24. I am planning to use one master and one slave right now but I am planning to increase no of slaves by 2 later. It is my first time and I do not know how to do it.

1. How many I/O pins do we need for communication between two stamps?
2. Can one stamp control more than one stamp at a same time?

Please let me know guys. Also if i get some more information about it. I read about stamps communication in basic stamp manual in SEROUT. Is it enough?

Regards,
Pathik Gohil

Comments

  • stamptrolstamptrol Posts: 1,731
    edited 2011-11-02 16:19
    Pathik,

    In the Editor helpfile, there is a detailed description of SERIN and SEROUT, including a sample program to connect two Stamps together for two-way communication.

    Depending on what data you wish to exchange, you could do it with as little as one pin per Stamp. As you will see in the example in the helpfile, adding an extra pin at each end can give better performance.

    As well, there is discussion on using the the open collector mode as one method of having one master talk to multiple slaves.

    Cheers,
  • Mike GreenMike Green Posts: 23,101
    edited 2011-11-02 16:20
    The description in the Basic Stamp Manual should work for what you want. You might also look in the Nuts and Volts Columns. I don't remember which ones, but there were two successive columns on a multiStamp network. Browse the index on Parallax's website.

    1) You only need one I/O pin for the network. Some networks might use two I/O pins, one for sending from the master and the other for receiving from the slaves.
    2) You need a program on each Stamp, a master program on one Stamp and a slave program on any others. Keep in mind that the master Stamp isn't really "controlling" the slave Stamps. It's just sending information out and the slaves have to be listening for it. They then obey any commands sent to them. In any event, read the two-part column on the multiStamp network.
  • pathikgohil85pathikgohil85 Posts: 21
    edited 2011-11-03 11:30
    Thanks guys.

    You have provided very good information. I would like to know, Can I use the same pins to communicate with all the slaves basic stamps?

    Pathik Gohil
  • Mike GreenMike Green Posts: 23,101
    edited 2011-11-03 15:29
    Usually you use the same I/O pin on each of the slave microcontrollers. That way you can use the same program code on each of the slaves without changing it to adjust for different I/O pin use.
  • pathikgohil85pathikgohil85 Posts: 21
    edited 2011-11-03 17:16
    I also made a circuit with 3 stamp controllers with one master controller. Please tell me your comments. what necessary changes should i do in demo program for one to one basic stamp communication?
  • stamptrolstamptrol Posts: 1,731
    edited 2011-11-04 06:28
    The concept in master-slave communication is this:

    1. All stations are normally set to be receivers, including the master. The master periodically sends a message to all slaves then returns to listening..
    2. Each slave will be listening for some unique identifying character. When the identifier is noted, the slave will receive the message. (use the WAIT modifier in SERIN)
    3. As decided by your slave program, it may send a message back to the master.
    4. The master acts on the slave's message and resumes sending.

    You can use the same pin for both sending and receiving. It will change function as the program uses the SERIN and SEROUT commands. For multiple slaves, you may want to use the "open collector mode" described in the Helpfile writeup.
    Without flow control, the Stamps will communicate best at speeds below 4800 baud.

    Cheers,
  • pathikgohil85pathikgohil85 Posts: 21
    edited 2011-11-04 13:36
    Hey guys,

    this is a code, I have written for one master and 3 basic slave basic stamps. Please let me know if you have any comment. It is just testing code to check if it is going to happen or not.

    ' RECEIVER - CONNECTED TO PC FOR DEBUG
    ' Sender - connected to slave basic stamps

    ' SERIN_SEROUT2.BS2
    ' Using 4 BS2-IC's, connect the circuit shown in the SERIN command
    ' description and run this program on the BASIC Stamp designated as the
    ' Receiver.

    ' This program will send as well as receive intruction from PC as well as from slave stamps.
    ' there are 3 basic stamp slaves, each basic stamp has their own board no which will help master to pass information
    to individule stamp.

    ' using pin 16 for serial communication. Flow pin will be always 1 because all basic stamps are in receive mode.

    ' {$STAMP BS2px}
    ' {$PBASIC 2.5}
    ' baudrate = 115200

    SI PIN 16 ' serial input
    FC PIN 1 ' flow control pin

    A VAR Byte
    Board_No VAR Byte
    CTR VAR BYTE

    Board_No = 1 ' respectively 1 , 2 and 3 for board no 1, 2 and 3

    Main:


    SERIN 16\1, 1, [SPSTR 78 ] ' Getting data from PC or slave basic stamps to 0-78 scratch pad ram.

    GET 0,CTR ' Identifying qulidier RX for input sring
    IF CTR = 82 THEN C1
    GOTO REPEAT
    C1:
    GET 1,CTR
    IF CTR = 88 THEN C2
    GOTO REPEAT

    C2:
    SEROUT 16\1,1, [ "RX ", DEC BOARD_NO, " "] ' Sending data to PC or slave basic stamps with board no/slave no.

    FOR CTR = 2 TO 78
    GET CTR,A
    SEROUT 16\1, 1, [ DEC A, " "]
    NEXT

    PAUSE 500 ' wait one second

    REPEAT: ' repeat forever

    END

    Regards

    Pathik Gohil
  • stamptrolstamptrol Posts: 1,731
    edited 2011-11-05 05:30
    Pin 16 is a special case in that there is on-board level shifting to make the signals more compatible with rs-232 voltage levels.

    You may have to use another pin (0 - 15) to allow multiple slaves.

    Other than that, hook them up and give it a try!

    Cheers,
Sign In or Register to comment.