Shift register randomly freezes

Hello there,

I've set up 2 shift registers and 16 LEDS as shown in the ShiftOut tutorial http://www.arduino.cc/en/Tutorial/ShiftOut

I've soldered it all onto stripboard and got it to flash as a test. I've set up a few boards the same as this without hiccup in the past, but this board seems to randomly freeze every 10 seconds or so and stay in whatever state it was last in (all on or all off). After a few seconds it will carry on the loop as normal (or light the first LED and then carry on as normal). I have tried printing to the serial monitor every time the state changes, and this carries on as normal so it's not the Arduino crashing.

I've scoured the internet but not come across this problem. If anyone knows why this is happening, any help would be appreciated.

int latchPin = 26;
int clockPin = 24;
int dataPin = 22;



void setup() {
  Serial.begin(9600);
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
}

void loop() {
  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, 255);  
  shiftOut(dataPin, clockPin, MSBFIRST, 255);  
  digitalWrite(latchPin, HIGH);
  Serial.println("ON");  
  delay(500);

  digitalWrite(latchPin, LOW);

  shiftOut(dataPin, clockPin, MSBFIRST, 0);  
  shiftOut(dataPin, clockPin, MSBFIRST, 0);  
  digitalWrite(latchPin, HIGH);
  Serial.println("OFF");
  delay(500);

}

As a thought, I haven't followed the tutorial exactly as I heard a capacitor on the clock pin can damage the Arduino. Do I need a capacitor between the 5v and Gnd? Could the lack of a capacitor be the problem?

I've set up a few boards the same as this without hiccup in the past, but this board seems to randomly freeze every 10 seconds

Wouldn't that suggest the issue, whatever it is, is very specific to this particular board (or parts on this board)?

That's where I would start digging.

Apologies, I meant the same as in using 2 shift registers. I'm using higher power LEDs this time so I have a feeling it's a problem I need to solve with a de-coupling capacitor. I'll confirm if this is the case after I've tested it.

Cheers

Does anyone know the correct way to report a bug in a tutorial like this one - capacitor on latch pin is a real howler and embarassing to see it there still.

In fact someone needs to systematically check all the tutorials to ensure decoupling is correctly depicted in all the fritzing diagrams...

To the OP: try 10uF (across supply!) on every 74HC595, should nail any decoupling issues.

I've PM'd the admin's about the cap several times, to no avail apparently.

MarkT:
To the OP: try 10uF (across supply!) on every 74HC595, should nail any decoupling issues.

I've ordered some 0.1uF caps. Are these going to be too small? I presume larger caps, such as 10uF just store more charge and wont damage the chip?

Are these going to be too small?

Those are better (but marginally so) than the 10uf electrolytics for decoupling.

But I don't think your issue is decoupling.

mibix:
I've ordered some 0.1uF caps. Are these going to be too small? I presume larger caps, such as 10uF just store more charge and wont damage the chip?

Different types have different response speeds.

dhenry:

Are these going to be too small?

Those are better (but marginally so) than the 10uf electrolytics for decoupling.

I suspect the 10uF are a better bet for higher currents - ceramic is prefered but any decoupling will do better than nothing!

But I don't think your issue is decoupling.

I reckon it is, hit this problem before several times.

dhenry:
But I don't think your issue is decoupling.

I think you're right. I've added the caps to the shift registers and the problem persists.

I've tried re-soldering bits and re-arranging but am getting some weird results. I've got a second set of identical components. Will try again from scratch and word methodically.

Cheers