Shop OBEX P1 Docs P2 Docs Learn Events
8x8 led matrix — Parallax Forums

8x8 led matrix

PatrickS1981PatrickS1981 Posts: 17
edited 2011-02-08 10:44 in Propeller 1
Hi,

I wanted to create an more advanced project to learn more about microcontrollers. I thought it would be fun to create a 8x8 led matrix. I saw there are dedicated controllers for it, but it should also be possible with row column addressing using 2x8 pins of my propeller.
Does anyone knows a sample project to see how this would be done? I need to know for instance if I need resistors to prevent damage to the LED's. Also I wonder how I can sync the row and column's to activate 1 unique led.

Hope someone can help me out,

Patrick

Comments

  • idbruceidbruce Posts: 6,197
    edited 2011-02-08 03:58
    PatrickS1981

    I am no expert in this field, but if I am not mistaken, there should be many IC's available for this particular purpose (LED drivers).

    If you want to attempt this without IC's, I remember seeing something in the OBEX about a capacitve approach to a pushbutton matrix, perhaps something similar could be used for LED output.

    I suggest using IC's for this particular purpose.

    Bruce
  • PatrickS1981PatrickS1981 Posts: 17
    edited 2011-02-08 04:00
    I saw that it could be done with a led driver, but I thoutgh I would learn a lot of new stuff by actually build it with a plain microcontroller.
  • idbruceidbruce Posts: 6,197
    edited 2011-02-08 04:04
    PatrickS1981

    Then I would suggest at least looking at the datasheets for these drivers, to get a better understanding of addressing. Most of the time they will give a block diagram explaining theory of operation.

    Bruce
  • LeonLeon Posts: 7,620
    edited 2011-02-08 04:31
    I've got one of those 8x8 LED arrays on a little ARM evaluation board that Silica gave me at a seminar. Here's the code I wrote to test a push-button:
    /*
    ** led.c
    **
    ** simple program to test switch input and LED output
    */
    
    #include <targets/LPC210x.h>
    
    void LED_on();
    void LED_off();
    
    #define LED_ROW     0x04000000  //P0.26
    #define LED_COLUMN  0x00000008  //P0.3
    #define SWITCH_PIN 15           // Button 1
    
    int main(void)
    {
      while(1)
      {
        if (IOPIN & (1<<SWITCH_PIN)) 
          LED_on();
        else 
          LED_off();
      }
    }
    
    void LED_on()
    {
      IODIR = 0x00000000;
      IODIR |= (LED_ROW | LED_COLUMN);
      IOSET = LED_ROW;    // row high
      IOSET = LED_COLUMN; // column high
    }
    
    void LED_off()
    {
      IODIR = 0x00000000;
      IODIR |= (LED_ROW | LED_COLUMN);
      IOCLR = LED_ROW;    // row low  
      IOCLR = LED_COLUMN; // column low
    }
    
    

    The display doesn't need any drivers, the LEDs are driven directly from the output pins (with resistors). 16 outputs are needed, of course.
  • idbruceidbruce Posts: 6,197
    edited 2011-02-08 04:35
    Leon

    I think he wants to create it from individual LEDs. I believe he is searching for advice on how to wire the matrix using as few pins as possible. Of course he will need code also. :)

    Bruce
  • LeonLeon Posts: 7,620
    edited 2011-02-08 04:42
    The data sheet for that display will have the wiring details for the LEDs. They are made by Kingbright.
  • Jay KickliterJay Kickliter Posts: 446
    edited 2011-02-08 04:59
    Yes, the easiest method would be to use 16 pins. 8 for rows, and 8 for the columns. You can charlieplex to reduce your pin count, but unless your project needs a lot of free pins it isn't necessary.

    I dont have any Spin code, but I've been working on something similar. But I can tell you that I've been using blue LED's on my projects that have a fairly high forward voltage, and haven't found it necessary to use current limiting resistors. If you have access to decent test equipment, the best thing to do is ramp up voltage on a bare LED until you either hit 3.3 V or the max current you want or the LED can handle. Since I've been making coin-cell powered Prop projects lately, running at ~2.9 V, I find even without a limiting resistor the blue LED's sink only about 2 mA, and are still very bright.

    If you only want monochrome, and can handle the current, you can light all 8 LED's in a row at a time. If you want greyscale, you'll have to cycle through the LED's individually. Or you can designate a set time each row gets, and light all your ON LED's and turn off individual ones within that time period to get different brightnesses. Either way, you may find Spin not fast enough, and get visible flicker. That's where I am now, so I can't give any advice if Spin is fast enough to handle a greyscale matrix. I'm sure someone else has done this.

    I really don't see the need to use an external driver chip unless you want to learn how to use them. Kind of defeats the point of using a Prop with all that power. But don't listen to me, I'm the idiot using a Propeller on my business card when a $0.50 uC would do.
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2011-02-08 05:01
    Yes go for it, no need for controller chips, it is simple enough. This is the basic idea:

    http://www.winpicprog.co.uk/pic_tutorial_matrix_led_board.htm

    You energize the column that the led you want to light is on and then ground the row it is on, that way current will flow from one propeller pin to the other, of course this needs a resistor to limit the current. R = (3.3-Vf)/If

    You then energize each led in turn at high speed and nobody notices :)

    Graham
  • LeonLeon Posts: 7,620
    edited 2011-02-08 05:01
    I just found that ARM board of mine. It actually uses transistors to drive the rows and columns - 16 of them.
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2011-02-08 05:03
    Jay makes a good point, if you are careful to ensure the on time for the LED is short you can increase the peak current by reducing the resistance. This is because Power is IV but the energy is the power * time. So a smaller time allows a higher power with the same total energy output (and dissipation), however it may actually look brighter to humans.

    Graham
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2011-02-08 05:06
    If you want to drive big LEDs you will need transistors but the prop can handle most OK.

    You know you can use LEDs as input too? Perhaps that could be the next project :)
  • idbruceidbruce Posts: 6,197
    edited 2011-02-08 05:09
    Graham
    no need for controller chips

    That was a nice link for an example.

    Anyhow, can you get the same amount of control with the method that you suggest, as compared to using a driver?

    Bruce
  • LeonLeon Posts: 7,620
    edited 2011-02-08 05:16
    The ARM on that board of mine only has 4 mA drive on the outputs, hence the driver transistors. The Propeller won't need them.
  • MagIO2MagIO2 Posts: 2,243
    edited 2011-02-08 05:56
    Ok, guys ... so you really suggest that a newbie should try to drive the LED's without limiting resistor?! Only a little bug needed and at least 8 LEDs are gone ... maybe more plus propeller PINs.
  • LeonLeon Posts: 7,620
    edited 2011-02-08 06:05
    I mentioned resistors. :)
  • Jay KickliterJay Kickliter Posts: 446
    edited 2011-02-08 06:19
    MagIO2 wrote: »
    Ok, guys ... so you really suggest that a newbie should try to drive the LED's without limiting resistor?! Only a little bug needed and at least 8 LEDs are gone ... maybe more plus propeller PINs.

    Burning stuff is best long term lesson you can learn. But like I said, this only works on blue LED's. Might as well add limiting resistors, you can always use 0 ohm resistors if necessary.
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2011-02-08 06:34
    idbruce wrote: »
    Anyhow, can you get the same amount of control with the method that you suggest, as compared to using a driver?

    What level of control do you expect to get? Some of the chips have fonts etc, no problem for the prop, should be possible to modulate the brightness too if he fancies. The guy specifically said he wanted to learn how to do it himself. I'm not clear why you suggest things you are not familiar with? Large RGB screens might be a different story.
    MagIO2 wrote: »
    Ok, guys ... so you really suggest that a newbie should try to drive the LED's without limiting resistor?!

    Not me.
    Leon wrote: »
    The ARM on that board of mine only has 4 mA drive on the outputs, hence the driver transistors. The Propeller won't need them.

    Stop being so down on other processors ;)

    Graham
  • MagIO2MagIO2 Posts: 2,243
    edited 2011-02-08 06:54
    The logic of operation is simple for the board that's been linked to:
    loop over rows
      activate the current row bit (set output to 1 - anode side)
      loop over columns
        if LED should be lit
          set output of actual column to 0 (cathod side)
        else
          set output of actual column to 1 or disable output
    

    But as far as I interpret that board it's only good for simple on/off stuff .. like scrolling text.
    If you want it more sophisticated you should try to build a board that allows "greyscale" pictures.

    Why do I think the board is simple:
    You have 64 LEDs. So, each LED is lit for 1/64 second if you have a refresh rate of 1Hz. As we all know this is not enough. At a refresh rate of 100Hz one LED is only lit for 1/6400 second. If you want to do PWM for creating greyscale, your on-time will drop further.

    Instead you could:
    Use transistors to drive a common cathode per row and output 8 pixels at once.
    This means that the on-time at 100Hz will rise up to 1/800. With this value PWM might make more sense.

    I am currently experimenting with an RGB LED. And especially the dim color values are hard to reach if the PWM does not have a good resolution. In other words in this case the LEDs will raise brightness very fast.
  • JonnyMacJonnyMac Posts: 9,208
    edited 2011-02-08 08:05
    You really should use current limiters in your LED drive pins, and you should put a buffer in your column pins. Lookup the ULN2803; you can use this between your eight column pins and the cathodes of the LEDs in that column. The ULN2803 will let you sink all the current running through the group of LEDs. Each Propeller pin in the rows group will have a current limiter to keep the pin and group current within limits.
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2011-02-08 10:44
    MagIO2 wrote: »
    But as far as I interpret that board it's only good for simple on/off stuff .. like scrolling text.
    If you want it more sophisticated you should try to build a board that allows "greyscale" pictures.
    Why do I think the board is simple:

    The OP was not sure how to address a single LED in an array, this lead me to believe that at least in the first instance scrolling text etc would be OK. We can let him decide what he wants, at least I hope this simple example shows the basic way it works and he can now understand the idea behind operating an entire row/col simultaneously using a transistor as you suggest.

    Graham
Sign In or Register to comment.