Click here to load reader

Đồ án môn học MẠCH ĐỒNG HỒ SỐ

  • View
    1.516

  • Download
    1

Embed Size (px)

Text of Đồ án môn học MẠCH ĐỒNG HỒ SỐ

n mn hc 1

MCH NG H S

TRNG I HC DUY TN KHOA: IN T VIN THNG B MN: N C S

---00O ** **O00---

N MN HCTN TI:

NG H SGVHD: NGUYN VN TH SVTH: NGUYN THNH T LP: K15EVT MSSV: 152132550

Nng, Thng 4 nm 2011

SVTH: NGUYN THNH T

n mn hc 1

MCH NG H S

TRNG I HC DUY TN KHOA: IN T VIN THNG B MN: N C S

---00O ** **O00---

N MN HCTN TI:

NG H SGVHD: NGUYN VN TH SVTH: NGUYN THNH T LP: K15EVT MSSV: 152132550

Nng, Thng 4 nm 2011

SVTH: Nguyn Thnh t

n mn hc 1

MCH NG H S

MC LCNhn xt ca gio vin hng dn.................................................................4 Li cm n............................................................................................ . . . . . .5 Phn I: Dn Nhp......................................................................................6 t vn . Mc ch v yu cu. Gii hn ti Phn II. C s l thuyt.......................................................................... . . . .8 Gii thiu IC AT 89C51 Gii thiu Led 7 on Gii thiu v transistor C1815, T , in tr. Phn III: Thit k v thi cng...................................................................19 Chng I: Thit k mch.......................................................... . . . . . . .19 S khi. Cc khi chc nng S nguyn l v s mch in M phng mch v hnh nh thc t Gii thut main Nguyn l hot ng ca cc khi. Chng II: Thi cng mch.......................................... .. . . . . . . . . . . . .38 Dng c s dng. Qu trnh thi cng. Phn IV: Kt lun.......................................................................................39 u im Nhc im Hng pht trin Li kt Ti liu tham kho

SVTH: Nguyn Thnh t

n mn hc 1

MCH NG H S

NHN XT CA GIO VIN HNG DN. ....................................................................................................................... ....................................................................................................................... ....................................................................................................................... ....................................................................................................................... ....................................................................................................................... ....................................................................................................................... ....................................................................................................................... ....................................................................................................................... ....................................................................................................................... ....................................................................................................................... ....................................................................................................................... ....................................................................................................................... ....................................................................................................................... ....................................................................................................................... ....................................................................................................................... ....................................................................................................................... ....................................................................................................................... ....................................................................................................................... ....................................................................................................................... ....................................................................................................................... ....................................................................................................................... ....................................................................................................................... .......................................................................................................................Ch k ca gio vin hng dn

SVTH: Nguyn Thnh t

n mn hc 1

MCH NG H S

LI CM N- Li u tin chng em xin chn thnh cm n thy Nguyn Vn Th cng qu thy c b mn khoa in T Vin Thng Trng i Hc Duy Tn Thnh Ph Nng. - Trong qu trnh thc hin n gp nhng kh khn v thiu st khi thc hin n, trong thc hin v thi cng mch v phn cng cng nh v phn mm. Nhng c s hng dn v ch dy nhit tnh ca qu thy c gip chng em khc phc c nhng thiu st v c th hon thnh c ti. - K xin gi li cm n ti cc bn trong lp gip hon thnh n nhanh nht!.

Nng, thng 4 nm 2011 SV thc hin Nguyn Thnh t

SVTH: Nguyn Thnh t

n mn hc 1

MCH NG H S

PHN IDn Nhp1.1/ t vn : Cng vi s pht trin ca khoa hc v cng ngh, cc thit b in t , ang v s tip tc c ng dng ngy cng rng ri v mang li hiu qu trong hu ht cc lnh vc khoa hc k thut cng nh trong i sng x hi. Vic gia cng, x l cc tn hiu in t hin i u da trn c s nguyn l s. V cc thit b lm vic da trn c s nguyn l s c u im hn hn so vi cc thit b lm vic d trn c s nguyn l tng t, c bit l trong k thut tnh ton. S pht trin mnh m ca cng ngh in t cho ra i nhiu vi mch s c ln vi gi thnh r v kh nng lp trnh cao mang li nhng thay i ln trong ngnh in t. Mch s nhng mc khc nhau ang thm nhp trong cc lnh vc in t thng dng v chuyn nghip mt cch nhanh chng. Cc trng k thut l ni mch s thm nhp mnh m v c hc sinh, sinh vin a chung do li ch v tnh kh thi ca n. V th s hiu bit su sc v k thut s l khng th thiu i vi sinh vin ngnh in t hin nay. Nhu cu hiu bit v k thut s khng ch ring i vi nhng ngi theo chuyn ngnh in t m cn i vi nhng cn b k thut khc c s dng thit b in t.

SVTH: Nguyn Thnh t

n mn hc 11.2/ Mc ch yu cu :

MCH NG H S

S cn thit, quan trng cng nh tnh kh thi vo li ch ca mch s cng chnh l l do nn chn v thc hin n thit k mch ng h s nhm dng kin thc s hc v k thut s vo thc t. Yu cu ca bi ny l thit k ng H S dng vi x l 89C51. 1.3/ Gii hn ti: Trong phm vi thit k ny, ngi thc hin cn thit k v thi cng mch ng H S gn, n gin. ti ng H S rt a dng v phong ph, c nhiu loi hnh khc nhau da vo cng dng v phc tp. Do ti liu tham kho bng Ting Vit cn hn ch, trnh c hn v kinh nghim trong thc t cn non km, nn ti chc chn cn nhiu thiu st. V vy rt mong nhn c nhng kin ng gp, gip chn thnh ca cc thy c cng nh ca cc bn sinh vin.

SVTH: Nguyn Thnh t

n mn hc 1

MCH NG H S

PHN II C S L Thuyt2.1 / Gii thiu cc thng s AT 89C51 : 2.1.1/ Gii thiu: Nm vng vo chc nng hot ng ca cc IC MSC-51 hon ton tng t nhau, v gii thiu AT89C51. AT89C51 l phin bn 8051 c ROM trn chip l b nh Flash.Phin bn ny rt thch hp cho cc ng dng nhanh vi b nh Flash c th xa c trong vi giy. - 4 KB EPROM bn trong - 128 Bytes RAM ni - 4 Port xut nhp I/O 8 bit - Giao tip ni tip - Cho php x l bit. - 210 v tr nh c th nh v bit. - 4 chu k my (4 s i vi thch anh 12MHz) cho hot ng nhn hoc chia. - C cc ch ngh (Low-power Idle) v ch ngun gim (Power- down). Ngoi ra, mt s IC khc ca h MCS-51 c thm b nh thi th 3 v 256 byte RAM ni. AT89C51 c th giao tip vi b nh ngoi dung lng ln n 64KB, 89C51 c 2 ngt ngoi v 2 ngt time mc u tin c quy nh c th, 8951 cng c 2 b m 16 bit, knh giao tip ni 2 chiu.Vi b x l i s Boole cho php x l tng bit ca RAM va thit b ngoi vi, mi lnh ca ko di 1 n 2 micro giy.

SVTH: Nguyn Thnh t

n mn hc 12.1.2/ Cu trc bn trong ca IC 89C51

MCH NG H S

+ Thnh phn chnh ca vi iu khin 89C51 l b x l trung tm hay cn gi l b CPU. CPU bao gm: - Thanh ghi tch ly A - Thanh ghi tch ly B, dng cho php nhn v chia - n v logic hoc ALU - To trng thi chng trnh PSW - 4 bn thanh ghi - Con tr ngn xp - Ngoi ra cn c b nh chng trnh, bao gm: M lnh, b iu khin thi gian v logic. + n v x l trung tm nhn trc tip xung ta a nng. + Chng trnh ny chy c th cho dng li nh mch khoi iu khin bn trong. Cc ngun ngt c th l cc bin c bn ngoi, s tran bo em nh thi hoc cng c th l giao din ni tip.

n mn hc 1

MCH NG H S

+ 2 bo nh thi 16 bit hoat ong nh mot bo em. + Cc cng port 0, port 1, port 2, port 3 n s dng vo mc ch iu khin, cng port 3 c thm cc cng dn iu khin dung e trao oi vi mt bo nh bn ngoi, hoac e au noi giao din ni tip cng nh cc cng dn ngt bn ngoi. + Giao din ni tip cn cha mt bo truyen va mot bo nhan khong ong bo lm vic oc lap vi nhau. Toc o truyn qua cng ni tip c th at trong dai rong va c an nh bang mot bo nh thi. + Trong vi iu khin 8051 cn c hai thnh phn quan trng khc l b nh v cc thanh ghi + B nh cn c Ram v Rom dung e lu d liu vo m lnh. + Cc thanh ghi s dng e lu d thng tin trong qa trnh x l. Khi CPU lm vic, n lm thay i ni dung ca thanh ghi. 2.1.3/ S chn 89C51: AT89C51 c tt c 40 chn c chc nng nh cc ng xut nhp. Trong c 24 chn c tc dng kp (c ngha 1 chn c 2 chc nng), mi ng c th hot ng nh ng xut nhp hoc nh ng iu khin hoc l thnh phn ca cc bus d liu v bus a ch.

n mn hc 1

MCH NG H S

SVTH: Nguyn Thnh t

n mn hc 1a.Cc Port :

MCH NG H S

Port 0: L port hai chc nng trn cc chn 32 39. Khi s dng b nh trong th n nh l mt port I/O ( P0.0P0.7) .Khi s dng b nh ngoi th n ng vai tr nh mt b MUX a ch/data. Port 1: L mt port I/O trn cc chn 1 8 (P1.0P1.7) n ch c dng giao tip vi cc thit b ngoi v khng c cc chc nng khc. Port 2: L mt port cng dng kp trn cc chn 21 28. Khi s dngb nh trong th n nh l mt port I/O a dng (P2.0P2.7), khi s dng bnh ngoi th port 2 chnh l byte cao ca cc ng a ch (A8A15). Port 3: Chim cc chn t 10 n 17, ngoi chc nng chnh l mt I/Oport a dng (P3.0P3.7), mi chn ca port 3 cn c cc chc nng khc nhau, c lp.

b .Nhm chn ngun, dao ng v iu khin -VCC - Chn 40 c ni ln ngun 5V. -GND - Chn 20 ni t - X TA L1-chn 19 v X TA L2-chn 18 : B dao ng c tch hp bn trong 8951, khi s dng 8951 ngi thit k ch cn kt ni thm thch anh v cc t nh hnh v trong s XTAL1-chn 19 v XTAL2-chn 18. Tn s thch anh thng s dng cho AT89C51 l 12Mhz. PSEN : (Program Store Enable)Chn 29, tch cc mc thp trong chu k nhn lnh , ch bo datatrn dus l m lnh.Trong trng hp s dng b nh chng trnh trong th PSENkhng tch cc. ALE : (Address Latch Enable )Chn 30 , tch cc mc cao trong na chu k u ch bo d liutrn port chnh l a ch byte thp A0A7. EA : (External Acess)Chn 31 , cho php chn b nh chng trnh trong hay ngoi. + EA =0 : MCU s dng b nh chng trnh ngoi + EA = 1 : MCU s dng b nh chng trnh trong.

RST (Reset ): Ng vo RST trn chn 9 l ng Reset ca 8951, khi ng ny ln mc cao (trong t nht hai chu k my) cc thanh ghi bn trong 8951 c a v trng thi mc nh. c. Cc thanh ghi chc nng c bit Vng RAM ni a ch t 80H FFH , trong vng ny b tr khong 21thanh ghi c bit , ph trch mt chc nng no ca MCU.i . T h a n h g h i P S W ( P r o g r a m s t a t u s W o r d ) : Thanh ghi t trng thi chng trnh a ch D0H cha cc c ( cc bi t chc nng ) trng thi ca h thng :

Ng vo RST trn chn 9 l ng Reset ca 8951 , khi ng ny ln mc cao(trong t nht hai chu k my ) cc thanh ghi bn trong 8951 c a v trng thi mc nh. i . T h a n h g h i P S W : ( P r o g r a m s t a t u s W o r d ) : Thanh ghi t trng thi chng trnh a ch D0H cha cc c ( ccbit chc nng ) trng thi ca h thng :

Bit PSW.7 PSW.6 PSW.5 PSW.4 PSW.3

K hiu CY AC F0 RS1 RS0

a ch D7H D6H D5H D4H D3H

ngha C nh C nh ph C 0 Bit 1 chn bank thanh ghi Bit 0 chn bank thanh ghi 00: bank 0 01: bank 1 10: bank 2 11: bank 3 C trn D tr C parity chn

PSW.2 PSW.1 PSW.0

OV P

D2H D1H D0H

i i . Thanh ghi B : a ch F0H, truy xut bit, ngoi chc nng l thanh ghi a dng cn tham gia vo 2 php ton nhn v chia.Bit K hiu a ch ngha iii. Thanh ghi SP: (Stack Poiter): a ch 81H , vng ngn xp nm trong RAM ni v nguyn l dunglng ti a l 128 byte. Trc khi ct vo stack ni dung SP tng ln 1 rimi ct (ni dung SP l con tr a ch ), khi ly d liu ra khi stack nidung SP gim i 1 sau khi ly data. iv. Thanh ghi DPTR: (Data Pointer): S dng lm con tr a ch b nh d liu ngoi. Chia lm hai thanh ghi : DPL ( a ch 82H ) cha byte thp DPH ( a ch 83H) cha byte cao. v. Cc thanh ghi cng ngoi vi: Cc lnh lin quan n xu t nhp ngoi vi u thng qua cc thanh ghi cng .Port 0: Thanh ghi P0 (a ch 80H) Port 1: Thanh ghi P1 ( a ch 90H) Port 2: Thanh ghi P2 ( a ch A0H) Port 3: thanh ghi P3 (a ch B0H) vi. Cc thanh ghi timer: TMOD (a ch 89H) : Chn mode lm vic timer. TCON ( a ch 88H) : iu khin timer TL0 (a ch 8AH): byte thp timer 0 TH0 (a ch 8CH): byte cao timer 0 TL1 (a ch 8BH): byte thp timer 1 TH1 ( a ch 80H): byte cao ca timer 1 vii. Cc thanh ghi SIO:

SCON (98H) : khi ng mode v iu khin SIO. SBUF ( 99H) : chuyn d liu t ni tip thnh song song v ngcli. i.Cc thanh ghi phc v ngt : C 5 ngun ngt vi 2 cp u tin: +Thao tc trn thanh ghi IE (A 8H) : cho php / cm ngt. +Thao tc trn thanh ghi IP (B8H) : cp u tin ngt. ii. Cc thanh ghi iu khin cng sut (PCON): a ch 87H , khng truy xut bit c, cc bit ca thanh ghi nyc dng trong vic tc ng ln tc baud (SMOD) trong truyn thng ni tip, a vi mch vo mode tm ngh hay mode h ngun. d. Hot ng ca timer : 89C51 c 2 b timer 16 bit: Timer 0 v timer 1.i . T h a n h g h i T M O D : C a ch 89H , l thanh ghi 8 bit, c cc mode lm vic cho timer. Tm tt thanh ghi TMOD : Bit 7 6 Tn GATE C/T Timer 1 1 M t Bit cng, GATE =1 timer ch m khi INT1=1 Bit chn counter/timer C/T=1: counter, m bng xung ck ngoi ng vo T1 C/T=0: timer, xung ck trong t dao ng ni Bit 1 chn mode Bit 0 chon mode Bit cng (timer 0) Bit chn timer/counter Bit 1 chn mode Bit 0 chon mode

5 4 3 2 1 0

M1 M0 GATE C/T M1 M0 Chn mode:

1 1 0 0 0 0

M1 0 0 1 1

M0 0 1 0 1

Mode `0 1 2 3

M t Timer 13 bit Timer 16 bit Timer 8 bit Timer tch bit

Thanh ghi TCON: a ch 88H, truy xut bit c, l thanh ghi 8 bit Tm tt thanh ghi TCON:

Bit TCON.7 TCON.6 TCON.5 TCON.4 e. Cng ni tip :

K hiu TF1 TR1 TF0 TR0

a ch bit 8FH 8EH 8DH 8CH

M t C bo trn timer 1, phn cng t TF1=1 khi timer trn, xa bng mm hoc cng iu khin ON/OFF timer 1, TR1=1: chy TR1=0: ngng C bo trn timer 1 iu khin ON/OFF timer 0

Giao din ni tip bn trong ca b vi x l 8951 cho php ni bvi x l vi mt vi x l khc hay vi mt my tnh mt cch rt n gin. Bi v giao din c thc hin nh b UART hot ng c lp, nn b vix l hon ton t do i vi cc nhim v khc. khi to giao din thanh ghi SCON cn phi c np bng cc gi tr thch hp Thanh ghi SCON ( a ch 98h) SM0 SM1 SM2 REN TB8 RB8 TI RI

SM0, SM1 Chn mode lm vic: SM0 SM1 0 0 :Mode 0 thanh ghi dch 8 bit, baud rate c nh (f ck/12) 0 1 :Mode 1 UART 8 bit, baud rate thay i (t bng timer 1) 1 0 :Mode 2 UART 9 bit, baud rate c nh (f ck/32 hoc f ck/64) 1 1 :Mode 3 UART 9 bit, baud rate thay i (t bng timer 1) SM2: Ch nhiu my tnh REN: Cho php b thu, cho php b pht TB8: Bit pht th 9 trong mode 2 v 3, t xa bng mm. RB8: Bit nhn th 9 TI : C ngt pht, phn cng t TI = 1 khi pht xong mt k t, xa bng mm . RI : C ngt thu , phn cng t RI =1 khi thu xong mt k t, xa bng mm. Thanh ghi d liu ca giao din ni tip l SBUF ( a c h 9 9 H ) . Thc t pha sau thanh ghi SBUF l hai thanh ghi, c th l thtanh ghi dliu pht v thanh ghi d liu thu. Qu trnh pht c m u mt cchn gin l truy nhp ghi ln thanh ghi SBUF. Ngc li , mt byte

c nhn c th c c t SBUF. Trong ch 9 bit , mi mt bit th9 (TB8 hoc TR8 ) trong thanh ghi SMOD cn phi c n . Trong rt nhiu trng hp , ngi ta s dng ch hot ngloi 1 v nh vy c mt UART 8 bit vi vic to ra tc baud bng timer 1. Dng d liu 8 bit c m u bng mt bit bt u (startr bit ) v ktthtc bng mt bit dng(stop bit). Tc baud bng 1/16(SMOD=1) hoc1/32 (SMOD=0) ca tc trn ca timer 1. f. Hot ng ngt (interrupt): i. Gii thiu: Mt ngt l s xy ra mt iu kin mt s kin- m n gy ratreo tm thi chng trnh trong khi iu kin c phc v bi mtchng trnh khc. ii. T chc ngt trong 8951: 8951 c 5 ngun ngt : + Ngt bng tn hiu ngoi qua ng INT0 (ngt ngoi INT0). + Ngt bng tn hiu ngoi qua ng INT1 (ngt ngoi INT1). + Ngt khi timer 0 trn (ngt timer 0). + Ngt khi timer1 trn (ngt timer 1). + Ngt khi SIO pht / thu xong 1 k t (ngt SIO). a chA8H, truy xut bit c, cho php / cm ngt. Thanh ghi IE: Bit IE.7 IE.6 IE.5 IE.4 IE.3 IE.2 IE.1 IE.0 K hiu EA ES ET1 EX1 ET0 EX0 a ch bit AFH AEH ADH ACH ABH AAH A9H A8H M t Cho php/ cm ton cc Khng nh ngha Cho php ngt SIO Cho php ngt timer 1 Cho php ngt INT1 Cho php ngt timer 0 Cho php ngt INT 0

T chc v s dng cc chn ra ca 89C51: S lc v chc nng phn cng cng nh chng trnh phn mm nh sau:

-o nhit v hin th ln LED, lu li gi tr nhit hinti v gi v my tnh. Ty theo gi tr ca nhit o c m vi x l 89C51 s nhn ranhit ang nm tm bo ng no v c hnh ng tng ng: + to< 50oC : bo ng cp 1- ch bo chung + to< 80oC : bo ng cp 2- bo chung hai ln + to= 100oC: bo ng cp 5 : bo chung ba ln Cm bin quang: chng trm : pht tn hiu kch chung reo khicm bin ny tc ng. Mch m phng cm bin quang m s ngi trong phng S ngi trong phng >= 1: ng thit b S ngi trong phng < 1: tt thit b Mch nt nhn dng yu cu tt / ng thit b theo munca ngi trong phng. Port 0 : y l port xut nhp hai chiu, na chu k l ng data v na chu k k l ng a ch ( byte thp). Em dngport ny c gi tr i c t ADC0809. Port 2: dng gii m LED v to TH chn LED sang 4 bit thp nht ca port 2: p2.0, po2.1, p2.2,p2.3 dng a vo mch gii m LED 74247. 2 bit k tip : p2.4, p2.5 a vo mch gii m7 4 1 S D t o T H c h n LED no sng . Do LED thuc loi Anodchung nn ch LED n o c T H c h n L E D m c t h p t h n s sng. Ngha l tn hiu chn LED sng tch cc mc 0. P2.7 dng to mt nt nhn yu cu ngct n. Khi nt nhn, P2.7 a xung mc 0, chng trnh phnmm s kim tra chn ny xem nt c b nhn hay khng. To xung start cho ADC0809 ta dng chnW R , u C T t a t v x a c h n n y s t o r a m t x u n g k c h c h o ADC 0809 i v i cho n khi ADC i xong. Tn s vo ADC0809 nh hn 12 MHz nn taphi h tn s t 12 MHz xung mc cn thit : 12 MHz / 16 = 750KHz. lm vic ny ta dng IC 74393 to tn hiu kch ng cc Relay ta dngcc chn P1.2, P1.4, P1.5 v P1.6 + P1.2 : iu khin Relay ng / ngt qut + P1.4: iu khin Relay ng / ngt n + P1.5 : iu khin Relay ng / ngt ngun in khi xy ra tnh hungkhn cp. + P1.6: iu khin chung. m bo cc tn hiu kch ny c th kch c cc Relay ng honton, ta cho cc tn hiu ny i qua IC m 74373 Chn T0 dng iu khin phn xut nhp data ca vi x l. + T0 = 0 : vi x l nhn d liu t PC

+ T0 = 1 : vi x l truyn d liu v PC.

2.2/LED 7 ON

Mt trong cc ch bo hin th s thp phn v mt d k t khc l Led 7 on.Led c 2 loi Anot chung v Catot chung.Sau y chng ta s tm hiu loi Anot chung s dng.Led Anode chung :

i vi dng Led anode chung, chn COM phi c mc logic 1 v mun sng Led th tng ng cc chn a f, dp s mc logic 0. Bng m cho Led Anode chung (a l LSB, dp l MSB): S 0 1 2 3 4 5 6 7 8 9 dp 1 1 1 1 1 1 1 1 1 1 g 1 1 0 0 0 0 0 1 0 0 f 0 1 1 1 0 0 0 1 0 0 e 0 1 0 1 1 1 0 1 0 1 d 0 1 0 0 1 0 0 1 0 0 c 0 0 1 0 0 0 0 0 0 0 b 0 0 0 0 0 1 1 0 0 0 a 0 1 0 0 1 0 0 0 0 0 M hex 0C0H 0F9H 0A4H 0B0H 99H 92H 82H 0F8H 80H 90H

- hin th d liu trn Led dng AT 89C51 c 2 phng php l cht d liu dng mt s loi IC cht nh: 74HC573, 74LS373, 74LS374v phng php qut Led.

- Trong n ny em dng phng php qut Led, l mt trong nhng phng php c dng nhiu hin ti. 2.3 / Transistor iu khin nng dng C1815

PHN III Thit K V Thi Cng Chng I THIT K MCHI.S KHI CA MCH