Message Timing



IR communication faces two timing issues.

First of all, communication in any form takes time. Even though IR travels at the speed of light (186,000 miles per second), it takes time to send each of the pulses that makes up a message, and it takes even more time for the receiving RCX to interpret the message. If a second message byte arrives while the RCX is still processing the last one, it will completely miss the new byte. If you want to be able to send messages quickly, it's important to know how fast you can send each byte to be fairly certain that the other RCX won't miss any.

Furthermore, each RCX has just one component that is used to both send and receive messages. If you try to read a message too soon after sending one, you might accidently just read a reflection of the message you just sent! Therefore, you need a short break between sending messages and trying to receive a new message from the other RCX.

The next question is, of course, how long do you need to wait in each case? We'll figure this out in two separate test programs.

For the first problem, we want to figure out how quickly we can receive messages. One way to do this is found in the following files:

Sender

sendnumbers.nqc

HTML version

Receiver

receivenumbers.nqc

HTML version

Download each program to a separate RCX. Run the "Receiver" first, then hit run on the "Sender". The Sender will each possible message byte (1 through 255), and then display how many tens of milliseconds it took to send all of them. The Receiver will display a count of how many messages it received. Once both numbers have stopped increasing, you'll have how many messages an RCX was able to receive over some amount of time. Write both numbers down. Do this a few times. You should get results similar to these:

10s of ms

Number Received

416

91

420

91

423

92

422

91

419

92

The average over all the trials was 91.4 messages received in 4.2 seconds (420 tens of milliseconds), or about 21.8 messages per second. If we take the inverse of that answer, we get how many seconds we need for one message, which is about 0.046, or 46 ms. To be safe, then, we should pause for 50 ms between sending messages.

For the second problem, we need to know how long after sending a message a new message can be read.

Sender/Receiver

sendreceive.nqc

HTML version

Leave the "sendnumbers.nqc" program from the last test on one RCX, and program the other RCX with the above file. All this new file does is send a message, then wait until it receives a message, and displays how long it took to receive the new message. Start the Sender program running first, but start the Sender/Receiver program as soon as you can afterwards, so that the Sender is still sending messages. Do this several times. Running this seven times, I got numbers from 11 to 20, with an average of 14.9 tens of milliseconds. To be safe, though, you should be sure to wait at least 200 ms between sends and receives. (Another way of looking at this is that one RCX should wait that long before sending a response to a message, in order to be sure the first RCX will be able to receive the message.)



Return to Intro to IR

Home


LEGO, LEGO Mindstorms, Robotics Invention System, and RCX are registered trademarks of the LEGO Group, Inc.

This project is funded by Carnegie Mellon's Undergraduate Research Initiative. These results represent the views of the author and not those of Carnegie Mellon University.


All material contained within this site is
© 2003 Rachel Gockley
except where otherwise noted.