Go Down

Topic: Problem when expanding on the ShifOut tutorial for LEDs (Read 9 times) previous topic - next topic

David82

May 01, 2012, 04:50 am Last Edit: May 01, 2012, 05:00 am by David82 Reason: 1
I've expanded this tutorial http://arduino.cc/en/Tutorial/ShiftOut to use around 90 LEDs using multiple 74HC595's instead of the 2 in the example. I don't use the capacitor though.
I can only get the Blink code example http://arduino.cc/en/Tutorial/ShftOut22 to work if I disconnect the Shift register clock pin jumper going from the 2nd chip to the 3rd chip as noted by the red line in the image below. When it is disconnected, the LEDs blink in an unrecognizable pattern all the way down the board. Is there some aspect of the original code that stops it from working at all when wired for more than 2 chips? Do you think this is a CODE problem or a WIRING problem? I've double checked the wiring and all seems fine.


Nick Gammon

Can you define "works" for me? You say it works if you disconnect the wire, but "the LEDs blink in an unrecognizable pattern all the way down the board". So it doesn't work? What happens with the wire connected, exactly?
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Nick Gammon

I would start by adding some decoupling capacitors between the Vcc and Gnd pins of each chip.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

David82


I would start by adding some decoupling capacitors between the Vcc and Gnd pins of each chip.
Why? What problem does that address and in what way?

Nick Gammon

You should be able to get any number of chips to work. I did some work on them here:

http://www.gammon.com.au/forum/?id=11518

You need to chain them by connecting pin 9 of the first chip (Q7') to pin 14 (DS) of the second chip, and then pin 9 of the second chip to pin 14 of the third chip and so on.

I found the sketch a bit confusing, but with your 11 chips something like this should push a pattern onto all of them

Code: [Select]
digitalWrite (LATCH, LOW);
  SPI.transfer (0xAB);  // chip 1
  SPI.transfer (0xCD);  // chip 2
  SPI.transfer (0xEF);  // chip 3
  SPI.transfer (0x42);  // chip 4
  SPI.transfer (0x55);  // chip 5
  SPI.transfer (0x66);  // chip 6
  SPI.transfer (0x77);  // chip 7
  SPI.transfer (0x88);  // chip 8
  SPI.transfer (0x44);  // chip 9
  SPI.transfer (0x22);  // chip 10
  SPI.transfer (0x3C);  // chip 11
  digitalWrite (LATCH, HIGH);


Basically you need one SPI.transfer per chip, and as each one goes in it gets pushed out to the next chip.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

David82


Can you define "works" for me? You say it works if you disconnect the wire, but "the LEDs blink in an unrecognizable pattern all the way down the board". So it doesn't work? What happens with the wire connected, exactly?
Works means LEDs light up in some way, even if not as intended. Doesn't work means LEDs don't light up at all.

Nick Gammon


Why? What problem does that address and in what way?


Read Grumpy Mike's tutorial about them:

http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html

Basically by the end of the chain the noise from all that digital transferring may be corrupting the signal.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Nick Gammon


Works means LEDs light up in some way, even if not as intended. Doesn't work means LEDs don't light up at all.


You can check your wiring by simply bypassing the first couple of chips. In other words, connect MOSI not to the first chip but the third one. See what happens then.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

David82

#8
May 01, 2012, 06:14 am Last Edit: May 01, 2012, 06:26 am by David82 Reason: 1

You should be able to get any number of chips to work. I did some work on them here:

http://www.gammon.com.au/forum/?id=11518


Basically you need one SPI.transfer per chip, and as each one goes in it gets pushed out to the next chip.


can you post more complete code?

I do have Q7 -> DS connections going down the whole array as you described but I also have:
Shift register clock pin of chip one -> Shift register clock pin of chip two going down the whole array AND
Storage register clock pin (latch pin) of chip one -> Storage register clock pin (latch pin) of chip two going down the whole array as per the image below. Is that the wrong way to wire them?

David82


You can check your wiring by simply bypassing the first couple of chips. In other words, connect MOSI not to the first chip but the third one. See what happens then.
Which pin is MOSI? And what about the other data/latch pin connections going from the arduino to  the first chip? They can just be left there while only moving the MOSI jumper?

Nick Gammon

I'm hoping you made a mistake with your diagram because D13 is SCK (which you have not connected) and D12 is MISO which you have connected but should not have.

Quote
Which pin is MOSI?


My page lists all the pins.

http://www.gammon.com.au/forum/?id=11518

Quote
can you post more complete code?


Code: [Select]
#include <SPI.h>

const byte LATCH = 10;

void setup ()
{
  SPI.begin ();
}  // end of setup

void loop ()
{
  digitalWrite (LATCH, LOW);
  SPI.transfer (0xAB);  // chip 1
  SPI.transfer (0xCD);  // chip 2
  SPI.transfer (0xEF);  // chip 3
  SPI.transfer (0x42);  // chip 4
  SPI.transfer (0x55);  // chip 5
  SPI.transfer (0x66);  // chip 6
  SPI.transfer (0x77);  // chip 7
  SPI.transfer (0x88);  // chip 8
  SPI.transfer (0x44);  // chip 9
  SPI.transfer (0x22);  // chip 10
  SPI.transfer (0x3C);  // chip 11
  digitalWrite (LATCH, HIGH);
  delay (20);
}  // end of loop
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Nick Gammon

Quote
And what about the other data/latch pin connections going from the arduino to  the first chip? They can just be left there while only moving the MOSI jumper?


Look at the circuit on my page. You parallel up SS and SCK. MOSI (D11 from the Arduino) goes into DS on the first chip. Then the output of that chip (Q7') goes to DS on the second chip. And so on.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics


David82

I've got it wired as you described and am using the code you recommended but am getting nothing.
Arduino D13 goes to SH_CP 11
Arduino D11 goes to DS 14
Arduino D10 goes to ST_CP 12
What can I do to troubleshoot it?

Nick Gammon

For a start, since you only have one LED per chip, change the transfers to be all 0xFF:

Code: [Select]
  SPI.transfer (0xFF);  // chip 1
  SPI.transfer (0xFF);  // chip 2
... and so on ...
  SPI.transfer (0xFF);  // chip 11


That way the LED should definitely light up.

Try that and see if at least the first LED lights up.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Go Up