Shift registers

Evening all!

I have just got my head around the theory of using one shift register (SR) at a time, inputting 01011011 will have the effect of turning the LEDs on in that pattern, but I don't know how to make the code do this! It seems silly but I can't grasp sending commands and writing to a digital pin with the correct timings for a SR.

Then there is cascading. At this point my head explodes.

Can any one shed some light onto what appears to be a complex issue?

Regards, /me

but I don't know how to make the code do this!

See:- http://www.arduino.cc/en/Tutorial/ShiftOut At the end of the page there are links to download the code.

Don't have time to read that page, but I don't think it has anything about cascading on it, so I'll try my best to explain it.

If you input into a shift register 10101010, the register will be full (assuming it's an 8 bit register). Now, you can kind of picture the shift register as a thin building with 8 rooms, each of them a "bit". As you put in the first 1, that goes into the first room. Now, when you enter that 0, it forces the 1 out of the room, and into the next. Repeat for all 8 bits, and the building is full.

The problem you've got now is, if you put in another 1 or 0, because there's no room, the number in the last "room" is forced out, and lost forever.

The way around this is cascading. The 74HC595 for example, has a Q7' pin, which outputs bits that are shifted outside. You can hook up the cascading pin to the data pin of the second shift register, and form a sort of passageway between the two buildings, allowing the bit that is moved outside to enter the new building. Shift in 16 bits, and you've got 2 full registers.

You can continue to add new shift registers in this manner a theoretically infinite amount of times.

I tried my best to make that understandable, hope it helps! :D

Don't have time to read that page, but I don't think it has anything about cascading on it

Well it does :P

So it takes you longer to read a page than type that reply???

Ah, right; so I put in 10101010 then 10101010 into the top one and the data gets shuffled down into the subsequent SRs, so for an set of 7 segments with one SR for each I put the last number into the top register and shuffle it down using the other numbers as digital fingers (think of shuffling)

I see

The tutorial helped too, all I need to do is to use that and mearly run the method for each register to move the data down the line.

EASY!

Thanks guys, I shall try to make a video from this info and put it on youtube so other people can learn too!

I love you!

So it takes you longer to read a page than type that reply???

I thought I had to go, but when I got halfway through, I was told I didn't :P, so I figured I'd finish.

so for an set of 7 segments with one SR for each I put the last number into the top register and shuffle it down using the other numbers as digital fingers (think of shuffling)

Sounds right. One convenient thing about shiftOut() is that the third parameter can be either MSBFIRST or LSBFIRST. If you shift out "10101010" MSBFIRST, then the register will hold "01010101", but if you shift it out LSBFIRST, the register holds "10101010". Basically it either mirrors what you typed, or puts it verbatim.

I think MSB stands for Most Significant Bit, and LSB might stand for something like Left Side Bit, but I don't really remember. ;D

I love you!

aww thanks!

(yea thats how it is, i provide no help and take all the love) :wink:

I think MSB stands for Most Significant Bit, and LSB might stand for something like Left Side Bit

How about Least Significant Bit? ;)

How about Least Significant Bit?

Facepalm. I suppose that could be it…maybe…

Well I bit (LOL) the bullet and bought some to have a play, I have it going through some funky binary patterns on some bog standard LEDs next to me now. It would seem it makes more sense when you have a play with it.

Thanks a lot guys! (An don't fight, Left Side Bit means as much to a n00b like me as less significant bit) :P

Left Side Bit means as much to a n00b like me as less significant bit

Except the the least significant bit is written on the right hand end of a number. ;)

In the number 4369 the 9 is the least significant digit of all the digits in the number.

Keep on learning ;)

Ah, but some of us robots haven't had the firmware update that corrects the mirror effect from the lens on our cameras. Bill Gates from the future is scary, so we never updated. Tux told us not to.