Pages: [1]   Go Down
Author Topic: Shift register randomly freezes  (Read 839 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

}
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
Shannon Member
****
Karma: 199
Posts: 11671
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

[ I won't respond to messages, use the forum please ]

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 518
Posts: 26344
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 143
Posts: 5301
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

0
Offline Offline
Shannon Member
****
Karma: 199
Posts: 11671
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

[ I won't respond to messages, use the forum please ]

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


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
Logged

Pages: [1]   Go Up
Jump to: