Communications Protocol
One of the requirements for the game was that every LUC must be able to send commands to every HZV, and every HZV must be able to respond to these commands appropriately. To make this possible, all ME218C teams had to agree upon a standard protocol for deciphering radio communications.
XBee Protocol
The XBee Module communicates with the PIC microcontroller via UART asynchronous communication. Before discussing the ME218 specific protocol, it's helpful to see where this fits into the XBee's API.
To transmit a message, the PIC must first send a 0x7E start delimiter followed by the MSB and LSB describing the length of the frame data. Next, the PIC sends the frame data, which consists of the frame ID (we kept this at 0 to disable XBee response messages), the destination address, an options byte, and finally the user-defined message (up to 100 bytes, but we only used 7). The last byte of the XBee message is a checksum, which is used to check for transmission issues and invalid messages.
To transmit a message, the PIC must first send a 0x7E start delimiter followed by the MSB and LSB describing the length of the frame data. Next, the PIC sends the frame data, which consists of the frame ID (we kept this at 0 to disable XBee response messages), the destination address, an options byte, and finally the user-defined message (up to 100 bytes, but we only used 7). The last byte of the XBee message is a checksum, which is used to check for transmission issues and invalid messages.
User-Defined Protocol
Each team sent a member to the Great Committee of Communications, where many hours were spent arguing and synergyzing, until at last a protocol was decreed. From the long-tables of Peterson Lab was produced a document, to which every team must adhere, else face the wrath of Ed.
In said document, the following commands were procured.
In said document, the following commands were procured.
Handshake/Connection
Initially, the LUC is waiting for the connect buttons to be pressed. Once this is done, the LUC tries to initiate contact by sending an identifier 0x03 followed by a 0xED. If this was received by the HZV, it in turn sends back a 0x03 followed by a 0xCD. This tells the LUC that it indeed has connected and can begin sending commands to control the boat.
Boat Commands
The boat commands consist of an identifier followed by a speed byte, a direction byte, an action byte, and 3 "special function" bytes that can be used to the discretion of each individual group. Our group chose not to use special functions, but we included controls for them (2 potentiometers and a button) in the event that another team would choose to include them.
The speed and direction bytes are signed chars. A value of 127 translates to full speed forward and right turn for speed and direction respectively, whereas a value of -128 translates to full speed reverse and left turn. The attack byte uses only the last bit and translates to an "attack" command if the bit is high.
The speed and direction bytes are signed chars. A value of 127 translates to full speed forward and right turn for speed and direction respectively, whereas a value of -128 translates to full speed reverse and left turn. The attack byte uses only the last bit and translates to an "attack" command if the bit is high.
Necromancer Commands
The necromancer is a devious PIC that broadcasts commands to all zombie boats, ordering them to reverse forward and backward, left and right, and change their speed at the whim of the almighty Ed (or maybe G.I.). The structure of these bytes were determined by Ed.
Connection
Whenever the HZV was receiving commands from the LUC, it would send ACK messages back to the LUC consisting of only a 0x04 identifier at a 5Hz rate. If the LUC didn't get an ACK for more than 1 second, it would assume loss of connection and indicate to the user that it was ready to select another boat. If the HZV failed to receive an LUC command for more than 1 second, it would indicate to the field that it was disconnected and go back to waiting for connection.
communication_protocol_revb.docx | |
File Size: | 189 kb |
File Type: | docx |