Sunteți pe pagina 1din 18

nguyenvanbientbd47@gmail.

com

Bo co mn hc
Mn:Thit k mch logic

ti: Thit k h thng iu khin thang my

I.

II.

III.

IV.

Mc lc
Gii thiu ..
2
1. Gii thiu ti
2
2. Gii thiu k thut s
2
tng. .
3
1. Thc t. ..
3
a. H thng thang my thc t . 3
b. Hot ng .
3
2. tng ..
3
gii thiu linh kin s dng
4
1. Cng lgic ..
4
2. IC gii m ..
5
3. n LED
5
v
4. Rle in p 5 .
5
5. Vi iu khin AT89C51.
6
m t chi tit . ...
7

nguyenvanbientbd47@gmail.com
A. S khi h thng .

7
B. Thit k tng.
7
1. Khi yu cu v bo tng
7
2. Khi iu khin Cabin v ca
9
3. Khi ch th yu cu
9
4. Khi ch th hot ng
9
5. Khi iu khin trung tm
10
a. Lp so snh ..
10
b. Hot ng h thng trong cc Mode.
10
c. Lp iu khin ch th yu cu ..11
6. Yu cu mi khi ..
11
V.
thit k mch nguyn l
11
1. Mch lp m.
11
2. Mch hin th tng .
12
3. Cc khi iu khin hot ng
12
4. Khi iu khin trung tm..
12
VI.
chng trnh iu khin
13
1. hnh chng trnh ..
14
2. Chng trnh iu khin..
15
Cc ph lc.
sau trang
15

nguyenvanbientbd47@gmail.com

i. Gii thiu

1. Gii thiu ti
Cng vi s pht trin ca x hi, nh cao tng ngy cng nhiu ph

hp vi yu cu ca cuc sng. Thang my tr nn rt quan trng v tin li hn


rt nhiu so vi cu thang b.Thang my gip con ngi tit kim thi gian v
sc lc.
H thng iu khin thang my rt phc tp, nht l i vi k thut tng
t. Tuy nhin, vi s pht trin ca k thut s gip cho h thng iu khin
thang my c n gin hn.
Trong thc t, h thng iu khin thang my rt phc tp cho nhiu kiu
nh khc nhau. Nhng vi mn hc thit k mch logic , mc ch l tip cn vi
vic ng dng k thut s vo cuc sng nn h thng c thit k trong ti
ny l mt h thng iu khin thang my ti a l chn tng hot ng theo ch
taxi

2. Gii thiu k thut s


K thut s (Digital) l mt k thut mi trong nghin cu v ng dng
tn hiu in. Nhng khc vi k thut tng t, ngha l vi tn hiu vo v ra c
cng dng bin i, k thut s l s t hp cc mc tn hiu to thnh cc
m. Trong k thut s hin i ngi ta dng h s nh phn. Tuy khng th b
qua k thut tng t nhng ta cng nhn thy rng k thut s em li nhiu
thnh cng ln trong k thut, dn dng, v nhiu lnh vc bn ngoi.

nguyenvanbientbd47@gmail.com

II. tng

1. Thc t
a. H thng thang my thc t gm
H thng iu khin Cabin
- H thng ca
- H thng yu cu
- H thng ch th yu cu
- Bo hiu qu ti
- B iu khin trung tm
- H thng cp thng tin v nng lng
b. Hot ng
Cabin lun ch ch ngha l:
- Khi Cabin ang trong ch khng ti (Khng chuyn ng) th
Cabin lun ch ch th ngi s dng. Khi c lnh t ngi s dng, h
thng x l kim tra v quyt nh hot ng cho Cabin, h thng ca,
h thng thng bo hay h thng bo ng.
- Khi Cabin ang hot ng nu ngi s dng ra ch th, b iu khin
trung tm s nhn tn hiu v kim tra hot ng hin thi v hot
ng yu cu a ra qut nh tip tc hot ng hay ngng hot
ng ca Cabin.
2. tng
Thit k 1 H thng iu khin thang my gm:
- H thng iu khin Cabin
- H thng ca
- H thng yu cu ( ch hin th tng )
- H thng ch th yu cu
- Khi iu khin trung tm

nguyenvanbientbd47@gmail.com

- H thng ch th hot ng ( tng ln hoc gim )


Hot ng : lm vic theo ch taxi.
C ngha l : Cabin c th ln xung theo yu cu nhng khng chp nhn
ngt hot ng hin hnh. H thng ch nhn lnh khi c thng bo Cabin ang
khng lm vic v b qua tt c cc yu cu khi Cabin ang hot ng. Khi
Cabin khng hot ng h thng chp nhn yu cu. Thng tin v tng ang
hin hnh v thng tin v tng yu cu n c lu li v so snh. Nu ch s
tng hin hnh ln hn ch s tng yu cu n th h thng ra tn hiu cho
Cabin i xung. Nu ch s tng hin hnh nh hn ch s tng yu cu n th
h thng ra tn hiu cho Cabin i ln. Nu hai ch s ny bng nhau th h thng
cho ca m, sau mt thi gian nh trc th cho ng li v ch ch th tip theo.
V trong qu trnh vn hnh ca Cabin h thng lun lu li hai ch s v
Cabin ch ngng hot ng khi hai ch s ny bng nhau.
III. Gii thiu linh kin s dng

1. Cng logic
Trong thit k ta ch s dng cng OR trong IC74LS32.

DM74LS32

IC74LS32 : l mt IC cha 4 cng or c s chn nh sau:

VCC A4

A1 B1

B4

Y1

Y4

A2

A3

B2

B3

Y2

Y3

GND

nguyenvanbientbd47@gmail.com

2. IC gii m
Trong thit k ti ta dng IC gii m 74LS47 .
IC74LS47 l IC gii m cho n LED 7 thanh vi u vo m BCD v
u ra l 7 u a vo 7 chn ca LED 7 thanh.
VCC

74LS47

3. n LED

GND

g f 5v a b

e d

Chn - +
LED n
4.

LED 7 thanh

Rle hot ng in p 5V
L loi Rle dng ng ngt mch bng dng 5V . Khi c dng 5V mt

mch t c ng li . V vy ta c th dng loi Rle ny ng cc mch


dung ngun ln hn 5V

6 5

RY5W-K

2
6

nguyenvanbientbd47@gmail.com

Chn 1, 8 : l hai chn iu khin, khi c hiu in th 5v trn hai u


chn ny th mch t c ng.
Chn 2, 3, 4 : khi mch t c ng th hai chn 2, 4 c ni, con khi
mch .t m th 3, 4 c ni
Chn 5, 6, 7 : khi mch t c ng th hai chn 5, 7 c ni, con khi
mch t m th 5, 6 c ni.

5. Vi iu khin A89C51

P1.0
P1.1
P1.2
P1.3
P1.4
P1.5
P1.6
P1.7
P3.0
P3.1
P3.2
P3.3
P3.4

P3.5
P3.6
P3.7
XTAL2
XTAL1
GND

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

40
39
38
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21

VCC
P0.0
P0.1
P0.2
P0.3
P0.4
P0.5
P0.6
P0.7
EA/VPP
ALE
PSEN
P2.0
P2.1
P2.2
P2.3
P2.4

P2.5
P2.6
P2.7

y l IC vi iu khin (Micro Controller) hot ng theo chng trnh lp


trnh trc. IC ny c 3 Port c th vo ra d liu digital (cc tn hiu in 5v,0v).
Chng trnh lp trnh trc c a vo ROM ca IC ny. V ta c th lp trnh
cho ROM hot ng nh mt mch s hc bnh thng vi y cc chc nng.
Chng trnh dnh cho ti ny nm trong phn cui bo co.

nguyenvanbientbd47@gmail.com

IV. M t chi tit


A. S khi H thng iu khin thang my

Khi hin
th tng

Khi
bn
phm

Khi
iu
khin
trung
tm

Khi
bo
tng

Ch th
hot ng
Khi iu
khin
Motor

HNH 1 : S KhI H THNG IU KHIN THANG MY

B. Thit k tng

1. Khi yu cu v bo tng
Hai khi ny c nguyn tc hot ng v cu to tng t nhau.
M BCD c lp

9 u vo
I1
I2
I3
I4
I5
I6
I7
I8

B
lp
m

B
C
D

Hnh 2: S khi gii m


8

nguyenvanbientbd47@gmail.com

y l 1 mch logic gm 9 u vo tch cc mc cao va 4 u ra di dng


m BCD c th gi y l 1 khi lp m BCD.
S
1
2
3
4
5
6
7
8
9

V1
1
0
0
0
0
0
0
0
0

V2
0
1
0
0
0
0
0
0
0

Gi tr u vo
V3 V4 V5 V6 V7
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
1
0
0
0
0
0
1
0
0
0
0
0
1
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0

V8
0
0
0
0
0
0
0
1
0

V9
0
0
0
0
0
0
0
0
1

Gi tr u ra
D
C
B
A
0
0
0
1
0
0
1
0
0
0
1
1
0
1
0
0
0
1
0
1
0
1
1
0
0
1
1
1
1
0
0
0
1
0
0
1

Bng chn l b gii m


u ra ta ch chp nhn m t 0000 1001. Nh vy trong b ny ta
khng chp nhn gi tr V=1 cung lc v nh vy s to ra 1 m khc.
S khc nhau gia khi yu cu v khi bo tng:
-

Trong khi yu cu: u vo gii m (9 chn) ca khi c ni vi 1


bn phm chn nt. Bn phm c thit k sao cho khi 1 phm c nhn
gi tr u vo b gii m c tn ng vi gi tr trn phm l mc
H(=1). Tt c cc u cn li = 0, nu khng c phm c nhn th
tt c cc u = L(=0)

- Trong khi bo tng: 9 u vo mch gii m c ni vi 9 u vo


chuyn mch dng theo nguyn tc c hc. (Khi cabin ti mt tng th
u vo tng c ng vi mc logic 1 cn tt c cc u cn li
bng 0)
- Trong thc t ngi ta dng chuyn mch t. Trong ti ny ta dng
chuyn mch c kh (tip xc kim loi).
2.

Khi iu khin cabin v m ca

nguyenvanbientbd47@gmail.com

Dng hai tn hiu iu khin chiu quay ca motor 1 chiu 16 vn in


p. Mt tn hiu in khin quay thun, 1 tn hiu iu khin quay ngc. Hai tn
hiu ny khng bao gi ng thi mc cao. Ta dng 2 rle 5V ng mch ti
a 30V. Mt rle nhn tn hiu iu khin quay thun, 1 rle nhn tn hiu
iu khin quay ngc. Tn hiu iu khin hai motor ny ly trc tip t vi x
l s dng 4 bit trong 1 Port ca Vi x l . Ta lp trnh vi x l hai motor
khng hot ng cng mt lc.
Khi cabin ang chuyn ng th ca khng m v ngc li .
3. Khi ch th yu cu : gm 2 LED 7 thanh
Mc ch : Thng bo cho ngi s dng bit cabin tng yu cu n v
tng hin ti. Trong trng hp cabin ng yn, c 2 LED 7 thanh u hin th s
th t tng hin ti. Ta a m t khi iu khin trung tm qua mt b gii m
ti LED 7 thanh

4. Khi ch th hot ng
Gm 4 LED ch th trng thi hot ng ca cabin. Trong mt thi im
bt k ch duy nht mt n sng .
n 1 : Thng bo cabin ang ln.
n 2 : Thng bo cabin ang xung .
n 3 : Thng bo ca cabin ang m .
n 4 : Thng bo cabin ngh .
4 LED c iu khin bi 4 bit trong port 2 t khi iu khin trung tm
.
Bng trng thi hot ng
Trng thi
hot ng
Cacbin ln
Cabin xung
Cabin ngh
M ca

n bo ln

n bo xung

n bo ngh

n bo m ca

1
0
0
0

0
1
0
0

0
0
1
0

0
0
0
1

10

nguyenvanbientbd47@gmail.com

5. Khi iu khin trung tm


M BCD t:

Lp
so
snh 4
bt

bn phm A
cabin B
Hin th:
Tng hin
hnh

Lp
hin
th

Tng yu
cu

Lp
nhn
lnh
v thi
hnh

iu
khin
ch
th

Lp
hin
th
hot
ng

M t hot ng ca khi iu khin trung tm


a. Lp so snh
L mt b so snh 4 bit (8 u vo) A v B c 3 u ra
A > B u ra 1 = 1 , u ra 2,3 = 0 -> Mode 1
A = B u ra 2 = 1 , u ra 1,3 = 0 -> Mode 2
A < B u ra 3 = 1 , u ra 2,1 = 0 -> Mode 3
3 u ra ny s iu khin hot ng khi c kh nh sau:
b. Hot ng h thng trong cc mode
- Mode1 : Thang my ln ti khi co bo hiu tng ang qua trng
tng cn n.
- Mode2 : Thang my xung ti khi co bo hiu tng ang qua
trng tng cn n.
- Mode3 : Ca m .
iu khin hot ng lp iu khin ch th hot ng

11

nguyenvanbientbd47@gmail.com

c. Lp iu khin th yu cu
Nhn trc tip m t bn phm v cabin a ra LED 7 thanh .
6. Yu cu mi khi
Phi lu c trng thi c trc khi trng thi mi c xc lp :
Vi cc IC s hc bnh thng (Automat c nh v khng nh) ta s dng
vic lu trng thi bng cc Flip-Flop. Vi k thut Vi x l ta dng cc thanh
ghi.
v. thit k mch nguyn l

1. Mch lp m
T phn tch trong phn IV/1 v bng chn l ta c:
A = V1+V3+V5+V7+V9
B = V2+V3+V6+V7
C = V4+V5+V6+V7
D =V8+V9
V vy ta a ra mch sau:
v1 v2 v3 v4 v5 v6 v7 v8 v9
1

12

13

11

2
4

10

10
12
13

11

12
11

13

1
2

Mch lp m BCD 9 u vo

12

nguyenvanbientbd47@gmail.com

2. Mch hin th tng


Mch hin th tng hin hnh cng nh tng cn n l tng ng, ch
khc l u vo mch hin thi tng yu cu n nhn tn hiu t 4 bit cao ca
Port 2 cn mch hin thi tng hin hnh nhn tn hiu t cc bit cn li ca

4 Bit

Port 2

vcc

Port 2.
7
1
2
6
3
5

D0
D1
D2
D3
LT
RBI

A
B
C
D
E
F
G
BI/RBO

13
12
11
10
9
15
14
4

a
b
c
d
e
f
g
.

74LS47
Mch gii m BCD -> LED 7 thanh

3. Cc khi iu khin hot ng


Nh ni phn trn ta dng hai tn hiu iu khin hot ng ca
cc motor (Motor Cabin cng nh Motor ca)
Mch iu khin c thit k nh sau:
16vDC
Thun

Rle

Motor

Ngc
Rle
16vD
Mch iu khin Motor

4. Khi iu khin trung tm


(Xem s ton h thng trong ph lc)

13

nguyenvanbientbd47@gmail.com

VI. Chng trnh iu khin

1. hnh chng trnh

Start
Bo trng thi ngh
Kim tra phm bm
ng

Sai

C bm
M phm vo A
M Cabin vo B
Cho ra hin th
ng

sai

A=B
M ca
Cho ra hin th
ng ca

End

Sai

A<B
i ln

ng

i xung

M Cabin vo B

M Cabin vo B

Cho ra hin th

Cho ra hin th

14
Lu khi ca chng trnh iu khin

nguyenvanbientbd47@gmail.com

2. Chng trnh iu khin

Dng
1
2
3
4
5

6
7
8
9
10

11
12

13
14
15

$DEBUG
$NOPAGING
$NOSYMBOLS
; FILE : THANGMAY. SCR
;**********************************************************
;
CHUONG TRINH CHO DIEU KHIEN THANG MAY
;**********************************************************
MAIN
: CALL IN_bcd
; Nhp m t bn phm
JC action
; Cho hot ng
sjmp main
; lp li
;**********************************************************
;in_bcd : Nhp m s l m BCD t bn phm c chng nyphm khi n
;v khi nh ( lp li cho 50 ln mi khi n hoc nh )
;**********************************************************
in_bcd
: mov r3,#50
; s m chng ny
15

nguyenvanbientbd47@gmail.com
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

34
35
36

37
38
39

40
41
42
43
44
45
46
47
48
49

50

back

: call get_key
; gi trnh nhn phm
jnc in_bcd
; nu c nh=0 nhy
djnz r3, back
;gim nhy ti khi R3=0
push acc
; ct vo stack
back2
: mov r3 , #50
; s m l 50
back3
: call get_key
; goi trnh nhn phm
jc back2
; c C=0 nhy
djnz r3 , back3
; r3 khc 0 nhy
pop acc
; ly ra khi stack
ret
; kt thc
get_key : mov a , P0
; a p0 vo a
anl a , #f0h
; ly phn cao
swap a
; quay a
cjne a, #00h , done
; nu A khc 0 done
clr c
; xa c nh
sjmp exit
; thot
done
: setb c
; c c phm vi C=1
exit
: ret
; kt thc trnh con
;**********************************************************
; nh vy ta c m bn phm trong A m Cabin trong B
;**********************************************************
;**********************************************************
;action : Trnh con iu khin hot ng cho ton h thng
;chc nng : so snh hai gi tr trong hai thanh ghi A v B a ra
;hot ng
;**********************************************************
action : mov r6 , a
; a mbnphmvo R6
mov b , r6
; a m bn phm vo B
mov a , p0
; a P0 vo a
anl a , #0f
; ch ly m cabin
cjne a , b , up_down ; so snh m cabin v
sjmp mocua
; bn phm, bng nhau th
ljmp esc
; m ca, khc ln xung
;**********************************************************
; Trnh con m ca khi nhn kt qu bng trong php so snh m bn
16

nguyenvanbientbd47@gmail.com

51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68

69
70
71
72
73
74

75
76
77
78
79
80
81
82
83
84
85

86

;phm v m Cabin
; **********************************************************
mocua
: mov r5 , a
; a m Cabin vo r5
mov a , b
; a m phm vo a
swap a
; quay m phm
orl a , r5
;Hp m phm v m cabin
mov p2, a
; a a ra port 2
mov p1 , #00010010b
; a ra p1 lnh m ca
mov r5 , #0ffh
; cho s m
wait1
: djnz r5 , wait1
; m r5
mov p1 , #00000010b
; tm dng ch vo
mov r5 , #0ffh
; cho s m
wait2
: djnz r5 , wait2
; m R5
mov p1 , #00100010b
; tm dng ch ng
mov r5 , #0ffh
; cho s m
wait3
: djnz r5 , wait3
; m R5
sjmp esc
; thot
;**********************************************************
; Trnh con iu khin ln xung khi nhn kt qu khng bng trong
;php so snh m bn phm v m Cabin
; **********************************************************
Up_down : jc down
; c nh bng 1 down
Sjmp up
; bng 0 up
;**********************************************************
; Trnh con iu khin xung khi nhn kt qu km trong php so snh
; m bn phm v m Cabin
;**********************************************************
down
: mov p1 , #01000100b
; cho lnh xung
mov r6 , a
; cho mcabin vo r6
mov a , b
; cho m phm vo a
swap a
; quay a
orl a , r6
; Hp hai m
mov p1 , A
; a hai m ra hin th
sjmp action
; quay v action
; **********************************************************
; Trnh con iu khin xung khi nhn kt qu km trong php so snh
17

nguyenvanbientbd47@gmail.com

87
88
89
90
91
92
93
94
95

96
97
98

; m bn phm v m Cabin
;**********************************************************
up
: mov p1 , #10001000b
; a ra ch th ln
mov r6 , a
; cho mcabin vo r6
mov a , b
; cho m phm vo a
swap a
; quay a
orl a , r6
; hp hai m
mov p1 , A
; a hai m ra hin th
sjmp action
; tr v action
;**********************************************************
; Trnh con h tr thot
;**********************************************************
sc
: ret
; thot chng trnh con

18