Hi, Andy!
Andrew Warren wrote:
{Quote hidden}> Bob Axtell <
PICLISTEraseME
.....mitvma.mit.edu> wrote:
>
>
>>>What happens with key bounce? Isn't it possible that bouncing
>>>during release of the key would produce the pattern b'11101000'?
>>
>>certainly. Happens all the time. Doesn't match, so is ignored.
>
>
> But that means that the entire press-and-release sequence will
> be ignored, so your user will have to press the key over and over
> until there's no bounce on release.
>
> What you want is this:
>
> 1. Wait for key to be pressed for 40 msec.
> 2. Wait for key to be released for 40 msec.
> 3. Signal "key pressed and released".
Thats EXACTLY what I have.
>
> What you have is this:
>
> 1. Wait for key to be pressed for 40 msec.
> 2. Wait for key to be released.
> 3. Watch the key for 40 msec; if it bounces, go back to 1.
> 4. Signal "key pressed and released".
hmmm
>
> As I said earlier... If I had to do it this way (shifting samples
> into a register instead of just using a counter), I'd probably
> match on "xxx11110" to avoid that problem.
>
ah! But what if it is just a single '0' noise glitch...? This would be a
problem. We just set off WWIII because of noise...
> If you really do need to debounce the key-release, maybe you
> could shift 1s in from the right and 0s in from the left: Wait
> for "11111111" (or "xxxx1111") for the keypress, then wait for
> "00000000" (or "0000xxxx")for the release.
Actually, from time to time I HAVE changed it slightly. For example, I
could apply a don't care mask so that 11110000 could be interpreted as
111xx000 and might solve things.
> But if your algorithm seems to work for you, great.
Actually, it works perfectly, and doesn't tie up the main loop.
--Bob
Replier: Most attachments rejected
--------------
Bob Axtell
PIC Hardware & Firmware Dev
http://beam.to/baxtell
1-520-219-2363
--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email EraseMElistserv
mitvma.mit.edu with SET PICList DIGEST in the body