[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Apple II's paddle 3 button
Michael J. Mahon (mjmahon@aol.com) wrote:
: 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.
It is most certainly not a mechanical bounce, as you suggest. I suspect
the problem is with the edge of the target, complicated further by the
fact that I am shooting through a Ferris wheel structure with *two* spokes
between the emitter and detector. I'm getting multiple state changes
every time a spoke goes by. I'm wondering if I should add a cap to the
circuit to slow the hardware response time just a little.
It has been a while since I looked at the program, too. Conveniently, the
Wheel has 16 seats (identified, of course, as 0-F). Using the single
detector, I should be able to calculate which seat is approaching the
boarding platform, and even come up with motor control to bring the system
to a smooth stop at each seat. (I already have a PWM motor control
program...one of the annunciators controls the DC motor switch. Works
kinda neat!)
I need to get back to work on that thing...!
--Dave Althoff, ][.
--
/-\ _ *** Respect rides. They do not respect you. ***
/XXX\ /X\ /X\_ _ /X\__ _ _ _____
/XXXXX\ /XXX\ _/XXXX\_ /X\ /XXXXX\ /X\ /X\ /XXXXX
_/XXXXXXX\__/XXXXX\/XXXXXXXX\_/XXX\_/XXXXXXX\__/XXX\_/XXX\_/\_/XXXXXX