Communications
Zigbee Communications
As the project specification stressed interoperability among the different helms and watercraft in the class, a communications standard for the project had to be created. Each helm and each watercraft were outfitted with a Zigbee wireless module, which allows each to both send and receive packets of data.
Each packet, per the Zigbee standard, must contain a certain number of 'overhead' packets in addition to the actual data which is being sent. These overhead bytes of data include a start byte, the length of the data being sent (in bytes), an API structure, and a checksum for the detection of errors in transmission. The API structure in turn is composed of a command, frame data, the address of both the sender and the intended recipient, several options that may be selected by the sender, and finally, the actual data which is being sent.
The overhead bytes alone account for 9 bytes of every Zigbee transmission. In addition to these required bytes, the ME218C classwide communications protocol, designed by a committee of students, requires that each transmission furthermore include 3 bytes of data for communications between the helm, craft, and Admiral.
The bytes, in order, are:
- Data Byte 0: A Header byte, which denotes what type of message is being sent, and how the 1st and 2nd bytes should be interpreted. Most messages in the game are 'Navigation' messages desigend to control watercraft, but other messages serving special functions such as delivering Admiral commands, pairing helms and craft, and acknowledging the proper receipt of communications are also included in the specification.
- Data Byte 1: A Navigation byte, which contains a direction nibble and a speed nibble in the case of a navigation message
- Data Byte 2: A Special byte, which in the case of a navigation message contains one bit for each of two 'special' functions, which may be decided by the team. The byte also includes a water nibble that communicates levels of water flow between 'off' and 'full on'
The navigation and special bytes only contain navigation and special data for navigation messages. For other types of messages, these bytes have a different significance.
The full specification, with all the details for all of the possible messages, as well as the required responses to each, is included in the communications protocol (.DOC)
Inter-chip Communications
A second requirement of the project was the implementation of inter-chip communication within either the craft or the helm. Due to the limitations of the hardware PWM subsystem on the PIC16F690, as well as this requirement, SPI communications was used between a single ''master' PIC that handled radio messages on the craft, and three 'slave' motor driver PICs, each of which operates a different motor. Because the EUSART lines for the 'master' PIC were already used to send and receive data between the PIC and the Zigbee module, SPI was used to communicate between the master and slave PICs .