NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Microcontroller Programming » Problems with LED Array Display
October 30, 2011 by claesz |
Hi! Just for the sake of practice I wanted to put together my own LED Array Display. Please bear with me; I know there is a great example of such a display under "tutorials", but I wanted to make it from scratch myself and not just copy the code. Now, the display is 15 x 5. The size is neither here nor there, I know, but I got bored of soldering after 75 LEDs so decided to just go with that. (Yes, I know that at least 16x5 would have made more sense since with 15 I don't get the "free" pin on reverse current). I use 13 pins (8 for columns and 5 for rows. My code seems to work fine, and is quite short and efficient, I felt. However I am noticing some odd problems: -First of all I get a pile of warnings on compile. I presume this is related to my declaration of pointers to port addresses. I wanted a code where I could pick and choose pins depending on whatever ports I had available in a project, and I can't think of any other way. Declaring them as const would through up an error since they are being addressed in the script. -Secondly, and my main irritation: For reasons I cannot understand, certain LEDs shine much brighter than others - particularly on the last row. -And thirdly, there seem to be some very faint light in some of the LEDs when they should be completely off. I am copying in the code below. I would really appreciate it if anyone had any thoughts on those problems mentioned above or just any comment on the code in general. My C skills leave a lot to be desired. Cheers, Claes.
The font.h file being included is basically just:
If anyone wants to try out the code, just let me know and I'll include the whole file if you need it. |
---|---|
October 30, 2011 by Rick_S |
Just a quick observation. It appears from a glance that you are using a timer to determine what letter/column position placement interval?? Typically in an array like this, the timer is used to determine the row refresh rate. In your program, the rows appear to refresh based on how long it takes the other code running in updatebuffer and the timer to run. Change anything in those and your refresh will change. By making the timer refresh the display, you can set how long of an interval between each row update and do all your other stuff between those. This may be why you see one row brighter than the others... I'd recommend at least looking over the code for the LED Array project or some of the other iterations here on the forums (I have a post on the forums where I added a lot of extra functions to the basic program) By looking those over, you can see the logic flow in a working program. BTW, while I see no reason to re-invent the wheel myself, I do commend your attempt. LED Array projects have always been one of my favorite. I have my original NK Scratch built array as well as some pre-made panels with shift registers. Here is a LINK to several links to some of my NK array info. Have fun! Rick |
October 30, 2011 by claesz |
Hi Rick! Thanks for the link. When I planned the script, I didn't really see the need for a timer interrupt for the LED refresh. Since the script did nothing but handling the LED array, I figured I might as well have it refresh the LED as often as it could. The only thing I put on a timer was the update of the output array (since you need that to control scrolling speed). However, reading through your comments I realized that I still had updateBuffer() in main(). That obviously was a mistake. Since it only updates the output buffer, it need only change when the content change (basically when there is a scroll movement), so I moved it into the interrupt where it should have been all along.
That fixed the problem with the brighter LEDs on the last row (basically only those LEDs are left on at the end of the refresh run, and since it then went off and did the buffer update before returning to refresh, they appeared brighter. Visually the thing appears perfect now. Still can notice a faint light in some of the off LEDs if you use a magnifying glass, though. Seems to me there must be some sort of problem with pins not being turned off entirely. I'll have a look at the other samples. I am sure they are far superior in both functionality and use of resources. It was just important for me to do this from scratch without having any preconceived notions about how to structure the code. |
Please log in to post a reply.
Did you know that negative numbers are represented in two's complement notation in binary? Learn more...
|