Nick -> Projects -> Elevator Controller

Elevator Controller

This microcontroller design is the final project for the Digital Systems Lab (ECE249). The breakdown for this project was to use both hardware circuits and software code to accomplish the task of developing a working elevator controller.
My partner and I split all sorts of functions between hardware and software sections. I know this project may not be of any interest to you, but this project basically just shows off my knowledge 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 just like the real elevators have for direction indications 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 has been asking me for a more detailed description of this project. So, here goes.

Note: I didn't get the report we submitted back to us. And the project was -- well a sophomore project. (That was a long time ago.)


Since this was a hardware class, we used a lot of hardware chips that could have easily been implemented with software code.

Use the following table to find the software to hardware equivalents:
Hardware Component Software Component
Flip-Flop Switches Flags
Comparators if ( a == b)

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. Some people has aske about the cost for the project. The price of the items can vary from your supplier. The College of Engineering at the University of Illinois made parts available for free for the students in EE. So, you are on your own on trying to figure the cost issues.

Here's the (hardware) 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.

Copyright © 2001 by Nick Shin. All Rights Reserved.
These pages are designed by ESTSS.