Pages: [1] 2   Go Down
Author Topic: shifter register  (Read 1795 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i am attempting to get 8 leds to do a sweep with my arduino mega and an 74hc595n shifter regester after folling many tutorials and sample codes i get nothing.

Code:
int dataPin = 2;        //Define which pins will be used for the Shift Register control
int latchPin = 3;
int clockPin = 4;

int seq[14] = {1,2,4,8,16,32,64,128,64,32,16,8,4,2};       //The byte sequence

void setup()
{
    pinMode(dataPin, OUTPUT);       //Configure each IO Pin
    pinMode(latchPin, OUTPUT);
    pinMode(clockPin, OUTPUT);
}

void loop()
{
    for (int n = 0; n < 14; n++)
    {
        digitalWrite(latchPin, LOW);             //Pull latch LOW to start sending data
        shiftOut(dataPin, clockPin, MSBFIRST, seq[n]);          //Send the data
        digitalWrite(latchPin, HIGH);            //Pull latch HIGH to stop sending data
        delay(75);
    }
}

and i have the shift register connected to pins 2,3,4, but i get nothing out of it the code compiles to the board fine
Logged

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


that is my wiring set up
Logged

0
Offline Offline
God Member
*****
Karma: 39
Posts: 988
Get Bitlash: http://bitlash.net
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Nothing jumps out as a problem.

Does it help if you set latchpin HIGH in setup()?

It might be worth operating the hardware side without the arduino attached -- jumper the latch pin low and the data pin high and wiggle the clock line by jumpering it to ground and +5 alternately…

-br
http://bitlash.net
Logged

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

ok that makes sense and i think i have bad shift registers out of the ten i have none of them do the same thing when i run that test on just the hardware
Logged

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

when i direct drive the matrix i have no problems my 595's must be duds
Logged

0
Offline Offline
Shannon Member
****
Karma: 200
Posts: 11718
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You need decoupling on the 595, could easily be the problem.
Logged

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

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

what do you mean by that?
Logged

0
Offline Offline
Shannon Member
****
Karma: 200
Posts: 11718
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You are switching lots of current to the LEDs at fantastic speeds, if there's no decoupling capacitor close to the shift register the transients could reset the chip as it latches and make it look like its broken.  Every logic chip should have decoupling close-by (within a cm or so), 0.1uF as a minimum, for higher current loads 1uF or more could be wise.

You don't show decoupling in your diagram so I assumed you'd omitted it...

[ assume 8 times 20mA, thats upto 0.16A switching in 3ns or so, over 50 million amps/second -
  it doesn't take much stray inductance to induce several volts at those rates ]
« Last Edit: November 19, 2012, 10:28:31 pm by MarkT » Logged

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

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

so a capicotor between the latch pin and ground?
Logged

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

Power and Gnd (VCC and Gnd).
Logged

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

Quote
my 595's must be duds

One can go bad - I have yet to see a bad ic in my life, however. However, it is unlikely all of them have gone back.

Maybe the issue is your wiring?

If you have a logic analyzer / scope you can put it on the sck/mosi pins to see if the right sequency is actually piped to the chip.
Logged

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

hmm i dont know i was just following a tutorial and its wiring diagram just to get a start on how the shift registers work and when i set it up it didnt work. So basically i am lost.
Logged

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

my goal was to grasp the understanding of the shift register then move on to an 8x8 matrix with shift register.
Logged

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

See my page here:

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

Also one about the 8x8 matrix:

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

The decoupling capacitors (between Vcc and Gnd) will probably help. I found my shift registers behaved a bit strangely without them.
Logged

0
Offline Offline
Shannon Member
****
Karma: 200
Posts: 11718
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hmm i dont know i was just following a tutorial and its wiring diagram just to get a start on how the shift registers work and when i set it up it didnt work. So basically i am lost.


Go and complain to the author of the tutorial!  Decoupling capacitors are essential...
Logged

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

Pages: [1] 2   Go Up
Jump to: