Shop OBEX P1 Docs P2 Docs Learn Events
[RESOLVED] Odd problem with controlling LED array with shift registers. — Parallax Forums

[RESOLVED] Odd problem with controlling LED array with shift registers.

WossnameWossname Posts: 174
edited 2011-11-28 11:22 in General Discussion
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


Comments

  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2011-11-25 11:10
    I can't see the video on the computer that I am on, but just a guess.. are there decoupling capacitors (0.01uF or so) on each of the 74HC595 IC's?
  • graffixgraffix Posts: 389
    edited 2011-11-25 11:26
    Your video is private.
  • kwinnkwinn Posts: 8,697
    edited 2011-11-25 16:59
    Are you clearing the registers and shifting in the correct bit pattern to start with?
  • frank freedmanfrank freedman Posts: 1,983
    edited 2011-11-25 21:59
    If you simply put a clock pulse say from a 555 or other osc. set slow enough to see the shifts into the column shift register and a switch to set H/L for the data pin and then if you grounded any single row selector, do you see the leds light up in the proper sequence? If not, check your wiring. If they do check your code as you may not be counting the correct number of pulses out to the shift register and the residual may give the appearance of starting in the wrong column.

    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.......
  • WossnameWossname Posts: 174
    edited 2011-11-26 06:57
    Sorry I've fixed that video link...
    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 :D
  • Duane DegnDuane Degn Posts: 10,588
    edited 2011-11-26 07:47
    Wassname,

    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.
  • WossnameWossname Posts: 174
    edited 2011-11-26 08:51
    Here's what I'm trying to do and to the best of my ability to tell this is identical to my breadboard...

    595_led_matrix.jpg


    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...
    1024 x 616 - 100K
  • Duane DegnDuane Degn Posts: 10,588
    edited 2011-11-26 10:22
    Wossname wrote: »
    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.

    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?
  • kwinnkwinn Posts: 8,697
    edited 2011-11-26 11:04
    Going by your schematic you have the '595's for the 8 rows (cathode) and 24 colums (anode) wired to the prop as outlined.

    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.
  • WossnameWossname Posts: 174
    edited 2011-11-27 04:47
    The /SRCLR lines are tied to +3.3V the whole time on my diagram also, P1 and P2 on the triangular symbols are "Power".

    kwinn, Your schematic uses QH and not /QH... why is that?
  • WossnameWossname Posts: 174
    edited 2011-11-27 08:30
    I'm damned if I can get this to work properly. I also tried kwinn's circuit and I couldn't make that work either.

    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.
  • kwinnkwinn Posts: 8,697
    edited 2011-11-27 12:00
    kwinn, Your schematic uses QH and not /QH... why is that?

    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.
    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.

    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.
  • kwinnkwinn Posts: 8,697
    edited 2011-11-27 14:05
    Wossname, I owe you an apology for misleading you with my previous schematic. I have attached the corrected schematic here.

    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.
  • tonyp12tonyp12 Posts: 1,951
    edited 2011-11-27 15:26
    If your future plan is to have more than a few leds on at any time you better change the sinking 595 to a TPIC6C595
    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)
  • kwinnkwinn Posts: 8,697
    edited 2011-11-27 16:26
    tonyp12 has a good point. If you are planning to use the led array as a multiplexed character display you will need to provide more current to the columns than a 595 can provide and many times more current to the rows since each row has to handle the sum of the currents from each column.
  • WossnameWossname Posts: 174
    edited 2011-11-28 05:43
    No apology required Kwinn, your schematic was closer than I had managed on my own. I'll try your revised one tonight.

    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! :D

    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!
  • WossnameWossname Posts: 174
    edited 2011-11-28 11:22
    Resolved!

    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. :)
Sign In or Register to comment.