Bizarre Multiple 595 Shift Register Problem

Hi all, this is my first post - I've looked around but can't find anyone with the same problem - I'd be hugely grateful for any help. I've been using Arduinos for a while and have successfully used multiple shift registers before using the shiftOut setup but I am definitely no expert!

  • I have 10 x 1m boards set up - each one has 2 shift registers in it. The first one is using all 8 pins and the second is using only 2 pins. So in total I have 10m of track, 20 x 595 shift registers and 100 LEDs.

  • I'm sending out the commands like this (this would be 2 pairs obv):

shiftOut(dataPin, clockPin,MSBFIRST, B00000000);
shiftOut(dataPin, clockPin,MSBFIRST, B00000001);
shiftOut(dataPin, clockPin,MSBFIRST, B00000000);
shiftOut(dataPin, clockPin,MSBFIRST, B00000011);

SCENARIOS (assuming the top of each pair is always B00000000)

  • If I send a different bit of data (like above) to each of the second registers - ALL FINE
  • If I send the same data to each of the second ones, write for 4 pairs and connect 4 pairs - ALL FINE
  • If I send the same data to each of the second ones, write for more than 4 pairs and connect more than 4 pairs - starts doing weird things. The pattern lighting is nothing like what I've written and I just can't work it out.

I'm afraid that after quite a lot of trying, I'm totally stuck.

Just so I'm totally clear, here is the code I'm using for all 10 pairs:

digitalWrite(latchPin, 0);
shiftOut(dataPin, clockPin,MSBFIRST, 0);
shiftOut(dataPin, clockPin,MSBFIRST, 1);
shiftOut(dataPin, clockPin,MSBFIRST, 0);
shiftOut(dataPin, clockPin,MSBFIRST, 1);
shiftOut(dataPin, clockPin,MSBFIRST, 0);
shiftOut(dataPin, clockPin,MSBFIRST, 1);
shiftOut(dataPin, clockPin,MSBFIRST, 0);
shiftOut(dataPin, clockPin,MSBFIRST, 1);
shiftOut(dataPin, clockPin,MSBFIRST, 0);
shiftOut(dataPin, clockPin,MSBFIRST, 1);
shiftOut(dataPin, clockPin,MSBFIRST, 0);
shiftOut(dataPin, clockPin,MSBFIRST, 1);
shiftOut(dataPin, clockPin,MSBFIRST, 0);
shiftOut(dataPin, clockPin,MSBFIRST, 1);
shiftOut(dataPin, clockPin,MSBFIRST, 0);
shiftOut(dataPin, clockPin,MSBFIRST, 1);
shiftOut(dataPin, clockPin,MSBFIRST, 0);
shiftOut(dataPin, clockPin,MSBFIRST, 1);
shiftOut(dataPin, clockPin,MSBFIRST, 0);
shiftOut(dataPin, clockPin,MSBFIRST, 1);
digitalWrite(latchPin, 1); 
delay(500);

Can anyone shed any light on this at all - I'm totally confused! Many thanks in advance, Ken

Ok more info from me. I have now set it up doing a chasing sequence - 3 LEDs on at a time and going all the way along the 10 panels (20 shift registers). It is definitely not behaving properly, certain LEDs are left on (tends to be the first one in the MSB order, ie. B10000000 in MSB) and this is left on until I clear them all.

I've also tried the following programme, which should just send the one set of data out but it changes on every cycle - how is this possible?!:

void loop(){
digitalWrite(latchPin, 0);
shiftOut(dataPin, clockPin,MSBFIRST, 0);
shiftOut(dataPin, clockPin,MSBFIRST, 1);
shiftOut(dataPin, clockPin,MSBFIRST, 0);
shiftOut(dataPin, clockPin,MSBFIRST, 1);
shiftOut(dataPin, clockPin,MSBFIRST, 0);
shiftOut(dataPin, clockPin,MSBFIRST, 1);
shiftOut(dataPin, clockPin,MSBFIRST, 0);
shiftOut(dataPin, clockPin,MSBFIRST, 1);
shiftOut(dataPin, clockPin,MSBFIRST, 0);
shiftOut(dataPin, clockPin,MSBFIRST, 1);
shiftOut(dataPin, clockPin,MSBFIRST, 0);
shiftOut(dataPin, clockPin,MSBFIRST, 1);
shiftOut(dataPin, clockPin,MSBFIRST, 0);
shiftOut(dataPin, clockPin,MSBFIRST, 1);
shiftOut(dataPin, clockPin,MSBFIRST, 0);
shiftOut(dataPin, clockPin,MSBFIRST, 1);
shiftOut(dataPin, clockPin,MSBFIRST, 0);
shiftOut(dataPin, clockPin,MSBFIRST, 1);
shiftOut(dataPin, clockPin,MSBFIRST, 0);
shiftOut(dataPin, clockPin,MSBFIRST, 1);
digitalWrite(latchPin, 1); 
delay(1000);
}

Many thanks in advance, I'm a bit lost!

Got any decoupling on those shift registers?
http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html

Mike, the answer is no - I'm looking into this now, should I be putting one across the power lines on every register? Chrs, K

should I be putting one across the power lines on every register

Yes or else odd things happen like you are seeing. You need them whether or not this is a cure, but I think it might be.

Mike, thanks for the advice. This requires a bit of work for us so we'll get onto this tomorrow. Mean time, I notice that the problems are very repeatable - the same pattern (the wrong pattern) seems to occur every time. Would you imagine that this type of repeatable error could be a symptom of a lack of decoupling cap or does that sound like there is more going on? Thanks K

It is perfectly possible that the results could be repeatable because so would the current surges and so therefore the interference.

Mike thanks, caps are on and no difference, i'm just testing stuff now and will update the post here. On every 2nd register we do have 6 floating outputs, could this be a problem do you think?

On every 2nd register we do have 6 floating outputs, could this be a problem do you think?

No outputs don't float they are just unconnected.
I will have a closer look at the code.

Ok I think I need to know how these are wired up.
There is a tutorial that shows a capacitor on the clock line to the shift registers, this is wrong and should be removed.

You talk about 10 pairs of shift registers, does that mean you have got 20 shift registers connected together?

Did you connect pin #13 ?

Guys thanks for the help.

madworm:
Did you connect pin #13 ?

No - pin 13 is not connected

Grumpy_Mike:
There is a tutorial that shows a capacitor on the clock line to the shift registers, this is wrong and should be removed.

You talk about 10 pairs of shift registers, does that mean you have got 20 shift registers connected together?

Yes I've got 20 shift registers in a line, one after the other.

The weird thing is that for the code that we are needing for this project, it is working fine - that is the 3 LEDs chasing from one end to the other (so no more than 3 LEDs are ever on on out of the 100 LEDs). However, I have a few test programmes and these are not working so for interest sake I would like to resolve the problem.

Changing the length of wire between the arduino and the first board does make a difference to the pattern but it is still the wrong pattern.

We are working with about 4 different test programmes.

Problems only occur beyond board 6, or in some test programmes, board 8.

The weird thing is that to my eye, it all revolves around lighting the same LED on multiple boards. If for example we have a pattern like this:
B10000000
B01000000
B00100000
where the bits are different on each one, then it all works fine

but if we were to do this:
B10000001
B01000001
B00100001
where one LED is on on more than one board, then everything starts going wrong.

That's about where we've got to - we def don't have a capacitor on the clock line. We do have a long strip of these and a lot of cable. As I said above, the panic is over because the project we need this for is now working but I'm keen to sort this for the future! Many thanks, Ken

Pin 13 should be connected to ground, it is the output enable line and I am not sure how you are getting away with not connecting it to ground, maybe it is floating low.

OK well you have the clock line going to 20 chips, and the same for the load / shift line.
This is too much for the arduino to power correctly. I would test this by disconnecting half the shift registers and seeing if it improves.
What you should do with this many shift registers is to split then into two groups and drive each group separately through a buffed output. Use a 74HC04 (six inverting buffers in one package) generate two non inverted signals for each line.

the panic is over because the project we need this for is now working

I wouldn't stop panicking because you have proved that your circuit is flaky and that behavior could appear any time in the future on your required bit pattern.

Mike, thanks again! On most of the test setups, it only works to 6 shift registers. So yes, cutting the quantity of registers does solve the problem but does 7 registers seem a small number to trip it up?

but does 7 registers seem a small number to trip it up?

Well I might have expected 10 but you probably have them a long way from each other. A 3K pull up resistor to +5V at the far end might extend things a bit but it looks like you will have to divide them into groups of 5 just to be on the safe side.

Mike, Madworm

Thanks so much for your help. I wanted to hang fire until I had some more info.

First off - my mistake RE pin 13 - I thought you meant on the Arduino - we DO have pin 13 on each of the registers connected - sorry about that.

We have tried out various things and found that the problem does lie in the clock line as you said Mike. We have found a post from Deuplonicus (signals for shift registers over long distance - Interfacing - Arduino Forum) which relates to the same issue we think and he says that in the end he used an RS485 transceiver at the arduino and receivers at each of the shift registers.

We are going to try this and were wondering if anyone who had tried it already had any advice on this technique including for example, any specific hardware to use and how it should be connected.

Many thanks for all the help so far!

Cheers, Ken

Yes a pair of RS485 transceiver will work but it might be overkill depending on how long you have between your shift registers. However, you might also have to do this on the shift / load signal as well because this also is a signal that gets applied to all shift registers.

I would try with a couple of hex buffers first, then if that fails then use an open collector drive, maybe even to a higher voltage say 12V. I have gone over half a kilometer with this. Then the next step is the RS485.

Guys

I just wanted to finish this post off just incase anyone has the same issues as us. Thanks for all the help - it is much appreciated - we now have a fully working system.

We resolved the problem by using a 485 network for the clock and latch line. Because of what we were making, this actually was the easiest thing to do and it has worked reliably. The voltage drop is something we need to look out for on longer systems but the 485 network has sorted the clock problem.

Many thanks, Ken

Grumpy_Mike:
Got any decoupling on those shift registers?
http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html

HAH! This and your site has solved so much pain for me. You deserve a gold statue in town square.