PDA

View Full Version : Help with passcode



m0cke
- 22nd March 2004, 12:56
Hi all,

I'm currently trying to get a passcode working for a BCD input (i.e. DTMF decoder output)

I have the BCD Input as follows

GetDtmf:
dtmf = 0
IF DT0 = 1 Then 'Check Input port 0
dtmf = dtmf + 1
EndIF
IF DT1 = 1 Then 'Check Input port 1
dtmf = dtmf + 2
EndIF
IF DT2 = 1 Then 'Check Input port 2
dtmf = dtmf + 4
EndIF
IF DT3 = 1 Then 'Check Input port 3
dtmf = dtmf + 8
EndIF

So each BCD line is added to the VAR dtmf,

Then further down I have a lookup section of code

C = C + 1 'Add 1 to Tone Count Register
LookDown dtmf,["0,4,8,2,3,9,1,7,5,6"],J 'LookDown Table
IF J = 0 then error
IF C = 1 AND J = 1 Then Key 'Check Codes are sent in correct order
IF C = 2 AND J = 2 Then Key
IF C = 3 AND J = 3 Then Key
IF C = 4 AND J = 4 Then Key
IF C = 5 AND J = 5 Then Key
IF C = 6 AND J = 6 Then Key
IF C = 7 AND J = 7 Then Key
IF C = 8 AND J = 8 Then Key
IF C = 9 AND J = 9 Then Key

So if I send a 4 on DTMF which will activate DT2 and write 4 to the var dtmf, then the loookup table should see the 4 at position 1 and write a 1 to the var J, problem is it's error out here at the line
IF J = 0 then error ..

Any ideas anyone please?

Regards,

Jim

Dave
- 22nd March 2004, 13:09
Jim, Here is how I do it for a repeater control link w an 16F628.

CHECKIN:' GATHER TOUCH TONE DATA FROM RECEIVER
DVEDGE = 1 'REMEMBER THE LEADING EDGE
POINTER = PORTA & 15 'PULL IN DATA AND STRIP TO 4 BITS

REORDER:' REORDER OUTPUT FROM TONE DECODER
' ACTUAL KEY= D 1 2 3 4 5 6 7 8 9 0 * # A B C
lOOKUP POINTER,[$D,$1,$2,$3,$4,$5,$6,$7,$8,$9,$0,$E,$F,$A,$B,$C],POINTER
IF POINTER = $F THEN EVALKEY 'IF # KEY THEN EVALUATE TONE SEQUENCE
CCOUNT = CCOUNT + 1 'ADD 1 TO THE CODE COUNTER
CCOUNT = CCOUNT MIN 9 'LIMIT TOUCH TONE CHARACTERS
TONES(CCOUNT) = POINTER 'COPY TONE TO ARRAY FOR LATER EVALUATION
GOTO LOOP

EVALKEY:' EVALUATE TONE SEQUENCE
TONE = 0 'CLEAR TONE OUTPUT FLAG
BADCOD = 1 'SET BADCOD FLAG
IF CCOUNT > 6 THEN
FOR SCRATCH1 = 1 TO 4
CODEWRD = CODEWRD << 4 'MAKE ROOM FOR THE NEW CODE
CODEWRD = CODEWRD | TONES(SCRATCH1)
NEXT
IF CODEWRD = UNLOCK THEN 'IF CORRECT UNLOCK CODE THEN EVALUATE REST OF MESSSAGE
CODEWRD = 0 'MAKE ROOM FOR THE NEW CODES
ENDIF

m0cke
- 22nd March 2004, 14:16
Hi Dave,

Thanks for the info, I'm struggling to understand what's happening in your code.

This is also for a repeater, I'm trying to program 3 different modes, the first being basic users so no access code is required, this works fine, next I want an advanced user section which is only active after a pass code is entered and finally the keepers section which is only active after another different passcode.

So i have the system working except for the 2 passcode areas which i'm using the lookdown which doesn't seem to be working and i'm, not sure why.

If I save a value .. lets say 1 into a var named code

then I use the following line

LookDown code,["0,8,1,4,2,9,3"],J

Surely the var J should then have the value of 2

Am I correct?
If so this is not happening and I dont know why.

I'm unclear as to how your system is looking for a passcode.

Regards,

Jim

Dave
- 22nd March 2004, 17:59
Jim, Tones(*) is an array for storing the incomming touch tones. The first 4 tones are the password. The tone is decoded into a nibble of either 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f. These are shifted into a word sized variable called codewrd. After all 4 tones are shifted into codewrd it is compared to a constant called unlock. It once again can have a value of 0000 to ffff. If the two compare then the system is unlocked...... This same type of method can be used for even longer unlock codes.

Dave Purola,

m0cke
- 23rd March 2004, 08:55
Hi Dave,

OK I'll look a little more in depth at the code.

For now I have scrapped the lookdown table and i've gone with a simple code as follows:-

IF dtmf = 4 Then 'First code digit
gosub Getdtmf
else
goto error
ENDIF
IF dtmf = 1 Then 'Second code digit
gosub Getdtmf
else
goto error
ENDIF
IF dtmf = 7 Then 'Third code digit
gosub Getdtmf
else
goto error

This seems to work OK, but I have no option of changing the code remotely.

How could I store the codes and re-program them remotely from the DTMF decoder?

Regards,

Jim