
This microcontroller design was for a final project for the Digital Systems
Lab (ECE249). The breakdown
for this project was to use both hardware circuits and software coding
to accomplish the task of designing a working elevator controller.
My partner and I split all sorts of functions into hardware sections and
software sections. I know this project may not be of any interest to you,
but this project just shows off my knowledge and capabilities in the following
areas:
The project's microcomputer controller was the Motorola's M68HC11. The hardware wiring was designed to provide interaction with the person and the elevator. Switches/Buttons are used like the real elevator for indications of the direction and floor requests. It was possible to do the whole project with code only, but the hardware section of this project was done to see if we can utilize a lot of flip-flop chips as flags to indicate the elevator's direction, present floor, and user's requests. Here is the code for this project is just to show-off that I know how to program the M68HC11.
Alot of people have been asking me for a more detailed description of this project. So, here goes.
Note: I didn't get the paper we submitted back and the project was -- well a sophomore project.
Since this was a hardware class, we used a lot of hardware chips that could have easily been implemented with software code.
Such as:
|
And those were the only core items we needed to complete the project. Extra stuff was used for user interface such as:
The SR flip flops are standard latches you learn in basic electronic classes. The price of the items can vary from your supplier. I got all of my parts for free because the College of Engineering at the University of Illinois made them all available to the students in EE. So, you are on your own on trying to figure the cost issues.
Here's the algorithm that we might have used (this is from memory so bear with me):
initial state:
direction flag ON = up
(elevator is on floor 1)
onfloor first flag ON
onfloor(s) middle flag OFF
onfloor last flag OFF
floordisplay is 1
(first floor)
upbutton flag OFF
(middle floor(s) [this can be all the
floors that are not first and last if
you have more than 2 floors] )
upbutton flag OFF
downbutton flag OFF
(last floor)
downbutton flag OFF
(all floors)
destination floor buttons are all OFF
(the number of buttons should match
the number of floors you have)
main program loop
{
when no up or down button is pressed
{
( you really don't need this section
but i wrote this to let you know
what to do if you hit this )
elevator stays put
}
( continue checking the upbutton and
downbutton flags )
if direction flag is ON ( up )
{
check all "upper floor" upbutton flags
if one was found
{
move up one floor at a time, checking
each upbutton flag ( this ensures that
while the elevator is moving up and
another floor has its upbutton pressed
the elevator will stop there.
[for example, if elevator was on floor 1
and upbutton was pressed on floor 4 -
while the elevator is traveling up and
floor 3's upbutton was pressed, we still
want the elevator to stop at floor 3
instead of running right by it.] )
perform that floor's routines
go back up to the top of the loop to restart
the program cycle
}
else ( is upper floor found? )
{
( if here then it means that no upper floors
upbutton is ON so we need to go down first
and find the floor that has it's upbutton
pressed )
move down one floor at a time, checking
each upbutton flag ( this ensures that
while the elevator is moving down and
another floor has its upbutton pressed
the elevator will stop there.
[for example, if elevator was on floor 4
and upbutton was pressed on floor 1 -
while the elevator is traveling down and
floor 2's upbutton was pressed, we still
want the elevator to stop at floor 2
instead of running right by it. yes,
floor 1 will be bypassed.] the elevator
will resume going up even if there is an
up request at a floor lower then current
floor ).
perform that floor's routines
go back up to the top of the loop to restart
the program cycle
} ( is upper floor found? )
} ( is direction flag ON? )
if direction flag is OFF ( down )
{ ( you could have made this just an "else"
statement - but the "if" statement here
is just for clarity )
check all "lower floor" downbutton flags
if one was found
{
move down one floor at a time, checking
each downbutton flag
perform that floor's routines
go back up to the top of the loop to restart
the program cycle
}
else ( is "lower floor" found? )
{
( if here then it means that no upper floors
upbutton is ON so we need to go down first
and find the floor that has it's upbutton
pressed )
move down one floor at a time, checking
each upbutton flag
perform that floor's routines
go back up to the top of the loop to restart
the program cycle
} ( is "lower floor" found? )
} ( is direction flag OFF? )
} ( main program loop )
floor's routine
{
if direction flag is ON ( up )
{
check current floor's upbutton flag
( obviously if no upbutton flag exists
then we are on the last floor )
if upbutton flag is ON
{
( there's a person outside the elevator
who wants in )
open doors
wait a few cycles
close doors
}
( else )
check to see if destination floor buttons
are pressed ON
if destination floor equals current floor number
{
open doors
wait a few cycles
close doors
}
} ( is direction flag ON? )
if direction flag is OFF ( down )
{ ( you could have made this just an "else"
statement - but the "if" statement here
is just for clarity )
check current floor's downbutton flag
( obviously if no downbutton flag exists
then we are on the first floor )
if downbutton flag is ON
{
( there's a person outside the elevator
who wants in )
open doors
wait a few cycles
close doors
}
( else )
check to see if destination floor buttons
are pressed ON
if destination floor equals current floor number
{
open doors
wait a few cycles
close doors
}
} ( is direction flag OFF? )
} ( floor's routine )
Hope this helps! Drop me a line if you find this stuff useful.