Microcontroller Software Details

We chose to implement a State Machine/Event Checking framework, provided to us by Professor Carryer. Given the structure of our game, we designed a state machine for the monkey pulley system and replicated it three times in order to control the three motors with feedback from their respective sensors. The state machine diagram for one motor is provided below:

The three state machines perform exactly the same tasks when it comes to directing the motor. The first state machine also executes some game level functions, like determining whether the user has won or lost, displaying the results, and setting the game timers. As such, the Conveyor 1 state machine has an additional Win/Loss Game state, indicated by the red box. Once this state is completed (i.e. win or loss is displayed), the motor SM1 posts an event to all SMs triggering the reversal of all the motors, in order to move towards the reset stage.

Here are links to pseudocode, header files, and code listings for each module we developed. Please refer to Conveyor1SM.h and Conveyor1SM.c for comments on state machine and helper functions, since SM2 & 3 are more simplified copies (same helper fxns and no game level control). The code to execute the Event Framework is not included.