Baseball Pitcher Finite State Machine

This academic project was completed in July 2020 for my Microprocessors class (ELET 3405). This course taught me the principles of microprocessor architecture and assembly language programming using the ARM family of microprocessors.

The idea was inspired by my experience playing baseball and the difficulty of approaching breaking-ball pitches. This FSM controller allows batters to practices hitting fastballs and curveballs in a specific, repetitive pitch sequence.

Looking back at this FSM, it was my most enjoyable project and it helped me visualize the application of state machines.

Design

Tools and Technologies:
Block Diagram
Module Intialization

The initialization of the module includes the input for our continuous clock, reset switch, timeout sensor, and base sensor. The reset switch is utilized to completely turn off the machine, whereas the timeout sensor brings the machine back to its initial state, which is “no pitch”. This state is indicated by the red LED.


Reset and "No pitch" State

The machine will not initialize unless the reset switch is turned on. The machine will remain in the “no pitch” state until the timeout sensor is NOT utilized. The “no pitch” state also sets the initial values of all outputs, including the release for the pitches, counters, and all other LED’s.


"Choose pitch" State

If the batter has not called timeout, the machine moves on to the next state, which is selecting the pitch sequence desired by the batter. This state is indicated by the green LED. The state will not begin assessing the base sensor input until 5 seconds has passed, which is where the choice counter is utilized. If the base was not tapped by the bat, it will transition to the states of the first sequence. If it is tapped once, it will transition to the states of the second sequence.


"Fastball/Curveball Pitch" States

These are the states that follow the pitch sequence selection. If the first sequence is chosen, the yellow LED indicates a fastball will be thrown utilizing the “fastball release” output sensor. The first pitch counter will count down 2 seconds before the release to give the batter more time to prepare for the pitch. Once the pitch is thrown, the machine transitions to the second pitch of the first sequence, which is a curveball. The blue LED indicates this pitch. The second sequence does the opposite of the first sequence, throwing a curveball first and fastball second. Once the second pitch is thrown in both cases, the machine transitions to the “after pitch” state.


"After pitch" State

The “after pitch” state is a cooldown for the machine before it goes back to the initial state. It is indicated by the red LED as well, and it will automatically go back to the “no pitch” state after 2 seconds. The default case exists to provide an output for any possible errors throughout the state machine.


Testbench

Module Code

Compiled a testbench to stimulate the DUT and simulate each state in the FSM utilizing ModelSim.


Sample ModelSim Output

This waveform successfully simulates the first sequence of pitches.


Quartus Final FSM Output

This is the Finite State Machine diagram that is generated by the emulated FPGA in Quartus II Prime Software