Tutorial Microcontroller MCS-51 ATMEL ISP
 

 

Super MCS51 Trainer

Standart MCS51 Trainer

Standart AVR Trainer

Programmer USBASP

Standart ARM Trainer

 

Listing Program

           controlbit1 bit 20h.0
           controlbit2 bit 20h.1
           dataADC equ 31h
           setingsuhu equ 32h
           setingsuhuratusan equ 33h
           setingsuhupuluhan equ 34h
           setingsuhusatuan equ 35h
           ;
           tanda equ 36h
           counter20 equ 60h
           setingtimer equ 61h
           setingtimerratusan equ 62h
           setingtimerpuluhan equ 63h
           setingtimersatuan equ 64h
           detik equ 65h
           detikpuluhan equ 66h
           detiksatuan equ 67h
           menit equ 68h
           menitpuluhan equ 69h
           menitsatuan equ 6ah
           dataSetSuhu equ 70h
           dataSetSuhu2 equ 71h
           ;
           ;=============================================================
           org 0h
           ljmp start
           ;=============================================================
           ; Lokasi Vektor Interupsi
           ;============================================================= 
           org 3h
           reti
           org 0bh
           ajmp timerinterrupt
           org 13h
           reti
           org 23h
           reti
           ;
           ;===========================================================
           ; Proses
           ;===========================================================
start:
           acall set1
           acall set2
           acall set3
           jb p1.2,start
           jnb p1.2,$
           acall buzz
           ;
wait1: 
           Jnb p1.2,wait1
           jnb p1.2,$
           acall scansetingsuhu
           ; 
getoutsuhu:
           jb p1.2, getoutsuhu
           jnb p1.2,$
           acall cek
           acall buzz
           wait2:
           mov detik,#00
           mov detiksatuan,#00
           mov detikpuluhan,#00
           mov menit,#00
           mov menitsatuan,#00
           mov menitpuluhan,#00
           ;
wait3: 
           Jnb p1.2,wait3
           jnb p1.2,$
           acall setingwaktu
           ;
getoutwaktu:
           jb p1.2,getoutwaktu
           jnb p1.2,$
           mov menit,R7
           acall buzz
           ;
startproses:
           acall ADC
           acall errorB
           jb tanda,iki
           acall Display2SevenSegmen
           acall Displaysetingtimer
           acall ControlSuhu1
           jnb p1.2,startAgain
           jnb p1.2,$
           jb controlbit1,startproses
           ;
           setb p2.0; driver heater Off
           acall cek2
           ;
Forever:
           acall ADC
           acall Display2SevenSegmen
           acall Displaysetingtimer
           acall Controlsuhu3
           jnb p1.2,startAgain
           jnb p1.2,$
           jb controlbit2,forever 
           ;
           acall buzz
           nop
           nop
           acall ADC
           acall Display2SevenSegmen
           acall InitTimer 
           ;
Forever2:
           acall ADC
           acall errorA
           jb tanda,iki2
           acall Display2SevenSegmen
           acall ClockDisplay
           acall ControlSuhu2
           jnb p1.2,startAgain
           jnb p1.2,$
           sjmp forever2
           iki: sjmp startproses
           iki2: sjmp forever2
           ;==========================================
           ; Reset Ulang
           ;==========================================
StartAgain:
           jnb p1.2,startAgain
           jnb p1.2,$
           acall buzz
           clr TR0
           clr ET0
           clr EA
           clr p1.3; reset mikrokontroler
           nop
           nop
           setb p1.3
           ljmp start
           ;
           ;================================================
           ; ending Proses
           ;================================================
endproses:
           acall ADC
           acall Display2SevenSegmen
           acall ClockDisplay
           acall ControlSuhu2
           clr p2.1; Driver buzzer aktif
           jnb p1.2,startAgain
           sjmp endproses
           ret
           ; 
           ;=================================================
           ; Pengambilan dataADC
           ;=================================================
ADC: 
           clr P2.3; pin wr ADC 0804
           nop
           nop
           nop
           nop
           setb P2.3; pin wr ADC 0804
           eoc: 
           jb P2.2,eoc; pin int ADC 0804
           clr p2.4; pin rd ADC 0804
           mov A,P3
           acall delay
           nop
           mov dataADC,A
           setb p2.4; pin rd ADC 0804
           ret
           ;==========================================
           ; Setting Suhu
           ;==========================================
scansetingsuhu:
           mov R6,#30 
           Setupsuhu: 
           mov a,R6 
           acall bin2decsuhu
           acall displaysetingsuhu
           jnb p1.2,getoutsuhu1
           jb P1.0,SetDnsuhu 
           jnb p1.0,$
           acall buzz
           inc R6 
           cjne R6,#41d,setupsuhu
           mov R6,#40d 
           sjmp Setupsuhu
           ;
SetDnsuhu: 
           Mov a,R6 
           acall bin2decsuhu
           acall displaysetingsuhu
           jnb P1.2,getoutsuhu1
           jb p1.1,Setupsuhu
           jnb p1.1,$
           acall buzz
           dec R6 
           cjne R6,#29d,setDnsuhu
           mov R6,#30d
           sjmp Setdnsuhu
           ret
           ;=====================================================
getoutsuhu1:
           ljmp getoutsuhu 
           ;
           ;=====================================================
cek:
           cek30: cjne r6,#30d,cek31
           mov dataSetSuhu,#97d;set off 29.5
           ret
           ;
cek31:     cjne r6,#31d,cek32
           mov dataSetSuhu,#108d;set off 30.5
           ret
           ;
cek32:     cjne r6,#32d,cek33
           mov dataSetSuhu,#118d;set off 31.5
           ret
           ;
cek33:     cjne r6,#33d,cek34
           mov dataSetSuhu,#128d;set off 32.5
           ret
           ;
cek34:     cjne r6,#34d,cek35
           mov dataSetSuhu,#138d;set off 33.5
           ret
           ;
cek35:     cjne r6,#35d,cek36
           mov dataSetSuhu,#148d;set off 34.5
           ret
           ;
cek36:     cjne r6,#36d,cek37
           mov dataSetSuhu,#159d;set off 35.5
           ret
           ;
cek37:     cjne r6,#37d,cek38
           mov dataSetSuhu,#169d;set off 36.5
           ret
           ;
cek38:     cjne r6,#38d,cek39
           mov dataSetSuhu,#179d;set off 37.5
           ret
           ;
cek39:     cjne r6,#39d,cek40
           mov dataSetSuhu,#189d;set off 38.5
           ret
           ;
cek40:      cjne r6,#40d,cek30
           mov dataSetSuhu,#199d;set off 39.5 
           ret
           ;
           ;================================================
ControlSuhu1:
           acall ADC
           mov a,dataSetSuhu 
           mov b,dataADC 
           clr c
           subb a,b
           jnz OnHeater
           ret
OnHeater:
           jc OffHeater
           acall On_Off;Instruksi hidupkan heater
           setb controlbit1
           ret
OffHeater:
           acall Off_Heat;Instruksi matikan heater
           clr controlbit1
           ret
           ;
On_Off: 
           clr p2.0; Driver heater aktif
           acall Display2SevenSegmen
           acall Displaysetingtimer
           acall Display2SevenSegmen
           acall Displaysetingtimer
           acall Display2SevenSegmen
           acall Displaysetingtimer
           setb p2.0; Driver heater non aktif
           acall Display2SevenSegmen
           acall Displaysetingtimer
           acall Display2SevenSegmen
           acall Displaysetingtimer
           acall Display2SevenSegmen
           acall Displaysetingtimer
           acall Display2SevenSegmen
           acall Displaysetingtimer
           acall Display2SevenSegmen
           acall Displaysetingtimer
           acall Display2SevenSegmen
           acall Displaysetingtimer
           acall Display2SevenSegmen
           acall Displaysetingtimer
           acall Display2SevenSegmen
           acall Displaysetingtimer
           ret
           ;
Off_Heat:
           setb p2.0; Driver heater non aktif
           acall Display2SevenSegmen
           acall Displaysetingtimer
           acall Display2SevenSegmen
           acall Displaysetingtimer
           acall Display2SevenSegmen
           acall Displaysetingtimer
           acall Display2SevenSegmen
           acall Displaysetingtimer
           ret
           ;
           ;==========================================
ControlSuhu2:
           acall ADC
           mov a,dataSetSuhu2 
           mov b,dataADC 
           clr c
           subb a,b
           jnz OnHeater2
           ret
           OnHeater2:
           jc OffHeater2
           acall On_Off2;Instruksi hidupkan heater
           ret
           OffHeater2:
           acall Off_Heat2;Instruksi matikan heater
           ret
           ;
           On_Off2:
           acall ADC
           clr p2.0; Driver heater aktif
           acall Display2SevenSegmen
           acall ClockDisplay
           acall delay
           setb p2.0; Driver heater non aktif
           acall Display2SevenSegmen
           acall ClockDisplay
           acall Display2SevenSegmen
           acall ClockDisplay
           acall Display2SevenSegmen
           acall ClockDisplay
           acall Display2SevenSegmen
           acall ClockDisplay
           acall Display2SevenSegmen
           acall ClockDisplay
           acall Display2SevenSegmen
           acall ClockDisplay
           acall Display2SevenSegmen
           acall ClockDisplay
           acall Display2SevenSegmen
           acall ClockDisplay
           acall Display2SevenSegmen
           acall ClockDisplay
           acall Display2SevenSegmen
           acall ClockDisplay
           ret
           ;
           Off_Heat2:
           acall ADC
           setb p2.0; Driver heater non aktif
           acall Display2SevenSegmen
           acall ClockDisplay
           acall Display2SevenSegmen
           acall ClockDisplay
           acall Display2SevenSegmen
           acall ClockDisplay
           acall Display2SevenSegmen
           acall ClockDisplay
           acall Display2SevenSegmen
           acall ClockDisplay
           acall Display2SevenSegmen
           acall ClockDisplay
           acall Display2SevenSegmen
           acall ClockDisplay
           ret
           ;
           ;=============================================
ControlSuhu3:
           acall ADC
           mov a,dataSetSuhu2 
           mov b,dataADC 
           clr c
           subb a,b
           jnz OnHeater3
           ret
           OnHeater3:
           jc OffHeater3
           acall On_Off3;Instruksi hidupkan heater
           setb controlbit2
           ret
           OffHeater3: 
           acall On_Off3;Instruksi hidupkan heater
           clr controlbit2
           ret
           ;
           On_Off3:
           clr p2.0; Driver heater aktif
           acall delay
           acall delay
           setb p2.0; Driver heater non aktif
           acall Display2SevenSegmen
           acall Displaysetingtimer
           acall Display2SevenSegmen
           acall Displaysetingtimer
           acall Display2SevenSegmen
           acall Displaysetingtimer
           acall Display2SevenSegmen
           acall Displaysetingtimer
           acall Display2SevenSegmen
           acall Displaysetingtimer
           acall Display2SevenSegmen
           acall Displaysetingtimer
           acall Display2SevenSegmen
           acall Displaysetingtimer
           acall Display2SevenSegmen
           acall Displaysetingtimer
           acall Display2SevenSegmen
           acall Displaysetingtimer
           acall Display2SevenSegmen
           acall Displaysetingtimer
           ret
           ;
           Off_Heat3:
           setb p2.0; Driver heater non aktif
           acall Display2SevenSegmen
           acall Displaysetingtimer
           acall Display2SevenSegmen
           acall Displaysetingtimer
           acall Display2SevenSegmen
           acall Displaysetingtimer
           acall Display2SevenSegmen
           acall Displaysetingtimer
           acall Display2SevenSegmen
           acall Displaysetingtimer
           acall Display2SevenSegmen
           acall Displaysetingtimer
           acall Display2SevenSegmen
           acall Displaysetingtimer
           ret
           ;
        

NEXT