Communication between BS2p24 to BS2p24
pathikgohil85
Posts: 21
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
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
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,
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.
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
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,
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
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,