6
\$\begingroup\$

Building on this question, I've now got a shift register to play with, and I've been trying to work it manually with a couple of switches, like so: shift register LED array

I have resistors (2.2K) between the switches and VCC, even though that's not shown in the schematic. It doesn't work, though.

When I press the clock switch, sometimes an LED will light, and sometimes it won't. Sometimes several LEDs light. Never does it "shift" a zero "bit". If I just hit the input switch a bunch of times, it shifts in bits, sometimes one at a time, sometimes several at a time.

What gives? What have I done wrong here?

\$\endgroup\$
10
\$\begingroup\$

The switch is "bouncing": Each time you open or close it, there is a period where it makes a bit of noise on the clock line. The chip sees this noise as multiple transitions and clocks in more bits than you intended. To fix this, you need a "debouncing" circuit. Google should find you something.

edit:

You can't just switch voltage to an input like that. Then the input is at +5V when the switch is closed, but floating when the switch is open. You need at least a pulldown resistor after the switch.

\$\endgroup\$
  • \$\begingroup\$ By "pulldown resistor after the switch" I assume you mean that I need to connect the inputs to ground through a high-value resistor (5k or more)? Remember, it's been 20 years since my limited education on the subject... \$\endgroup\$ – Mark Mar 15 '11 at 17:28
  • \$\begingroup\$ seattlerobotics.org/encoder/mar97/basics.html was extremely helpful. I'll set it up like that. \$\endgroup\$ – Mark Mar 15 '11 at 17:57
  • \$\begingroup\$ Also, I can debounce the switch with something like a simple 100nF ceramic cap? \$\endgroup\$ – Mark Mar 15 '11 at 18:18
  • \$\begingroup\$ A 100nF will help, but a capacitor is not a great debouncer. Would be better to follow it with a 74hc14 or similar. \$\endgroup\$ – markrages Mar 15 '11 at 19:31
  • \$\begingroup\$ Note you only need to debounce the clock line. The other lines aren't edge-sensitive. \$\endgroup\$ – markrages Mar 15 '11 at 19:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.