Go Down

Topic: [SOLVED] Two Or More 74HC595 SR's On Uno (Read 699 times) previous topic - next topic

Cosmic-Wizard

Feb 15, 2013, 04:55 pm Last Edit: Feb 16, 2013, 10:33 pm by Cosmic-Wizard Reason: 1
Hi everyone :)

Firstly I would just like to say hello. My name is James and I'm from S.E London in the U.K.

I'm currently having a problem getting two or more shift registers to work on the Arduino Uno. I've learnt alot over the last few months, and any problems I've encountered I've muddled through and solved either by myself, or by reading this brilliant forum.

However, I'm totally stuck trying to figure out how to operate all or each output on two or more shift registers individually. I've read the 'shiftOut' tutorial, and I've also looked at some other peoples shift register projects on the internet, but I can't get them to do what I want them to.

Basically I want to create a bargraph display using LEDs, and I can achive this by using one shift register, but when I use two or more, they are copying what the first one does. I can understand that you are outputting 8 bits per SR which makes a byte. What I can't work out is how to operate the shift registers or bytes individually by turning on specific outputs or bits.

I think I must have the electronics engineers version of 'writers block' because it's just not sinking in. I'm blaming that on the long hours I've been working over the last couple of weeks lol.

I would genuinely appreciate any help or advice you guys have to offer.
Many thanks
James

Boffin1

Hi James,   have you got the serial out from the first 595 going to the serial in of the second?     (the clock and latch lines are paralleled to all the chips.)

And after you take the latch low you must send enought data - 2 bytes, to fill both shift registers , before taking the latch pins high again.

( The first 8 bits will go right through the first register and out the far end to fill the second )

Only when you have filled all the registers do you want to latch the data to the outputs by taking the latch high again.

( and ignore the capacitor shown on the latch pin on the tutorial, it should not be there )
With my mobile phone I can call people and talk to them -  how smart can you get ?

Cosmic-Wizard

Hi Boffin,

I've just looked at the shiftOut tutorial again and rewired my breadboard just incase I made a mistake. I can confirm that it's all wired correctly, and don't worry, I haven't connected the capacitor ;)

The code below is what I've just uploaded to the Arduino. Am I right in saying that only one LED should be lit? At the moment there are two lit - one on each shift register :smiley-roll:

Code: [Select]
int latchPin = 8;
int dataPin  = 11;
int clockPin = 12;

void setup() {
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
}

void loop() {
  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, B00000001);
  digitalWrite(latchPin, HIGH);
}


Thanks for the quick reply :)

Boffin1

#3
Feb 15, 2013, 06:57 pm Last Edit: Feb 16, 2013, 08:46 am by Boffin1 Reason: 1

Youre only pushing one byte in, so next loop it is pushed through to the next register

try

Code: [Select]
int latchPin = 8;
int dataPin  = 11;
int clockPin = 12;

void setup() {
 pinMode(latchPin, OUTPUT);
 pinMode(clockPin, OUTPUT);
 pinMode(dataPin, OUTPUT);
}

void loop() {

 digitalWrite(latchPin, LOW);
 shiftOut(dataPin, clockPin, MSBFIRST, B00000001);
 shiftOut(dataPin, clockPin, MSBFIRST, B11111110);
 digitalWrite(latchPin, HIGH);
delay (1000);  // so you can see the results

 digitalWrite(latchPin, LOW);
 shiftOut(dataPin, clockPin, MSBFIRST, B11111110);
 shiftOut(dataPin, clockPin, MSBFIRST, B00000001);
 digitalWrite(latchPin, HIGH);

delay (1000);  // so you can see the results

}


(modified to swap display)
With my mobile phone I can call people and talk to them -  how smart can you get ?

Cosmic-Wizard

Hello again Boffin.

I can't believe I've struggled to understand this, the example you've given me makes perfect sense and it works. I actually feel a bit stupid now lol

Many thanks for your help :D

Boffin1

With my mobile phone I can call people and talk to them -  how smart can you get ?

Go Up