Sensor Suhu Ruangan dengan Display LCD
komponen yang digunakan :
- LM016L (Display LCD)
- LM35 (Sensor Suhu)
- Transistor 2N2222
- IC 74LS138
- IC 74LS139
- IC 74LS245
- IC 74LS373
- Resistor 3005P-1-501
- RAM 6116
- Mikroprosesor 8086
- PPI 8255
- ROM 27128
- ADC0804
- BATTERY
- CAPASITOR
- RESISTOR
- DIODE
- DIODE-ZEN
- INVERTER
- KEYPAD-PHONE
- MM74C922
- MOTOR
- OPAMP
- WIRE
- BUS WIRE
- GROUND
- POWER VCC
Listing Program (menggunakan emu8086) :
; You may customize this and other start-up templates;
; The location of this template is c:\emu8086\inc\0_com_template.txt
org 100h
; PROGGRAM9.ASM DIGUNAKAN UNTUK MENAMPILKAN INPUT KEYPAD
; DAN DATA SENSOR SUHU KE LCD DAN MENGONTROL SUHU
; Data LCD: Port A
; E : PC0
; RS : PC1
; Data ADC : Port B17 s/d Port B10, kontrol PC10,
; PC11 dan PC14
; Data DAC : dari Port A17 s/d Port A10
CODE_SEG SEGMENT
ASSUME CS:CODE_SEG,DS:CODE_SEG,SS:CODE_SEG
ORG 100H
start: jmp mulai
porta equ 00h
portb equ 01h
portc equ 02h
cw equ 03h
port1a equ 10h
port1b equ 11h
port1c equ 12h
cw1 equ 13h
DISPCLR EQU 00000001B
FUNCSET EQU 00111000B
ENTRMOD EQU 00000110B
DISPON EQU 00001100B
awal db ?
kolom db ?
data db ?
data_teks db ?
data_keypad1 db ?
data_keypad2 db ?
data_keypad3 db ?
ratusan db ?
puluhan db ?
satuan db ?
setting db ?
ADC :
keypad_ke db ?
status db ?
data_setting db ?
dataADC db ?
dataDAC db ?
akhir db ?
mulai:
Mov AX, CS
Mov DS, AX
Xor AX, AX
Mov ES, AX
Mov SS, AX
Lea SI, Awal
Lea CX, Akhir
Mov DI, SI
Sub CX, SI
Cld
Rep Movsb
Mov SP,800h
Xor AX,AX
Mov DS,AX
Mov al,82h ;Port A dan Port C = output dan
; Port B = input
mov dx,cw
out dx,al
mov al,82h ;Port A dan Port C = output dan Port B
; = input
mov dx,cw1
out dx,al
call initialisasi_LCD
balik:
call display_set
call display_hasil
;-------------------------
;Tekan Tombol ke-1
;--------------------------
tombol1:
mov al,8Bh
mov data,al
call control_out
call tombol_ditekan
je tombol1
in al,dx
and al,00001111B
call konversi_keypad_to_bin
mov data_keypad1,al
mov ah,0
add ax,30h
mov data,al
call data_out
subanta:
call tombol_dilepas
je subanta
;-------------------------
;Tekan Tombol ke-2
;--------------------------
Tombol2:
mov al,8Ch
mov data,al
call control_out
call tombol_ditekan
je tombol2
in al,dx
and al,00001111B
call konversi_keypad_to_bin
mov data_keypad2,al
mov ah,0
add ax,30h
mov data,al
call data_out
subanta2:
call tombol_dilepas
je subanta2
jmp tombol3
baliak_ka_muko:
jmp balik
;-------------------------
;Tekan Tombol ke-3
;--------------------------
tombol3:
mov al,8Dh
mov data,al
call control_out
call tombol_ditekan
je tombol3
in al,dx
and al,00001111B
call konversi_keypad_to_bin
mov data_keypad3,al
mov ah,0
add ax,30h
mov data,al
call data_out
subanta3:
call tombol_dilepas
je subanta3
;----------
;Cek status
;---------
cek:
call tombol_ditekan
je cek
in al,dx
and al,00001111B
call konversi_keypad_to_bin
mov status,al
subanta4:
call tombol_dilepas
je subanta4
mov al,status
cmp al,32 ; tombol * ditekan?
je baliak_ka_muko
cmp al,40 ; tombol # ditekan?
je tampil
jne cek
tampil:
xor ax,ax
mov al,data_keypad1
mov bl,100
mul bl
mov ratusan,al
xor ax,ax
mov al,data_keypad2
mov bl,10
mul bl
mov puluhan,al
xor ax,ax
mov al,data_keypad3
xor bx,bx
mov bl,puluhan
add ax,bx
xor bx,bx
mov bl,ratusan
add ax,bx
mov dx,port1a
out dx,al
mov data_setting,al
looping:
call delay
call read_ADC
call display_ADC
call ceksuhu
ja looping
call onmotor
call delay
jmp looping
;--------------
; on motor
;-------------
Onmotor proc near
Mov dx,port1a
Mov al,0ffh
Out dx,al
ret
onmotor endp
;--------------
; cek suhu
;--------------
Ceksuhu proc near
Mov al,data_setting
Mov bl,dataADC
Cmp al,bl
ret
ceksuhu endp
;---------------
; Test tombol ditekan
;------------
tombol_ditekan proc near
mov dx,portb
in al,dx
and al,128
cmp al,128
ret
tombol_ditekan endp
;------------
;Tes tombol dilepas
;-------------------
tombol_dilepas proc near
mov dx,portb
in al,dx
and al,128
cmp al,0
ret
tombol_dilepas endp
konversi_keypad_to_bin proc near
cmp al,1
jne keypad2
mov al,1
ret
keypad2:
cmp al,2
jne keypad3
mov al,2
ret
keypad3:
cmp al,3
jne keypad4
mov al,3
ret
keypad4:
cmp al,4
jne keypad5
mov al,4
ret
keypad5:
cmp al,5
jne keypad6
mov al,5
ret
keypad6:
cmp al,6
jne keypad7
mov al,6
ret
keypad7:
cmp al,7
jne keypad8
mov al,7
ret
keypad8:
cmp al,8
jne keypad9
mov al,8
ret
keypad9:
cmp al,9
jne keypad0
mov al,9
ret
keypad0:
cmp al,10
jne keypadb
mov al,0
ret
keypadb:
cmp al,11
jne keypadg
mov al,2ah
ret
keypadg:
cmp al,12
jne keluar
mov al,23h
ret
keluar:
ret
konversi_keypad_to_bin endp
; -------
; Baca ADC
; -------------
read_ADC proc near
mov dx,port1c
mov al,3
out dx,al
call delay_lcd
mov al,1
out dx,al
call delay_lcd
mov al,3
out dx,al
call delay
mov al,2
out dx,al
call delay_lcd
mov dx,port1b
in al,dx
mov dataADC,al
call delay_lcd
mov dx,port1c
mov al,3
out dx,al
call delay_lcd
ret
read_ADC endp
;-----------
; Tampil data AD di LCD
;---------------------
display_ADC proc near
xor ax,ax
mov al,dataADC
mov bl,10
mov satuan,ah
mov ah,0
mov bl,10
div bl
mov puluhan,ah
mov ratusan,al
mov data,0CAh
call control_out
xor ax,ax
mov al,ratusan
add ax,30h
mov data,al
call data_out
mov data,0CBh
call control_out
xor ax,ax
mov al,puluhan
add ax,30h
mov data,al
call data_out
mov data,0CCh
call control_out
xor ax,ax
mov al,satuan
add ax,30h
mov data,al
call data_out
ret
display_ADC endp
;-------------------------
; control instruction
;-------------------------
; E : PC0
; RS : PC1
control_out proc near
mov dx,portc
mov al,00000000b ; E = 0, RS = 0
out dx,al
call delay_lcd
mov dx,portc
mov al,00000001b ; E = 1, RS = 0
out dx,al
call delay_lcd
mov dx,porta
mov al,data
out dx,al
call delay_lcd
mov dx,portc
mov al,00000000b ; E = 0, RS = 0
out dx,al
call delay_lcd
ret
control_out endp
;-------------------------
; data instruction
;-------------------------
; E : PC0
; RS : PC1
data_out proc near
mov dx,portc
mov al,00000010b ; E = 0, RS = 1
out dx,al
call delay_lcd
mov dx,portc
mov al,00000011b ; E = 1, RS = 1
out dx,al
call delay_lcd
mov dx,porta
mov al,data
out dx,al
call delay_lcd
mov dx,portc
mov al,00000010b ; E = 0, RS = 1
out dx,al
call delay_lcd
ret
data_out endp
;--------------------
; inisialisasi LCD
;--------------------
initialisasi_LCD proc near
mov data,DISPCLR
call control_out
call delay_lcd
mov data,FUNCSET
call control_out
call delay_lcd
mov data,ENTRMOD
call control_out
call delay_lcd
mov data,DISPON
call control_out
call delay_lcd
ret
initialisasi_LCD endp
;---------------
; Tulis teks di baris pertama
;-------------------
baris1 proc near
mov ah,0
mov al,kolom
add ax,80h
mov data,al
call control_out
mov al,data_teks
mov data,al
call data_out
ret
baris1 endp
;---------------
; Tulis teks di baris ke-2
;-------------------
Baris2 proc near
mov ah,0
mov al,kolom
add ax,0C0h
mov data,al
call control_out
mov al,data_teks
mov data,al
call data_out
ret
baris2 endp
;----------
; Ambil data teks baris pertama ke memori LCD
;----------------
display_set proc near
mov kolom,0
xor bx,bx
lea bx,setting
mov cx,16
lagi1:
mov dl,[bx]
mov data_teks,dl
call baris1
inc bx
inc kolom
loop lagi1
ret
display_set endp
;----------
; Ambil data teks baris ke-2 ke memori LCD
;----------------
display_hasil proc near
mov kolom,0
xor bx,bx
lea bx,akhir
mov cx,16
lagi2:
mov dl,[bx]
mov data_teks,dl
call baris2
inc bx
inc kolom
loop lagi2
ret
display_hasil endp
delay_lcd proc near
push cx
mov cx,07fffh
loop $
pop cx
ret
delay_lcd endp
delay proc near
push cx
mov cx,0ffffh
loop $
pop cx
ret
delay endp
ORG 40F0H
DB 0EAH
DW 0100H
DW 0FBF0H
CODE_SEG ENDS
END START
ret
DOWNLOAD FILE
- File Rangakain Simulasi dan Listing Program bisa didownload disini
- Aplikasi Emu8086 bisa didownload disini , atau klik pada menu dropdown aplikasi → emu8086
Tidak ada komentar:
Posting Komentar