[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Apple II's paddle 3 button



Dave Althoff Jr wrote:

<snip>

>On a related note...does anyone have any suggestions for the best way to
>de-bounce the paddle button input?  I've got an IR phototransistor
>triggering my PB0 input on an old ][e, sensing when the spokes go by on a
>K'Nex Ferris wheel, but I'm having trouble getting any accuracy out of it
>because the signal bounces.  And yet, I need fast response...

Are you sure the problem is bounce?  A phototransistor should faithfully
sense the instantaneous light level falling on it, and is not subject to
switch bounce (actual "bouncing" of mechanical contacts, causing noise
on "make").

It might be useful to write a short M/L program to sample the button
input at high speed and record the approximate times between "makes"
and "breaks".  You might find that some other timing issue is creating
the problem.

The general issue of debouncing a switch in software is accomplished
by:

1. Scan until a change is sensed,
2. Wait a short period (usually a millisecond or two, depending
   on the switch characteristics), and
3. Re-sample the switch.

If the resampling shows the same state as the first scan, then it
is presumed to be a real event, and the bounce has settled.

It is possible to scan for other events during the waiting period,
so this can be easily generalized to reading the states of large
numbers of switches (as in a matrix).  If the full scan takes a
millisecond or more, then simply finding the same (changed)
state on two successive scans is equivalent to debouncing.

You can always examine the level with an oscilloscope and
verify the transitions and how long noise persists.  The debounce
interval should be somewhat longer than the maximum noise
period observed--doubling the longest observed noise is a good
place to start.

-michael

Check out amazing quality sound for 8-bit Apples on my
Home page:  http://members.aol.com/MJMahon/