Garage Door Opener Controller
State Machine Project

For this project, you are designing the controller embedded in a garage door opener. The main function for this controller is to respond to user commands to raise and lower the garage door. This is done primarily by turning on the motor in either of its two directions and stopping when the full open and closed signals are active. There are also safety concerns that the controller must address.

System Description

This section lists the characteristics of the system in which the controller you are implementing works.

Controller Requirements

This section specifies the functional requirements for your system:

  1. The controller will raise the door when the user presses the remote pushbutton and the door is in the full closed position.
  2. The controller will stop raising the door when the full open position is reached.
  3. The controller will lower the door when the user presses the remote pushbutton and the door is in the full open position.
  4. The controller will stop lowering the door when the full closed position is reached.
  5. The controller will stop the door if the user presses the remote pushbutton while the door is moving.
  6. The controller will raise the door when the user presses the remote pushbutton and the door is stopped and the door was lowering prior to stopping.
  7. The controller will lower the door when the user presses the remote pushbutton and the door is stopped and the door was raising prior to stopping.
  8. The controller will raise the door if the door is lowering and a motor overcurrent indication is received.
  9. The controller will stop the door if the door is raising and a motor overcurrent indication is received.
  10. The controller turns on the infrared beam sensor whenever the door is lowering.
  11. The controller will raise the door if the door is lowering and an infrared beam interruption is recieved.

Implementation Requirements

Your team will capture the behavior of this garage door controller via a statechart created in Rhapsody. By the appropriate use of guards, events and actions you may be able to define the operation of this controller as only a single state. This is not an acceptable design choice.

After capturing the system behavior in a statechart, your team will implement an executable version of the system in C++.

Your controller will scan the digital inputs at a periodic rate. Model this as an orthogonal region in your door opener controller that generates events on changes in the inputs. You will generate the inputs using simulations of the motor, door, and remote, which are described next. Use shared variables to represent the digital inputs to your controller. You can assume that these are clean inputs, i.e. you do not have to do any debouncing.

The user will provide some control of your program via keyboard input. Define an input class that runs as an active object in its own thread. It will be responsible for reading user input and setting the shared variables that represent the digital inputs to your controller. Define the behavior of this class using a statechart. Use the following letters for input:

  1. m - motor overcurrent detected; Clear this input when the motor changes direction or stops.
  2. i - infrared beam interruption; Clear this input when the infrared beam is turned off. You can assume that this input will only occur when the beam is turned on.
  3. r - remote button press; Your input system should simulate a 1 second press on the button.

Your implementation will also simulate the motor driving the door up and down. Define a motor class that runs as an active object in its own thread. It will be responsibile for interpretting the controller's motor commands and simulating the door moving up and down. This class is also responsible for generating the door open and closed signals. Use variables shared between your controller and the motor simulation for the controller motor commands and door status signals. Define the behavior of this class using a statechart. Assume that it takes 10 seconds for the door to travel from fully closed to open and vice versa. This task can run on a 1 Hz period.

Your program will use standard output to show its operation. The motor should print a message whenever the controller turns it on and off, and when either door limit changes. The controller should print a message whenever it turns the infrared beam on or off.

On startup, initialize the system with the door fully closed, and the motor and infrared beam off.

Documentation Requirements

For your documentation of this project you will submit a single Word file that holds, at a minimum, the following information: (This list is not necessarily in the best order for presentation in your document.) Be sure that all diagrams are readable at 100% magnification of the document.

  1. A short introductory section.
  2. Class diagram for your system with discussion of design highlights. Use multiple diagrams, at different abstraction levels as necessary, to clearly show the system structure.
  3. A sequence diagram that shows the operation of the garage door opener controller and simulation. Start the sequence with a key press detection that starts a closed door opening and ends with the motor stopped when the door is fully opened. Include in the sequence, objects associated with both the garage door opener controller and the simulation of the non-existent hardware.
  4. Statecharts for your system with discussion of design highlights. Use multiple diagrams, at different abstraction levels as necessary, to clearly show the system behavior.
  5. A discussion of your implementation of the statechart and event processing.
  6. General comments and impressions of using Rhapsody and statecharts to model the behavior of a system and implement the state machine.

Demonstration

You will demonstrate your working controller to the instructor on the day the project is due.

Submission

Submit a single zip file that contains your Word documentation, a model directory containing your Rhapsody files, a code directory containing the program files.  In the code directory include an executable file.   You can include a readme file with any additional information I should know.  Place the zip file in the dropbox in the myCourses files area before its closing time (11:59pm on the day of class demonstrations).


$Id: DoorOpener-StateMachine.htm 173 2013-01-06 21:46:34Z jrv $