Software
State Diagrams
The robot has 2 hierarchical state machines, 2 flat state machines and 1 service.
1. MasterGameHSM: Top level hierarchical state machine determining the robot's behavior. Handles the transition between waiting for permits, playing the game, and handling collisions.
2. AccelerometerFSM: This flat state machine is in charge of the constant communication with the accelerometer. 3. SPUDHSM: Top level hierarchical state machine. Transforms the queries of the SPUD to the query command.
4. DriveService: Handles the PI control of the motors to translate and rotate. 5. BumperFSM: Debouncing of the bumper switches |
The system has 8 event checkers:
The Robot has 7 interrupts:
- Check4MinerRing: Uses the tape sensor to detect when the ring of the MINER is close enough to the electromagnet.
- Check4Beacon: Checks if the period of the signal detected by the IR transistor corresponds to the desired MINER.
- Check4FrontBump: Checks for falling edges from the depression of switches on the front bumper.
- Check4RearBump: Checks for falling edges from the depression of switches on the rear bumper.
- IsI2C0Finished: Checks when the I2C transfer completes (used for color sensor).
- ColorChanged: Determines if the color perceived by the color sensor on the robot has changed. It ignores white, black, and unknown colors.
- Check4Data: Checks if the INT1 pin from the accelerometer has produced a rising edge. This signals there is data ready to be read from the meter.
- Check4Tap: Checks if there is an acceleration spike.
The Robot has 7 interrupts:
- AcclFSM_EOTISR: Occurs once the SPI communication with the accelerometer is over
- EncLib_Capture0ISR: Uses a timer register to capture the period of the motor encoder (0). Restarts the stall timer.
- EncLib_Capture1ISR: Uses a timer register to capture the period of the motor encoder (1). Restarts the stall timer.
- EncLib_StallISR0: If this timer reaches 0, indicates that the motor 0 has stopped turning. Sets a stop flag and restarts the timer.
- EncLib_StallISR1: If this timer reaches 0, indicates that the motor 1 has stopped turning. Sets a stop flag and restarts the timer.
- DriveService_PIctrlISR: Implements PI control of the motors RPM. It also handles position control when the drive service is in position mode.
- MinerLib_BeaconISR: Calculates the perceived IR signal period and stores it in a module variable.
- SPUD_EOTISR: SPUD end of transmission interrupt.