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.
- Your system is the embedded microcontroller and its associated program and data memory.
- Unless otherwise noted, external sensors and switches provide contact closure digital inputs to the controller.
- The controller receives the following inputs: remote pushbutton indication, full open position, full closed position, motor overcurrent indication, infrared beam interruption.
- The controller generates the following outputs: motor up, motor down, infrared beam on.
- An external motor power module accepts two digital inputs from your controller: motor up, motor down. The motor will be stopped when both signals are inactive. As a safety measure, the power module will stop the motor and enter an error state, if both control inputs are active.
- The infrared beam goes across the garage opening a small distance above the floor level. When it is turned on, the infrared beam interruption input is active when an object blocks the beam's path. The input is inactive, if the path is clear or the beam is off.
- The motor overcurrent input indicates that the motor is drawing too much current and may be jammed. The motor overcurrent input is inactive when the motor is stopped
or the motor reverses direction.
Controller Requirements
This section specifies the functional requirements for your system:
- The controller will raise the door when the user presses the remote pushbutton and the door is in the full closed position.
- The controller will stop raising the door when the full open position is reached.
- The controller will lower the door when the user presses the remote pushbutton and the door is in the full open position.
- The controller will stop lowering the door when the full closed position is reached.
- The controller will stop the door if the user presses the remote pushbutton while the door is moving.
- 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.
- 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.
- The controller will raise the door if the door is lowering and a motor overcurrent indication is received.
- The controller will stop the door if the door is raising and a motor overcurrent indication is received.
- The controller turns on the infrared beam sensor whenever the door is lowering.
- 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:
- m - motor overcurrent detected; Clear this input when the motor changes direction or stops.
- 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.
- 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.
- A short introductory section.
- 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.
- 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.
- Statecharts for your system with discussion of design highlights. Use multiple diagrams, at different abstraction levels as necessary, to clearly show the system behavior.
- A discussion of your implementation of the statechart and event processing.
- 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 $