ViProje


 MENÜ
 
  • Anasayfa
  • Malzeme Bilgisi
  • Forum
  • Downloads
  • Linkler
  •  

     Language
         

    Google Translate

     

     Tüm Projeler
     

     

     Dost Likler
      · 1: İkinciElKamyonlar.CoM
    · 2: Menacam.CoM
    · 3: PiCProje
    · 4: OselSan.CoM
    · 5: Saltnlight-e.CoM
     

    Pic 16F84A İle Şifreli Kilit - Microchip - ViProje. CoM - NET
    Microchip Pic 16F84A İle Şifreli Kilit

    PIC16F84 kullanılarak gerçekleştirilen bu uygulamada, 4 haneli bir şifre önceden belirlenmiş ve tuş takımından bu şifre girildiğinde roleye bağlı bir yükün çalıştırılması amaçlananmıştır. Devre şöyle çalışır; Ilk enerji verildiğinde kırmızı LED yanıktır ve role kapalıdır. Doğru şifre girilinceye kadar devre bu durumda bekler. Tuş takımından, doğru şifre rakamları sıra ile tuşlanıp "BA" butonu (AÇ Butonu) tuşlandığında, role çeker ve YEŞIL LED yanar. Bu durumun ardından herhangi bir tuşa basıldığında, role tekrar kapanır ve kırmızı LED yanar.

    Devre için belirlenen şifre "1881" rakamlarıdır. Bu şifre değerini aşağıdaki satırları değiştirerek, istediğiniz bir şifre belirleyebilirsiniz.
    	SIFRE1 EQU	D'1'
    	SIFRE2 EQU	D'8'
    	SIFRE3 EQU	D'8'
    	SIFRE4 EQU	D'1'
    
    Devrenin çalıştırılması için gerekli dosyalar sifreli_kilit.zip dosyası içerisinde yer almaktadır. Dosyayı indirmek için linke tıklayınız. (sifreli_kilit.zip)
    DEVRENIN AÇIK ŞEMASI (PROTEUS 5.2 ile çizilmiş ve simule edilmiştir.):
    Açýk Þema
    DEVRENIN PROGRAMI (MPASM 5.2 ile derlemiştir ve denemiştir.):
    ;PIC16F84 ILE YAPILAN SIFRELI KILIT
    ;H.SERIMER 4/2002
    ;WWW.EPROJE.COM ICIN TAZIRLANMISTIR
    ;DENEYSEL AMACLIDIR
    ;****************************************************************************
    TANIMLAMALAR:
    	list      p=16F84A             	; DERLEYICIYE ISLEMCI TANITILIR
    	#include          	; PIC16F84 TANIMLAMA DOSYASI
    
    	KEYB_DATA	EQU	H'0010'
    	KEYB_SCAN	EQU	H'0011'
    	SOFT_INT_TIMER1	EQU	H'0012'
    	FONKSIYON	EQU	H'0013'
    	msb		EQU	H'0014'
    	lsb		EQU	H'0015'
    	SYSCON		EQU	H'0016'
    	M_TEMP0		EQU	H'0017'
    	KEYCOUNT	EQU	H'0018'	
    
    	KEY_BUFFER1	EQU	H'0020'
    	KEY_BUFFER2	EQU	H'0021'
    	KEY_BUFFER3	EQU	H'0022'
    	KEY_BUFFER4	EQU	H'0023'
    	KEY_BUFFER5	EQU	H'0024'
    	KEY_BUFFER6	EQU	H'0025'
    	KEY_BUFFER7	EQU	H'0026'
    	KEY_BUFFER8	EQU	H'0027'
    
    	; SIFRELI KILIT ICIN ISTEDIGINIZ 4 HANELI SIFREYI
    	; BURADA BELIRLEYIN
    	; SUAN SIFRE 1881 OLARAK TANIMLIDIR
    	SIFRE1		EQU	D'1'
    	SIFRE2		EQU	D'8'
    	SIFRE3		EQU	D'8'
    	SIFRE4		EQU	D'1'
    
    
    ;PORTB UCLARI
    	KEY_SCAN0	EQU	H'0003'
    	KEY_SCAN1	EQU	H'0002'
    	KEY_SCAN2	EQU	H'0001'
    
    ;PORTA UCLARI
    	IRCODE		EQU	H'0000'
    	KIRMIZILED	EQU	H'0003'
    	YESILLED	EQU	H'0002'
    	ROLE		EQU	H'0001'
    	BUZZER		EQU	H'0004'
    
    ;SYSCON UCLARI
    	BUTON_BASILI	EQU	H'0000'
    	SIFRE_GECERLI	EQU	H'0001'
    	KILIT_DURUM	EQU	H'0002'
    
    
    	__CONFIG   _CP_OFF & _WDT_ON & _PWRTE_ON & _RC_OSC
    
    
    	ORG	H'0000'
    	GOTO	BASLA
    
    	ORG	H'0004'
    	GOTO	INT_VECTOR
    
    ;****************************************************************************
    ;****************************************************************************
    BEKLEME_DONGUSU:
    	NOP
    	clrwdt
    	NOP
    	GOTO	BEKLEME_DONGUSU	
    
    ;****************************************************************************
    ;****************************************************************************
    	ORG	H'0010'	
    INT_VECTOR
    	;TIMER0 INTERRUPTU ?
    	;BORTB KEYPRESS?
    	GOTO	BEKLEME_DONGUSU
    
    ;****************************************************************************
    ;****************************************************************************
    BASLA:
    	CLRF	SYSCON
    	CLRF	KEYCOUNT
    
    	MOVLW	H'FF'
    	MOVWF	KEYB_DATA
    	MOVLW	B'11111110'
    	MOVWF	SOFT_INT_TIMER1
    
    	MOVLW	B'11111110'
    	MOVWF	KEYB_SCAN
    	CALL	PORTLARI_AYARLA
    
    ALGORITMA:
    	clrwdt
    	NOP
    	CALL	TUS_DEGERI_HESAPLA
    
    ;KILIT DURUMU KONTROLU
    	BTFSC	SYSCON,KILIT_DURUM
    	GOTO	KILITDURUM1
    	GOTO	KILITDURUM2
    KILITDURUM1:
    ;KILITACIK
    ;KILIT ACIK KONUMDA ISE YESIL LED YAKILIR KIMIZI LED SONDURULUR
    	BSF	PORTA,YESILLED
    	BCF	PORTA,KIRMIZILED
    	BSF	PORTA,ROLE
    	GOTO	KILITDURUMSON
    KILITDURUM2
    ;KILIT KAPALI:
    ;KILIT KAPALI KONUMDA ISE KIMIZI LED YAKILIR YESIL LED SONDURULUR
    	BSF	PORTA,KIRMIZILED
    	BCF	PORTA,YESILLED
    	BCF	PORTA,ROLE
    KILITDURUMSON:
    ;TEST ICIN
    
    	CALL	SIFRE_KARSILASTIR
    
    	MOVFW	KEYB_DATA
    	MOVWF	M_TEMP0
    	MOVF	M_TEMP0,W	;karsilatirilacak degisken onceden MTEMP'e yuklenmistir
    	XORLW	D'11'		;W ile karsilastirilacak tamsayi xor'lanir
    	BTFSC	STATUS,Z	;IF W=M_TEMP 
    	CLRF	KEYCOUNT
    
    	goto ALGORITMA
    
    ;****************************************************************************
    ;****************************************************************************
    TUS_DEGERI_HESAPLA:
    ;	MOVLW	H'FF'
    	MOVFW	KEYB_DATA
    	MOVWF	M_TEMP0
    
    ;1.sutun 1,4,7,bk
    	BCF	PORTB,KEY_SCAN0
    	BSF	PORTB,KEY_SCAN1
    	BSF	PORTB,KEY_SCAN2
    	CALL	DLY_1MS		; BUTON TEKPI SURESI ICIN 1mS BEKLENIR
    T_D_H_1:
    	BTFSC	PORTB,4
    	GOTO	T_D_H_4
    	MOVLW	D'1'
    	MOVWF	KEYB_DATA
    	GOTO	T_D_H_TUSABASILDI
    
    T_D_H_4:
    	BTFSC	PORTB,5
    	GOTO	T_D_H_7
    	MOVLW	D'4'
    	MOVWF	KEYB_DATA
    	GOTO	T_D_H_TUSABASILDI
    
    T_D_H_7:
    	BTFSC	PORTB,6
    	GOTO	T_D_H_K
    	MOVLW	D'7'
    	MOVWF	KEYB_DATA
    	GOTO	T_D_H_TUSABASILDI
    
    T_D_H_K:
    	BTFSC	PORTB,7
    	GOTO	T_D_H_1SON
    	MOVLW	D'10'
    	MOVWF	KEYB_DATA
    	GOTO	T_D_H_TUSABASILDI
    
    T_D_H_1SON:
    ;2.sutun 2,5,8,0
    	BSF	PORTB,KEY_SCAN0
    	BCF	PORTB,KEY_SCAN1
    	BSF	PORTB,KEY_SCAN2
    	CALL	DLY_1MS		; BUTON TEKPI SURESI ICIN 1mS BEKLENIR
    
    T_D_H_2:
    	BTFSC	PORTB,4
    	GOTO	T_D_H_5
    	MOVLW	D'2'
    	MOVWF	KEYB_DATA
    	GOTO	T_D_H_TUSABASILDI
    
    T_D_H_5:
    	BTFSC	PORTB,5
    	GOTO	T_D_H_8
    	MOVLW	D'5'
    	MOVWF	KEYB_DATA
    	GOTO	T_D_H_TUSABASILDI
    
    T_D_H_8:
    	BTFSC	PORTB,6
    	GOTO	T_D_H_0
    	MOVLW	D'8'
    	MOVWF	KEYB_DATA
    	GOTO	T_D_H_TUSABASILDI
    
    T_D_H_0:
    	BTFSC	PORTB,7
    	GOTO	T_D_H_2SON
    	MOVLW	D'0'
    	MOVWF	KEYB_DATA
    	GOTO	T_D_H_TUSABASILDI
    
    T_D_H_2SON:
    ;3.sutun 3,6,9,ba
    	BSF	PORTB,KEY_SCAN0
    	BSF	PORTB,KEY_SCAN1
    	BCF	PORTB,KEY_SCAN2
    	CALL	DLY_1MS		; BUTON TEKPI SURESI ICIN 1mS BEKLENIR
    T_D_H_3:
    	BTFSC	PORTB,4
    	GOTO	T_D_H_6
    	MOVLW	D'3'
    	MOVWF	KEYB_DATA
    	GOTO	T_D_H_TUSABASILDI
    
    T_D_H_6:
    	BTFSC	PORTB,5
    	GOTO	T_D_H_9
    	MOVLW	D'6'
    	MOVWF	KEYB_DATA
    	GOTO	T_D_H_TUSABASILDI
    
    T_D_H_9:
    	BTFSC	PORTB,6
    	GOTO	T_D_H_A
    	MOVLW	D'9'
    	MOVWF	KEYB_DATA
    	GOTO	T_D_H_TUSABASILDI
    
    T_D_H_A:
    	BTFSC	PORTB,7
    	GOTO	T_D_H_3SON
    	MOVLW	D'11'
    	MOVWF	KEYB_DATA
    	GOTO	T_D_H_TUSABASILDI
    T_D_H_3SON:
    
    
    ;BUTON BASILI KALDI ISE SON TUS HAFIZADA BEKLETILIR
    ;DEGILSE FF DEGERI VERILIR
    T_D_H_BT0:
    	BTFSC	SYSCON,BUTON_BASILI
    	GOTO	T_D_H_BT1
    	GOTO	T_D_H_BT2
    T_D_H_BT1:
    	MOVFW	M_TEMP0
    	MOVWF	KEYB_DATA
    	GOTO	T_D_H_BT3
    T_D_H_BT2:
    	MOVLW	H'FF'
    	MOVWF	KEYB_DATA
    T_D_H_BT3:
    
    T_D_H_TUSYOK:
    	BCF	SYSCON,BUTON_BASILI
    	BCF	PORTA,KIRMIZILED
    	GOTO	T_D_H_SON
    
    T_D_H_TUSABASILDI:
    	BTFSS	SYSCON,BUTON_BASILI
    	CALL	KEY_BUFFER_TAZELE
    	NOP
    
    	BSF	SYSCON,BUTON_BASILI
    	BSF	PORTA,KIRMIZILED
    
    T_D_H_SON:
    ;TUS TARAMA KAPALI
    	BSF	PORTB,KEY_SCAN0
    	BSF	PORTB,KEY_SCAN1
    	BSF	PORTB,KEY_SCAN2
    RETURN
    ;****************************************************************************
    KEY_BUFFER_TAZELE:
    	INCF	KEYCOUNT
    	MOVFW	KEY_BUFFER2
    	MOVWF	KEY_BUFFER1
    
    	MOVFW	KEY_BUFFER3
    	MOVWF	KEY_BUFFER2
    
    	MOVFW	KEY_BUFFER4
    	MOVWF	KEY_BUFFER3
    
    	MOVFW	KEY_BUFFER5
    	MOVWF	KEY_BUFFER4
    
    	MOVFW	KEYB_DATA
    	MOVWF	KEY_BUFFER5
    
    RETURN
    ;****************************************************************************
    ;****************************************************************************
    SIFRE_KARSILASTIR:
    S_K1:
    	MOVFW	KEY_BUFFER1
    	MOVWF	M_TEMP0
    	MOVF	M_TEMP0,W	;karsilatirilacak degisken onceden MTEMP'e yuklenmistir
    	XORLW	SIFRE1		;W ile karsilastirilacak tamsayi xor'lanir
    	BTFSS	STATUS,Z	;IF W=M_TEMP 
    	GOTO	S_K_YANLIS	;M_TEMP != 3 else SATIR_1 den sonraki islemler
    S_K2:
    	MOVFW	KEY_BUFFER2
    	MOVWF	M_TEMP0
    	MOVF	M_TEMP0,W
    	XORLW	SIFRE2
    	BTFSS	STATUS,Z
    	GOTO	S_K_YANLIS
    S_K3:
    	MOVFW	KEY_BUFFER3
    	MOVWF	M_TEMP0
    	MOVF	M_TEMP0,W
    	XORLW	SIFRE3
    	BTFSS	STATUS,Z
    	GOTO	S_K_YANLIS
    S_K4:
    	MOVFW	KEY_BUFFER4
    	MOVWF	M_TEMP0
    	MOVF	M_TEMP0,W
    	XORLW	SIFRE4
    	BTFSS	STATUS,Z
    	GOTO	S_K_YANLIS
    S_K5:
    	MOVFW	KEY_BUFFER5
    	MOVWF	M_TEMP0
    	MOVF	M_TEMP0,W
    	XORLW	D'11'
    	BTFSS	STATUS,Z
    	GOTO	S_K_YANLIS
    
    S_K_DOGRU:
    	BSF	SYSCON,KILIT_DURUM
    	GOTO	S_K_SON
    S_K_YANLIS:
    	BCF	SYSCON,KILIT_DURUM
    
    S_K_SON:	
    RETURN
    ;****************************************************************************
    ;PIC0007 SIFRELI KILIT ICIN PORT AYARLARI
    ;****************************************************************************
    PORTLARI_AYARLA:
    	CLRF	PORTB			; RESET portb
    	CLRF	PORTA			; RESET portA
    
    	BSF	STATUS, RP0		; BANK 1 GECILIR
    	MOVLW	B'11110001'		; RB0-7=CIKIS
    	MOVWF	TRISB
    	MOVLW	B'00010000'		; RA0-5=GIRIS
    	MOVWF	TRISA
            bcf     OPTION_REG,NOT_RBPU	;PORTB pull-up
    	BCF	STATUS, RP0		; BANK 0 GECILIR
    	RETURN
    ;****************************************************************************
    ;	4MHz CLOCK ICIN BEKLETME RUTINLERI
    ;	BU RUTIN CALL ILE FLIP_FLOP DONGUSUNDEN CAGIRILIR
    ;****************************************************************************
    BEKLET_100MS:
    	DLY_100MS		;YAKLASIK 100 MILI SANIYE
    		CLRWDT
    	        movlw   D'200'
            	movwf   msb
    		GOTO	DLY1
    	DLY_10MS		;YAKLASIK 10 MILI SANIYE
    		CLRWDT
    	        movlw   D'20'
            	movwf   msb
    		GOTO	DLY1
    
    	DLY_1MS			;YAKLASIK 1 MILI SANIYE
    		CLRWDT
    	        movlw   D'2'
            	movwf   msb
    		GOTO	DLY1
    	DLY1
    		movlw   D'168'
    	        movwf   lsb
    	DLY2			;YAKLASIK 3 MICRO SANIYE
    		decfsz  lsb,F	;1 INS
    	        goto    DLY2	;2 INS
    	        decfsz  msb,F	;1 INS
            	goto    DLY1	;2 INS
    	RETURN
    
    
    org	h'03ff'
    end
    
    
    
    

    Gönderen: Hüseyin GÜNER Tarih: 09/02/2006 Pic 16F84A İle Şifreli Kilit Yazdır

    Yorumu Gönderen : September Tarihi : 27/05/2013 11:20 am

    == disk-to-FRAM on-the-flyTo re-synchronize to byte boundaries, we could etiehr* insert fake zero bits just before that sync header, or* delete up to 7 bits just before that sync headerThe stuff just before the sync header is merely garbage in the between-sector gap, right?(I probably should have mentioned this back in 2005) The reason why I don’t like this is TIME. I agree we don't want interrupts be bloated pigs that take so much time that they block the next interrupt.But I suspect synchronizing will add less than 10 instruction-times to your worst-case floppy-to-FRAM interrupt time. it's wafer-thin! Didn't you post your interrupt code once ? searches in vain for the interrupt code I assume you have something like - assumed code -bits RES 1bitcount RES 1store_one_bit: bsf STATUS,C ; (necessary) jmp finish_storing_bitstore_zero_bit: bcf STATUS,C ; (necessary) jmp finish_storing_bitfinish_storing_bit: RLF bits,f; check bits remaining.; if bits+0 is full, dump it to FRAM.; Otherwise return and wait for another bit. decfsz bitcount returndump_bits_to_FRAM: movlw 8 movwf bitcount movf bits,W call write_w_to_FRAM return - end assumed code -It's just a little more code to also detect and synchronize to the 4489 4489 sync header, something like this: - code to detect and synchronize -; WARNING: untested code.; Written by David Cary 2007-02-06 and put into the public domain.bits RES 3bitcount RES 1store_one_bit: bsf STATUS,C ; (necessary) jmp finish_storing_bitstore_zero_bit:; Just before adding zero bit, check sync.; compare (bits+1):(bits+2) to 0 4489; compare_unsigned_16:movf bits+1,waddlw (0xFF 0 44 + 1);; Are they equal ?skpz goto continue_storing_bit; yes, hi bytes are equal compare lomovf bits+2,w addlw (0xFF 0 89 + 1); skpz goto continue_storing_bit ; yes, both bytes are equal now what? ; throw away bits to re-sync. ; 8 cases: ; bitcount = 8: we're already synchronized ; (so leave bitcount alone). ; bitcount = 1..7: not synchronized ; (so reset bitcount to 8 to throw away bits). movlw 8 movwf bitcount ; also consider setting a sync found flag continue_storing_bit:; resume storing zero bit bcf STATUS,C ; (necessary) jmp finish_storing_bitfinish_storing_bit: RLF bits+2,f RLF bits+1,f RLF bits+0,f; check bits remaining.; if bits+0 is full, dump it to FRAM.; Otherwise return and wait for another bit. decfsz bitcount returndump_bits_to_FRAM: movlw 8 movwf bitcount movf bits+0,W call write_w_to_FRAM return - end code to detect and synchronize -

    Yorumu Gönderen : Buff Tarihi : 25/05/2013 12:41 pm

    I told my kids we'd play after I found what I ndeeed. Damnit.
    İsim/Nic:
    E-mail: (optional)
    Smile: smile wink wassat tongue laughing sad angry crying 

    Onay Kodu


     Anket
       

    Sitemizde Bir Forum Açılmasını İstermisiniz??
    Evet Güzel Olur.
    Hayır Gerek Yok.
    Bir Fikrim YOK.
    Sonuçlar

     Tüm Kategoriler

     

     

     

     

    Bu site Hüseyin GÜNER tarafından çeşitli scriptler bir araya getirilerek yazılmıştır. Tüm hakları saklıdır.

    WebHost 000WebHost.Com




    www.000webhost.com