Hi, William wrote: >Can anyone tell me if using software to obmit this mechanical noise, >how long time delay is needed before reading the proper keying? >Ans also how long is a valid key (single key) press, for determine a >valid key! Well as other has stated, normally 10-20ms should be enough, but it is dependant on the quality of the switch, i.e. I've found that very cheap swithces has long settling times and higher quality has shorter settling time, but don't regard this as a rule. ( depends also on the mechanical configuration od the switch ). Mark Willis replyed: >One good thing to do: Set up an O-Scope and see what that switch bounce >looks like in average use of your switch (This way you can use an old >"knife switch" or a little tactile switch or a "dome" switch and know >the right answer from seeing the results.) A despiking capacitor, Good advice, as I stated above not two switches are alike. >Better: Scott Dattalo has code on debouncing and vertical counters at >http://www.dattalo.com/technical/software/pic/debounce.html and >http://www.dattalo.com/technical/software/pic/vertcnt.html, good info. >His code repeatedly scans the switch, when it's the same state "often >enough" it calls it switched (Works pretty well.) 15 cycles means it's >QUITE fast (Scott D's a good coder, FYI ) Very good suggestion, I've used these vertical counter for an pic-pc keyboard emulator with very good results. ( PicBoard located at the piclist site at http://204.210.50.240/techref/default.asp?url=3Dmicrochip/picboard.htm= ). Here are some pseudo code from it (note many parts ommitted to save space ): In main loop I read the switches, 4 by 4, assemble them into one byte called kbColumnVal and call the routine KB_DEBOUNCE. There I jump to column specific debounce routine ( sw adresses 8 columns by 4 keys, I assemble these into 4 columns(bytes) by 8 keys(bits) ). For example for comlumn 1&2 something like this is executed: ; debounce columns 1 & 2 DEBOUNCE_BYTE kbColumnVal,kbColumn12_New,kbColumn12Cnt,kbColumn12State MOVF kbColumn12_New,W ; get debounced sample XORWF kbColumn12_Old,W ; get changed bits = BTFSC STATUS,Z ; check if zero =3D no change RETURN ; no change. return = ; key/s has been changed, w contains which key/s that has been changed in column 1 & 2 ; Note ! Not the actual state of the key, only 'change has occured' =3D '1' .. .. .. .. KB_12_DONE: ; and update our 'last known' status for the column MOVF kbColumn12_New,W ; get new status MOVWF kbColumn12_Old ; and store it.. RETURN = Then I return into the main loop, I read the next column, and = perform the same debouncing for that column. = Between each 4 keys reading I have an delay of 1 ms, which gives and delay of 2 ms per/loop. AS I have 4 columns ( logically ) = that would give me about 8 ms between each sample/comlumn, then using the debounce routine it will 'only' pass through the change after an key value has been the same state for 4 consecutive 'debounces', which give an total time of (roughfly) 32 ms for a key to be detected either '0' or '1'. The very nice thing about Scott's code is that no delay's are needed in the actual debouncing, ofcource you need to space the sampling out in time so that the 4 consecutive values are having atleast something around 20-30 ms in total between them. But your code is free to do other stuff while waiting for the next sample. /Tony Tony K=FCbek, Flintab AB = =B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2= =B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2= =B2=B2=B2=B2=B2=B2=B2=B2=B2=B2 E-mail: tony.kubek@flintab.com =B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2= =B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2= =B2=B2=B2=B2=B2=B2=B2=B2=B2=B2 -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics