Dear all,
i have a small problem with my code and circuit.
After 3 or 4 tries, maybe less maybe after 2 or 3 minutes.....(it is strange) when i pass the RFID from the reader, the first circuit, works perfect, but the second circuit, looks like does not listen to any command from the keypad.
It looks like that it gets power from the first circuit, but when i try to press any button from the Keypad, does not respond.
here is the code of the circuit that is related to the keypad.
If you notice, i havent add any commands for the fuses....because when i did that i was getting errors
;@ DEVICE pic16F84A, HS_OSC, WDT_OFF, PWRT_ON, PROTECT_OFF --> this is not working.
;@ __config _HS_OSC & _WDT_OFF & _PWRTE_ON & _CP_OFF --> this was passing the first error the counldnt find the PIC16F84A but i was getting an error (2007)
The problem is: If i load the code without fuses, the program and circuit works fine on the test board.
When i transfer it to the PCB after 2-3 minutes when i try to pass the TAG from the reader, the Keypad looks like that is not responding.
Code:
'****************************************************************
'* Name : CodeLock.bas *
'* Author : xxxxxx *
'* Date : xxxxxxxxxx *
'* Version : 1.0 *
'* Notes : Programable Code Lock with the PIC-16F84 *
'****************************************************************
; Change the code from 1234 by typing the code 1234 then * 1961#1961#
Include "MODEDEFS.BAS"
'**************************************************
RL1_ON_time con 1000 * 5 'sec. Relay ON time
'**************************************************
TrisA = 0 ' PORTA, all outputs
PortA = 16 ' turn off Buzer
OPTION_REG.7 = 0 ' PORTB Pullups.
TrisB = %11110000 ' PORTB.0-3 outputs, 4-7 inputs
PortB = 0
LD1 var PortA.2
RL1 var PortA.3
BUZ var portA.4
cnt var byte
key var byte
col var byte
row var byte
keycnt var byte
pwOK var bit
keybuf var byte[15]
pwbuf var byte[4]
EEPROM 0,[1,2,3,4] 'Default password 1,2,3,4 programmed at EEprom location 0..3
Read 0, pwbuf[0] 'Copy password from EEprom address 0..3 in to pwbuf[0..3]
Read 1, pwbuf[1]
Read 2, pwbuf[2]
Read 3, pwbuf[3]
pwOK = 0
keycnt = 0
Main:
high ld1
pause 1
gosub Chk_KEYPAD
goto Main
Chk_KEYPAD:
for row = 0 to 3
PORTB = (dcd row) ^ $f
pause 1
col = PORTB >> 4
if (col <> $f) then 'key pressed
key = (row * 3) + (ncd (col ^ $f))
gosub Got_KEY
key = 255
endif
next
return
Beep:
low ld1
low buz
pause 40
high buz
return
Got_KEY:
gosub Beep
while (PORTB >> 4) <> $f
pause 1
wend
if key = 11 then key = 0
keybuf[keycnt] = key
gosub Chk_keycnt
return
Chk_PwOK:
PwOK = 0
if (keybuf[0] = pwbuf[0]) and (keybuf[1] = pwbuf[1]) and (keybuf[2] = pwbuf[2]) and (keybuf[3] = pwbuf[3]) then pwok = 1
return
Chk_NewPwOK:
PwOK = 0
if (keybuf[5] = keybuf[10]) and (keybuf[6] = keybuf[11]) and (keybuf[7] = keybuf[12]) and (keybuf[8] = keybuf[13]) then pwok = 1
return
Pw_Change:
pwbuf[0] = keybuf[5]
pwbuf[1] = keybuf[6]
pwbuf[2] = keybuf[7]
pwbuf[3] = keybuf[8]
Write 0, pwbuf[0] 'Store new password to EEprom location 0..3
Write 1, pwbuf[1]
Write 2, pwbuf[2]
Write 3, pwbuf[3]
return
Chk_keycnt:
select case keycnt
case 4
gosub Chk_PwOK
if pwOK then
if keybuf[keycnt] = 12 then Access_OK
if keybuf[keycnt] <> 10 then Clr_keybuf
gosub Beep
else
goto Clr_keybuf
endif
case 9
if keybuf[keycnt] <> 12 then Clr_keybuf
gosub Beep
case 14
if keybuf[keycnt] <> 12 then Clr_keybuf
gosub Beep
gosub Chk_NewPwOK
if pwOK then
gosub Beep
gosub Pw_Change
gosub Beep
goto Clr_keybuf
else
goto Clr_keybuf
endif
case else
if keybuf[keycnt] = 12 then Clr_keybuf
end select
keycnt = keycnt + 1
return
Access_OK:
High RL1
pause RL1_ON_time
low RL1
Clr_keybuf:
for cnt = 0 to 14
keybuf[cnt] = cnt
next
keycnt = 0
goto Main
end
Quick reply to this message Reply Reply With Quote Reply With Quote Multi-Quote This Message
Bookmarks