Just had a go at my first tutorial on the 74HC595 shift register and I'm getting pretty frustrated!
Hopefully you can can see my circuit and code in the following link...
It works perfectly when I re-create it in curcuits.io but doesn't work when I build it... Can anyone offer any help?
:: I've tested all the LEDS and all connections - I think they're fine
:: Occasionally, some random LEDS will light and stay in that state
:: I removed the ground from the Arduino so the circuit had no ground return and (surprisingly to me), the LEDS stayed on and some actually cycled? (Albeit in the reverse direction!)
When for a start there's no decoupling capacitor on that chip, an elementary error. All logic chips require
decoupling always. Symptoms of inadequate decoupling can be almost any sort of wierd behaviour, so
fix this first.
Thanks for the reply Mark, I read on the Arduino.cc tutorial that if you have some flicker when the latch pin pulses you can use a capacitor to even it out.... So didn't realise it was elementary...
I'll let you know how I get on...
Will a 0.1uF cap between the latch and ground be sufficient?
Will a 0.1uF cap between the latch and ground be sufficient?
That is not decoupling. Decoupling caps would go from the chip positive supply pin to ground, as close to the chip as possible. The purpose of the decoupling cap is to shunt noise on the supply rail to ground. 0.1uf is a good value for decoupling. A cap on the latch pin will just mess up the rise and fall times of the latch pulse (not good).
emeraldbot:
Thanks for the reply Mark, I read on the Arduino.cc tutorial that if you have some flicker when the latch pin pulses you can use a capacitor to even it out.... So didn't realise it was elementary...
I'll let you know how I get on...
Will a 0.1uF cap between the latch and ground be sufficient?
No, that's completely wrong, that tutorial hasn't been fixed for ages. Putting a capacitor on a logic signal
is definitely bad. Decoupling the supply and ensuring signal paths are short and neat is good.
Understood Mark and fungus... thanks for explaining...
Incidentally, I built another circuit last night using the 74HC595 connected to a 7 segment display. It worked fine with and without the decoupling capacitor so I wasn't able to re-create the original problem.
Following your recommendation for future, I'll add a 0.1uF cap between the chips Vcc and ground...
One issue about decoupling is that sometimes you can get away with it - but the very same circuit using
the same components might fail, or only fail every few hours, or work for years and then start failing - the
whole setup is flaky.
The kind of transients on the power lines that are causing the issue are hard to see without expensive
fast oscilloscopes as they can be a few nanoseconds in duration. These are speeds where stray inductance
of wiring is dominant and layout is crucial. It can seem like complete hocus pocus if all you are used to
are Kirchoff's and Ohm's laws. Only Maxwell's equations can describe this sort of behaviour.
A typical logic signal on one of these CMOS chips can switch 5V / 20mA in a few ns, which means
voltage changes at billions of volts a second, current at 10's of megaamps/second. Those are high
values that mean small amounts of stray capacitance and inductance are important. With a latched
shift register driving 8 LEDs, you have 8 times the rate of current change when the latch clocks, which
without decoupling can cause the power rail to dip on-chip and corrupt the state of the internal register or
false-clock from the inputs.
Thanks for your help and taking the time to explain this...
It's surprising; I went through 2 separate beginner tutorials for these chips and neither included a decoupling capacitor. I get that the theory is maybe advanced for a beginner level but if it causes erroneous results it's going to cause much confusion and frustration for the beginner...