Elevator Controller Implementation
Elevator Controller Implementation
Elevator Controller Implementation
Department of Computer Science and Engineering Indian Institute of Technology, Guwahati India December 20th, 2005
Acknowledgements
We are very grateful to our advisor, D. J.K Deka (Asst. Professor IITG), whose guidance has enabled us to understand the various facets of Elevator control and its HDL implementation. His ideas have been a constant source of inspiration and have deeply motivated us to think at a higher level.
Problem statement:
To design an Elevator controller for any number of floors.
Algorithm:
There are different algorithms that could be used for designing the elevator controller. The important ones are: 1. elevator algorithm:: Serve the entire request in one direction and then reverse the direction. 2. shortest seek first Serve the request closest to the present floor 3. first come first serve Serve requests as they arrive. We have used ELEVATOR ALGORITHM. Justification for using elevator algorithm 1. Disadvantages of shortest seek first: Irrespective of the time at which request is placed, it only caters to the request closest to the present floor. e.g. If someone places a request for 100th floor there are lots of other requests for nearby floor as it is a busy place also if they keep coming . then that persons request is not at all catered to for a long time . 2. Disadvantages of first come first serve basis e.g. Inefficient as far as power requirements are concerned also more time will be taken on an average to reach the required destination. The elevator algorithm takes care of these two shortcomings
by catering to the request in its direction then reverses direction when we reach top floor or there are no more request for the upper floors ;the same is repeated for the downward direction .
Also if there is no request in a floor above the present floor then it checks if some request has come in some floor below the present floor. If true the control is sent back to T [3] else T [1]. Implementation of queue: Queue is defined as input to our main module and is defined as reg in test bench and the value is altered from the test bench.
Note: States are a direct consequence of state diagram, since we are using One hot assignment Output module T: The value of the states depending on the state as evaluated by control logic, the present floor is either incremented or decremented or remains same. Unload reachfloor: Depending on whether we have reached our destination or not, we unload that floors entry from the queue.
Other important variables: 1. xl: It is 1 denotes that there is at least one unattended request for a floor less than equal to it .It is 0 denotes that there is no request that is unattended at a floor less than equal to it .
2. xr: It is 1 denotes that there is at least one unattended request for a floor greater than equal to it . It is 0 denotes that there is no request that is unattended at a floor greater than equal to it. Other calculations: 1. Finding xr: Present floor value is saved in a temporary variable it is fed into a decoder these values are multiplied with the output of the queue .If this value is 0 then increment the value of temporary variable and repeat the process .This process stops only when output after the taking the product of bits of temporary variable comes out to be 1. Also we have to make sure that the value of temporary variable does not exceed 6 and if it reaches 6 it implies that there is no request in the queue above the current flloor. Hence value of xr is set to 0 if floor reaches 6.Else the value of xr is set to 1 if temporary variable does not reach 6 and is stopped in between. 2. Finding xl: Same circuit as above, instead of incrementor we put a decrementor.
Output module: Pfloor: The value of the present floor. Initially we have loaded the present floor value as zero. We have asynchronous clear to clear its value to zero. If supply goes off, then lift remains at the present floor and it starts its function as required the moment the supply is turned on again.
This module basically increments or decrements the value of the present floor depending on its current state at positive edge of the clock.
Comments
The code can be made to work for any number of floors by using the appropriate decoder.
References:
1:M. Morris Mano: Digital Design 3rd edition: Prentice Hall of India. 2: Palnitkar, S: Verilog HDL: A Guide to Digital Design and Synthesis: SunSoft Press (A Prentice Hall Title) 3: Thomas D.E and P.R Moorby: The Verilog hardware Description Language: 4th edition: Kluwer Academic Publishers. 4: Enhanced Verilog Tutorial with applications from aldec.com