Hi all a few days ago i decided it was time to embark on my first serious solo arduino project and i decided to do an LED matrix. I’m fairly new to this so i thought it would be nice to work on this post some of the things i’ve done to get some feed back.
At this point i’ve decided to go with a 6 x 24 led matrix controlled via the arduino and mux/demuxers. My only real concern with this design is 16MHz being fast enough to refresh all the LEDs so as to operate via persistence of vision. Concerns aside I’ve ordered my LEDs and mux/demuxers and i’ve even written a little snippet of code to test lighting the whole thing up (which i will attach.) So if you would like feel free to criticize my code (learning the language) and design. Well here is my code for testing. If all goes well i will get parts by thursday/friday and be started working on a library to drive it. I’ll update this thread as i progress.
MatrixTestSketch.ino (5.29 KB)
You don't specify what chips you're using so I can't comment directly on your setup but a 16 MHz 328 runs my 24x16 matrix with 32 levels of PWM with no problems, so what you want to do is absolutely doable.
The Arduino is plenty fast enough to update 144 leds. Here is a thread on how many clock cycles it takes to toggle a pin:
How bright they will be and how much time each will be on for of course depends on how many you’re lighting at once and how much current you put through them. If it’s 24 at once in 6 rows, then the current per led will be /6. If you’re only lighting 6 at once, then it will be /24 so they might be kinda dim. And if you’re only lighting one at a time, they’re gonna be pretty dim.
I myself at one point multiplexed an array of 64 leds, and I think I calculated that lighting 8 leds at a time, I could update the array at 480hz. I think this gave me something like 8-bit brightness control, but I forget how I did the math to come to that conclusion. Assuming 60fps though, that’s 8 times a frame I could switch the led on and off to adjust the brightness and still maintain persistence of vision.
To get to that point though I had to really optimize my code. I actually sorted all the leds by brightness, inserting each into an array according to what time it should turn off, so in the main loop I only had to check the times of those that were turning off.
But if you just want to turn them on and off, you don’t need to go quite that far.
Why would lighting only one at a time be dim? My design as is now will ONLY be able to light one at a time. I plan on setting it up like a typical grid of leds driven strictly by a system of multiplexer/demultiplexers. What it boils down to is that I can only have one led on at any given time. Each led should get the 20mA it needs though unless pov will make them appear dimmer.
thanks for the input
Why would lighting only one at a time be dim?
Because each LED will be on (at most) 0.7% (1/144th) of the time. It will be (roughly) the same as if you're only passing 0.2mA through the LED.
So is their a transient state LEDs have that i'm not aware of? This is a pretty serious oversight on my part :s
Either you're not understanding us or we're not understanding you. You say you're going to have 144 LEDs but you're only going to light up one at a time...
There's only two ways I can think to do that. Either each LED is only on for 1/144th of the time, or you only pulse the entries of a sparse matrix, linked list, etc. Given the limited RAM of the ATMega, I'm not sure that would be worth it.
Like I said maybe I'm just not understanding how you're going to do this. In any event, I look forward to hearing more about your project and with you good luck with it.
No. You understood me perfectly the first time around and then i confused the issue sorry. I think I see what your saying, correct me if i’m wrong: due to the nature of persistence of vision the LEDs will appear much dimmer than if they were constantly on. This is something i wasn’t aware of as i didn’t read up enough on this kind of thing… Oh well i received 200 LED’s and a whole bunch of other stuff today. Tomorrow or Friday I’ll be getting the rest of my parts and i will be able to test it out and see how it works.
BTW thanks for that link swift i learned a fair bit :]
I'm not sure we agree on the terminology, but that's the general idea.
One thing to note is if you blink them fast enough you may be able to pump more current through them. Check your LED's spec sheet for something like "peak forward current" -- a lot of the time you can overdrive them at 5x the always-on current if the pulse is short (typically 0.1 ms). Due to the non-linear nature of the human eye, this can help more than you'd expect.
think I see what your saying, correct me if i'm wrong: due to the nature of persistence of vision the LEDs will appear much dimmer than if they were constantly on.
Correct. Persistence of vision works because the eye averages the light received over the last few milliseconds. So if the LED is on 50% of the time during that period it will look like it was on the whole time but be 50% as bright.
So if the LED is on 50% of the time during that period it will look like it was on the whole time but be 50% as bright.
Just one minor nit - human eyes respond non linearly to light...our eyes use the inverse square law for brightness. So a light on 50% of the time actually appears to be about 70% as bright.
This is why you sometimes see lookup tables in PWM code where people are trying to get perceived linear brightness changes.
Here's a cheesy Instructibles:
Here's a more technical explanation:
And here's a video showing the difference:
I pride myself on my ability to turn a phrase, but in this case, I would amend my original statement to this:
"If the LED is on 50% of the time during that period it will look like it was on the whole time but be as bright as if you were putting 50% of the current through it."
Well i certainly didn't anticipate my research for this project taking me down this field of study. It seems i have some design changes to consider although i will still experiment with my original design as in practical cases all 144 LEDs will never be on at once. I still suspect that the display will appear fairly dim the situation is confused somewhat by the lack of a linear relationship. I admittedly am not sure what to expect. I would like to avoid using an IC developed just for controlling LED's. Perhaps I will research Decoders and Shift Registers as alternate column controllers.
Thank you for the driving information guys you've been a lot of help I'll probably have the thing built according to my original design this weekend so i'll let you know how that goes.
ive decided to go with shift registers (74hc595) to control the columns and a demuxer(74HC4052 w/ some tinkering) to control the rows. I do have a general electronics question that someone could probably answer in about two seconds. If i power the arduino and the ICs with a different source will i still tie all grounds together. If so will a large resistor be plenty to protect my arduino(or necesary)?
Yes, you connect the grounds together. I'm not sure about a resistor - where do you think you'd put it?
i was thinking right outside the ground terminal on the arduino. I don't know, but i suspect sending a potentially large current into my arduino's ground could be a bad thing? Maybe i'm being overly paranoid?
You're probably right about large current damaging your Arduino, but the few times I've used multiple power supplies I've just connected all grounds and nothing else. I think it's an issue if there could be a path for the high amperage circuit through your low voltage's ground path but if you keep the busses completely separate except for a single link between two ground points you should be ok.
My notes say I followed this when I made a plant light timer that needed 2 power supplies:
Thanks for the relevant link and insight. I think i've got everything now except for a long enough proto-board. I'm building a 6x6 proof of concept this weekend and when i get it up and running i will update this thread as well as begin work on the full sized 6x24.
Alright, I have all the parts in hand 2 74hc595s and 1 74hc4052 (with some external modification to make it 1 to 8) that i already had. I already have the LEDs soldered together hopefully sometime today i will the ICs breadboarded and ready to go. Thanks again for all the help.
alright the matrix is together and i have tested all the individual LEDs... no shorts or open circuits now i'm having trouble with the electronics part of it. I'm linking up my test sketch with this post. It's going to be running on an UNO. I'm working on a more clear computer generated schematic so that i can have a more clean approach this time I'll link that up when i'm done.