Water Craft: Software | ||
|
Home
The Game Water Craft Microcontrollers Software Electronics Mechanics Helm Communications Gems of Wisdom Media |
Each PIC on the craft was coded individually to perform functions specific to that PIC. Full assembly code for the Smart PIC may be found here and the full assembly code for the Dumb PIC may be found here.
Pseudocode for the craft as a whole may be found below. Pseudocode: · Initialize ports · Configure communication to xBee UART o 9600 baud · Loop until iButton is detected o Check for PING from admiral o Check for iButton · Read iButton · Loop until IBUTTON broadcast with correct iButton ID is heard o Check for messages · Store address of helm sending IBUTTON command with correct address · Send MATCHED command to that helm · Activate correct team indicator (blue for even iButton #, red for odd) · Start 3 second timer · Loop until HARD_RESET is received from admiral o Listen for messages § If message received · Reset 3 second timer · If message received o Check byte 0 § If admiral message (byte 0 = 0x04) · If STAND_DOWN received o Turn off all actuators, water, special abilities o Send STAND_DOWN_RECEIVED to helm o Wait for acknowledgement from helm · If SOFT_RESET received o Turn off all actuators, water, special abilities o Send acknowledgement to admiral · If PING received o Send ping response to admiral · If HARD_RESET received o Turn off all actuators, water, special abilities o Break out of message check loop · If navigation command received (Byte 0 = 0x02) o Check helm sending command § If paired helm · Respond according to communications protocol § If not paired helm · Ignore message o If 3 second timer expires (no messages detected during 3 second period) § Turn off all actuators, water, special abilities · Disassociate from helm o Reset helm address o Reset iButton ID · Return to checking for iButton | |