Go Down

Topic: Shift register randomly freezes (Read 972 times) previous topic - next topic

mibix

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.

Code: [Select]

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);

}

mibix

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?

dhenry

Quote
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.

mibix

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

MarkT

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 won't respond to messages, use the forum please ]

CrossRoads

I've PM'd the admin's about the cap several times, to no avail apparently.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

mibix


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?

dhenry

Quote
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.

fungus


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.
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

MarkT


Quote
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!
Quote

But I don't think your issue is decoupling.

I reckon it is, hit this problem before several times.
[ I won't respond to messages, use the forum please ]

mibix



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

Go Up