CS281: Computer Organization

Lab: Finite State Machines -- Garage Opener

Purpose
Learn to specify and implement a finite state machine.
Method
Design and build a simulation of a garage door controller. Represent a finite state machine using a state diagram, truth tables, and logic circuits.
Files to Use
What to Hand In

Specifications

You are to design a controller for a garage door opener with the following specifications.

Inputs

top (T)
When the door is at the top, this input is true.
bottom (B)
When the door is at the bottom, this input is true.
eye (E)
There is a light beam across the doorway with an electric eye. When the electric eye detects the light beam, this input is true. If the light beam is blocked, such as by a small child standing in the doorway, then this input is false.
go (G)
When the button on the remote control is pressed, this input becomes true. When the button on the remote control is released, this input becomes false.

Outputs

up (U)
When this output is true, the motor moves the door upward to open it.
down (D)
When this output is true, the motor moves the door downward to close it.

If both U and D are false, then the motor will be stopped. The U and D outputs should never both be true at the same time to avoid damaging the motor.

Operation

The input from the button on the remote control (G) will be processed by the one-shot circuit, which happens to be a finite state machine. This circuit prevents the G input from staying true for more than one clock cycle, even if the button is held down for a long period of time.

  1. Assume that the clock rate is 10 Hz so that the controller will respond to changes in the inputs within one tenth of a second, quickly enough to avoid causing injury or damaging the motor.
  2. If the door is closed, pressing the button (G = 1) causes the door to begin opening.
  3. If the door reaches the top (T = 1) while opening, the motor will stop.
  4. If the door is open, pressing the button (G = 1) causes the door to begin closing.
  5. If the door reaches the bottom (B = 1) while closing, the motor will stop.
  6. If the electric eye detects that the light beam has been interrupted (E = 0) while the door is closing, the door will reverse direction and begin opening. This is an important safety feature, so the electric eye should take priority over the other inputs in this situation.
  7. If the light beam is interrupted (E = 0) while the door is opening then the door continues opening.
  8. Pressing the button (G = 1) while the door is opening causes the door to stop. Pressing the button again (G = 1) causes the door to begin closing.
  9. Pressing the button (G = 1) while the door is closing causes the door to reverse direction and immediately begin opening.

Procedure

  1. Draw a state transition diagram for this finite state machine. Use four states numbered as follows: closed (00), opening (01), open (10), and closing (11). Each transition (edge) should be labeled with the values of the inputs (TBEG) for which it is taken. Use X to indicate "don't care" for input values when appropriate.
  2. Construct a compressed truth table corresponding to your state transition diagram. Use X to indicate "don't care" for input values. This table should be less than a quarter of the size of the full truth table. Use the tables in the file garage.doc or garage.pdf.
  3. Complete the full truth table corresponding to the state transition diagram and the compressed truth table. The columns in this table should be (from left to right): current state, T, B, E, G, next state. There should be one line for each combination of current state and input values (64 lines).
  4. Construct a full truth table for the output. The columns in this table should be (from left to right): current state, U, D. There should be one line for each combination of state values (4 lines).
  5. While viewing the NextState_0 circuit in the file garage.circ, select "Analyze Circuit" from the "Project" menu. Complete the table using your values from the full truth table, then click on the "Build Circuit" button. Does the minimized circuit correspond to your compressed truth table?
  6. Build the Output_0 circuit in the same manner.
  7. Test the operation of the completed finite state machine with the main circuit in the file main.circ. Choose "Ticks Enabled" from the "Simulation" menu. Observe the response to changes of the input signals. Can you cause the state machine to visit every state? Can you cause the state machine to follow every possible transition?
  8. Implement the circuit on the breadboards. Keep organized, with portions of the circuit separated from one another.