Trường ĐH SPKT Luận văn tốt nghiệp GVHD: Nguyễn Đình Phú SVTH: Nguyễn Trung Dũng
TÀI LIỆU THAM KHẢO
1. ĐO LƯỜNG VÀ ĐIỀU KHIỂN BẰNG MÁY VI TÍNH
Ngô Diện Tập _ NXB KHKT Hà Nội _ 1996
1. ĐIỀU KHIỂN VÀ GHÉP NỐI CC THIẾT BỊ NGOẠI VI
Trần Bá Thái _ NXB KHKT Hà Nội _ 1984
2. KỸ THUẬT GHÉP NỐI MÁY VI TÍNH
Nguyễn Mạnh Giang _ NXB GD Hà Nội _1997
3. TRUYỀN DỮ LIỆU
Tống Văn On _ ĐH KỸ THUẬT TPHCM _ 1999
4. VI XỬ LÝ TRONG ĐO LƯỜNG VÀ ĐIỀU KHIỂN
Ngô Diện Tập _ NXB KHKT Hà Nội _ 1996
5. KỸ THUẬT VI XỬ LÝ
Văn Thế Minh _ NXB GD _ 1997
6. ASSEMBLY LANGUAGE TOOLS and TECHNIQUES FOR
THE IBM MICROCOMPUTERS
Julio Sanches _ Prentice Hall _ 1990
7. MICROCOMPUTER INTERFACING
Bruce A.Artwick _ Prentice Hall _ 1980
Trường ĐH SPKT Luận văn tốt nghiệp GVHD: Nguyễn Đình Phú SVTH: Nguyễn Trung Dũng
PHỤ LỤC
db 0dh,0a`,'$'
PROT_MS db '* Installed communications
protocol',0dh,0ah
db 'Baud rate:'
Baud% db '2400',0dh,0ah
db 'Parity:'
Par% db 'Even',0dh,0ah
db 'Stop bit:'
Stop% db '1',0dh,0ah
db 'Word length:'
Word% db '8',0dh,0ah,0ah,'$'
Baud$$ db '110 150 300 600 1200 2400 4800 9600'
Trường ĐH SPKT Luận văn tốt nghiệp GVHD: Nguyễn Đình Phú SVTH: Nguyễn Trung Dũng
Par$$ db 'odd noneven'
baud_menu db 0dh,0ah,'**New communication parameter'
db 'rs input **',0dh,0ah
db 'baud rate:',0dh,0ah
db '1 = 110',0dh,0ah
db '2 = 150',0dh,0ah
db '3 = 300',0dh,0ah
db '4 = 600',0dh,0ah
db '5 = 1200',0dh,0ah
db '6 = 2400',0dh,0ah
db '7 = 4800',0dh,0ah
dw 0
data_in dw 0 ;imput pointer
data_out dw 0 ;output pointer
Trường ĐH SPKT Luận văn tốt nghiệp GVHD: Nguyễn Đình Phú SVTH: Nguyễn Trung Dũng
data ends
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx CODE xxxxxxxxxxxxxxxxxx
code segment
assume CS:code
start:
mov ax,data
mov ds,ax
assume ds:data
mov es,ax
assume es:data
;display MENU at cursor
mov dx,offset menu_ms ;messages
call show_message
;hardware type
push ds
mov dx,0f000h
mov ds,dx
mov al,ds:[0fffeh] ;code to AL
;get addr of the RS232 card from BIOS data area
mov dx,0
mov ds,dx
mov ah,0
mov dx,0
int 14h
call comm_on
call flush ;
monitor:
mov ah,1
int 16h
jz ser_imp
jmp char_typed
ser_imp:
sti ;interrupt on
mov cx,50
delay: nop
nop
loop delay
;test for new data received
cli
mov bx,data_out
cmp bx,data_in
jne new_data
sti
jmp monitor
;process char
char_typed:
mov ah,0
int 16h
;test for <F1>,<F2>,<F3>,<F4> and <F9> keys
cmp ax,3b00h
jne test_f2
int 21h
;exit
mov ah,76
mov al,0
int 21h
;redisplay menu
show_menu:
mov dx,offset menu_ms
call show_message
jmp monitor
;new data receiver
new_data:
lea si,circ_buf
mov bx,data_out
add si,bx
mov al,byte ptr[si]
;update output pointer
inc bx
cmp bx,20
jne ok_out_ptr
mov bx,0
ok_out_ptr:
mov data_out,bx
sti
call tty
jmp monitor
set_protocol:
call comm_off
baud_rates:
mov setup_byte,al
parity:
mov dx,offset par_menu
call show_message
call get_key
call tty
;valid input range is "1" to "3"
cmp al,'1'
jc parity
cmp al,'4'
jnc parity
;input is valid range
sub al,30h
push ax
;select 4 byte parity message and place in display area
sub al,1
mov al,4
mul cl
mov si,offset par$$
mov ah,0
add si,ax
mov di,offset par%
mov cx,4
cld
push ds
Trường ĐH SPKT Luận văn tốt nghiệp
;valid input range is '1' or '2'
cmp al,'1'
jc word_length
cmp al,'3'
jnc word_length
push ax
;Input in valid range. Add 6 and move input to display
area
add al,6
mov si,offset word%
mov byte ptr[si],al
pop ax
sub al,30h
inc al
or setup_byte,al
;install new parameter
mov al,setup_byte
mov dx,0
mov ah,0
Trường ĐH SPKT Luận văn tốt nghiệp GVHD: Nguyễn Đình Phú SVTH: Nguyễn Trung Dũng
int 14h
;line feed and cariage reture before exit
mov al,0dh
call tty
mov al,0ah
call tty
;place in transmitter hoding register to send
mov dx,card_base
out dx,al
jmp short $+2
;display character
call tty
jmp monitor
;*********************************************************
*****
;CAC CHUONG TRINH CON
Trường ĐH SPKT Luận văn tốt nghiệp GVHD: Nguyễn Đình Phú SVTH: Nguyễn Trung Dũng
comm_on proc near
cli ;interrupt off
;reset buffer pginter to start of buffer
mov data_in,0
mov data_out,0
;set dx to base address of RS 232 card from BIOS
mov dx,card_base
mov dl,0fch
mov al,00001011b
out dx,al
jmp short $+2
;set bit 7
mov dl,0fbh
in al,dx
jmp short $+2
tty_one:
Trường ĐH SPKT Luận văn tốt nghiệp GVHD: Nguyễn Đình Phú SVTH: Nguyễn Trung Dũng
push ax
mov ah,14
mov bx,0
int 10h
pop ax
cmp al,0dh
jne not_cr
mov al,0ah
jmp tty_one
not_cr: ret
tty endp
flush proc near
flush_1:
mov ah,1
int 16h
jz no_old_chars
mov ah,0
int 16h
jmp flush_1
no_old_chars:
ret
flush endp
jnz data_error
jmp data_check
data_error:
mov al,'1'
jmp store_byte
data_ready:
mov dl,0f8h
in al,dx
jmp short $+2
and al,7fh
store_byte:
lea di,circ_buf
mov bx,data_in
add di,bx
mov byte ptr[diU,al
inc bx
cmp bx,20
jne ok_in_ptr
mov bx,0
ok_in_ptr:
mov data_in,bx
mov al,20h
out 20h,al
jmp short $+2
pop ds
pop di
pop dx
pop bx
pop ax