Saturday 6 February 2016

Membuat Speker Dua Nada Seperti Pintu Rel Kereta Api dengan Bahasa Assembly

pada rangkaian ini menggunakan ic keluaran atmel yaitu AT89s51, program ini menggunakan interupt time1. speaker dipasang pada port 1.7.


Circuit diagram:





;---------------------------------------------------------------
;Program demo HB2000 untuk drive speker bunyi tone
;Pintu Rel Kereta Api dan lampu flip-loop, selang waktu
;pakai interupt Timer 1, sepeker di pasang pada P1.7
;Lampu flip-loop pada port 1.4 dan port 1.7
;file name HL14.H51           By. haline, des 1999 ver 0.0
;---------------------------------------------------------------
      Org  0h
      Ljmp Mulai
;
      Org  1Bh                ;alamat untuk interupt timer 1
      Ljmp timer_1
;
Delay :     Mov   79h,#0      ;sub routine delay
Delay1:     Nop
      Djnz  79h,Delay1        ;
      Ret
Ldelay:
      Mov   7Ah,#0
Ld1:       Acall Delay
      Acall Delay
      Djnz 7Ah,ld1
      ret
;------------------------------------
;sub routine interupt timer 1
;penghasil pulsa pada port 1 bit ke 0
;------------------------------------
Timer_1:
      clr TCON.6        ;stop timer 1
      Cjne R0,#0, Tone1
      Setb P1.0
      Mov R0,#1         ; +---
      Sjmp Tone2        ; ---+
Tone1:
      Clr P1.0          ;Buat P1.0 berlogika 0 --+
      Mov R0,#0
Tone2:
      Cjne R1,#0,Tone3
      Mov  TL1,#06Bh    ;Tone 500 hz = 1ms x 2
      Mov  TH1,#0FCh
      Sjmp Tone4
Tone3:
      Mov TL1,#0D7h     ;Tone 225 Hz= 1.8 ms x 2
      Mov TH1,#0F8h
Tone4:                        ; Perhitungan Frekuensi Tone
Setb TCON.6       ;Fosc = 11Mhz (Tergantung
;Crystalnya)
      Reti              ;F Timer = 11 Mhz/12=916 Khz
                        ;T Timer = 1/916=1.09 us
                        ;T Tone = (65535-THxTLx) * 1.09 us
                        ;THxTLx (500Hz)= 65535-(1 ,s/1.09us)





;=65535-916=64619dec
                              ;=FC6B Hex (THx=FC, TLx=6B)
;------------------
;Awal dari program
;------------------
Mulai:
      Clr   A           ;nolkan accumulator
      Mov   IE,A       ;dissable semua interrupt
      Setb IE.7        ;enable interupt
      Setb  Ie.3       ;enable interupt timer 1
      Mov   TCON,A      ;clear tcon A
      Mov   TMOD,#11h   ;mode timer 16 bit
      Setb TCON.6      ;start timer 1
Tunggu:
      Mov   R1,#0      ;Flag untuk tone 500Hz
      Setb P1.7
      Setb P1.6
      Clr   P1.5
      Clr   P1.4
      Lcall Delay
      Mov   R1,#1       ;Flag untuk tone 225 Hz
      Setb P1.4
      Setb P1.5
      Clr   P1.6
      Clr   P1.7
      Lcall Delay
      Sjmp Tunggu      ;ulangi terus menerus
;    

End
Comments
0 Comments
Facebook Comments by otak einstein

0 comments:

Post a Comment