You are on page 1of 10

Phng th nghim Vi x l

Bi th nghim Vi x l

BI 05: KHO ST B BIN I S - TNG T (DIGITAL TO ANALOG CONVERTER)


MC CH TH NGHIM Gip sinh vin bng thc nghim kho st cc vn chnh sau y : - Kho st b chuyn i s sang tng t v cch ghp ni vi my tnh 1. 2. 3. 4. 5. THIT B S DNG B th nghim PTS-31. Board th nghim PM-305. My vi tnh. ng h s VOM. Dao ng k C S L THUYT

PHN I : I.

KT NI PHN CNG

B bin i s - tng t (DAC ) thc hin cng vic bin i cc gi tr s thnh cc i lng tng t (dng in hoc in p) tng ng. Khi PM-305 c xy dng trn vi mch DAC0808 l loi DAC 8 bit c cc ng vo v ra nh sau: * Ng vo: - A8 (bit 0) -A1 (bit7): Ng vo s 8 bit (PORT B). -VREF +/- : Ng vo in p chun, cho php chnh thang o. * Ng ra : - IOUT : Ng ra tng t. Mch s dng b khuch i thut ton JR4558 cho php bin i dng ra thnh in p dng OUT + hay m OUT -. Mch s dng ngun 12V. II. PHN MM

Trong my tnh np sn hai chng trnh phc v cho bi th nghim bin i tng t s DAC trong th mc C:\TNVXL\TASM - UPM304.ASM : Cha trong th mc UPBAS l chng trnh son tho bng ngn ng ASSEMBLY - UPM304.EXE : L chng trnh m my.

Trang 46

Phng th nghim Vi x l

R13 4 R16 R14 1 5.35K R15 2.7K 5.35K 6 5 4

OUT +

DAC0808 8 7 6 5 4 3 2 1 PORT B +12V R9 R10 2.7K P1 + C4 100uF D1 Z5V1 C5 0.01uF C2 0.01uF R11 2.7K

2.7K IOUT IOUT 4 2 R12 2.7K 2 3

COMP

16

14 15

VR+ VRC3 0.01uF -12V

820

A8 A7 A6 A5 A4 A3 A2 A1

PB0 PB1 PB2 PB3 PB4 PB5 PB6 PB7

12 11 10 9 8 7 6 5

OUT -

Trang 47

Bi th nghim Vi x l

Phng th nghim Vi x l

Bi th nghim Vi x l

Lu chng trnh cho bi th nghim PM305:


Begin

nh cu hnh cho 8255 (U9) PA: xut, PB: xut, PC: xut

C phm nhn?

Nhn phm 'X'?


N Y

Nhn phm 'N'?

To dng sng rng ca ng ra DAC

Nhp d liu s t bn phm v xut ra DAC


N

C phm nhn?

Nhn phm ESC?

End

PHN II : I.

TIN TRNH TH NGHIM

KT NI PHN CNG

1. Ni CON 1 (PART A) ca thit b chnh PTS-31 vi ra ca b giao tip PCBUS-2 gn trong Slot ca my tnh. 2. S dng dy c cht cm 2 u ni mch:
Trang 48

Phng th nghim Vi x l

Bi th nghim Vi x l

II.

Ni cc cht ngun +5V, 12V v t (POWER PORT) ca khi PM-305 vi ngun nui +5V, 12V v t ca thit b chnh PTS-31. Ch cm ng phn cc ngun. Ni trm PORT B ca PTS-31 vi trm PART B ca khi PM-305.

CH HOT NG VI IU KHIN N Thc hin chng trnh sau: .model .stack .data msg1 clr .code main DB DB small 100h
Nhan ''N'' nhap gia

msg DB 'Nhan ESC thoat tri DAC Nhan ''X'' xuat$'

'Gia tri DAC:$' $ ; 3 khoang trang de xoa gia tri cu

proc mov ax,@data mov ds,ax mov ax,02h int 10h mov ah,09h lea dx,msg int 21h mov dx,0B10h call gotoxy lea dx,msg1 mov ah,09h int 21h mov dx,30Bh mov al,90h out dx,al ;Xuat thong bao ra man hinh

; Chuyen toa do con tro ; den hang 11, cot 16

; Dinh cau hinh cho U9 ; Kiem tra phim nhan

start: mov int cmp jne

ah,0Bh 21h al,0FFh start

mov ah,01h int 21h cmp al,N je NhapDAC


Trang 49

Phng th nghim Vi x l

Bi th nghim Vi x l

cmp je cmp je cmp je

al,n NhapDAC al,X Xuatxung al,x Xuatxung

cmp al,27 je exit jmp start Xuatxung: mov int cmp je ah,0Bh 21h al,0FFh start

mov cx,30 Xuat1: mov al,0 mov dx,309h Xuat: out inc cmp jne dx,al al al,200 Xuat

loop Xuat1 jmp Xuatxung ;---------------------------------------NhapDAC: mov dx,0B1Dh call gotoxy lea dx,clr mov ah,09h int 21h mov call mov out jmp exit: dx,0B1Dh scan_kb ; Nhap tu ban phim dx,309h dx,al start

mov ah,4Ch int 21h endp


Trang 50

main

Phng th nghim Vi x l

Bi th nghim Vi x l

include tnvxl.asm end main

Khi cn chuyn i DAC cho 1 gi tr s no u tin nhn N con tr nhy v hng gi tr DAC, sau nhp s cn chuyn i vo, my tnh s chuyn ra b chuyn i DAC trn PM-305 v chuyn sang tn hiu tng t tng ng. V d nhp cho DAC l 255 thao tc ln lt nh sau: u tin nhm N, con tr nhy v hng Gi tr DAC, nhp s 255 vo t bn phm - iu chnh ch 1 chiu: Xc lp in p chun: o in p ra. V s liu np l 255 s ng vi gi tr s cc i, chnh P1 c in p ra l tng ng OUT+ l 2,55V. - Kim tra hot ng: Thay i gi tr np t my tnh, o in p ra tng ng, ghi kt qu. Dng th gia in p ra (trc y) theo s liu nhp vo my tnh (trc x). Gi tr nhp 0 5 10 15 20 40 60 80 90 100 III. in p ra Gi tr nhp 120 140 160 180 200 220 250 255 270 300 in p ra

CH HOT NG VI IU KHIN THEO VNG LP - Khi my tnh ang chng trnh phc v cho khi chuyn i DAC PM305. Nhn phm X My tnh s t ng iu khin DAC hot ng theo ch vng lp. Cc gi tr xut cho DAC s tng dn tng mt n v. - S dng dao ng k quan st in p ra ti ng ra OUT + /-. V li dng tn hiu ra. - B on in m trong chng trnh trn, quan st li kt qu - Vit li chng trnh dng tn hiu ti ng ra l vung hay tam gic. Gi : on chng trnh to sng vung: mov dx,309h mov al,0 out dx,al
Trang 51

Phng th nghim Vi x l

Bi th nghim Vi x l

call mov mov out call

delay dx,309h al,200 dx,al delay

on chng trnh to sng tam gic: mov al,0 mov dx,309h Tang: out dx,al inc al cmp al,200 jne Tang mov al,200 mov dx,309h Giam: out dec cmp jne dx,al al al,0 Giam

Vit chng trnh to mt dng sng bt k. Thc hin kt hp vi mch ADC to sng vung c bin thay i theo in p DC.

Trang 52

Phng th nghim Vi x l

Bi th nghim Vi x l

PH LC
Ni dung file tnvxl.asm: ;--------------------------------------------; Ket thuc chuong trinh ;--------------------------------------------quit proc mov ah,0Bh int 21h cmp al,0 je Notread mov ah,08h int 21h Notread: mov ah,4Ch int 21h ret quit endp ;-----------------------------------------------; Xoa man hinh ; Thanh ghi thay doi AX ;----------------------------------------------clrscr proc mov ax,02h int 10h ret clrscr endp ;----------------------------------------------; Chuyen toa do con tro ; Vao: DX: toa do con tro ; Thanh ghi thay doi AH,BH ;---------------------------------------------gotoxy proc mov ah,02h mov bh,0 int 10h ret gotoxy endp ;---------------------------------------------; Nhap mot so trong khoang 0 - 255 tu ban phim ; So nhap toi da co 3 ky tu (0-9), neu co it hon 3 ky tu ; thi ket thuc so bang phim Enter ; Vao: DX: vi tri con tro ; Ra : So da nhap chua trong thanh ghi AL ; Thanh ghi thay doi: AX, DL ;--------------------------------------------scan_kb proc near push bx
Trang 53

Phng th nghim Vi x l

Bi th nghim Vi x l

push call mov mov mov kb:

cx gotoxy cx,0 dl,0 bl,1

mov ah,01h int 21h ; Nhap ky tu cmp al,0Dh je kt_so ; Neu nhap ky tu Enter sub al,'0' ; Chuyen tu ky tu sang dang so push ax ; Dua so vua nhap vao stack inc cx ; Nhap them 1 ky tu cmp cx,3 ; Neu da nhap 3 ky tu thi ket thuc nhap jne kb kt_so: pop ax ; Lay tu stack mul bl add dl,al mov al,10 mul bl mov bl,al loop kt_so mov al,dl ; Dua ket qua vao AL pop cx pop bx ret scan_kb endp ;------------------------------------; Xuat mot ky tu ra man hinh ; Vao: DL: ma ASCII cua ky tu ; BX: toa do xuat ky tu ; Thanh ghi thay doi AH ;-----------------------------------out_char proc near push dx push bx mov dx,bx mov ah,2 mov bh,0 int 10h pop bx pop dx mov ah,02h int 21h ret out_char endp ;-----------------------------------Trang 54

Phng th nghim Vi x l

Bi th nghim Vi x l

; In mot so nguyen ra man hinh ; Vao: AL chua gia tri so nguyen ; BX chua toa do in so ;-----------------------------------print_monitor proc push ax mov cx,3 read: aam push ax mov al,ah loop read mov cx,3 print: pop dx add dl,'0' call out_char inc bx loop print pop ax ret print_monitor endp ;---------------------------------------------------------

Trang 55