Pelatihan Mikrokontroler
Pelatihan Mikrokontroler
UNIVERSITAS NASIONAL
SPESIFIKASI PERALATAN
HARDWARE
- PC Minimal P3-450 atau Laptop
- Modul Mikrokontroller (Dz - USB AVR+MCS ISP MKII) + Kabel Downloader
SOFTWARE
- Sistem Operasi Windows (98, Me atau XP SP2)
- Topview Simulator
Mengcompile program
Melakukan setting simulator
Tampilan simulator
Menjalankan simulator
Mematikan simulator
40
10k
U?
39 1 a
VC C
P00 P10
38 2 b
P01 P11
37 3 c
P02 P12
36 4 d
P03 P13
35 5 e
P04 P14
34 6 f
P05 P15
33 7 g
P06 P16
32 8 Dp
P07 P17
Com
21 10
P20 P30/RXD
22 11 7SEG
P21 P31/TXD
23 12
P22 P32/INT0
24 13
P23 P33/INT1
25 14
P24 P34/T0
26 15
P25 P35/T1
27 16
P26 P36/W R VCC
28 17
P27 P37/RD
19
X1
31 U?
VCC EA/VP
18
X2
30
GND
ALE/P
29 9 CRYSTAL
PSEN RESET
89C51
20
VCC
10K
1uF
Rangkaian 7 Segment
Tabel Susunan pin 7segment terhadap port mikrokontroller:
Tampilan PX.7 PX.6 PX.5 PX.4 PX.3 PX.2 PX.1 PX.0
Dot g f e d c b a Hex
Digit
0 1 1 0 0 0 0 0 0 C0H
1 1 1 1 1 1 0 0 1 F9H
2 1 0 1 0 0 1 0 0 A4H
3 1 0 1 1 0 0 0 0 B0H
4 1 0 0 1 1 0 0 1 99H
5 1 0 0 1 0 0 1 0 92H
6 1 0 0 0 0 0 1 0 82H
7 1 1 1 1 1 0 0 0 F8H
8 1 0 0 0 0 0 0 0 80H
9 1 0 0 1 0 0 0 0 90H
Program menampilkan digit ”0” s/d ”9” pada modul 7 segment.
$Mod51
Start:
Clr P0.1
Loop:
Mov P1,#11000000b ; Menampilkan Angka 0
Acall Two_Seconds_Delay
Mov P1,#111111001b ; Menampilkan Angka 1
Acall Two_Seconds_Delay
Mov P1,#10100100b ; Menampilkan Angka 2
Acall Two_Seconds_Delay
Mov P1,#10110000b ; Menampilkan Angka 3
Acall Two_Seconds_Delay
Mov P1,#10011001b ; Menampilkan Angka 4
Acall Two_Seconds_Delay
Mov P1,#10010010b ; Menampilkan Angka 5
Acall Two_Seconds_Delay
Mov P1,#10000010b ; Menampilkan Angka 6
Acall Two_Seconds_Delay
Mov P1,#11111000b ; Menampilkan Angka 7
Acall Two_Seconds_Delay
Mov P1,#10000000b ; Menampilkan Angka 8
Acall Two_Seconds_Delay
Mov P1,#10010000b ; Menampilkan Angka 9
Acall Two_Seconds_Delay
Jmp Loop
$Include(Tunda.asm)
End
40
U? U? U? U? U? U? U? U?
P00 39 1 a a a a a a a a
P00 P10
VC C
P01 38 2 b b b b b b b b
P01 P11
P02 37 3 c c c c c c c c
P02 P12
P03 36 4 d d d d d d d d
P03 P13
P04 35 5 e e e e e e e e
P04 P14
P05 34 6 f f f f f f f f
P05 P15
P06 33 7 g g g g g g g g
P06 P16
P07 32 8 Dp Dp Dp Dp Dp Dp Dp Dp
P07 P17
Com Com Com Com Com Com Com Com
21 10
P20 P30/RXD
22 11 7SEG 7SEG 7SEG 7SEG 7SEG 7SEG 7SEG 7SEG
P21 P31/TXD
23 12
P22 P32/INT0
24 13
P23 P33/INT1
25 14
P24 P34/T0
26 15 4k7 4k7 4k7 4k7 4k7 4k7 4k7 4k7
P25 P35/T1
27 16
P26 P36/W R
28 17 VCC VCC VCC VCC VCC VCC VCC VCC
P27 P37/RD
P 00
P 01
P 02
P 03
P 04
P 05
P 06
P 07
19
X1
31
VCC EA/VP
18
X2
30
ALE/P
GND
29 9 11,059200
PSEN RESET 33p 33p
89C51
20
VCC
10K
1uF
Dengan mengatur penundaan waktu pengiriman data yang pas, maka akan menimbulkan efek
seolah-olah sevent segmen aktif dalam waktu yang bersamaan.
Bagaimana caranya?
Untuk menampilkan angka 123 pada segmen 0-2 prosesnya adalah sebagai berikut:
Two_Seconds_Delay:
Two_Seconds_Delay_1:
Long_Delay:
Long_Delay_1:
Delay: