Sei sulla pagina 1di 16

Design lab II

Design Lab II : Report


Elevator Control Mechanism

Prasant Kumar
Umang Mahajan
Gritika Valechha
Shreya Ganguly

001110501044
001110501047
001110501055
001110501056

Design lab II

INDEX

Problem Statement
Equipment Catalogue
Design Overview
Scheduling Algorithm
Interfacing With The Kit
Code
Further Considerations
Acknowledgements

3
4
5
6
9
10
15
16

Design lab II

PROBLEM STATEMENT

The main task of the lab assignment is to design an Elevator Control


Mechanism for a single elevator system using the 8085 Microprocessor
Training kit (VMC-8506) and other peripherals as required.

Design lab II

EQUIPMENT CATALOGUE
8085 based microprocessor trainer kit
14 LEDs
6 Push Buttons
26-pin FRC connector
Connecting wires
+5V D.C. power supply
20 100ohm resistors
Bread Board

The kit provides a 8 bit microprocessor (8085-A) interfaced with 8K bytes of


RAM using 6264 and 8K bytes of EPROM using 2764 loaded with powerful
monitor programs. The monitor is incorporated from 0000h to 1FFFh and the
RAM has an address from 2000h to 3FFFh. Additionally the training kit has got
a 16 bit programmable timer/counter using 8253 and 24 I/O lines using 8255
PPI. 8 different levels of interrupts are provided using 8259. Besides other
features, the kit also provides 6 seven segment display and a 28 key keyboard.
The power requirement of the kit is +5V, 1.5A.

Design lab II

DESIGN OVERVIEW
Initial settings and assumptions:

There are a total of 4 floors in the building ranging from floor 0 to floor 3.
The elevator cabin is initially at floor zero (ground level).
There are no requests and the corresponding LEDs are off.
The elevator services requests in one direction at a time and then reverses
direction to serve the remaining requests in that direction.
If there are no more requests to service then the elevator stays at the last floor
serviced until a new request has been made.
We use push buttons to request service from the elevator. There are two push
buttons allotted for each level(floor) except the topmost and the bottom most
floors for obvious reasons. The button(s) indicates the direction in which the
user wants to go. When a button is pressed the corresponding LED glows to
indicate that a request is made. If the request lies in direction of
motion(remaining) of the elevator it is serviced otherwise it is kept in memory
and serviced in the next turn as per the scheduling algorithm mentioned later.
The current location(floor) of the elevator is displayed in the data segment of
the display present in the kit. Its motion(ascent or descent) is shown by two
LEDs. Once inside the cabin of the elevator, the user can input its desired
destination using the keyboard provided in the kit. No provision has been made
to show the destination selected by the user.

Design lab II

SCHEDULING ALGORITHM
We have stored the ascent and descent in separate memory locations as bit
patterns consisting of 4 bits each. The upper nibble in both cases is set to 0000.
When a particular request(ascent or descent) is made, then the content of the
corresponding memory location is updated by setting the requisite bit according
to the floor the request came from(Suppose a request came from floor n for
ascent. Then the nth bit in the contents of the memory location for ascent is set
to 1). The elevator operates continuously in two cycles, an UP cycle and a
DOWN cycle. When servicing the UP cycle, requests are serviced from LSB to
MSB of the contents(lower nibble). If any bit is set to 1, then the elevator stops
at that floor, resets the corresponding bit to 0 and resumes ascent. In the DOWN
cycle, requests are serviced from MSB to LSB of contents(lower nibble). The
same logic is followed for updating the corresponding memory location
contents. (note: this system is valid for 4 floors).
The various cases that may arise during the motion of the elevator has been
captured and tabulated in the following table. (see next page to understand the
working of the last row).
Elevator Ascent
User Ascent

Elevator Descent

User Descent

User current
level <
Elevator
current level

User current
level > =
Elevator
current level

User
current
level <
Elevator
current
level

User
current
level > =
Elevator
current
level

Request to
be
processed in
the next
ascent.

Request to
be
processed in
the current
ascent.

Request to be
processed in the
following downward
descent.

Add the
request level
to the next
min heap
(min_heap#2
) and
Heapify!

Add the
request level
to the
current min
heap
(min_heap#1
) and
Heapify!

Add the request level


to the current max
heap (max_heap#1)
and Heapify!

User Ascent
User
current
level <
Elevator
current
level

User
current
level > =
Elevator
current
level

User Descent
User current
level <
Elevator
current level

User current
level > =
Elevator
current level

Request to be
processed in the
following upward
ascent.

Request to be
processed in
the current
descent.

Request to be
processed in
the next
descent.

Add the request level


to the next min heap
(min_heap#2) and
Heapify!

Add the
request level
to the current
max heap
(max_heap#1
) and Heapify!

Add the
request level
to the next
max heap
(max_heap#2
) and Heapify!

Design lab II

When the number of floors is large:


A more efficient method would be to maintain separate heaps for ascent and
descent. The various operations performed according to the nature of the inputs
are described in the table in the previous page. This is not necessarily for an
8085 microprocessor based system. It can be generalised for other high level
language implementations.
The destination levels are selected from the heap#1 (min_heap#1 for elevator
ascent phase and max_heap#1 for elevator descent phase).
After the completion of a particular phase the heap#1 for that phase is assigned
the values of heap#2 and heap#2 is cleared.
Since min/max heap is used for ascent/descent , the destination closest to the
elevators current location in sync with the motion of the elevator is serviced
first, thus eliminating the possibility of the elevator performing to and fro
motion between specific (highly used) levels.
The flowchart for the working of the elevator is shown below :

Design lab II

Design lab II

INTERFACING WITH THE KIT


We make use of the 8255 Programmable Peripheral Interface provided on the
kit to connect the push buttons and LEDs with the processor.
We use the 8255 in Mode 0, with Port B as input for the push buttons and Port
A and Port C as outputs for the LEDs. The control word fed to the 8255 for
setting the above configuration is 10000010. The interfacing circuit is shown
below.

Design lab II

10

CODE
PORT A EQU 00
PORT B EQU 01
PORT C EQU 02
CWR EQU 03

Design lab II
MEMORY LOC

11
ASSEMBLY CODE

MACHINE CODE

3000

MVI C,00

0E 00

3002

MVI A,82

3E 82

3004

OUT 03

D3 03

3006

MVI A,00

3E 00

3008

OUT 00

D3 00

300A

CALL DISPLAY

CD 0025

IN 01

DB 01

300F

MOV B,A

47

3010

ANI 07

36 07

3019

JNZ Y

C2 1F30

301C

MOV A,B

78

301D

ANI E0

EC E0

JZ X

CA 11 30

MVI D,00

16 00

MVI E,01

1E 01

RRC

0F

3024

JC P

DA 37 30

3027

INR D

14

3028

JMP L

C3 23 30

302B

MVI D,03

16 03

302E

MVI E,00

1E 00

RLC

07

3030

JC P

DA 37 30

3033

DCRD

15

3034

JMP L1

C3 2F 30

MOV A,C

79

3038

CMP D

BA

3039

JC UP

DA 53 30

303C

JNZ DOWN

C2 68 30

3041

CMP E

BB

3042

JZ L2

CA 4A 30

300D

301F

LABEL

3021
3023

302F

3037

L1

Design lab II

12

3045

MVI H,43

26 43

3047

JMP L3

C3 4C 20

304A

L2

MVI H,42

26 42

304C

L3

MOV L,C

69

CALL CLEAR

CD 00 40

ASSEMBLY CODE

MACHINE CODE

JMP X

C3 11 30

CALL DELAY

CD 00 41

3056

INR C

0C

3057

CALL DISPLAY

CD 00 25

305A

MVI H,42

26 42

305C

MOV LC

69

305D

CALL CLEAR

CD 00 40

3060

MOV A,C

79

3061

CMP D

BA

3062

JNZ UP

C2 53 30

3065

JMP X

C3 11 30

CALL DELAY

CD 00 41

306C

DCR C

0D

306D

CALL DISPLAY

CD 00 25

3070

MVI H,43

26 43

3072

MOV L,C

69

3073

CALL CLEAR

CD 00 49

3076

MOV A,C

79

3077

CMP D

BA

3078

JNZ DOWN

C2 68 30

307A

JMP X

C3 11 30

MOV A,H

7E

OUT 00

D3 00

304D

MEMORY LOC

LABEL

3050
3053

3068

4000
4001

UP

DOWN

CLEAR

Design lab II

13

4003

MVI A,FF

3E FF

4005

OUT 00

D3 00

4007

RET

C9

PUSH B

C5

4101

PUSH D

D5

4102

PSW

F5

4103

MVI B,0A

06 0A

LXI D,FFFF

11 FFFF

4108

CALL SYSDELAY

CD BC 03

410B

DCRB

05

410C

JNZ X

C2 05 41

410F

POP PSW

F1

4110

POP D

D1

4111

POP B

C1

4112

RET

C9

MOV A,C

79

2501

STC

37

2502

CMC

3F

2503

RAL

17

2504

RAL

17

2505

RAL

17

2506

RAL

17

2507

ORI 20

F6 20

4100

4105

2500

DELAY

DISPLAY

Design lab II

14

2509

MOV H,A

67

250A

MVI L,00

2E 00

250C

MOV A,M

7E

250D

PUSH PSW

F5

250E

MVI A,85

3E 85

2510

OUT 19

03 19

2512

POP PSW

F1

2513

OUT 18

D3 18

2515

RET

C9

2000: 03(LED 0)
2100: 9F(LED 1)
2200: 25(LED 2)
2300: 0D(LED 3)

Design lab II

15

FURTHER CONSIDERATIONS
As an extension of the given project, we were asked to interface the given
system with stepper motors in order to physically simulate the elevator system
designed. Owing to time constraints, this could not be implemented physically
on the circuit. Nevertheless, we present how to interface stepper motors using
8255.
AIM:
To write a program to rotate the stepper motor clockwise/anticlockwise through
definite number of steps.
LOGIC:
Initialize stack pointer and 8255 port A as output port.
Out this control word to control word register.
Give data CCh to accumulator to activate the stepper motor.
Load the count in one of the register to determine number of steps.
Loop1: Use RLC instruction in order to rotate clockwise.
Out it to port A where we have connected stepper motor.
Call delay subroutine. Decrement the count.
Check the count for zero.
If no, jump to Loop1.
Otherwise, give data CCh to accumulator to activate the stepper motor.
Load the count in one of the register to determine number of steps
Loop2: Use RRC instruction in order to rotate anticlockwise.
Out it to port A where we have connected stepper motor.
Call Delay subroutine.
Decrement the count.
Check the count for zero.
If no, jump to Loop2.
Stop.
Delay: Load one register with count.
Decrement the register.
Check for zero.
If no, jump to step 2 of the delay.
If yes, return to the main program.

Design lab II

16

ACKNOWLEDGEMENTS
The design of the elevator control mechanism was a challenging job. We would
like to extend our gratitude to the concerned professor for providing us with
valuable inputs and suggestions from time to time and making our task easier.

Potrebbero piacerti anche