Help with Transciever code between to stamps. Can two stamp communicate between
hybrid
Posts: 16
Hey Parallax group. Here is my question: I have two basic stamps communicating over the rf modules. I am having trouble synchronizing the two stamps. If i send a serout command for stamp1 over rf and have stamp2 to recieve the signal it creates a synchronization dilema. There is a chance that the sent message from stamp1 is not recieved by stamp2. The first stamp will continue with its code. In my case it has several serout commands in a row. I could make the serin comman on stamp 2 use a timeout option, but then the following serin commands on stamp 2 would not match with the serout commands of stamp1. Is there anyway to code around this sychronization problem. Someone said something about the stamps handshaking, but i don't know what that means. Any help would be great. Thank you very much.
Comments
Welcome to the world of RF communicatons...
What you describe is a classic problem. With one way communication, it can be a toughie. With two way comms you can use a checksum and retransmit if needed scheme. In a one way, you can use a checksum or byte count to know if you got all the data, but you can't request a resend. Most RF units do not support handshaking, which is a system of sending bytes only when the recivier is ready.
One totally trouble free way of doing it is with transeiver units that have built in error checking. I use Parallax's EB500 bluetooth unit, and it takes care of all the error checking, I just get clean data from the output. I beleive there is at least one other Parallax RF product that has error checking.
What are you trying to do, exactly? There may well be ab accepatable way of doing it with the units youi have. What RF unit are you using, BTW?
Jonathan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
It sometime helps to prefix the data like this:
255, 0, 255, 0, 255, 0, id , data
Then program the receiver to wait for 255, then wait for 0 then wait for a byte that is NOT 0 or 255, that number is the id, and the next byte is the databyte.
If the id matches the id of the last reception, then it is a repeat so ignore it.
What you do is send this multiple times with the same id. The receiver ignores anything with the same id after it gets data.
Repeat it as many times as you need to get good data (will take some trial and error).
All you have to do is change the id for the next data byte. (id cannot be 0 or 255, I would roll it from 1 to 254 then back to 1 again). The receiver can also use the id to make sure it didn't miss a datebyte.
Hope this makes sense...
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95
http://www.parallax.com/detail.asp?product_id=30012
"SX-Video OSD module" Now available from Parallax for only·$49.95
http://www.parallax.com/detail.asp?product_id=30015
Product web site: www.sxvm.com
Those that would give up freedom for security will have neither.
Post Edited (Bean (Hitt Consulting)) : 11/16/2005 3:25:01 AM GMT
One very common standard way of doing this is to have the base station query the the field units one at a time.
The field units use the SERIN "WAIT" feature and sit there until they see they address, as per Bean's earlier post.
When the field unit sees its address, then it can send the data back, knowing that no one else will be transmitting at the same time.
I've used this technique on both wired and RF systems.
It means that you can set up a breadboard without the RF transcievers in order to get your code debugged, and then add them in later.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)
······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
I think that that would imply that the remote Stamps have a means of "detecting" that it is their turn to transmit...implying another transmitter/receiver pair. I think that hybrid is trying to find a solution using only the transmitters on each of his remotes and the receiver on his base station.
Does that sound right, hybrid?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Truly Understand the Fundamentals and the Path will be so much easier...
What we did was make the interaction a two step one. The master asks the slave for recent data. As the slave transmits the data, it sets a flag. When the master receives data, it then sends back a character which acknowledges receipt and tells the slave to reset its flag.
If the master doesn't receive data from a slave, it knows to re-query. The slave knows which data to re-send because of the flag.
This was used on a 1000 HP air blower system and has been running for 6 years or so. The data exchanged included all data measurements, start-stop commands for the motors and the data used by the trending software. The system had one master set up as described and 6 slaves; one by RF and the others by hardwire RS-485.
Cheers