[RESOLVED] Odd problem with controlling LED array with shift registers.
Wossname
Posts: 174
I'm having a hard time driving a rectangular grid of 24 (across) by 8 (down) LEDs.
I'm using three 74HC595 shift registers cascaded in a 24-bit ring buffer formation to select a single column by using that high bit to source current.
Then there's a fourth 595 that selects a column (in an 8-bit ring buffer on its own) by using that low bit to sink current.
So the cascaded three shift registers have a single high bit rolling through them, and the fourth shift register has a single low bit rolling through it.
I'm using the rolling high bit in the 24 bit ring to clock the 8 bit ring (when it reaches the 3rd register's ~G pin (pin9)). This means that all I have to do to sequentially flash each LED in the entire array is to repeatedly clock the 24-bit ring.
So far so good...
However, it looks like the last 2 columns are addressed before the first. A workaround for it would be to re-wire the matrix so that the last 2 columns actually connect immediately before the first column - but that somehow seems like a silly idea and rather unbalanced. There shouldn't be anything special about these two columns in the design and so I figure it's either a timing issue when I'm configuring the shift registers or is something else I don't comprehend.
To make matters worse this is all on breadboard and I have no schematic. But on the plus side the entire array does get flashed and there are no gaps in the sequence.
I'm not very experienced with circuit debugging yet and so I'm a bit stumped regarding how to proceed. Can anyone suggest either what I'm doing wrong or what I could try in order to debug further?
For illustrative purposes, have a look at this short video of the light sequence...
http://www.flickr.com/photos/adamneilward/6400894757
I'm using three 74HC595 shift registers cascaded in a 24-bit ring buffer formation to select a single column by using that high bit to source current.
Then there's a fourth 595 that selects a column (in an 8-bit ring buffer on its own) by using that low bit to sink current.
So the cascaded three shift registers have a single high bit rolling through them, and the fourth shift register has a single low bit rolling through it.
I'm using the rolling high bit in the 24 bit ring to clock the 8 bit ring (when it reaches the 3rd register's ~G pin (pin9)). This means that all I have to do to sequentially flash each LED in the entire array is to repeatedly clock the 24-bit ring.
So far so good...
However, it looks like the last 2 columns are addressed before the first. A workaround for it would be to re-wire the matrix so that the last 2 columns actually connect immediately before the first column - but that somehow seems like a silly idea and rather unbalanced. There shouldn't be anything special about these two columns in the design and so I figure it's either a timing issue when I'm configuring the shift registers or is something else I don't comprehend.
To make matters worse this is all on breadboard and I have no schematic. But on the plus side the entire array does get flashed and there are no gaps in the sequence.
I'm not very experienced with circuit debugging yet and so I'm a bit stumped regarding how to proceed. Can anyone suggest either what I'm doing wrong or what I could try in order to debug further?
For illustrative purposes, have a look at this short video of the light sequence...
http://www.flickr.com/photos/adamneilward/6400894757
Comments
Frank
P.S. Not to sound snarky, but seriously, stop. Draw out your schematic to work from. Otherwise you are only going to be guessing at what the wiring should be. At least with a schematic, you can mark off each line you have verified as you go. Then test small subsets of the design and build upon what is working sequentially. It gets late we get tired and we cross Q0 and Q1 etc.......
http://www.flickr.com/photos/adamneilward/6400894757
I'm driving this with pulses from a Propeller chip so I can slow things down as much as I want, and I did so for the video, you can see that the LEDs come on in the sequence: 2, 1, 24, 23, 22, 21, 20, 19....5, 4, 3, then the next row.
I'll transcribe this circuit into a schematic and see if that shows up any oddities. Thank you for being patient with me, I just with someone would event a machine that lets you upload hardware onto the internet
I have a 12 x 10 LED array. I use shift registers with it also.
I don't see any code? If you post it, I should have time to look it over.
The the Propeller Tools "Archive" feature (under the file menu). Then we'll have all the objects you're using.
I've not bothered to draw on the decoupling caps or the power supplies but they are there in my breadboard. The propeller is on my home-brew dev board which has a 3.3v regulator circuit on it and I've checked voltages throughout the whole build - everything is running off this smooth 3.3v supply.
Regarding the way I'm using the propeller inputs: I'm trying to be a bit clever and initialise the 24-bit ring first, then the 8-bit ring and then changing some of the prop IO pins to inputs so they don't interfere once the shift register buffers have been fully initialised. I want the same clocked in bits to cycle round and round forever.
So in theory what happens if that once both ring buffers are initialised, all I have to do is basically strobe the clock lines on the 24-bit ring and that will sequentially iterate through each LED in the entire matrix. Which works perfectly as it stands - apart from the fact that the last 2 columns are being lit before the first one. Note that the code (I hope) doesn't ever allow P0 and P4 to both be outputs at the same time - they are wired together and would cause a short if they were both outputs potentially.
I feel it's something wrong with the sequence of events here but I can't seem to get to grips with it.
Things I've tried so far, to no avail...
- Using a different pin to trigger the 8-bit ring buffer clock. Instead of QH' I tried QH and that improved matters by fixing one of the columns! Then logically I then tried QG but then the problem came back, which I don't understand.
- I tried changing the way that I'm initialising the ring buffers. But this is already working correctly as far as I can tell. If my wiring theory is sound (it may not be) then the two ring buffers will interact correctly when the high bit rolls around the 24-bit ring it clocks the 8-bit ring at the end of each row.
Here's my PASM code if anyone feels like perusing it...This is where I'm guessing the problem is. The clock line could be triggered while both pins are inputs.
Maybe a pull-down resistor would help?
P0 – SER anode serial data input
P1 – SRCLK anode serial register clock
P1 – /SRCLR cathode serial register clear
P2 – /OE anode output enable
P2 – /SRCLR anode serial register clear
P3 – SER cathode serial data input
P4 – SRCLK cathode serial register clock
P4 – /QH anode /QH output
P4 – P0 propeller P0 pin
P5 – /OE cathode output enable
I suspect you have made a mistake with the schematic. I don't see how it could work as shown in the video if the circuit is wired like this.
kwinn, Your schematic uses QH and not /QH... why is that?
I've spend too much time on this so I'm going to re-do it all but just having the propeller drive all the input pins directly and just push bits in manually.
The /QH pin is directly tied to the serial shift register not the parallel output register. That means your row bit will be shifted to the next row while the column registers still contain the data from the previous row. This may explain why your display did not start in the first column as you expected. The way you are using the '595's makes coordinating the row/colum bits a little trickier than using one long register.
Thats what I have done as well. I have only built a couple of led character displays (8x56 and 8x112) and connected all the shift registers in series and shifted out all the row and column bits sequentially then transferred all of them to the output registers simultaneously. It makes the hardware and software simpler and the display more flexible.
BTW, I agree with what you say in post 12. Much simpler to shift out the data you want to all the chips in a series string.
http://www.mouser.com/Semiconductors/Logic-ICs/Counter-Shift-Registers/_/N-55d4h?P=1z0z44dZ1z0z5fd&Keyword=TPIC6C595&FS=True&Ns=Package%20/%20Case|0
And you still would have to mutlipex as one pin from a 595 can not source 8 leds (unless you get high resistor and only ~3mA per LED)
I'm not planning to light up more than a single LED at any given time, I'm just going to run the entire matrix as a stationary POV display. I've actually tried this already. Even with the annoying columns issue, the timing and stability is fine and runs happily up to several hundred "frames per second", and the brightness is just right even with double the normal value of current limiting resistance. Another bonus is that it never uses more than 1 LED's worth of current at any given time.
Hmmm, I just hope it's not giving off radio waves!
I'm really grateful for all your help Kwinn and everyone else. I've said it before and I'll say it again, I think this is probably the most friendly and genuinely helpful forum I've ever been a member of. Much appreciated.
Cheers!
I've opted to keep both the two separate ring buffers, but now they are not connected by a clock line. I'm clocking them both manually which means I only have to worry about three IO lines (x clock, y clock and /OE). I'm happy with that as a result, although I don't really understand why it's so hard to do what I originally thought would be easy.
No matter, job done!
Woooohooo.