Está en la página 1de 45

THIT K MCH IN BNG MY TNH

Ging vin: V Chin Thng Bi tho lun: hin th nhit trn LCD Thnh vin nhm: 1.Trn Vn subtitle style Click to edit Masterc 2.inh Th Thy 3.on Th V 4.Nguyn Th Minh Hin

4/21/12

Phn 1: gii thiu phn mm m phng proteus


1.gii thiu : Proteus l phn mm ca hng Labcenter dng v s nguyn l, m phng v thit k mch in. Gi phn mm gm c phn mm chnh: . ISI dng v s nguyn l v m phng . . ARES dng thit k mch in. Sau khi ti v qu trnh ci t chng trnh bnh thng , sau khi ci t thnh cng bn s thy chng trnh trong start menu.
4/21/12

2.Hng dn s . dng: a. V s nguyn l vi ISIS :


4/21/12

Giao din ca chng trnh nh sau

4/21/12

Thanh trnh n: bao gm cc menu nh: file, view,

edit..ta c th thc hin hu ht cc lnh ISIS ti y( tr cc lnh thanh cng c) Thanh tc v: cha mt s lnh ca thanh trnh n dng shortcut nh: new, save open, v cc nt sau:

4/21/12

4/21/12

Thanh cng c:

4/21/12

Cc nt m phng

Vng hin th: hin th khi qut vng lm vic hin hnh, khung mu xanh dng biu hin cho ton bn v; khung xanh l biu hin cho phn bn v ang hin th trn vng lm vic chnh. Khi chn mt linh kin, k hiu nguyn l ca n cng c hin th trn vng ny. Vng lm vic chnh: Dy l ni thc hin ton b cc thao tc hon thnh bn v
4/21/12

S dng th vin ISIS


m th vin ISIS ta chn

nt Component nhp tri ln nt P Th vin ISIS c m:

4/21/12

Ta ln lt nhp i vo cc linh kin cn dng, cc

linh kin ny s xut hin vng ly thit b. Khi ly linh kin, bm Close ng th vin Trn vng chn nhp tri chn linh kin sau nhp tri ln vng lm vic t ln mch

4/21/12

Ngoi ra ISIS cn h tr cng c tm kim kh nhanh,

trong lc ang v mch bm phm P xut hin ca s tm kim. V d ta tm IC 555:

4/21/12

Phn 2: Mch in m phng trn proteus


I.S nguyn l :

4/21/12

Nguyn l hot ng
Khi cm bin nhit ic lm35 c nhim v thay i gi

tr in p u ra theo nhit m c th l 10mv/.Tn hiu tng t u ra ca lm 35 s c a vo b chuyn i ADC0804. Ti ADC0804 tn hiu tng t nhn c s c chuyn i thnh tn hiu s a vo vi iu khin 8051. Vi iu khin nhn c tn hiu t cng p0 sau s x l tn hiu s ny trc khi xut ra lcd LCD nhn c d liu v lnh t vi iu khin s hin th d liu trn mn hnh
4/21/12

II.Cc khi chc nng ca mch


1.Khi cm bin nhit LM35:

+B cm bin chuyn i cc i lng vt l nh : nhit , cng nh sng....thnh cc tn hiu in. Ph thuc vo b cm bin m u ra c th l tn hiu dng in p, dng, tr khng hay dung khng.

4/21/12

+ y nhit c bin i thnh tn hiu in s dng b cm bin nhit l themistor. +B cm bin nhit p ng s thay i nhit bng cch thay i tr khng song p ng ny khng tuyn tnh. +Bng tr khng ca b cm bin nhit theo nhit .
.

Nhit 0 25 50 75 100
4/21/12

Tr khng ca cm bin (k) 29.490 10.000 3.893 1.700 0.817

+LM35 l h cm bin nhit, mch tch hp, chnh xc cao c in p u ra t l tuyn tnh vi nhit theo thang Celsius. H ny khng yu cu cn chnh ngoi +LM35 cho ra in p 10mV ng vi thay i nhit 10C

4/21/12

2.Khi chuyn i ADC :

+ Chip ADC0804 l b chuyn i tng t s thuc h ADC800 ca hng National Semiconductor +Chip c in p nui +5V v phn gii 8 bit. +Thi gian chuyn i c nh ngha l thi gian m b ADC cn chuyn mt u vo tng t thnh mt s nh phn. +i vi ADC0804 th thi gian chuyn i ph thuc vo tn s ng h c cp ti chn CLK v CLK IN v khng b hn 110s.
4/21/12

Chc nng cc chn + CS (Chip select): Chn s 1, l chn chn Chip, u vo tch cc mc
.

thp c s dng kch hot Chip ADC0804. +RD (Read): Chn s 2, l mt tn hiu vo, tch cc mc thp. RD c s dng c d liu c chyn i ti u ra ca ADC0804. Khi CS = 0 nu c mt xung cao xung thp p n chn RD th d liu ra dng s 8 bit c a ti cc chn d liu (DB0 DB7).

4/21/12

+WR (Write): Chn s 3, y l chn vo tch cc mc thp c


.

dng bo cho ADC bit bt u qu trnh chuyn i. Nu CS = 0 khi WR to ra xung cao xung thp th b ADC0804 bt u qu trnh chuyn i gi tr u vo tng t Vin v s nh phn 8 bit.. + CLK IN v CLK R: CLK IN (chn s 4), l chn vo ni ti ng h ngoi c s dng to thgian. CLK R (chn s 19) c ni vi mt t in v mt in tr

4/21/12

+Ngt INTR (Interupt): Chn s 5, l chn ra tch cc mc thp.Bnh thng chn ny trng thi cao v khi vic chuyn i hon tt th n xung thp bo cho CPU bit l d liu chuyn i sn sng ly i. Sau khi INTR xung thp, cn t CS = 0 v gi mt xung cao xung thp ti chn RD a d liu ra. +Vin (+) v Vin (-): Chn s 6 v chn s 7, y l 2 u vo tng t vi sai, trong : Vin = Vin (+) Vin(-) . Thng thng Vin (-) c ni ti t v Vin (+) c dng lm u vo tng t v s c chuyn i v dng s.
.

4/21/12

+ VccL: Chn s 20, l chn ngun nui +5V. Chn ny cn c dng lm in p tham chiu khi u vo Vref/2 h. +Vref/2: Chn s 9, l chn in p u vo c dng lm in p tham chiu. Nu chn ny h th in p u vo tng t cho ADC0804 nm trong di 0 - +5V. Chn Vref/2 c dng thc hin cc in p u ra khc 0 - +5V.
.

4/21/12

Bng quan h in p Vref/2 vi Vin Vref/2 (V) H 2.0 1.5 0 2.56 1.0 0.5 Vin (V) 0-5 0-4 0-3 0 2.56 0-2 0-1 Kch thc bc (mV) 5/256 = 19.53 4/256 = 15.62 3/256 = 11.71 2.56/256 = 10 2/256 = 7.81 1/256 = 3.90

4/21/12

+D0 - D7: D0 - D7, chn s 18 11, l cc chn ra d liu s Cc chn ny c m ba trng thi v d liu c chuyn i ch c truy cp khi chn CS = 0 v chn RD a xung mc thp. tnh in p u ra ta tnh theo cng thc sau: Dout = Vin / kch thc bc Dout: u ra d liu s dng thp phn Vin: in p u vo tng t Kch thc bc: l s thay i nh nht c tnh bng (2 x Vref/2) chia cho 256 i vi ADC 8 bit.
.

4/21/12

3.Khi x l VDK 8051: :

Da trn nhng kin thc v vi iu khin,mn hnh LCD v lp trnh ghp ni gia vi iu khin vi thit b ngoi vi , c th l ghp ni vi iu khin 8051 vi mn hnh LCD hin th nhit trn LCD. lp trnh 8051 c th dng cc ngn ng bc cao nh: Forth, BASIC, Pascal, PL/M Modula 2, nhng ph bin l s dng trnh bin dch lp trnh C v Assembler .

4/21/12

Chp 8051(80C51) l b vi iu khin u tin ca h

vi iu khin MCS-51 bao gm : +4KB ROM, +128 byte RAM +32 ng xut nhp, chia lm 4 port(port0 n port3) +2 b nh thi 16 bit. +Mt cng ni tip +khng gian nh chng trnh ngoi 64KB +B x l bit +210 v tr nh c nh a ch,mi v tr mt bit
.

4/21/12

Hnh nh thc t v s chn

4/21/12

4.Khi hin th LCD HD44780 :

S dng LCD HD44780 l thit b hin th c s dng trong rt nhiu cc ng dng ca VK. LCD c rt nhiu u im so vi cc dng hin th khc: N c kh nng hin th k t a dng, trc quan (ch, s v k t ha), d dng a vo mch ng dng theo nhiu giao thc giao tip khc nhau, tn rt t ti nguyn h thng v gi thnh r

4/21/12

S chn:
.

Chn 1 2 3 4 5 6 7 ->14

K hiu VSS VCC VEE RS R/W E DB0 -> DB7

I/O I I I/O I/O

M t t Dng ngun Ngun diu khin tng phn RS = 0 chn thanh ghi lnh RS = 1 chn thanh ghi d liu R/W =1 c d liu. R/W = 0 ghi Cho php Bus d liu 8 bit

4/21/12

Cc thanh ghi :

+ Chp HD44780 c 2 thanh ghi 8 bit quan trng : Thanh ghi lnh IR (Instructor Register) v thanh ghi d liu DR (Data Register) + Thanh ghi IR : iu khin LCD, ngi dng phi ra lnh thng qua tm ng bus DB0-DB7 Ngi dng ch vic cung cp a ch lnh bng cch np vo thanh ghi IR. Ngha l, khi ta np vo thanh ghi IR mt chui 8 bit, chp HD44780 s tra bng m lnh ti a ch m IR cung cp v thc hin lnh . + Thanh ghi DR : Thanh ghi DR dng cha d liu 8 bit ghi vo vng RAM DDRAM hoc CGRAM .
.

4/21/12

Bng cch iu khin chn RS v R/W chng ta c th

chuyn qua li gi 2 thanh ghi ny khi giao tip vi MPU. Bng sau y tm tt li cc thit lp i vi hai chn RS v R/W theo mc ch s dng .
.

RS 0 0 1 1
4/21/12

R/W 0 1 0 1

Khi cn Ghi vo thanh ghi IR ra lnh cho LCD c c bn DB7 v gi tr ca b m a ch DB0-DB6 Ghi vo thanh ghi DR c d liu t DR

III.Chng trnh m phng:


#include<REGX51.h> #include<string.h> #define INTR P3_0 #define RD P3_1 #define WR P3_2 char k1,k2; void delay() //do tre la 25ms

4/21/12

{ TMOD=0x01; //ghi tu dieu khien vao thanh ghi tmode TH0=0x9e; //chon timer0 che do 1 TL0=0x58; TR0=1; while(TF0==0) {} TF0=0; } unsigned char k,i; void delay2(short int time) {unsigned n; for(n=0;n<time;n++); }
.

4/21/12

void LCD_write(unsigned char x) // gui du lieu len

man hinh { P1_0=1; //chon thanh ghi du lieu P1_1=0; // chon che do ghi du lieu P2= x ; // dua ra tren cong P0 gia tri du lieu P1_2=1; // dua chan cho phep tu cao xuong thap de chot du lieu P1_2=0; delay() ; }
.

4/21/12

void LCD_cmd( unsigned char x) //gui lenh len man

hinh

.

{ P1_0=0; //chon thanh ghi lenh P1_1=0; // chon che do ghi du lieu P2= x; // dua ra tren cong P0 gia tri du lieu P1_2=1; // dua chan cho phep tu cao xuong thap de chot du lieu P1_2=0; delay(); //cho cho den khi lenh gui da hoan tat

4/21/12

void LCD_init() { LCD_cmd(0x38); LCD_cmd(0x0c); LCD_cmd(0x01); LCD_cmd(0x06);


.

don vi }

// hai hang ma tran 5x7 // bat man hinh tat con tro // xoa man hinh // dich con tro sang phai mot

4/21/12

void giatri(char k) {WR=0; // Bat dau chuyen doi gia tri tu ADC delay2(100); // Tao tre de cap nhat du lieu tu ADC WR=1; // while(!INTR); RD=0; // Nhan du lieu da duoc chuyen doi k=P0; k1=k/10; //phan nguyen k2=k%10; //phan du LCD_write(k1+48); LCD_write(k2+48); }
.

4/21/12

void hienthihaihang(void) { unsigned char i; char H1[20]=" CAC THANH VIEN "; char H2[20]="Nhiet Do: "; LCD_cmd(0x80); // dua con tro toi vi tri 0x80
.

tren man hinh for(i=0;i<strlen(H1);i++)

4/21/12

{
.

LCD_write(H1[i]); delay2(3000);} LCD_cmd(0xcc); giatri(); LCD_write(223); LCD_write(67); LCD_cmd(0xc0); for(i=0;i<strlen(H2);i++) { LCD_write(H2[i]); } }

4/21/12

void hienthihaihang1(void) { unsigned char i; char H1[20]="1.TRAN VAN DUC "; char H2[20]="2.DINH THI THUY "; LCD_cmd(0xcc); giatri(); LCD_cmd(0x80); // dua con tro toi vi tri 0x80
.

tren man hinh for(i=0;i<strlen(H1);i++)

4/21/12

{
.

LCD_write(H1[i]);delay2(5000); } LCD_cmd(0xcc); giatri(); LCD_cmd(0x80); for(i=0;i<strlen(H2);i++) { LCD_write(H2[i]); delay2(5000); } }

4/21/12

void hienthihaihang2(void) { unsigned char i; char H1[20]=" 3.NGUYEN THI "; char H2[20]=" MINH HIEN "; LCD_cmd(0xcc); giatri(); LCD_cmd(0x80); // dua con tro toi vi tri 0x80
.

tren man hinh for(i=0;i<strlen(H1);i++)

4/21/12

{ LCD_write(H1[i]); delay2(5000); } LCD_cmd(0xcc); giatri(); LCD_cmd(0x80); for(i=0;i<strlen(H2);i++) { LCD_write(H2[i]); delay2(5000); } }


.

4/21/12

void hienthihaihang3(void) { unsigned char i; char H1[20]="4.DOAN THI VE "; char H2[20]=" BAI DO NHIET DO "; LCD_cmd(0xcc); giatri(); LCD_cmd(0x80); // dua con tro toi vi tri 0x80
.

tren man hinh for(i=0;i<strlen(H1);i++)

4/21/12

{
.

LCD_write(H1[i]);delay2(5000); } LCD_cmd(0xcc); giatri(); LCD_cmd(0x80); for(i=0;i<strlen(H2);i++) { LCD_write(H2[i]); delay2(5000); } }

4/21/12

main() { LCD_init(); P1_0=1; P1_1=1; for(;;){ hienthihaihang(); hienthihaihang1() ; hienthihaihang2() ; hienthihaihang3() ; } }


.

4/21/12