Jasen said:
+5v
+-----------------------------+----
| ____|________
+--o_ | |
-_ 11| 74hc595 |
-o--+-------------[| |
| |____________|
+--o === 100nF |
| | |
0v+----------+------------------+
I've been told the left part of the ciecuit is a good way to debounce
a switch but I'm seing on the outputs what appears to be contact bounce.
the the switch is a mini microswitch
there are several 1uF MLCCs across the supply
construction is on solderless breadboard
adding an active debounce using a 555 seems to solve it
can anyone explain what's going on?
Yep. but Jack G. Ganssle does it much better.
Read <
http://www.ganssle.com/debouncing.pdf>
You have been gifted with a truly crap debouncing circuit. It seems to
be designed to cause maximum 'hash' on any circuits in its neighbourhood
and violates most of the accepted rules for safely driving a CMOS input.
Even Muntz wouldn't use it . . . .
I'll just hit the highlights:
The capacitor stores 1.25 uJ of energy that is dumped in microseconds or
less when the contacts first touch. They *ARE* arcing and *WILL* fail
sooner than if you left the cap out. Worse - you are dumping large
currents into the power and ground wiring of your circuit.
Assume a total resistance in the loop cap - Switch - ground - other side
of cap of 1 ohm, not unreasonable if you have kept the wiring short and
the capacitor is a ceramic one and its a good quality switch. You are
creating current pulses that may well peak at 5 A (without knowing the
actual loop inductance and resistance, we can't predict closer than
that). It could well look like a 10 MHz pulse train to neighbouring
circuits, slower if there is more loop inductance. That is *guarenteed*
mis-clocking and other trouble.
It needs as a *MINIMUM* a resistor between the switch common and the cap
and another between the cap and the CMOS input to prevent any small ESD
event dumping all the cap's charge into the protection diodes and frying
the input. Even then it wont work as the '595 doesn't have Schmitt
trigger inputs so its input acts as a high gain amplifier as it goes
through its linear region and is either amplifying mV of noise into rail
to rail pulses or just plain oscillating as it transitions. I last got
bitten but this particular problem trying to clock a home-brew Z80 board
back in the dark ages. The clock drive had to have VERY clean edges or
it would skip apparently random instructions . . .
Lastly the classic SPDT switch debouncing circuit uses a SR flipflop.
Either pick a flipflop with active low set and reset inputs, e.g. 7474
and tie all other inputs to their inactive state so the D type function
is diabled and you are left with just SR or wire a quad 2 input NAND
gate as a flipflop. Either give you two debouncers in one 14 pin chip.
The moving contact goes to ground, the fixed contacts go to /S and /R
with 1K to 10K pullups to +5V. Guaranteed to toggle cleanly and have
good switch life.
The *preferred* debouncer for multiple individual buttons however is a
Schmitt input buffer, a SPST switch and a R.R-C-R debouncer. (The
switch grounds where the . is) which has one more resistor, (between the
capacitor and the input) than Ganssle's fig.2 circuit to provide some
ESD protection. Gansle recommends a 74xx14 and I see no reason to
question that. You get more debounced inputs per chip and can use a
wider range of cheaper switches. If you do a lot of breadboarding it
would be worth building a set of debounced buttons on veroboard to avoid
the hassle of assembling them each time.