this makes no sense at all
lenny1337
Posts: 26
If someone can tell me why this happens ill be really darn impressed.
The project i'm working on requires three independent units communicate over RF to a central unit. The way i set it up is they keep transmitting and listening for the head unit to ping their name back - in which case they'll know that the transmission went through.
heres a section of the code:
send:
namen = 0
PAUSE (name)
GOSUB blink
PULSOUT 15, 1200
SEROUT 15, 16468, [noparse][[/noparse]"!x!", counter.HIGHBYTE, counter.LOWBYTE, name]
SERIN 8, 16468, 40, send, [noparse][[/noparse]WAIT("!!!"), namen]
IF (namen <> name) THEN
GOTO send
ENDIF
however, it stops 'blinking' after two or three times regardless of whether the central unit is on or off. if its on, then it pings and only takes about one run through for the data to get through. If its off, then it might blink three times or four times, or 8 times, but it will always stop blinking.
HELP
Post Edited By Moderator (Chris Savage (Parallax)) : 7/26/2007 5:39:50 AM GMT
The project i'm working on requires three independent units communicate over RF to a central unit. The way i set it up is they keep transmitting and listening for the head unit to ping their name back - in which case they'll know that the transmission went through.
heres a section of the code:
send:
namen = 0
PAUSE (name)
GOSUB blink
PULSOUT 15, 1200
SEROUT 15, 16468, [noparse][[/noparse]"!x!", counter.HIGHBYTE, counter.LOWBYTE, name]
SERIN 8, 16468, 40, send, [noparse][[/noparse]WAIT("!!!"), namen]
IF (namen <> name) THEN
GOTO send
ENDIF
however, it stops 'blinking' after two or three times regardless of whether the central unit is on or off. if its on, then it pings and only takes about one run through for the data to get through. If its off, then it might blink three times or four times, or 8 times, but it will always stop blinking.
HELP
Post Edited By Moderator (Chris Savage (Parallax)) : 7/26/2007 5:39:50 AM GMT
Comments
You don't show how name, namen and counter are defined, why namen is reset each time, or what values for namen can be expected in the Serin statement
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Overall, what you want to do is pretty reasonable. Don't quite see why you PULSOUT the same pin you are using for serial comm, though.
But, I think with the field units all just blasting away, your chances of success are less than if you let every field unit just sit and listen. When a field unit sees its unique id, it will send data back to the central unit. At that point, if you want to do a check of some kind, you have the conversation limited to a single master-slave.
To set up a classic master-slave arrangement, in your SEROUT line, let "!x!" be a unique address for one slave. When the appropriate slave sees the address, it responds, and the master's SERIN command grabs whats coming in and either stores the info or acts on it. Then the master fires out another SEROUT with another unique id and a second slave responds, and so on.
Doing it this way gives predicabilty to the communication. This system has worked for me with 5 or more slave units, wired or wireless communication.
Cheers,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tom Sisk
http://www.siskconsult.com
·
Could you give an idea of what the time spans are for "when the slaves are done with their calculations.". If that is a relatively long and random time then it is possible to have multiple devices with little (but finite, as you know) chance of collision. A statistician can calculate the odds.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
http://www.parallax.com/detail.asp?product_id=28180
and i have a total of 4 receivers and 4 transceivers...when you say to send a preamble to silence the data slicer do you mean litterally send a string of data - 5555?
The three units are done anywhere from 500ms to 2s. They do finish at random times· - it is essentially these times that i am broadcasting. When they're really close together they finish almost simultaneously, however when they're far apart there is a significant pause between terminations.
The way i do it now is pause a function of these times between transmisisons which keeps collisions at a minimum.
The preamble is a binary pattern of %01010101..., which happens to be the number 5=%0101, or HEX $55 for a whole byte. The AM transmitter is keyed on an off repeatedly and the receiver can see that and set its automatic gain to the optimum level to "slice" between the zeros and the ones before it gets to the meat of the transmission. So your transmission would look something like this:
SEROUT 15, 16870, [noparse][[/noparse]REP $55\3,"!x!", counter.HIGHBYTE, counter.LOWBYTE, name] '<- note change to 2400 baud
What that does is send 3 repetitions of the on off pattern, then your ID header and then your data. Three repetitions should do it, but even one might work. On the receiving master end the SERIN command ignores the repeating pattern but has a WAIT("!x!") and then receives the data bytes. When the master transmits, it does the same thing, REP $55\3 preamble followed by the unique handshake that you have as WAIT("!!!"),namen".
The SEROUT above sends 8 bytes, which will take about 35 milliseconds. Are you doing some kind of ultrasonic+RF positioning system?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Is there a reason i might not want to do 9600? When you say about 35ms for 8 bytes do you mean @ 2400 baud? Also do you know off hand what the correlation for the number in the serout syntax and actual baud rate is?
As I know close to nothing about RF this has been incredibly helpful Tracy, I really appreciate your time.
Thanks again,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Lenny Bogdanov
Systems Concept Center
I took a look at the Parallax documents for that transceiver pair and they do indeed use 9600 baud in the BS2 example. Instead of the $55 preample, they suggest a single 2.4 millisecond PULSOUT to the transmitter, and I see now that you have that in your program. I still think that the $55 would serve better if the signal strength drops.
One thing I would change in my suggestion is to separate the preamble from the actual data by at least one byte time, so that there would not be any ambiguity about the start bit.
SEROUT 15, 16468, [noparse][[/noparse]$55] ' one byte preamble followed by delay time before next statement
SEROUT 15, 16468, [noparse][[/noparse]"!x!", counter.HIGHBYTE, counter.LOWBYTE, name] '<- back to 9600 baud,
or with pacing...
SEROUT 15, 16468, 1,[noparse][[/noparse]REP $55,"!x!", counter.HIGHBYTE, counter.LOWBYTE, name] '<- 9600 baud with pacing between bytes.
That would take about 12 milliseconds to transmit.
The manual has the formula for computing baud rate, under SEROUT and SERIN.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com