| ??? 11/25/05 17:47 Read: times |
#104165 - Software Debounce Responding to: ???'s previous message |
I agree with Tony, noise is your likely problem. Here is a software debounce routine that will make sure noise spikes < approx. 24 microsecs will be ignored (assuming 12 MHz Osc.).
; This routine waits till 6700 cycles from the pulse generator have been encountered. ; Assumes P1.1 has Pulse generator input. ; Uses R5, R6, & R7. WT6700: MOV R7,#67 ;67 TIMES THROUGH / 100 LOOP WL1: MOV R6,#100 ;SET UP / 100 COUNTER ;Wait for stable '1' WL2: MOV R5,#6 ;6*4 MICROSECS PER LOOP = 24 MICROSECS WL3: JNB P1.1,WL2 ;IF '0' ENCOUNTERED RESTART LOOP DJNZ R5,WL3 ;LOOP UNTIL 6 TIMES THROUGH LOOP ;Stable '1' was found, now wait for stable '0' WL4: MOV R5,#6 ;6*4 MICROSECS PER LOOP = 24 MICROSECS WL5: JB P1.1,WL4 ;IF '1' ENCOUNTERED RESTART LOOP DJNZ R5,WL5 ;LOOP UNTIL 6 TIMES THROUGH LOOP ;Stable '0' was found, dec counter DJNZ R6,WL2 ;DEC / 100 COUNTER, LOOP IF NOT 0 DJNZ R7,WL1 ;DEC / 67 COUNTER, LOOP IF NOT 0 RET |
| Topic | Author | Date |
| C2051 & Magnetic pulse generator | 01/01/70 00:00 | |
| either i or o | 01/01/70 00:00 | |
| hmmm..but | 01/01/70 00:00 | |
| Debug suggestions | 01/01/70 00:00 | |
| Software Debounce | 01/01/70 00:00 | |
| magnetic pick up tachometers experiences | 01/01/70 00:00 | |
| RE: magnetic pickup tachometer | 01/01/70 00:00 | |
| RS482 - Typo? | 01/01/70 00:00 | |
| darn thumbs | 01/01/70 00:00 | |
| This could be the reason... | 01/01/70 00:00 | |
| bufer amp | 01/01/70 00:00 | |
| why the UG? | 01/01/70 00:00 | |
| pc scopes | 01/01/70 00:00 | |
| could you | 01/01/70 00:00 | |
| What tells the oscilloscope? | 01/01/70 00:00 | |
| Build simple test tools to fix your unit | 01/01/70 00:00 | |
| Excessive rise times during startup? | 01/01/70 00:00 | |
| Good, but even better would be | 01/01/70 00:00 | |
| Full story | 01/01/70 00:00 | |
| thanks, so can I... | 01/01/70 00:00 | |
| yes, if and only if the channel A | 01/01/70 00:00 | |
| cheerz | 01/01/70 00:00 | |
| Time bomb.. | 01/01/70 00:00 | |
| Perhaps a little explanation? | 01/01/70 00:00 | |
| setting the hysteresis | 01/01/70 00:00 | |
Thank, Erik! | 01/01/70 00:00 |



