RE: New NQC API for RCX-Spybot or RCX-RC communication
"Dick Swan" <[email protected]>
| Newsgroups | gmane.comp.hardware.lego.robotics |
|---|---|
| Organization | None |
| Message-ID | <[email protected]> |
Minor correction and expansion to Juergen's description. Messages are currently preceded by an optional "preamble" sequence of "0x55 0xFF 0x00". When in "look for start of new message" mode, any of these three bytes are simply discarded/ignored by the RCX. They are completely optional and can be eliminated if you want to slightly reduce message transmission time. If one of these bytes is received incorrectly, then the RCX will think it is a "command" or "opcode" byte and the message reception will be corrupted. As well, any number of "preamble" bytes can be sent. The ROM state machine for message reception has a built-in timeout of 30 msec. If, during message reception, 30 msec elapses between characters then the state machine is reset to "look for start of new message". There's a bug in the ROM state machine that requires, for robust communications, that you must insert this delay between any messages if you're going to modify the number of preamble bytes sent. NOTE: not all PC based software is as understanding of the preamble bytes as the ROM state machine. Some implementations require the "0x55 0xFF 0x00" to be received correctly. Infrequently, the first byte of a message is corrupted. The ROM state machine will interpret a corrupted 0x55 as an opcode/command byte and the following 0xFF will be treated as a mismatched complement byte which resets to "look for start of new message". The 0x00 will be discarded as a preamble byte and then the message reception will precede OK. -----Original Message----- From: [email protected] [mailto:[email protected]]On Behalf Of Juergen Stuber Sent: Sunday, May 29, 2005 5:45 AM To: [email protected] Subject: Re: New NQC API for RCX-Spybot or RCX-RC communication Hi Gabriel, "Gabriel Petrut" <[email protected]> writes: > I am trying to emulate the infrared protocol on a > different microcontroller. > I want it to be able to be controlled by a Lego remote and > to send/receive messages to Lego devices. > What format does the Lego Remote protocol has? the format is 38kHz or 76kHz modulated infrared, with a standard 2400 baud serial format of 1 start bit, 8 data bits, odd parity, 1 stop bit (modulated infrared on = 0, off = 1). The packet format consists of a start byte 0x55, after that each byte is followed by its complement (this limits IR to be on half the time). The 0x55 may be lost or mangled on reception. The content bytes start with 0xff, then follow a command byte, data for the command and a checksum (all bytes with their complement as described above). The remote sends RemoteCommand (0xd2) and 16 bit data with one bit for each key. The commands are documented in the Mindstorms SDK (see http://mindstorms.lego.com/sdk2point5/default.asp) in the file "LASM Byte codes.pdf". Or see http://graphics.stanford.edu/~kekoa/rcx/ . > My microcontroller can do a standard protocol like 8 > bit command followed by 8 bit device. If you want to do this you need your own RCX firmware, it is probably easier to change the microcontroller program. Hope this helps Jürgen -- NO to software patents -- stop the European patents directive Jürgen Stuber <[email protected]> http://www.jstuber.net/ gnupg key fingerprint = 2767 CA3C 5680 58BA 9A91 23D9 BED6 9A7A AF9E 68B4