Download - Strep Per
VIKRI RISTANTO (2009-11-211)
TUGAS MIKROPROSESOR
MODUL 1
A. Tuliskan untuk membuat LED berjalan dengan alamat port a, port b, port c dan control wordJAWAB:
CODE_SEG SEGMENT ASSUME CS:CODE_SEG,DS:CODE_SEG,SS:CODE_SEGORG 100H
start: jmp mulai
porta equ 00hportb equ 01hportc equ 02hcw equ 03h
mulai:mov dx,03hmov al,80hout dx,al
putar:mov dx,00hmov al,10out dx,al
jmp putar
delay proc near push cxmov cx,02fffhloop $pop cxret
delay endp
ORG 20F0HDB 0EAHDW 0100HDW 0FDF0H
LABORATORIUM MIKROPROSESOR
VIKRI RISTANTO (2009-11-211)
CODE_SEG ENDSEND START
B. Pada percobaan Less 1, Lengkapilah tabel tabel tersebut
JAWAB:
TABEL 1
LABORATORIUM MIKROPROSESOR
VIKRI RISTANTO (2009-11-211)
LABORATORIUM MIKROPROSESOR
NO DATA LED YANG MENYALA1 1 L12 2 L23 4 L34 8 L45 16 L56 32 L67 64 L78 128 L8
VIKRI RISTANTO (2009-11-211)
TABEL 2
NO DATA LED YANG MENYALA1 5 L3,L12 7 L3,L2,L13 10 L4,L24 15 L4,L3,L2,L15 21 L5,L3,L16 31 L5,L4,L3,L2,L17 42 L6,L4,L28 87 L7,L5,L3,L2,L1
ANIMASI 1:
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
LABORATORIUM MIKROPROSESOR
VIKRI RISTANTO (2009-11-211)
mulai:
mov al,80h
mov dx,cw
out dx,al
putar:
mov al,255
mov dx,porta
out dx,al
call delay
mov dx,porta
mov al,0
out dx,al
call delay
jmp putar
delay proc near
push cx
mov cx,02fffh
loop $
pop cx
ret
delay endp
ORG 20F0H
DB 0EAH
LABORATORIUM MIKROPROSESOR
VIKRI RISTANTO (2009-11-211)
DW 0100H
DW 0FD0H
CODE_SEG ENDS
END START
Jalankan program di atas,apa yang anda lihat pada modul I/O
Jawab: Semua lampu berkedip dan menyala
C.Buat program untuk mengaturgerakan LED dari port A (Dari kiri ke kanan)
JAWAB:CODE_SEG SEGMENTASSUME CS:CODE_SEG,DS:CODE_SEG,SS:CODE_SEGORG 100H
start: jmp mulai
porta equ 00hportb equ 01hportc equ 02hcw equ 03h
mulai: mov al,80hmov dx,cwout dx,al
LABORATORIUM MIKROPROSESOR
VIKRI RISTANTO (2009-11-211)
ulang:mov al,1mov cx,8
putar:mov dx,portaout dx,alcall delayshl al,1loop putarjmp ulang
delay proc nearpush cxmov cx,02fffhloop $pop cxret
delay endpORG 20F0HDB 0EAHDW 0100HDW 0FDF0H
CODE_SEG ENDSEND START
Dan jalankan,apa yang anda lihat! Jawan: Lampu menyala dari kiri ke kananTUGAS
Buat program untuk mengaturgerakan LED dari port A (Dari kanan ke kiri)
JAWAB:CODE_SEG SEGMENTASSUME CS:CODE_SEG,DS:CODE_SEG,SS:CODE_SEGORG 100H
start: jmp mulai
porta equ 00hportb equ 01hportc equ 02hcw equ 03h
mulai: mov al,80h
LABORATORIUM MIKROPROSESOR
VIKRI RISTANTO (2009-11-211)
mov dx,cwout dx,al
ulang:mov al,128mov cx,8
putar:mov dx,portaout dx,alcall delayshr al,1loop putarjmp ulang
delay proc nearpush cxmov cx,02fffhloop $pop cxret
delay endpORG 20F0HDB 0EAHDW 0100HDW 0FDF0H
CODE_SEG ENDSEND STARTMODUL 2
a. Display SIPO & PIPOBuatlah display angka 0 sampai 9 berjalanJAWAB;CODE_SEG SEGMENT ; code_seg sebagai segment
ASSUME CS:CODE_SEG,DS:CODE_SEG,SS:CODE_SEG ORG 100H ; program ditulis mulai origin 100h
start: jmp mulai ; Awal program pada Org 0100H
porta equ 00h ; Menentukan alamat port A,B,Cportb equ 01h ; dan ctrlword sesuai denganportc equ 02h ; hardwarenyacw equ 03h
mulai: mov al,80h ; init ppi
LABORATORIUM MIKROPROSESOR
VIKRI RISTANTO (2009-11-211)
mov dx,cw ; 80H MODE = 0 out dx,al ; port ABC = output
call blank
putar:call a0call delay
call a1call delay
call a2call delay
call a3call delay
call a4call delay
call a5call delay
call a6call delay
call a7call delay
call a8call delay
call a9call delayjmp putar
delay proc near ; Procedure delay push cx ; simpan cx
mov cx,3xxx:
push cx mov cx,0ffffh ; isi cx dengan lama delay loop $ ; loopng sampai cx=0
pop cx
LABORATORIUM MIKROPROSESOR
VIKRI RISTANTO (2009-11-211)
loop xxx pop cx ; keluarkan cx ret ; kembali ke program utamadelay endp ; akhir procedure delay
pulse proc nearor al,1out dx,alret
pulse endp
;--------------------------; DISPLAY ANGKA 0; egdfcba; 0100000;--------------------------a0 proc near
call oncall oncall oncall oncall oncall offcall onret
a0 endp
;--------------------------; DISPLAY ANGKA 1; egdfcba; 1111001;--------------------------a1 proc near
call offcall oncall oncall offcall offcall offcall offret
a1 endp
;--------------------------
LABORATORIUM MIKROPROSESOR
VIKRI RISTANTO (2009-11-211)
; DISPLAY ANGKA 2; egdfcba; 0001100;--------------------------a2 proc near
call oncall oncall offcall offcall oncall oncall onret
a2 endp
;--------------------------; DISPLAY ANGKA 3; egdfcba; 1001000;--------------------------a3 proc near
call oncall oncall oncall offcall oncall oncall offret
a3 endp
;--------------------------; DISPLAY ANGKA 4; egdfcba; 1010001;--------------------------a4 proc near
call offcall oncall oncall oncall offcall oncall off
LABORATORIUM MIKROPROSESOR
VIKRI RISTANTO (2009-11-211)
reta4 endp
;--------------------------; DISPLAY ANGKA 5; egdfcba; 1000010;--------------------------a5 proc near
call oncall offcall oncall oncall oncall oncall offret
a5 endp
;--------------------------; DISPLAY ANGKA 6; egdfcba; 0000010;--------------------------a6 proc near
call oncall offcall oncall oncall oncall oncall onret
a6 endp
;--------------------------; DISPLAY ANGKA 7; egdfcba; 1111000;--------------------------a7 proc near
call oncall oncall on
LABORATORIUM MIKROPROSESOR
VIKRI RISTANTO (2009-11-211)
call offcall offcall offcall offret
a7 endp
;--------------------------; DISPLAY ANGKA 8; egdfcba; 0000000;--------------------------a8 proc near
call oncall oncall oncall oncall oncall oncall onret
a8 endp
;--------------------------; DISPLAY ANGKA 9; egdfcba; 1000000;--------------------------a9 proc near
call oncall oncall oncall oncall oncall oncall offret
a9 endp
off proc nearmov dx,portamov al,2out dx,alcall pulse
LABORATORIUM MIKROPROSESOR
VIKRI RISTANTO (2009-11-211)
retoff endp
on proc nearmov dx,portamov al,0out dx,alcall pulseret
on endp
blank proc nearmov cx,42
muter:mov dx,00hmov al,2out dx,alor al,1out dx,alloop muterret
blank endp
ORG 20F0H ; alamat yang dituju setelah reset DB 0EAH ; JMP reset ke DW 0100H ; alamat offset 0100h DW 0FDF0H ; alamat segmen 0FDFh
CODE_SEG ENDS ; batas segment code_seg END START ; akhir programb. Pada percobaan SIPO & PIPO lengkapilah Tabel Percobaan
TABEL
DATA S E G M E N T
O E G D F A C B01111110b 0 √01111101b 0 √01111011b 0 √01110111b 0 √01101111b 0 √01011111b 0 √00111111b 0 √
LABORATORIUM MIKROPROSESOR
VIKRI RISTANTO (2009-11-211)
TABEL PIPO
S E G M E N T DISPLAY0 E G D F A C B0 1 1 1 1 1 1 1 00 0 1 1 0 1 1 1 10 0 0 0 1 0 1 0 20 1 0 0 1 0 0 0 30 1 0 1 0 1 0 0 40 1 0 0 0 0 0 1 50 0 0 0 0 0 0 1 60 1 1 1 1 0 0 0 70 0 0 0 0 0 0 0 80 1 0 0 0 0 0 0 9
TABEL SIPO
S E G M E N T DISPLAY0 E g D f c b a0 1 1 1 1 1 1 1 00 1 1 1 1 1 0 0 10 0 0 0 1 1 0 0 20 1 0 0 1 0 0 0 30 1 0 1 0 0 0 1 40 1 0 0 0 0 1 0 50 0 0 0 0 0 1 0 60 1 1 1 1 0 0 0 70 0 0 0 0 0 0 0 80 1 0 0 0 0 0 0 9
c. Display LCD ; Buatlah Display tampilan Nama Mahasiswa beserta NIM pada LCD
LABORATORIUM MIKROPROSESOR
VIKRI RISTANTO (2009-11-211)
JAWAB:
; LESS15.ASM DIGUNAKAN MENAMPILKAN NAMA DAN NIM MAHASISWA DI LCD; data : portc; rs : pa6; e : pa7
CODE_SEG SEGMENT ASSUME CS:CODE_SEG,DS:CODE_SEG,ES:CODE_SEG,SS:CODE_SEG ORG 100H ;program mulai
;origin 100hstart: jmp mulai
DISPCLR EQU 00000001BFUNCSET EQU 00111000BENTRMOD EQU 00000110BDISPON EQU 00001100Bpa equ 00hpb equ 01hpc equ 02hcw equ 03hawal db ?data 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
LABORATORIUM MIKROPROSESOR
VIKRI RISTANTO (2009-11-211)
Rep Movsb
Mov SP,2000h
Xor AX,AX
Mov DS,AX
; 1 0 0 A Cu 0 B Cl; 1 0 0 0 0 0 1 0
mov dx,cwmov al,82hout dx,al
call init_LCDmov data,80hcall control_outmov data,56hcall data_out
mov data,81hcall control_outmov data,69hcall data_out
mov data,82hcall control_outmov data,6bhcall data_out
mov data,83hcall control_outmov data,72hcall data_out
mov data,84hcall control_outmov data,69hcall data_out
LABORATORIUM MIKROPROSESOR
VIKRI RISTANTO (2009-11-211)
mov data,0C0hcall control_outmov data,32hcall data_out
mov data,0C1hcall control_out
mov data,30hcall data_out
mov data,0C2hcall control_out
mov data,30hcall data_out
mov data,0C3hcall control_out
mov data,39hcall data_out
mov data,0C4hcall control_out
mov data,31hcall data_out
mov data,0C5hcall control_out
mov data,31hcall data_out
mov data,0C6hcall control_out
mov data,32hcall data_out
mov data,0C7hcall control_out
mov data,31hcall data_out
mov data,0C8h
LABORATORIUM MIKROPROSESOR
VIKRI RISTANTO (2009-11-211)
call control_out mov data,31h
call data_out
lagi:jmp lagi
;--------------------; inisialisasi LCD;--------------------init_LCD proc near
mov data,DISPCLRcall control_outcall delay
mov data,FUNCSETcall control_outcall delay
mov data,ENTRMODcall control_outcall delay
mov data,DISPONcall control_outcall delayret
init_LCD endp
;-------------------------; control instruction;-------------------------; E : Pa7; RS : Pa6control_out proc near
mov dx,pamov al,00000000bout dx,alcall delay
mov dx,pamov al,10000000bout dx,al
LABORATORIUM MIKROPROSESOR
VIKRI RISTANTO (2009-11-211)
call delay
mov dx,pcmov al,dataout dx,alcall delay
mov dx,pamov al,00000000bout dx,alcall delayret
control_out endp
;-------------------------; data instruction;-------------------------; E : PA7; RS : PA6
data_out proc nearmov dx,pamov al,01000000bout dx,alcall delay
mov dx,pamov al,11000000bout dx,alcall delay
mov dx,pcmov al,dataout dx,alcall delay
mov dx,pamov al,01000000bout dx,alcall delayret
data_out endp
delay proc near
LABORATORIUM MIKROPROSESOR
VIKRI RISTANTO (2009-11-211)
push cx mov cx,0fffh loop $ pop cx ret delay endp
ORG 20F0HDB 0EAH DW 0100HDW 0FDF0HCODE_SEG ENDS
END START
MODUL 3 ( PERCOBAAN MOTOR DC DAN STEPPER)
a. Buatlah program aplikasi program motor & stepper beserta hasil outputnya ( 1 program saja)JAWAB:(PROGRAM MOTOR)
CODE_SEG SEGMENT ASSUME CS:CODE_SEG,DS:CODE_SEG,ES:CODE_SEG,SS:CODE_SEG ORG 100H
start: jmp mulai
LABORATORIUM MIKROPROSESOR
VIKRI RISTANTO (2009-11-211)
porta equ 00hportb equ 01hportc equ 02hcw equ 03h
pa2 equ 304hpb2 equ 305hpc2 equ 306hcw2 equ 307h
mulai:mov al,80hmov dx,cwout dx,al
mov al,10001001bmov dx,cw2out dx,al
putar:mov dx,portcmov al,64out dx,aljmp putar
ORG 20F0HDB 0EAHDW 0100HDW 0FDF0H
CODE_SEG ENDSEND START
JAWAB:
LABORATORIUM MIKROPROSESOR
VIKRI RISTANTO (2009-11-211)
LABORATORIUM MIKROPROSESOR
DATA Tegangan di pin 1 LF353 (volt)0 Mati64 Lambat128 Agak Lambat192 Cepat255 Sangat Cepat
VIKRI RISTANTO (2009-11-211)
CODE_SEG SEGMENTASSUME CS:CODE_SEG,DS:CODE_SEG,SS:CODE_SEGORG 100H
start: jmp mulai
porta equ 00hportb equ 01hportc equ 02hcw equ 03h
LABORATORIUM MIKROPROSESOR
VIKRI RISTANTO (2009-11-211)
pa2 equ 304hpb2 equ 305hpc2 equ 306hcw2 equ 307hmulai:
mov al,80hmov dx,cwout dx,al
mov al,10001001bmov dx,cw2out dx,al
putar:mov dx,portcmov al,250out dx,al
mov dx,portbmov al,3out dx,aljmp putar
ORG 20F0HDB 0EAHDW 0100HDW 0FDF0H
CODE_SEG ENDSEND START
▪ Tabel:
Arah dataARAH GERAKAN
MOTORKECEPATAN
MOTOR0 0 Searah Jarum Jam Lambat0 120 Searah Jarum Jam Cepat0 250 Searah Jarum Jam Sangat Cepat
LABORATORIUM MIKROPROSESOR
VIKRI RISTANTO (2009-11-211)
▪ Tabel:
Arah DataARAH GERAKAN
MOTORKECEPATAN
MOTOR3 0 Berlawanan Jarum Jam Lambat3 120 Berlawanan Jarum Jam Cepat3 250 Berlawanan Jarum Jam Sangat Cepat
(PROGRAM STEPPER)CODE_SEG SEGMENT ASSUME CS:CODE_SEG,DS:CODE_SEG,ES:CODE_SEG,SS:CODE_SEG ORG 100H
start: jmp mulaiporta equ 00hportb equ 01hportc equ 02hcw equ 03h
LABORATORIUM MIKROPROSESOR
VIKRI RISTANTO (2009-11-211)
pa2equ 304hpb2 equ 305hpc2equ 306hcw2 equ 307h
mulai:mov al,80hmov dx,cwout dx,al
mov al,10001001bmov dx,cw2out dx,al
putar:mov dx,portAMOV al,14out dx,alcall delay
mov dx,portAMOV al,13out dx,alcall delay
mov dx,portAMOV al,11out dx,alcall delay
mov dx,portAMOV al,7out dx,alcall delay
jmp putar
delay proc nearpush cxmov cx,08fffhloop $pop cxret
LABORATORIUM MIKROPROSESOR
VIKRI RISTANTO (2009-11-211)
delay endp
ORG 20F0HDB 0EAHDW 0100HDW 0FDF0H
CODE_SEG ENDSEND START
PROGRAM 1: Searah Jarum Jam
▪ Kemanakah arah pergerakan dari motor stepper? Jawab: Searah Jarum Jam▪ Gantilah delay, dan amati pergerakannya. Semakin besar delay,semakin LAMBAT gerakan stepper dan semakin kecil delay, semakin CEPAT gerakan steppernya.
LABORATORIUM MIKROPROSESOR
DATA D3 D2 D1 D014 1 1 1 013 1 1 0 111 1 0 1 17 0 1 1 1
VIKRI RISTANTO (2009-11-211)
▪ CODE_SEG SEGMENT
ASSUME CS:CODE_SEG,DS:CODE_SEG,SS:CODE_SEGORG 100H
start: jmp mulai
porta equ 00hportb equ 01hportc equ 02hcw equ 03h
pa2equ 304hpb2 equ 305hpc2equ 306hcw2 equ 307hmulai:
mov al,80hmov dx,cwout dx,al
mov al,10001001bmov dx,cw2out dx,al
putar:mov dx,portamov al,7out dx,alcall delay
mov dx,portamov al,11out dx,alcall delay
mov dx,portamov al,13out dx,alcall delay
LABORATORIUM MIKROPROSESOR
VIKRI RISTANTO (2009-11-211)
mov dx,portamov al,14out dx,alcall delay
jmp putar
delay proc nearpush cxmov cx,02fffhloop $pop cxret
delay endpORG 20F0HDB 0EAHDW 0100HDW 0FDF0H
CODE_SEG ENDSEND START
▪ Tabel Berlawanan Arah Jarum Jam:
DATA D3 D2 D1 D07 0 1 1 0
11 1 0 1 113 1 1 0 114 1 1 1 0
Pertannyaan:▪ Kemankah arah pergerakan motor stepper? Jawab: Bergerak berlawanan arah jarum jam
CODE_SEG SEGMENT
LABORATORIUM MIKROPROSESOR
VIKRI RISTANTO (2009-11-211)
ASSUME CS:CODE_SEG,DS:CODE_SEG,SS:CODE_SEGORG 100H
start: jmp mulai
porta equ 00hportb equ 01hportc equ 02hcw equ 03h
pa2equ 304hpb2 equ 305hpc2equ 306hcw2 equ 307hmulai:
mov al,80hmov dx,cwout dx,al
mov al,10001001bmov dx,cw2out dx,al
putar:mov dx,portamov al,14out dx,alcall delay
mov dx,portamov al,12out dx,alcall delay
mov dx,portamov al,13
out dx,alcall delay
mov dx,porta
LABORATORIUM MIKROPROSESOR
VIKRI RISTANTO (2009-11-211)
mov al,9out dx,alcall delay
mov dx,portamov al,11out dx,alcall delay
mov dx,portamov al,3out dx,alcall delay
mov dx,portamov al,7out dx,alcall delay
jmp putar
delay proc nearpush cxmov cx,02fffhloop $pop cxret
delay endpORG 20F0HDB 0EAHDW 0100HDW 0FDF0H
CODE_SEG ENDSEND START
▪ Tabel ke 3
LABORATORIUM MIKROPROSESOR
VIKRI RISTANTO (2009-11-211)
▪ Kemanakah arah pergerakan dari motor stepper?
Jawab: Searah Jarum Jam
▪ Percobaan 4:
CODE_SEG SEGMENTASSUME CS:CODE_SEG,DS:CODE_SEG,SS:CODE_SEGORG 100H
start: jmp mulai
porta equ 00hportb equ 01h
LABORATORIUM MIKROPROSESOR
DATA D3 D2 D1 D014 1 1 1 012 1 1 0 013 1 1 0 19 1 0 0 1
11 1 0 1 13 0 0 1 17 0 1 1 1
VIKRI RISTANTO (2009-11-211)
portc equ 02hcw equ 03h
pa2equ 304hpb2 equ 305hpc2equ 306hcw2 equ 307hmulai:
mov al,80hmov dx,cwout dx,al
mov al,10001001b
mov dx,cw2
out dx,al
putar:mov dx,portamov al,7
out dx,alcall delay
mov dx,portamov al,3out dx,alcall delay
mov dx,portamov al,11out dx,alcall delay
mov dx,portamov al,9out dx,alcall delay
mov dx,portamov al,13out dx,al
LABORATORIUM MIKROPROSESOR
VIKRI RISTANTO (2009-11-211)
call delay
mov dx,portamov al,12out dx,alcall delay
mov dx,portamov al,14out dx,alcall delay
jmp putar
delay proc nearpush cxmov cx,02fffhloop $pop cxret
delay endpORG 20F0HDB 0EAHDW 0100HDW 0FDF0H
CODE_SEG ENDSEND START
▪ Tabel ke 4
DATA D3 D2 D1 D07 0 1 1 13 0 0 1 1
11 1 0 1 19 1 0 0 1
13 1 1 0 111 1 1 0 014 1 1 1 0
LABORATORIUM MIKROPROSESOR
VIKRI RISTANTO (2009-11-211)
▪ Kemanakah arah pergerakan arah dari motor stepper?
Jawab: Berlawanan arah jarum jam
LABORATORIUM MIKROPROSESOR