garagedoor document.doc

advertisement
Garage Door Opener
Armin Alaghi
Objective: In this example a garage door opener controller is to be designed.
Door Opener Specification:
1. The door can be closed, open or blocked.
2. There are four switches – they are Closed, Open, Blocked and Push - that control
the state of the door.
3. Your design will include the following outputs which are sent directly to the door
motor:



Go Up
Go Down
Stop
4. The Initial state of the door is closed and the Stop output is initially active. The door will
remain in this state until the Push Button is pressed. After receiving a pulse on the Push
Button, the Go Up output is activated and the door starts going up.
5. The door automatically stops whenever it reaches the top (The Open sensor of the door is
activated at this point to make the door stop.), the Go Up output becomes inactive and the
Stop output becomes active again.
6. The door remains in its current state until it receives another pulse on the Push Button
which makes the Go Down output be active. The door goes down until it is completely
closed. At this point, first the Closed sensor becomes active to stop the door from moving
downward and consequently the Stop output will be activated.
Assumptions:
The above specification describes the overall functionality of the door opener. To
design properly the following notes must be considered carefully.

Pressing the Push Button while the door is on the way up or down, stops the door.
And pressing it again changes the door's direction. For example, assume that the door
is opening and it is in half way up. Then if we push the button the door will stop. It
will remain in this state until the next pulse on the Push Button, which makes it go
down.

If the doorway is blocked (the Blocked sensor activates) while the door is going
down, it will automatically stop. It will go down again if and only if the blockade is
removed and the Push Button is pressed.
Design Core:
The design is a sequential circuit. Here, we have implemented our design using a Moore
machine. The State diagram of the design is shown in Fig. 1.
Design Prototyping and Testing:
We used Quartus II version 4.0 to program an Altera FLEX 10K device on an Altera UP1
development board.
We modeled our design by Verilog HDL Language (“doorpen.v"). The top level entity of
this project (“garagedoor.bdf”) is a schematic file, which contains the design core, as well as the
circuits used for the design's interface.
The Closed, Open and Blocked inputs of the core are directly connected to the
FLEX_SWITCH1, FLEX_SWITCH2 and FLEX_SWITCH3 relatively (pins #41, #40 and #39).
The FLEX_PB1 (pin #28) is the Push Button input and must be debounced. We used a switch
debouncing circuit named “Filter” for this purpose. It provides a Clean Switch, as well as
a Slow Clock, which are both used in the design core. The Slow Clock is created by
dividing the System Clock (pin #91) with an Altera Megafunction, LPM_COUNTER.
Another entity named “Onepulse” is used to send only one pulse whenever the button is pushed.
Using Glue Logic, we connected the outputs of the core to another entity named
"Motorturner". The Motorturner has two inputs (Enable and Left Right) and its outputs are the
Seven Segment Displays. The circuit uses a simple ring counter. When enabled it makes the light
turn in the SSD Clockwise or Anti-Clockwise according to the LeftRight input.
The Motorturner has a preset input which brings the Motorturner to a correct state if it's
initialized one is undesired.
The design core has a Reset input to bring the machine to its initial state (Closed). The
two latter inputs (Motorturner’s Preset and Dooropen's Reset) are connected to FLEX_SWITCH8
(pin #33), which is considered as our global reset.
The outputs of the Motorturner are connected to the Seven Segment Displays (pins #6-14
and #17-25). Turning Clockwise means that the door is opening and turning Anti-Clockwise
means that the door is going down. When there is no turning, it means that the motor is stopped.
0XXX
XXX1
Blocked
----------Stop
XXX1
0XXX
0XXX
0X0X
00X0
Closed
--------Stop
1XXX
Opening
-----------Go Up
1X0X
XX1X
1XXX
Open
--------Stop
1XXX
Closing
----------Stop
1XXX
1XXX
Stop Open
----------Stop
0XXX
X1XX
Stop Close
------------Stop
0XXX
Figure 1. The Design Core’s State Diagram
1XX0
Download