Skip to content | Skip to navigation
Powered by RSPowered by RSPowered by RS

LED Matrix messaging board

Application: Video & Imaging
Information type: Software Code
Keywords: chipKIT, LED Matrix, source code
Manufacturer: Microchip Technology
Product: Dev Kit
Technology: LED
Theme: chipKIT

Overview

4x (8x8 LED Matrix) displaying "Happy New Year 2012" with scrolling animation.

Tutorial, Source code, Breadboard, ChipKIT compatible, Single-Layer PCB (easy manufacturing for hobbyist) and design files.

Details

 

// A scrolling text "Happy New Year 2012" is displayed on a 4x (8x8 LED matrix) display

// using multiplexing, i.e. scan the display led by led at high speed and lighten up the led

// with either green or red color (or black color = led switched off).

// The messages to display are actually images (image1 and image2) that are created

// first in Excel (each cell is entered a number 0, 1 or 2, and conditional formatting

// gives a first impression about the obtained image), and then copied-pasted through

// Excel-CSV-export format (File Save As - Comma Separated Values) into the code

// as 'const byte' images.

// The image is then continuously read and copied to the led display through the

// function scan_Image_To_LEDdisplay, itself calling pulseRedPixel/pulseGreenPixel,

// itself calling pixel_Red_On/pixel_Green_On and pixel_Red_Off/pixel_Green_Off with

// an interleaved delay that keeps the corresponding led on for a short time.

// Scanning through all leds sufficiently fast (e.g. 100 microseconds) gives the illusion

// to create a continuous image.

// The scrolling/animation of the image is obtained by changing (cfr. for-loops in the loop()

// function)(row, column)-offsets, i.e. (rowShift, columnShift) in scan_Image_To_LEDdisplay.

 

Video uploads

Supporting Materials

Title Information type
Project description, Source code, PCB, ... for 4x(8x8 led) messaging board Design files & examples
4x (8x8 led) image/message board Design files & examples

Comments

Bugs Bunny

Belgium

19 weeks ago

Hi embeddedguy!

I would like to post a comment, point by point, about what you wrote.

Scanning is quite different of PWM. Scanning means... scan one element at a time, to do something, while PWM (Pulse Width Modulation), as the name clearly explains, means modulating one parameter of something by sending repetitive pulses with a “modulated” cyclic ratio from > 0.00..1 to < 0.99..9. The later being called “duty cycle”.

Now, if you scan a matrix of LEDs to light them on one at a time (“to do something”), you MUST include a current limiting device. You CAN NOT just simply use a switch on the power supply side, and another one on the ground side: you will short your LED between the rails, and burn it out immediately.

You wrote “a resistor driven by a constant voltage source”. Resistor or not resistor? Sorry, I neither follow nor understand what you mean or where to place this. Or perhaps is it a CURRENT SOURCE, inserted somewhere in the current path? I described it in my very first posts, but it is impossible to use with the matrix configuration between the ChipKIT's outputs.

Pulse Width Control (not Modulation) is a form of POWER limiting process, NOT current! The LED always sees the really applied current, not the average one. If you exceed its maximum allowed peak current, even with a very low duty cycle (unless specifically noted): burned out! As I wrote in a previous post, the POWER really dissipated by the “component” is the peak power dissipated during the “ON” state multiplied by the duty cycle, from > 0.00..1 to < 0.99..9. The frequency is without importance, the mean POWER is always P"on" x (d.c.).

Driving a LED with a MCU or anything else is absolutely without importance, too; it doesn't allow you to suppress any limiting device, if nothing is foreseen to respect ALL component's ratings. As previously said, you always need “something” to prevent a component to operate outside its SOAR (Safe Operating Area - voltage, current, power, temperature - all parameters who gently interfere together -, if you understand what I mean). Anyway, when a current of (e.g.) 100 mA is sourced by a 5V power supply, the power consumption will be 500 mW, limiting devices or not. The dissipated energy is just distributed among the different components in the current pathes.

Over 24Hz, the human eye interprets successive pictures as a continuous movement. For pulsed light, the eye sees the mean value, as soon as the repetitive rate produces the retinal persistence phenomenon; below, stroboscopic effect occurs. Remember the twinkling Charlie Chaplin's movies, at 16 pictures/second.

PWC allows to drive the “component” (the LED) at a higher (peak) current than the allowed continuous current, during a part of the cycle - the "ON" interval in the duty cycle. The later is commonly adjusted (to try) to give the same effect as a continuous drive. Care must always be taken not to exceed, in addition to the maximum allowed current, the maximum allowed power. And lowering operating conditions (safety factor), while turning towards high efficiency components will guarantee a reasonable lifetime to the device. Refer, once again, to what was written earlier.

A last word about multiplexing. What is its real benefit? In this specific application (a display), the power consumption is limited to the power needed by one LED, as they are all illuminated in sequence. This power is then spread over the whole display, resulting in low brightness. Follows the need to drive the LEDs at higher currents. And the process must be possible to implement, for any reason...

Sorry,

B.B.

P.S. : Mr Lafruit has chosen to use shift & store registers, instead of multiplexing... And PWM will be used to control the brightness of the display. Have a look at the 4794 data sheet.

Regards,

B.B.

embeddedguy

United States

19 weeks ago

Handy hint - if you are 'scanning' the LEDs (PWM) then it is NOT necessary to have a current limiting resistor.

You only need a resistor driven by a constant voltage source.

Think about it - PWM is a form of current limiting and if you get your scan frequency right you can limit the average current the LED 'sees'.

Note that in any power saving scenareo, it is an exceptional waste of power to include a current limit resistor on LEDs driven by an MCU. Each one of those resistors is a parasitic power sink!

Using PWM will reduce power used for two reasons;

    1) the eye will see anything over 24Hz as 'ON' so you can have to led OFF at least half the time as long as you cycle > 24Hz - this saves 50% of the power used by the LED.

   2) Power wasted in the resistor is no more.

You only need a resistor driven by a constant voltage source...

Enjoy

lafruit

Belgium

19 weeks ago

I'll do. I'll start with making the 8x8 led PCB. That's art. In a second phase I'll do the basic/minimal software. Later I'll attach more 8x8 led PCBs together. Then, the software will be finetuned (e.g. dimming) and cleaned. And if I have time, I'll make the opto-coupler 220V 8x8 light bulb equivalent.

Yes, the job is far from done ... Any help is welcome.

   Regards,

      Gauthier

Bugs Bunny

Belgium

19 weeks ago

 

Hello Gauthier!

I guessed what your were getting at, when I saw your question about recovering pixels!

For such video walls, it's of course evident that a high-current switching power supply will be needed for the LEDs, for efficiency and cost-saving reasons.

Good luck, the job is far to be done!

I believe that all has been said concerning hardware problems, but keep us informed of your progress.

Regards,

B.B.

lafruit

Belgium

19 weeks ago

Thanks Bugs Bunny for these clarifications, including the opto-triac idea.

Actually, I am thinking of making a kind of puzzle construction: each piece is one 8x8 led matrix with all its drivers, resistors (all underneath the led matrix to save space) and interconnections to adjacent led matrices, and a multitude of such pieces can be tiled together horizontally and/or vertically.

Large video walls will have the corresponding 8x8 led PCBs to be manufactured in "mass production", reducing the cost per module and giving the user the possibility to set up different video wall sizes depending on his budget.

... and now finding time to do the engineering ;-)

   Regards,

      G.

Retrophile

United Kingdom

19 weeks ago

Well I've now managed to find enough time to peruse your files and although there were no surprises the effort you put into documenting the process definitely made it easier to understand your intentions. Thanks. 

One thing that does intrigue me is your lack of consideration for displaying yellow. i.e red+green at the same time. It would appear that the code changes necessary would be trivial so I wonder if there was a hardware reason. I assume the reason for placing the current limiting resistors in the cathode lines was to enable the use of different values for each colour. Since this doubles the number of resistors needed was the difference in brightness levels that noticable? Obviously lighting both red and green LEDs at exactly the same time would affect the current calculations (both cathode resistors would be in parallel) but I wonder if showing each colour for half of the display period would work. Since you already have separate routines for each colour then if the brightness levels of the three colours are noticeably mismatched then they could be balanced by only lighting the brightest colour(s) for a portion of the pixel display period. If that works then you could use a single anode resistor per LED.

As for dropping the value of the resistors to increase brightness I have seen plenty of designs that claim to safely exceed max current limits for brief periods since the average current is less but I am afraid all the evidence is anecdotal and I haven't seen any official guidelines or reports on the long term lifespan effects.

lafruit

Belgium

19 weeks ago

You are right w.r.t. the yellow color: the only reason it's red EXOR green is that it is a "quick and dirty" prototype; once the hardware in place, it becomes "merely" a software problem. As you say, displaying green and red very rapidly alternatively on a single led will indeed give an orange/yellow color (I actually observed that during preliminary experiments on a single 8x8 led matrix).

W.r.t. the issue of "one resistor per LED", do you mean "per 8x8 LED matrix"? If so, I don't think it can work. Actually, (let's say for one color to make the explanation simple) the horizontal lines of the full LED display are the cathodes, and all the vertical lines are the anodes. Each LED is then activated by scanning the different horizontal lines (cathodes) and vertical lines (anodes), which are connected to the ChipKIT pins. Hence, if no other intermediate IC is used between the display and the ChipKIT, there should be at least 8 resistors in the design, possibly even up to 32. If however some intermediate circuitry is used (e.g. latches, current drivers, ...), then since during the scanning each column and row is activated indivdually while all others are inactive, we might imagine to have a current return path though one wire, hence one resistor.

W.r.t. the max current to have high bightness, I am however more and more convinced that I have no other choice than to put additional latches to increase the current in the design without destroying the ChipKIT ...

   G.

Retrophile

United Kingdom

19 weeks ago

Dohhh. Must engage brain before hitting send :) Since i have only used 1 matrix at a time I was thinking that with 1 8x8x2 matrix, only 8 resistors are needed if they are in the anode lines as opposed to 16 if in the cathode lines. I was forgetting that 4 matrices actually have 32 anodes and so would require twice the number you used rather than half.

As you say, if you are adding intermediate ICs to give you the extra current capabilities you want, then there are several ways to minimise resistor usage but the extra cost would be more than that of the resistors you saved.

Bugs Bunny

Belgium

19 weeks ago

Hi Gauthier!

First of all, I would like to insert a link for those who didn't follow our previous posts:

http://www.designspark.com/comment/5202

Now some comments about what was written earlier (including my own comments).

A single resistor in the return path is strictly impossible, because each LED is floating between two outputs, one sourcing current from power supply, the other one sinking this current to ground.

Due to the matrix organization, the best solution is to use only 8 resistors, one by row (based on 4 elements of 8x8). But the problem of brightness is not solved; it will be discussed later.

The duty cycle seems to be misunderstood. You CAN NOT exceed the Absolute Maximum Ratings of a component, you will destroy it. The effect of the duty cycle is simply a decrease the mean dissipated power. Suppose a 100 mW LED, forced at its maximum allowed peak current of 200 mA, which presents in this condition a voltage drop of 2V at its terminals. The continuous dissipated power should be 400 mW : burned. The LED will thouroughly survive at a waveform with a duty cycle (much) lower then 0.25 (< .25 x400, < 100), e.g. 15 msec on / 85 msec off.

The current limiting circuit I proposed earlier is valid for a full multiplexing of the LEDs, when only one is driven at a time. First remember that the current through the LEDs is limited by the output sourcing/sinking abilities of the ChipKIT. We must find a other path for this current : from power supply to ground. Here is now how I imagine the circuit - include the current limiter in the multiplexing process.

For components saving purpose, I should use a current source (limiter) to sink current from each row, build as follows. A NPN transistor with a limiting resistor between emitter and ground, a small LED used as voltage reference between base and ground, driven through a resistor by one output of the ChipKIT. Assuming a voltage drop across the LED of 1.6V @ 5mA, and a Vbe of .7V @100 mA of collector current, the limiting resistor would have a value of (1.6 - .7) / .1 = 9 Ohms. Let's choose 8.2 Ohms to furnish some more current at our display, 10 Ohms a little less. Assuming a high level output voltage from the ChipKIT of 2.7V, and a drive current for the reference LED of 5mA, the base resistor should be choosen near (2.7 -1.6) / .005 or 220 Ohms.

We must now source current to the 32 columns. The job becomes very simple: a PNP transistor used as a switch, emitter at power supply, collector at column, and a resistor between base and one output of the Chipkit. Let's sink a current of roughly 2mA from the base. With 3.3V for the power supply, .7V base-emitter voltage drop, and .6V low-level output voltage of the ChipKIT, the resistor value is just equal to 1Kohm.

And now, the 8-bit shift and store register, the 4794. A very good idea, indeed. But it changes the philosophy of your design, and by the same time solves the problem of the length of your display! Referring to the diagram of fig 6, the first IC should be placed at the rightmost position of the display, the second one at the lefthand side of this one, and so on. Doing so, each time you send a word (a burst) of eight bits, your text if shifted one column to the left! And you just need three outputs for an endless display (with a sufficient power supply, of course) : Data, Strobe and Clock Pulse. The problem of brightness is solved, as the LEDs are continuously ON. Furthermore , you can use the Dimmer input for flickering the text, or change this brighness. The resistor problem? With this circuit, you can use resistor's ARRAYS. Just reverse the position of the LED and the resistor in the diagram, and it's done.

And something else: if you can find 3-colors integrated LEDs, using the Dimmer input for each color will allow you to sweep through nearly the entire color range of the visible spectrum. Wunderbar, isn'it? How? Using (true, now) PWM, sending cyclic words to the Dimmer control input [1000000 (low) --> 1111000 (middle) --> 11111111 (high)] will control the brightness of each color.

Mechanically, the display should be assembled with as many as needed little PCBs on a motherboard, like the memory modules of your computer, each PCB containing 1 (3) ICs, 1 (3) resistors arrays, and 8 LEDs, soldered in the plane of the PCB.

And if you want to build a tremendous screen, mix both processes: multiplexing and 4794 ICs. Use the output lines of the ChipKIT as ADRESSES for two (e.g.) 1-out-of-16 demultiplexers (4 bits adressing each, thus). 11 lines would allow you to control 256 modules with 4794's, if you imagine that each cross-point of the 16x16 matrix is applied to the first 2 inputs of a 3-inputs AND-gate, and the data being fed at the third one.

What's your opinion?

Regards,

B.B.

lafruit

Belgium

19 weeks ago

Hi Bugs Bunny,

Thanks for all the explanations; it's really helpful.

From the two proposals (PNP/NPN transistors vs. 4794) I finally prefer the 4794 solution: it's cleaner, more scalable to more extensive displays, has all color schemes, and uses a limited number of components easy to put on PCB (the resistors were fringhtening me, but indeed with resistor arrays it becomes a piece of cake; anyway easier than so many PNP/NPN transistors, one for each row/column. Of course, the software has to change completely, but OK electronics/informatics=fun.

If someone feels he/she would like to contribute in a way, please speak out loudly ;-)

Thanks again (to all) for the brainstorming and valuable help.

    Regards,

      Gauthier

Bugs Bunny

Belgium

19 weeks ago

Hi Gauthier, I'm back (again!)

Glad you choose the 4794 solution, it's the best one.

But you have now to take care about the total amount of current consumed by the LEDs, as they might be ON all together.

What is preferable, as the outputs of the 4794 are open-drain one's, is to connect the common point of the resistor's arrays ahead of the voltage regulator (fortunately, the 4794 is able to work starting from a 3V supply), if physically possible, to avoid unnecessary overheating. You might also use an external, unregulated (roughly 5 V) power supply. Filtering is sufficient, providing the ripple is less than 5% in the worst case condition (max. current).

The filtering capacitor can be calculated from the formula C x dV = I x dt, where dV is the maximum allowed ripple voltage (here, 0.25V), I the maximum load current (depends upon the amount of LEDs simultaneously ON – add a 10% security factor, to compensate for tolerances over the capacitor real value), and dt the interval between two recharges of the filtering capacitor, i.e. 10 ms with bridge rectification and 50 Hz line frequency. C is returned in Farads.

The transformer must be able to deliver, at full load, a voltage equal to or slightly greater than (5 + 1.4) / (sqr 2) Volts – the 1.4 V takes two diodes voltage drop into account, with bridge rectification, and the (sqr2) factor is mandatory to recover the RMS (eff.) value from the necessary peak output voltage of the transformer. Be aware, too, of low cost transformers, which may deliver a significantly higher voltage in near-zero load conditions, and/or are unable to furnish the foreseen maximum current as described in their so-said datasheets.

One more chapter of the endless “Absolute Maximum Ratings & Worst-Case-Proof Design” story...

And, last but not least, if you replace the LEDs with opto-triac drivers, you will be able to drive incandescent lamps. Maybe to build an advertising screen for your local football team? 

Regards,

B.B.

Retrophile

United Kingdom

19 weeks ago

I would love to examine this project but find that the files are encrypted with an unneccessary proprietry compression format. I am sure that the benefits of .zipx are not significant enough to justify its use and are definitely contrary to the spirit of Open Source. So is this intended as an open project or as a device to increase sales of a product designed to lock the user in to the whims of the supplier?

lafruit

Belgium

19 weeks ago

Made a new .rar file with all files included. Hope you can read it now according to the Open Source spirit ;-)

Zipx was automatically created by WINzip. Didn't find a way to keep it in zip-format instead of zipx. Both files are available on the website.

 

   Regards,

      Gauthier (pronounced "GO-T-HEY")

Retrophile

United Kingdom

19 weeks ago

Thanks for that and especially for the rapid response, I will try again.

I hate to say though, that before I came across .ZIPX, .RAR was my most hated compression format for exactly the same reasons. Fortunately .RAR has been around long enough for free readers to be available although I suspect that most/all of them are breaching copyright claims. 

I don't know why people try to distribute files using compression methods that have no free decompression utilities. I'd never use self extracting archives as they are a frightening security risk unless you can trust the source absolutely. Basic .ZIP files are so well supported these days, across all platforms, that I see no reason to use anything else. While I can sympathise with WINzip and understand their attempt to recapture the market, the story behind how they got that market means that they are only getting their karmic backlash.

I was going to say that if you can't produce standard .ZIP files from WINzip then I would demand a refund! but then I fortunately checked before hitting send and saw your latest comment before I posted this one. However I can't see the URL for your website in either the post or your profile.

Thanks again. I look forward to checking the files out. 

 

Retrophile

United Kingdom

19 weeks ago

Ooops I see you meant both format are on the Designspark website. I now have the zip archive and access to the files. Thanks again. 

lafruit

Belgium

19 weeks ago

zip (not zipx) on website

lafruit

Belgium

19 weeks ago

This design was meant to demonstrate a message board functionality with as little add-on components as possible for the poor-man's hobbyist: single-layered PCB, couple of resistors and 8x8 led tiles, no additional current driving circuitry (e.g. http://pdfserv.maxim-ic.com/en/ds/MAX6974-MAX6975.pdf), ... in a word: simplest possible hardware. The price to pay is that because the system rapidly scans over 4x(8x8)=256 leds, the light intensity is 256 times smaller than in the case the leds would continuously stay on (comparable to a PWM effect). Luckily, the scrolling text/image is bright enough to be readable, unless it is put outdoors in sunlight.  The current limiting resistors of around 200 Ohm conform to the spec of no more than 25 mA per pin, cfr. ChipKIT datasheet. However, because of the aforementioned PWM phenomenon, the actual average current is far less, i.e. 25/256 = 0.1 mA, which explains the moderate led brightness. Is it safe (both for the ChipKIT and the leds) to reduce the current limiting resistors far below 200 Ohms? Has someone an idea of which peak current is allowed without damaging any component?    Thanks in advance,       Gauthier

About the author

lafruit: Electronic Imaging enthousiast, exploring Visual ART with Electronics (=ElectronARTics). Like sharing technical knowledge in Electronics and Image Processing. Professional experience in digital TV, 3…

Related blog posts

4 Mar 2012

Some eight months ago I had a play with the chipKIT MAX32. At the time I was not ov ...

Associated products and knowledge

Contribute

Like to share knowledge with the community or ask a question relating to this knowledge?