Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/03/07 06:45
Modified:
  03/03/07 06:46

Read: times


 
#134188 - Is there any better solution of Debouncing?
Hello to all, well now i have another problem, ;-) and i have created another post (Well no this time i can swear that its only here) well sir the problem is that i have created a HexPad and i have tested it, it was working just like dream (When ever i had increased the Debounce value) but the problem started over here that when ever i try to decrease the Debounce value the charecter pressed on keyboard is being ECHO on the UART, well sir i have read almost all the posts on Hexpad (Well this is off-topic) and i have found that we can increase the duration of debounce value only for the Key which is pressed for long time,

(I think that this might be a tricky technique, so does any one have sample code for that ?)

Other wise i have done my own try on it and i am sending you the code. so if there is any correcion (means better code then that) then please help me.

Here is the Code. (One more thing that there is TILT label which should be concidered)

Well sir for configuratin of the pins the Lower pins of P1 are connected to Columns, and the row pins are free to use any one and can be reffrenced by X1,X2,X3,X4,


<code>

SCANNING: CLR A ;STARTING SCANNIG THE KEYS
CLR X1 ;DOING NECCASRY THINGS THAT ALL ROWS = 0
CLR X2
CLR X3
CLR X4
SETB Y1 ;ALL COULUMNS = 1
SETB Y2
SETB Y3
SETB Y4
MOV A,P1 ;TAKING THE VALUE OF THE COULUMNS TO ACCUMULATOR
ANL A,#00001111B ;DONT EFFECT THE UNUSED BITS OF THE COULUMNS PORT
TXT: CJNE A,#00Fh,FIRST ;IF ANY KEY PRESSED THEN JUMP TO "FIRST"
MOV A,P1
ANL A,#00001111B
SJMP TXT
FIRST: LCALL DELAY ;DELAY FOR 30-MILI SECONDS
MOV A,P1
ANL A,#00001111B
TXT2: CJNE A,#00Fh,SECOND ;IF ANY KEY PRESSED THEN JUMP TO "SECOND"
MOV A,P1
ANL A,#00001111B
SJMP TXT2
SECOND: LCALL DELAY ;DELAY FOR 30-MILI SECONDS
CLR A
ROWS: SETB X1 ;CHECKING EVERY ROW BY MAKING IT "0"
SETB X2
SETB X3
CLR X4 ;FIRST ROW=0
MOV A,P1
ANL A,#00001111B
CJNE A,#00Fh,R1_H ;IF FIRST ROW CONTAINS THE KEY PRESSED THEN JUMP TO RI_H
SETB X1
SETB X2
CLR X3
SETB X4
MOV A,P1
ANL A,#00001111B
CJNE A,#00Fh,R2_H ;IF FIRST ROW CONTAINS THE KEY PRESSED THEN JUMP TO R2_H
SETB X1
CLR X2
SETB X3
SETB X4
MOV A,P1
ANL A,#00001111B
CJNE A,#00Fh,R3_H ;IF FIRST ROW CONTAINS THE KEY PRESSED THEN JUMP TO R3_H
CLR X1
SETB X2
SETB X3
SETB X4
MOV A,P1
ANL A,#00001111B
CJNE A,#00Fh,R4_H ;IF FIRST ROW CONTAINS THE KEY PRESSED THEN JUMP TO R3_H
SJMP ROWS ;IF NOT FOUND DO IT AGAIN
R1_H: MOV DPTR,#ROW1 ;SET THE DPTR TO ROW1
SJMP COLS ;JUMP TO COLS
R2_H: MOV DPTR,#ROW2 ;SET THE DPTR TO ROW1
SJMP COLS ;JUMP TO COLS
R3_H: MOV DPTR,#ROW3 ;SET THE DPTR TO ROW1
SJMP COLS ;JUMP TO COLS
R4_H: MOV DPTR,#ROW4 ;SET THE DPTR TO ROW1
SJMP COLS ;JUMP TO COLS
COLS: MOV R0,#0
C1: RRC A
JNC SHOW
INC R0
SJMP C1 ;IF NOT FOUND DO TI AGAIN
SHOW: MOV A,R0
MOVC A,@A+DPTR ;GET THE VALUE BY USING THE DISTANCE ADDRESSING
LCALL SEND ;SEND THE PRESSED CHAR TO UART
MOV B,A
TILT: CJNE R4,#13,DO_TILT ;MOST IMPORTANT LABEL TO BE SEE......
SJMP NO_KEY
DO_TILT: MOV A,P1
ANL A,#00001111B
CJNE A,#00001111B,DEB_CHE
RET
DEB_CHE: LCALL DELAY ;DELAY ROUTINE FOR 30-MILI SECONDS
CJNE A,#00001111B,KEY
KEY: INC R4
SJMP TILT
NO_KEY: MOV R4,#0
RET ;RETURNING THE SCANNING FUNCIONS.
;THE IMAGE OF THE KEYS,
MYDATA: DB "DD'S SECURITY TESTING",13,10,0
ROW1: DB '3','2','1','0'
ROW2: DB '7','6','5','4'
ROW3: DB 'B','A','9','8'
ROW4: DB 'F','E','D','C'

</code>


List of 21 messages in thread
TopicAuthorDate
Is there any better solution of Debouncing?            01/01/70 00:00      
   specify            01/01/70 00:00      
      probably            01/01/70 00:00      
         ultimately            01/01/70 00:00      
            no matter of defines            01/01/70 00:00      
            clear or not?            01/01/70 00:00      
            X1,X2,X3 and X4 are Output of Keypad            01/01/70 00:00      
               The Whole Code sir :-)            01/01/70 00:00      
               how to            01/01/70 00:00      
                  WoW what a complete guide...            01/01/70 00:00      
                     please explain            01/01/70 00:00      
                     debouncing algorithms            01/01/70 00:00      
                        Well sir thanks for your help i have got it....            01/01/70 00:00      
   my way            01/01/70 00:00      
   better? who knows            01/01/70 00:00      
   "help me"            01/01/70 00:00      
      first, second, third            01/01/70 00:00      

Back to Subject List