Go Down

Topic: 74HC595 troubles (Read 1 time) previous topic - next topic

Shpaget

I just started messing with shift registers and started off with http://arduino.cc/en/Reference/shiftOut http://arduino.cc/en/Tutorial/ShiftOut and few other web pages google came up with.

Currently I have single 74HC595 hooked up to an Uno, just the way it is connected here, with one difference. I don't have a 0.1"f capacitor (I suppose that is 0.1?F?) at hand so I tried without it.

The problem manifests in the way that although all the LEDs function at some time, they don't always light up. For example, in my attempt to pinpoint the problem I dumbed down the code to count to 9, took out all the ifs and loops and fancy variables. It now looks like this:

Code: [Select]
//Pin connected to ST_CP of 74HC595
int latchPin = 8;
//Pin connected to SH_CP of 74HC595
int clockPin = 12;
////Pin connected to DS of 74HC595
int dataPin = 11;



void setup() {
  //set pins to output so you can control the shift register
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
}

void loop() {
      digitalWrite(latchPin, LOW); 
    delay(1); 
    shiftOut(dataPin, clockPin, MSBFIRST, 0);
    delay(1);
    digitalWrite(latchPin, HIGH);   
    delay(1000);
   
      digitalWrite(latchPin, LOW);
   delay(1);   
    shiftOut(dataPin, clockPin, MSBFIRST, 1);
    delay(1);
    digitalWrite(latchPin, HIGH);   
    delay(1000);
   
      digitalWrite(latchPin, LOW);
   delay(1);   
    shiftOut(dataPin, clockPin, MSBFIRST, 2);
    digitalWrite(latchPin, HIGH);
delay(1);   
    delay(1000);
   
      digitalWrite(latchPin, LOW);
   delay(1);   
    shiftOut(dataPin, clockPin, MSBFIRST, 3);
    digitalWrite(latchPin, HIGH);
  delay(1); 
    delay(1000);
   
      digitalWrite(latchPin, LOW); 
    delay(1); 
    shiftOut(dataPin, clockPin, MSBFIRST, 4);
    digitalWrite(latchPin, HIGH);   
    delay(1);
    delay(1000);
   
      digitalWrite(latchPin, LOW);   
      delay(1);
    shiftOut(dataPin, clockPin, MSBFIRST, 5);
    delay(1);
    digitalWrite(latchPin, HIGH);   
    delay(1000);
   
      digitalWrite(latchPin, LOW);   
      delay(1);
    shiftOut(dataPin, clockPin, MSBFIRST, 6);
    delay(1);
    digitalWrite(latchPin, HIGH);   
    delay(1000);
 
  digitalWrite(latchPin, LOW);   
      delay(1);
    shiftOut(dataPin, clockPin, MSBFIRST, 7);
    delay(1);
    digitalWrite(latchPin, HIGH);   
    delay(1000);
   
    digitalWrite(latchPin, LOW);   
      delay(1);
    shiftOut(dataPin, clockPin, MSBFIRST, 8);
    delay(1);
    digitalWrite(latchPin, HIGH);   
    delay(1000);
   
    digitalWrite(latchPin, LOW);   
      delay(1);
    shiftOut(dataPin, clockPin, MSBFIRST, 9);
    delay(1);
    digitalWrite(latchPin, HIGH);   
    delay(1000);
}


See? Can't be much dumber than this.
The code is supposed to light up the LEDs and represent the numbers in binary. However, it skips some numbers entirely. For example, after the number three which is represented with LEDs one and two, all LEDs turn off until it is time for number five (LEDs three and one). Six also doesn't work at all, but seven (first three diodes) happily glows correctly like nothing happened.

Working and non working numbers are randomly interchanging so every number eventually lights up at exactly the right time, showing that everything is hooked up correctly, that arduino is sending the numbers at the right time.

Could all this come from the lacking cap? I tried 10?F (the only one I had around) but the problem just changes slightly (half works for a bit just like before, then completely freezes until the cap is removed).

fungus

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

Boffin1

The only caps that should be on the board, are a 0.1mFd  ( 100nF ) across the vcc and ground pins of the chip, with prefrably a 10 mFD electrolytic across that.

There should be no cap on the latch pin ( we have been trying to get that removed in the tutorial )

Make sure your grounds are connected propertly between the 595 and the Arduino ground.

Shpaget

with prefrably a 10 mFD electrolytic across that.

I'm not sure I understand this part. What is "that" you are referring to?


Make sure your grounds are connected propertly between the 595 and the Arduino ground.

I suppose they are, considering all the LEDs light up eventually.

Shpaget

Got it to work. The problem was... well, let's call it user error XD.

Ruffsta

#5
Feb 11, 2013, 11:57 pm Last Edit: Feb 12, 2013, 12:45 am by Ruffsta Reason: 1
i'm about to start the same exact thing... i just got my 0.1uF 50V's in the mail today..

100 of them for $3.00 on ebay.... seller:thaishine

CrossRoads

#6
Feb 12, 2013, 12:49 am Last Edit: Feb 12, 2013, 12:57 am by CrossRoads Reason: 1
I buy from here
Cheaper, and quicker delivery.
http://www.dipmicro.com/store/C5K10-50
or
http://www.taydaelectronics.com/capacitors/ceramic-disc-capacitors/10-x-0-1uf-50v-ceramic-disc-capacitor-pkg-of-10.html

e-bay often not the best choice, I rarely buy there.
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.

Ruffsta

#7
Feb 12, 2013, 01:15 am Last Edit: Feb 12, 2013, 01:37 am by Ruffsta Reason: 1
i normally would have ordered from dipmacro.. but i didn't see any uF's... i didn't know you could use nF's.. so i was looking for the specific ones..

i have also ordered from tayda... both are excellent and highly recommended sources!


for the most part, they are cheaper - but not in all instances..
ie:
100 Bright RGB LED 5mm Common Anode Clear Lense 4-pin Bulb Tri-Color's - dipmacro price: $19.94 + shipping - ebay price: $12.94 free shipping

that's just 1 example - overall yes, i would stick with dipmacro or tayda -but since i am not that much in a rush, waiting on delivery is ok at the moment with me.

Donziboy2

100nF is 0.1uF and its represented by a 104 on the side of most disk caps.

Ruffsta

not everybody knows that (especially new people to arduino).. uF and nF were 2 different things to me.. so i looked specifically for uF

Hippynerd

I often refer to them as 104 caps, that is often what is printed on the cap (even tiny smt ones)

Just be glad that you dont have to read color dots.
https://sites.google.com/site/rgbledcubes

pwillard

An interesting electronics hobby anomaly I've noticed over the years.    Tinkerers in the USA tend to avoid the nano-farad nomenclature entirely.  Commonly skipping from micro-farad ranges like  0.47uF .047uF and then slip right into pico-farad ranges like 4700pF, 470pF and 47pF....   while the rest of the world seems quit at home with using the "mid-range" nano-farad which really does help with keeping the numbers manageable.

http://www.justradios.com/uFnFpF.html

dannable

I find the use of centimetres odd. I can't immediately think of anything else where we use 'centi' in everyday measurement. Everything else is in powers of 103.
Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

Go Up