Vous êtes sur la page 1sur 20

1.

Introduction
This section of the paper describes the design and development of control system
of an elevator model with following requirements:
- Serve passengers quickly
- Highest proficiency and safety
- Low cost
2. Specification
2.1.
Features
The problem concern the logic required to move elevator between floors
according to the following constrains:
Each floor, except the first floor and top floor has two buttons, one to
request an up-elevator and one to request a down-elevator. These
buttons illuminate when pressed. The illumination is canceled when an
elevator visits the floor and then moves in the desired direction.
Inside the cabin, there is panel consisting of 8 buttons, these buttons
illuminate when pressed. The illumination is canceled when an elevator
visits the floor and then moves in the desired direction.
Continue traveling in the same direction while there are remaining
requests in that same direction.
When an elevator has no requests, it remains at its current floor with its
doors closed.
2.2.
Concept
Expending on our list of attribute, we speculate that the elevator circuit would
consists of five modules:
- Users inputs
Elevator button panel: consists of 6 buttons corresponding to 6
floors, in addition to close door button and hold button which take
the request to the visited floor.
Each floor, except the first floor and top floor has two buttons, one
to request an up-elevator and one to request a down-elevator.
- Display module
Indicating the position of the cabin on 7 segments LEDs
Showing the direction of the elevator car on an 8x8 Matrix LED
Illuminate the buttons when pressed using Red LEDs.
- Sensors
Floor sensors: each floor has a limit switch to indicate which floor
that the cabin has reached

2.3.

Secondary floor sensors: located at the haft way between floors, also
use limit switch
Opened and closed door sensors which signal that the doors have
completely opened or closed
Motors driver: control two motors, one to lift the elevator cabin and one to
drive the doors.
Power supply
Basic block diagram

2.4.
Limitations
Because we are dealing with a simulation meaning that not all features of the
real world can be implemented, these limitations can be summarized as
follows:
The door system includes several safety devices. Sensors detect
passengers or objects in the door opening, preventing the continued
closing of the doors.
A special fire emergency system has been installed. It may be manually
activated, or may respond to smoke sensors in the building. Exact
operation varies by local codes, but generally such systems return the
elevator to the main floor, open the doors to allow passengers to exit,
and make the elevators available to emergency personnel.

3. Hardware design
3.1. AVR Microcontroller
The ATMegal6 was chosen for the prototype development. The Mega16 is
pin-for-pin compatible with the smaller-memory model ATMega8535 as well
as with the larger-memory model ATMega32. This allows some freedom
during the design phase. The option of increasing the memory model may be
needed, since we do not know exactly how much code space is required in
either unit. At the end of the project, and after the features have ceased to
creep, if the code would fit into a potentially less expensive component with a
smaller memory size, that choice is available as well.

3.2.
Power supply
The supply power of the implemented circuit need to have a capability of
maintaining a steady voltage level despite vary current demands and input
voltage variations. For this purpose, we use IC 7805.

We use the power supply of the PC to generate the 12V sources from the 220V
AC at the input of IC7805. The role of capacitors is to store and release

electricity to smooth out noise, surges, and sags. Without the capacitors, the
7805 would still output 5 V but wouldnt react as quickly to changes in supply
and demand, and thus it wouldnt provide as clean of a regulated output.
3.3.
Users input and Floor sensors
Because ATmega16 has a limited number of pins and this system requires quite
many buttons to operate, except the button panel inside the cabin using four
pins of microcontroller, we use each of three pins to take the input of each
group of buttons and sensors. We can see the circuit of matrix 3x8 in the
following figure
3.4.
Display module
Indicating the position of the cabin using 7 segments LEDs, showing the
direction of the elevator car using an 8x8 Matrix LED and to illuminate the
buttons when pressed we use Red LEDs. Finally, to control all of these LEDs,
we use six ICs 74HC595
The 74HC595 shift register has an 8 bit storage register and an 8 bit shift
register. Data is written to the shift register serially, then, latched onto the
storage register. The storage register then controls 8 output lines.

Pin 14 (DS) is the Data pin.


When pin 11 (SH_CP) goes from Low to High, the value of DS is stored
into the shift register and the existing values of the register are shifted to
make room for the new bit.
Pin 12(ST_CP) is held low whilst data is being written to the shift
register. When it goes High, the values of the shift register are latched to
the storage register which are then outputted to pin Q0-Q7.

Thus, to control all of the LEDs, we just have to use three pins of the
Microcontroller which is an advantage of this method.
3.5.
Motors Driver
The motors driver circuit is required in order to drive the motors, for pulling or
lowering the elevator car, and for opening or closing the doors. The digital
control signal provided by ATMega16 Microcontroller does not deliver
sufficient current to drive the motors. Hence, a driver circuit, which is capable
of changing the direction of motors using the logic signals and is capable of
being driven at high current, is used.
4. Software Design
4.1. System Events
The system events can be summarized as follows:
Process Elevator Calls: These scenarios includes that the elevator
receives calls from the passengers outside the cabin, turns on or turns
off the light of elevator call buttons, updates the record of elevator calls
stored in system queues, etc.
Process Floor Calls: Similar to Elevator Call processing, this use case
includes that the elevator receives Floor calls from the passengers inside
the cabin, turns on or turns off the light of Floor calls buttons, updates
the record of floor calls in system queues, etc.
Move/Stop elevator: The main function of an elevator, how to make the
decision of stop, and driving directions of the elevator.
Indicating Moving Direction: This mechanism let the passengers know
the current moving direction of the elevator such that the passenger
might decide whether to enter the elevator or not.
Indicating Elevator Position: Similarly, the elevator let the passengers
know whether his/her destination floor is reached so that the passenger
may decide to leave the elevator.
Open/Close the Doors: The elevator is able to open and close the doors
for the passengers to get in and out of the elevator. The door function
also enables the passengers to make door reversals when the doors are
closing and the passenger wants to get in the elevator or close door
sooner than usual when there is no other passengers entering cabin.
On/Off illumination: The elevator and floor buttons are able inform the
passenger that his call has been scheduled and inform him that his call
has been requested, in which button illumination will be needed.

4.2.
Implementation
The basic concept of the software is to collect the inputs from users and
sensors (floor sensors and door sensors); base on these inputs, program will
drive the motors to serve every request, one after another, while displaying the
present status of the elevator to the users.
The task list is as follow:
1. Scan all the input ports of the Microcontroller to collect request from
users and signal from sensors every 200 milliseconds.
2. Display the elevator status every 14 milliseconds.
3. Have algorithm to process the inputs, and then drive the motors
correspondingly.
The first two tasks are handled on an interrupt basis, and the third task will be
put into the main operating loop of the software.
4.3.
Functions
4.3.1. Queue Functions
The following functions are used to interact with queues:
Create a new queue
void QueueCreate(Queue *q);
Check if the queue is empty or not
int QueueEmpty(Queue *q);
Put the requested floor into queue
void QueueEnter(const unsigned char c, Queue *q, unsigned
char x);
Take out the first queue element
unsigned char QueueRemove(Queue *q);
Sort the queue elements in ascending order
void QueueSort_Up(Queue *q);
Sort the queue elements in descending order
void QueueSort_Down(Queue *q);
Copy all of element from source queue to destination queue
void QueueCopy(const unsigned char c,Queue *sourceQueue,
Queue *destQueue);
Check the value of queue elements
int CheckSecQueue(const int c,Queue *qs,Queue *qd);
int CheckDup(Queue *q,unsigned char x);
int CheckDir(const int c,Queue *q,unsigned char currentFloor);
4.3.2. Elevator Algorithm Functions
The elevator algorithm will be based on the following functions:

Scan all buttons and sensors to take the input from users and
sensors (called every 200 ms)
void scan(void);
Display function using 74HC595 (called every 14 ms)
void display(void);
Control the door
void Door(void);
Main function implements the elevator algorithm
void Elevator(void);
Turn off the light of buttons
void Turnoff(void);
4.3.3. Secondary Functions
Initialize TIMER1 and TIMER2 interrupt and TIMER0 PWM
void Init_Timer(void);
Assign the first elevator state
void Elevator_init(void);
Function put data into IC 74HC595 used in Display function
void PutData(unsigned char data);
Swap the position of two queue elements
void swap(unsigned char *a, unsigned char *b);

4.4.
Flow Charts
4.4.1. Door Function

4.4.2. Elevator Algorithm


4.4.2.1.
Activity Diagram 1: User calls elevator

4.4.2.2.

Activity Diagram 2: User travel in elevator

4.4.2.3.
presses a floor button while traveling

Activity Diagram 3: User

4.5. Elevator Algorithm


4.5.1. Problem Statement
There are different algorithms that could be used for designing the elevator
controller:
Shortest seek first: Serve the request closest to the present floor.
This algorithm is 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 6th floor, there are a lot of other
requests for nearby floor as it is a busy section, also if they keep
coming, then that persons request is not served for a long time.
First come first serve: Serve the request as they arrive.
This is inefficient as far as power requirements are concerned and
more time will be taken on an average to reach the required
destination.
Elevator algorithm: Serve the entire request in one direction and then
reverse the direction.
After considering the advantage of all algorithms, we finally choose the
elevator algorithm to implement in this project.
4.5.2. Implementation
To implement the elevator algorithm, we use three queues (upQueue to
store requests going up, downQueue to store requests going down and
secQueue to store the requests that have not processed yet) and the elevator
has three states:
- IDLE State: Cabin is not moving
In this state, the elevator keeps checking the upQueue or
downQueue, if one of these queues is not empty, the elevator will
change to GO_UP state or GO_DOWN state, correspondingly.
- GO_UP State: Cabin goes up
In this state, the elevator will take the destination floor from the
upQueue, and then goes to this floor. While moving, if there is
request going up to the floor that is closer to the cabin than the
destination floor, the previous destination will be put into upQueue,
and destination floor will be assigned to this request. Other requests
will be put into corresponding Queue.
- GO_DOWN State: Cabin goes down

In this state, the elevator will take the destination floor from the
downQueue, and then goes to this floor. While moving, if there is
request going down to the floor that is closer to the cabin than the
destination floor, the previous destination will be put into
downQueue, and destination floor will be assigned to this request.
Other requests will be put into corresponding Queue.
4.5.3. Coding
/****************************************************
*
Main.c
****************************************************/
#include
#include
#include
#include

"Main.H"
"Port.H"
"Elevator.H"
"Queue.H"

unsigned char currentFloor=1, button, callUp,


callDown, destFloor, secSensor;
unsigned char buttonLed, upLed, downLed, direction,
index=0, column = 1;
Elevator_State E_State;
Queue upQueue, downQueue, secQueue;
void main()
{
Port_Init();
// Initialize Port
QueueCreate(&upQueue);
QueueCreate(&downQueue);
QueueCreate(&secQueue);
Init_Timer();
// Initialize TIMER
Elevator_init();
while(1)
{
Elevator();
}

}
/****************************************************
*
Elevator Function
****************************************************/
void Elevator(void)
{
switch(E_State)
{
case IDLE:
TCCR0=0x05;
PORTB.4=0;
PORTB.3=0;
direction = 0;

//Turn off PWM

if(!QueueEmpty(&upQueue))
E_State = GoUp;
else if(!QueueEmpty(&downQueue))
E_State = GoDown;
break;
case GoUp:
if(secSensor == currentFloor)
secSensor = currentFloor - 1;
destFloor = QueueRemove(&upQueue);
direction = 1;
TCCR0=0x6D;
//Turn on PWM
// Car goes up
while(destFloor != currentFloor)
{
if(secSensor == (destFloor - 1))
{
PORTB.4=1;
OCR0=170;
}
else

{
PORTB.4=1;
OCR0=0;
}
};
TCCR0=0x05;
PORTB.4 = 0;
PORTB.3 = 0;
Turnoff();
Door();
// If there is no command going up and there are
commands // going down, change state to GoDown
if(QueueEmpty(&upQueue)&&!
QueueEmpty(&downQueue))
{
// If the highest floor in downQueue is above the
current // floor, add it to upQueue
if(CheckDir(2,&downQueue,currentFloor))
{
uChar temp;
temp = QueueRemove(&downQueue);
QueueEnter(1,&upQueue,temp);
}
else
{
E_State = GoDown;
if(!QueueEmpty(&secQueue))
{
// If the lowest floor in the temporary queue is
below
// the lowest floor in downQueue, add it to
downQueue,
// and copy the rest to upQueue
if(CheckSecQueue(1,&secQueue,&downQueue))
{

uChar temp;
temp = QueueRemove(&secQueue);
QueueEnter(2,&downQueue,temp);
QueueCopy(1,&secQueue,&upQueue);
}
// If the lowest floor in temporary queue equals the
// lowest floor in downQueue, remove it, and copy the
// rest to upQueue
else if(CheckSecQueue(3,&secQueue,&downQueue))
{
QueueRemove(&secQueue);
QueueCopy(1,&secQueue,&upQueue);
}
else
QueueCopy(1,&secQueue,&upQueue); }}}
//If there is no command going up and down
else if(QueueEmpty(&upQueue)&&QueueEmpty(&downQueue))
{
if(!QueueEmpty(&secQueue))
{
uChar temp = QueueRemove(&secQueue);
QueueEnter(2,&downQueue,temp);
E_State = GoDown;
QueueCopy(1,&secQueue,&upQueue);
}
else
E_State = IDLE;
}
break;
case GoDown:
if(secSensor < currentFloor)
secSensor = currentFloor;
destFloor = QueueRemove(&downQueue);
direction = 2;
TCCR0=0x6D;

// Car goes down


while(destFloor != currentFloor)
{
if(secSensor == destFloor)
{
PORTB.4 = 0;
OCR0= 85;
}
else
{
PORTB.4 = 0;
OCR0 = 255;
}
};
TCCR0=0x05;
PORTB.4 = 0;
PORTB.3 = 0;
Turnoff();
Door();
//If there is no command going down and there are
commands going up, change state to GoUp
if(QueueEmpty(&downQueue)&&!
QueueEmpty(&upQueue))
{
// If the lowest floor in the upQueue is below the
// current floor, add it to downQueue
if(CheckDir(1,&upQueue,currentFloor))
{
uChar temp;
temp = QueueRemove(&upQueue);
QueueEnter(2,&downQueue,temp);
}
else
{
E_State = GoUp;

// If the highest floor in the temporary queue is


above
// the highest floor in upQueue, add it to
upQueue, and // copy the rest to downQueue
if(!QueueEmpty(&secQueue))
{
if(CheckSecQueue(2,&secQueue,&upQueue))
{
uChar temp = QueueRemove(&secQueue);
QueueEnter(1,&upQueue,temp);
QueueCopy(2,&secQueue,&downQueue);
}
// If the highest floor in temporary queue equals the
// highest floor in upQueue, remove it, and copy the
rest // to downQueue
else if(CheckSecQueue(3,&secQueue,&upQueue))
{
QueueRemove(&secQueue);
QueueCopy(2,&secQueue,&downQueue);
}
else
QueueCopy(2,&secQueue,&downQueue); }}}
//If there is no command going up and down
else
if(QueueEmpty(&upQueue)&&QueueEmpty(&downQueue))
{
if(!QueueEmpty(&secQueue))
{
uChar temp = QueueRemove(&secQueue);
QueueEnter(1,&upQueue,temp);
E_State = GoUp;
QueueCopy(2,&secQueue,&downQueue);
}
else

E_State = IDLE;
}
break;
}
}

Vous aimerez peut-être aussi