Pages: [1] 2 3 ... 9   Go Down
Author Topic: Problem when expanding on the ShifOut tutorial for LEDs  (Read 8127 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 340
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

« Last Edit: April 30, 2012, 10:00:34 pm by David82 » Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18819
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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


Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18819
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I would start by adding some decoupling capacitors between the Vcc and Gnd pins of each chip.
Logged


0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 340
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18819
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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


0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 340
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18819
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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


Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18819
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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


0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 340
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
« Last Edit: April 30, 2012, 11:26:11 pm by David82 » Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 340
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18819
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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
Logged


Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18819
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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


0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 340
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I see.
Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 340
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18819
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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


Pages: [1] 2 3 ... 9   Go Up
Jump to: