Shop OBEX P1 Docs P2 Docs Learn Events
LED Matrix hardware help please. — Parallax Forums

LED Matrix hardware help please.

JedJed Posts: 107
edited 2009-02-17 20:46 in BASIC Stamp
I'm going to mess around with an 8x8 LED dot matrix. Specifically this one
Ok, so I need some clarification on a few things. First, an LED dot matrix such as this one is not purely common-cathode, nor common-anode. It's both correct? Column is one and row is the other. I see some advertised as common cathode, which doesn't make sense to me. Someone please explain if I'm wrong.

Second, I'm trying to decide between a max7219, or a tlc5940. Not sure which one to use. I understand how the max7219 works. 8 channels source, and 8 channels sink. But if I understand correctly, the tlc5940 sinks all 16 channels, so I'm not sure how that could be used with a dot matrix? I'd prefer the TLC as it's half the cost.

Comments

  • LilDiLilDi Posts: 229
    edited 2009-02-12 23:59
    The LED matrix you listed is indeed an 8 muxed common cathode and 8 muxed common anode LED matrix.
    The TLC5940 will not work with that LED matrix as you suspected since it is a common anode driver IC.
    A single MAX7219 will drive the 8X8 matrix multiplexed no problem.
  • JedJed Posts: 107
    edited 2009-02-13 00:16
    Max7219's then! [noparse]:)[/noparse] Now my next question: This matrix is bi-color. How can I drive this with 2 max7219's to get use of both colors? My concern is that the 2 max chips will be controlling the same cathodes. If they're trying to light up led's at the same time they're going to interfere with each other. How do I get them to time right so that they're not pulsing at exactly the same time?
  • JedJed Posts: 107
    edited 2009-02-13 18:14
    Also, is it possible to use two 74HC595's to drive an 8x8 matrix? Will the same chip work on either anode or cathode? I know I'd have to do the multiplexing in software, but will I be able to update the chips fast enough to multiplex an 8x8 without flicker?

    Post Edited (Jed) : 2/13/2009 7:42:23 PM GMT
  • remmi870remmi870 Posts: 79
    edited 2009-02-14 02:17
    im not shure what the total output of a 595 is but i think it will run up to 20 ma out per pin, the pins will run high or low tho, so you dont get a "input" or high impeedence without shutting all pins off, so you would always light up the row of pins, either one color or another, for instance, a high on pin 0 on x axis and low on pin 0 on axis y with all other pins on y being high would give you a row0 colum 0 LED with one color, and all other LED with the second color.

    ive used these 595's before, i know it is low to ground, so a bipolar matrix may give you problems, however you might be able to use a 595 and 8 pins to alow you to use input to give you a low state.
  • JedJed Posts: 107
    edited 2009-02-16 15:51
    If you mean by "bipolar" that running current one direction give you red while running the other give you green, then no. This matrix has 8 common cathodes (for rows) and 8 anodes for each red and green (16 total). The max forward voltage is approx 2.0v-2.2v (depending on color) while the max current rating per LED is 20mA.

    Ok, now help me out with the math here, because I'm new at all this. [noparse];)[/noparse] Let's assume I'm only worried about 1 color for now.

    If each channel of the 595 is rated up to 20mA, and I'm using 2 of them to control an 8x8 matrix (one controlling cathode, one controlling anodes), that means I have to do 1 of 2 things:
    1) Pulse each led in the matrix individually and use a 150ohm resistor on each row, or
    2) Pulse one row at a time, but limit the current for each LED to 2.5mA, using 1.2k resistors on each row.
    (to figure the resistors, I use ohms law, but subtract the LED's forward voltage from the voltage source first, correct?)

    The stamp may not have enough speed for #1 without a flicker?
    #2 will cost me brightness, and I'll also have to adjust my pulse time per row depending on how many LEDs in that row are lighting so that brightness across the entire matrix looks uniform. Again, maybe a speed issue with the stamp updating the 595?

    Post Edited (Jed) : 2/16/2009 5:45:48 PM GMT
  • ZootZoot Posts: 2,227
    edited 2009-02-17 05:13
    You won't be able to control each LED as you describe with a Stamp. I would actually go back to using the MAX7219/7221, and use two of them, but hook them up so that

    driver A controls 4 cathode rows and 8 anode rows (red/green on each)
    driver B controls 4 cathode rows and 8 anode rows (ditto)

    Remember that the 7219/7221 has a scan digit setting -- really a scan cathode row setting -- which tells it how many cathode rows/digits to multiplex before going back to 0. If you set each driver to scan 4 digits, then you're set. The only thing you'll need to decide is how to wire/handle your red green. You could do evens/odds in each byte, or you could set it up so that all greens are on rows 0..3 and all reds on rows 4...7 -- virtually speaking -- in other words, the rows/segments from the driver, not the physical layout of your LEDs.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • remmi870remmi870 Posts: 79
    edited 2009-02-17 07:38
    the 595 doesnt flicker, when you change the state of the 8 bits, it shifts out the 8 bits, then you latch it, which changes the ouput pins, even if you shift in new information, out to dozens of 595's, the bits arnt set to the ouput pins untill you latch all of them, you could even separate the 595 input lines and write the 595's seperately(not needed tho).

    so for instance if you wanted to make a diagonal line, you would pulse out the data to light the first led, hold for a few ms and then write the next led out, keep sucessivly doing this only a few ms and so long as you can keep the pattern within 30 ms, which is the limit of human eyesite, you wouldnt see much of a difference.
  • JedJed Posts: 107
    edited 2009-02-17 15:38
    I'd prefer the 595's. The ultimate goal once I get familiar with 1 8x8 display is to cascade 10 of these displays to make a 8x80 dot matrix. I love the ease of the max7219's, but they are too pricey. I've got some 595's coming, so I'll play with using those and see what happens. When I do the large display, I'd like to use only 1 595 for the cathodes of all 10 displays if possible. Is there a different 595 anyone can recommend that would be able to handle that current?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2009-02-17 16:04
    Are you planning on using a BASIC Stamp to run this?· You asked about speed and flicker, but didn't list the microcontroller you would be using.· That determines the answer to your question as well as how many rows/columns you're trying to update.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
  • ZootZoot Posts: 2,227
    edited 2009-02-17 18:34
    Jed, aside from the speed in updating issue (don't underestimate this, esp. if using a Stamp), you have parts count issues --- I'm not saying spend $$ on the driver(s) if you don't have to, but if you want to run whole rows from a '595 you will need transistor drivers on each pin. Second, a huge advantage in using any kind of LED driver is that current can be set for ALL LEDs hooked up to the driver with a single resistor; otherwise you will need resistors on each LED, or each group of LEDs.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • JedJed Posts: 107
    edited 2009-02-17 20:25
    Chris: Yes, basic stamp for now. I can move to the SX if needed though. I've been looking for an excuse to learn it. [noparse];)[/noparse] Would prefer to do an initial 8x80 matrix on the basic stamp though if I can do so with IC's other than the max7219's.

    Zoot: Already over my head here. What's a transistor driver and why would I need it? Does it have something to do with all the forward voltage's of the LED's adding up in the rows? I understand the resistor part and I'm ok with wiring those up individually.

    Basically I'm just looking for the cheapest way possible to do a 8x80 dot matrix, preferable with the basic stamp. I don't mind extra programming requirements, nor extra wiring requirements.

    BTW, thank you for all the help, and putting up with my noobishness. [noparse];)[/noparse]
  • ZootZoot Posts: 2,227
    edited 2009-02-17 20:46
    Jed -- let's say you multiplex 8 rows and 8 columns. Let's further say that your code is at the point where column -- or "digit" -- 4 (of 0 through 7) is being "lit". At the same time, you are turning on/off individual segments/LEDs within that column. Let's further say that at that point in time, your code lights up all 8 leds in that row/digit. Lastly, let's say you want a standard 15-20ma running through each LED. Well at that point you are sucking up to 160ma through that particular "column/digit" pin of your Stamp.... that's too much.

    The solution is to:

    a) use a transistor on the Stamp pin to drive the whole column (individual segments will each pull < 20ma so the segment pins would be OK). That's 8 transistors + 8 base resistors minimum, plus a resistor of 100-220ohms on each LED. You can also use a single IC package driver like a ULN2803 which is like having 8 NPN transistor darlington arrays in one single (cheap!) IC.

    or

    b) use individual segment/led resistors that are higher in value (and hence dimmer LEDs) so that you limit the total possible current on the row/digit.

    or

    c) code your project so that you don't light too many LEDs on a given row/digit at any one time.

    or

    d) use a driver like a MAX62xx or MAX72xx

    All of these are good solutions depending on what you want. I often limit LED output and simplify circuitry, but sometimes you just want those LEDs hot and bright. I usually use an SX and sink drivers like the ULN2803 because I have them on hand and they are cheap. That's also nice for individual PWM of leds/segments. In other cases it's infinitely easier to use a driver like the MAX7221 -- the external circuitry is practically zero, the multiplexing is *very* fast -- 800hz across the whole matrix, and having a single iset (currernt limiting) resistor is nice because you can use a pot if you want to have a nice brightness control (and if the driver has a little air circulation, you can run your LEDs *very* bright and the chip doesn't get too warm).

    T&E Engineer builds his big matrixes with NPN transistors for each column and PNP for each row (or maybe the other way around smile.gif) so current is not an issue.

    Remember that the Stamp will be relatively slow... you may be able to do the multiplexing if your program is not doing too much else and/or if you consistently run a "gosub refresh" routine (sprinkled through your main loop) to keep the display multiplexing moving even while the main loop is cranking through other things... e.g.

    'pseudo code
    idx VAR Nib ' work var
    col VAR Nib ' pointer to current col
    leds VAR Byte(8) ' 8 bytes of rows (or vice versa)
    
    CathCols VAR OUTL ' pins 0-7 cathodes, low to turn on col
    AnodRows VAR OUTH ' pins 8-15 anode segments/leds
    
    '--- start ------------
    FOR idx = 0 TO 7
       leds(idx) = %11111111 ' turn on all LEDs on the display on startup!
       GOSUB Refresh_Leds   ' and move 'em out
    NEXT
    
    ' --- main -----------
    Main:
    
    RANDOM idx
    leds(idx&$07) = idx ' randomize each time through main loop
    
    GOSUB Refresh_Leds   ' run this often throughout main loop
    
    IF something THEN
       otherThing
    ENDIF
    GOSUB Refresh_Leds   ' run this often throughout main loop
    
    IF myCode THEN
       moreCode
    ENDIF
    GOSUB Refresh_Leds   ' run this often throughout main loop
    
    'etc
    
    GOSUB Refresh_Leds   ' run this often throughout main loop
    
    GOTO Main ' end of main loop
    
    '--- subs ------------
    Refresh_Leds:
       CathCols = %11111111 ' all high to turn off (plus maybe 150us of inter column blanking)
       col = col + 1 & $07  ' keep cycling through columns
       AnodRows = leds(col) ' get this columns segments and move 'em out
       CathCols.BIT0(col) = 0 ' and turn on this column
       RETURN
    
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php


    Post Edited (Zoot) : 2/17/2009 8:51:19 PM GMT
Sign In or Register to comment.