In their example both registers data, latch, and clock pins connected to same pins in the arduino.
Meaning when they want to turn on output pin number 2 in shift register A, it changes output pin number 2 in shift register B.
tautau123:
In their example both registers data, latch, and clock pins connected to same pins in the arduino.
Hi,
If you look closely, the data pin is not connected from the Arduino on the 2nd shift register, it is fed by the data output pin Q7 of the shift register before it in the daisy chain. So they aren't getting the same bit of data at each pulse, one gets it from the Arduino and the other receives the overflow from the previous shift register.
When outputting to multiple shift registers you have to send new outputs to all the pins. If you do not want a pin to change then the new output must be the same as the old output.
You do this by keeping a variable in the Arduino code that contains the outputs that you want. Use the bit write command to change just the bits in the variable you want to change then output the whole variable to the shift registers. As you have two shift registers this means you have to send two lots of 8 bits out, or two bytes one after the other.
When the arduino will sync the shift registers the first register will read the values he receives in the first 8 clock ticks
In the mean while, the second register will do the same with the value he receives in the ds (which is q7' of the first one).
The 9th value of the ds will be passed to q7' and so on till the 18th.
how the second register should know that now it is his turn to learn the values, he doesn't know he is the second one.
how the second register should know that now it is his turn to learn the values, he doesn't know he is the second one.
You have 16-bits of data (2 bytes). The first 8-bits sent end up in the second register.
After all bits are clocked out, the latchPin updates everything.
If there are no changes for the first register, it gets the same data as previous.
tautau123:
how the second register should know that now it is his turn to learn the values, he doesn't know he is the second one
In truth the first shift register doesn't know it's the first in the chain either. They don't need to know their position in the chain to function, they simply feed in a new bit at one end and overflow the last bit they have stored out Q7. In the start state, all values stored are zeroes.
If you have a pair of them to try it with and 16 LEDs you'll see how it works, and after that it will make perfect sense.
Make sure not to install the cap across the ST_CP pin, that is a mistake that we can't seem to get the webmaster to correct despite years of asking. There should only be a 0.1uF cap from each Vcc pin to Gnd.
The data that is clocked in with the shift clock goes into an input register. All the output registers are then updated together when the latchpin goes from low to high.
No, because logic outputs have a limited 'fan-out' - they can only drive a limited
number of (shift register) inputs before the capacitance of the inputs and the wiring is too
big. In practice you'll get away with at least 10 I suspect, the Arduino pins (on the ATmega Arduinos
at least) can output a fair bit of current to charge capacitances fast.
And you also have the issue of clock/data skew to worry about with a long chain of shift
registers - slight timing differences add up down the chain.
Both of these issues become more critical running at the fastest speeds, note.
With big arrays of shift registers you also have to consider the length of the wiring and
such things as signal reflection and cross-talk.
But in practice you'll be hard pressed to encounter these problems on even a large breadboard
full of shift registers!