• Home
  • Meet the Team
  • About the Project
  • Hardware
  • Software
  • Electronics
  • Bill of Materials
  • Gems of Wisdom

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:

Picture
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.

pseudocode:
event checkers
motor state machine
helper functions - for controlling motors, displaying win, and initializing
 

header files:
EF_Events.h
EventCheckers.h
Conveyor1SM.h
Conveyor2SM.h
Conveyor3SM.h

code listings:
EventCheckers.c
Conveyor1SM.c
Conveyor2SM.c
Conveyor3SM.c
TestMain.c
EF_PostList.c
EF_CheckEvents.c
Powered by Create your own unique website with customizable templates.