All software files for the Oilus PIC32 microcontroller are accessible in our 0ILUS PIC repository.
All software files for the Follower PIC32 microcontroller are accessible in our NEDMO PIC repository.
0ILUS
BoatHSM
Consisted of three states, the top-level BoatHSM manages the paring status of 0ILUS. BoatHSM initializes into Waiting For Pair Request state and starts listening to the pairing request from Xbee Service. The BoatHSM transits to Waiting For Control Packet State when receiving a pairing request. When a valid control is received in Waiting For Control Packet state, the BoatHSM transits to Paired state and starts updating movements and fuel level.
If the 0ILUS has not received any valid control commands for 4 seconds in either Waiting For Control Packet state or Paired state, the BoatHSM transits to Waiting For Pair Request state.
The paired status indication servo is set to the paired position when BoatHSM enters Paired state and set to the unpaired position when BoatHSM leaves Paired state.
DuringPairedState
The Paired lower-level state machine keeps track of the fuel level and controls the boat's movements. The Paired state machine is composed of two states: Fuel Not Empty and No Fuel. In Fuel Not Empty state, valid control commands may result in active motion.. While the thrusters and pump are disabled in No Fuel state. The Paired state machine enters the Fuel Not Empty state with full fuel when 0ILUS first pairs with NEDMO after 0ILUS is turned on.
The Paired state machine updates the thrusters power and pump states and checks if there are any active movements when a valid command is received in Fuel Not Empty state. if any movements are happening, The Paired state machine decreases the fuel level by one.
When the fuel level decreases to zero, the Paired state machine transits from Fuel Not Empty state to No Fuel state. The Rfueled event increases the fuel level and sends the Paired state machine from No Fuel state to Fuel Not Empty state.
The Paired state machine has a 5 Hz timer for sending fuel messages. The 5 Hz timer starts when entering Paired state and stops when exiting Paired state. When the 5 Hz timer expires, the Paired state machine restarts the timer again and sends the sending fuel message request to Xbee Service.
XbeeService
The Xbee service serves as the bridge between the Xbee transceiver and the BoatHSM.
The Xbee service decodes the incoming data when it receives a complete message. Based on the message decoded, Xbee service posts Request Received, Valid Control Received, or Refueled event to BoatHSM.
The Xbee service sends an acknowledgment message or fuel message to the Xbee transceiver when requested by BoatHSM.
NEDMO
List of Events
Fuelcon HSM
Fuelcon informs the user of the fuel level and receives input related to pairing and refueling. To manage these inputs and outputs, FuelconHSM communicates with XbeeFSM, which is part of NAVCON and handles various events. FuelconHSM starts in an unpaired state. When the user selects the target OILUS using the knob and presses the button to request pairing, this event is sent to XbeeFSM. If XbeeFSM successfully communicates with OILUS and receives an acknowledgment packet, it posts the ES_PAIRING_SUCCESSFUL event to FuelconHSM. Upon receiving this event, FuelconHSM activates its sub-state machine, PairedSM. If XbeeFSM does not receive any packets from OILUS within 4 seconds, both XbeeFSM and FuelconHSM return to the unpaired state.
PairedSM consists of two sub-states: Idle and Refueling. While the NAVCON user operates the boat, PairedSM remains in the Idle state. However, once refueling is requested by the users at any moment, PairedSM transitions to the Refueling state. In this state, it quantitatively measures the large-scale motion of the Fuelcon user to determine the amount of refueling to be provided.
Refueling can be terminated for three reasons:
If sufficient large-scale motion is detected over a sufficient amount of time, the maximum refueling amount is used as a parameter to post the ES_REFUEL_SUCCESSFUL event to XbeeFSM, and it transitions to the Idle state.
If enough time has passed but the large-scale motion is insufficient, after a grace period of 2.5 seconds, the refueling amount corresponding to the accumulated motion (less than the maximum) is used as a parameter to post the ES_REFUEL_SUCCESSFUL event to XbeeFSM, and it transitions to the Idle state.
If any user control input other than large-scale motion is detected before the above conditions are met, the ES_REFUEL_INTERRUPTED event is posted to XbeeFSM immediately, and no fuel is awarded.
Additionally, FuelconHSM communicates several pieces of information about the current state machine status through predefined beep (buzzer) patterns and timer interrupts, including:
Unpaired state | Attempting to pair with an OILUS | Paired state | Refueling in progress | Refueling completed/interrupted.
Navcon
Navcon controller has 1 joystick to control direction of the boat and 3 buttons to control the pump. The event checker constantly check the user control input from the joystick and buttons and encode the most updated control input to the control command and send to 0ILUS through XBee.
Navcon Control features
Joystick X direction: controls CW and CCW rotation of the 0ILUS
Joystick Y direction: controls forward and backward motion of the 0ILUS
Pump up button: increase the pitch angle of the pump nozzle
Pump down button: reduce the pitch angle of the pump nozzle
Shoot button: turn on and off the pump
XBee Communication
The wireless communication between the boat (0ILUS) and controller (NEDMO) is established using XBee modules. They are wireless communication modules that use Zigbee protocol. They are widely used in wireless control and sensor networks due to their low power consumption, ease of use, and reliability.
Both 0ILUS and NEDMO has a XBee module connected with TX and RX pins on a PIC32 microcontroller , the XBee is responsible for receiving data from another Xbee and transmitting data to its corresponding PIC32 using UART protocol.
To ensure that all teams are capable of controlling 0ILUS of other teams, a Communication Committee was formed to define details and specifications of 218C communication protocol. 2024 ME218C communication protocol is accessible from here.
Summary of Commands
There are 5 types of Commands defined by communication committee to support the functional requirements listed in the project handout and ensure any 0ILUS can be controlled by any NEDMO.
Control (NEDMO to 0ILUS): Control commands that encode information about joystick and button control
Fuel Status (0ILUS to NEDMO): encode information about fuel level of 0ILUS
Request to Pair (NEDMO to 0ILUS): encode 0ILUS ID information to pair NEDMO to 0ILUS
Pairing Acknowledgement (0ILUS to NEDMO): encode information to acknowledge the pairing of NEDMO and 0ILUS
Refueling (NEDMO to 0ILUS): encode refueling information to add fuels to 0ILUS