Rigging and powering multiple LEDs

Hi

I am completely new to Arduino as well as electronics in general, so I'd like to know whether it would be possible to run about 200 LEDs (5mm) off one Arduino board. I have tried using the max7219 driver, but with my limited knowledge of electronics have found it rather nightmarish. Please, any alternative suggestions would be very welcome. Would a transistor work? Or a digital potentiometer? ALSO, IF YOU HAVE ANY DIAGRAMS OF HOW TO RIG MULTIPLE LEDS, PLEASE SEND THEM TO ME! I still get totally lost unless I have some form of visual reference to fall back on.

Also, I am concerned about powering 200 LEDs per Arduino. Any suggestions?

Many thanks
mezusa

Hello mezusa,

Hi
I am completely new to Arduino as well as electronics in general, so I'd like to know whether it would be possible to run about 200 LEDs (5mm) off one Arduino board.

Yes it is possible.

I have tried using the max7219 driver, but with my limited knowledge of electronics have found it rather nightmarish.

This is a pity because it seems to be the natural choice for your problem.
I'll will try to connect a max7221 driver to my arduino next week, I already have it on my desk
but havenn't found the time yet to do it.

All other alternatives I can think of will involve more hardware-components making
things even more complex to you.

Would a transistor work? Or a digital potentiometer? ALSO, IF YOU HAVE ANY DIAGRAMS OF HOW TO RIG MULTIPLE LEDS, PLEASE SEND THEM TO ME! I still get totally lost unless I have some form of visual reference to fall back on.

Neither transitors nor potentiometers are part of the picture.
I would suggest you'll read through the max7219 datasheet again, slowly.
As a hint:
what you need is the schematic in the datasheet labeled:
Figure 3. Cascading MAX7219/MAX7221s to Drive 16 Seven-Segment LED Digits
If you can settle for 192 Led's you'll get by with 3 max7219, otherwise you will need 4 of them.
I would also suggest to go for the max7221 which gives you more control over the Leds.

On the software side you will have to read up on the shiftOut()-Function of the arduino.

Also, I am concerned about powering 200 LEDs per Arduino. Any suggestions?
Many thanks
mezusa

Since a single max7219/7221 only lights up 8 Leds at a time you have to provide something around
160 mA per max7219.
So with 3 max7219 (192 Leds) you'll end up with 480mA . This is just below the
Limit of an USB-Port ,(on a self-powered hub).
Otherwise get an external powersupply that provides
1000 mA at 5V and feed that into the max7219.

Eberhard

I just got a 7219 in the mail this week, and was planning on goofing around with it this weekend. I'll see if I can't upload pictures and my results as well.

Do you feel comfortable using a breadboard, and are you looking for a concrete diagram?

mezusa,

Are you trying to control each led individually? Are you trying to control groups of leds?

For instance if you need 10 groups of 20 leds to behave together than you could use 10 transisters to each turn on/off 20 leds.

If however, you need to control each individual led than perhaps you are making some kind of matrix display for graphics/text. In this case the leds are likely grouped in some matrix (perhaps 10 x 20). The max 72XX would work with one chip for each group of 64 leds (8x8).

Another possibility is to multiplex the columns and control the leds one column at a time. By using 3 3-8 demultiplexers you could control the 10x20 matrix with 15 control pins (doable by using some of the analog inputs as digital outputs)

You would load the column address into five digital pins and the row values into the other 10 and then proceed to scan through all 20 columns at least 30 times per second. This would give you the appearance of a continuous display with 200 leds. This is basically the same procedure that the MAX 7219's use just coded for 8x8 matrices.

Either approach will work.

Hi all,

since I had some leisure time to be wasted I got around to building a 4 digit 7-Segment display with the MAX7221.
After some minor problems, simply caused by the fact that I did not read through the whole of the datasheet, I now have the display showing me how the seconds of my life tick away silently.

Writing a small Test was straightforward (once I found out that the MAX7221 is always in shutdown mode when powerded up).

Define 3 pins on the arduino and then shiftOut() did the trick.
Is there anybody interested in a library for the 7221/7219 ?
I never created a library for the ardunino but I would give it a try...

Coming back to the original topic in this thread, I don't think there is an easier or even cheaper option than the 7221.

Eberhard

Coming back to the original topic in this thread, I don't think there is an easier or even cheaper option than the 7221.

Wouldn't multiplexing be cheaper?
Granted: I have no idea how feasible this is for 200 or so LED's, but the multiplexers I bought last week were far cheaper than the 7219. I think it boils down to how much work you want to do.

Speaking of work, I think someone made a 7219 matrix library already
Matrix \ Libraries \ Wiring :-[
I haven't gotten the chance to use this yet, but likely I will mess with it this weekend.

Oh, and also Mezusa: I think someone else mentioned this before, but please specify whether the LED's your using are loose or in a premade matrix.

Wouldn't multiplexing be cheaper?
Granted: I have no idea how feasible this is for 200 or so LED's, but the multiplexers I bought last week were far cheaper than the 7219. I think it boils down to how much work you want to do.

Chips are cheaper, but depending what you want to do with the hardware, these things also count:

You'll want a sockets for each of the chips,
A decoupling capacitor for each multilexer would be nice.
The 7221 only uses a single resistor for setting the current through the Leds, With Multiplexers you will need 1 resistor per column.
PCB-Costs! If you design your own board you'll pay by size (here things really get expensive)
Need a case for the whole thing, that also pays by volume.

For most of the things I build, the actual cost for the chips are very low. I spend more money on connectors, PCB's and all that mechanical stuff.

Eberhard

Forgot about this one:

Speaking of work, I think someone made a 7219 matrix library already
Matrix \ Libraries \ Wiring :-[
I haven't gotten the chance to use this yet, but likely I will mess with it this weekend.

I just had a look at the page, but there are more options on the 7221 that are not being care of in the above library.
There is no function call for putting the display into powersaving mode, nor are there comannds targeted at the use of 7-segment Led-displays.

I'm looking for something more complete.

Eberhard

I'm looking for something more complete.

Then, by all means, please!
I'm actually working on a project in which I was thinking of using 7 segment LED displays, and an updated library would really come in handy!

As for cheapness: I suppose you're right that the costs for ICs are relatively low in the long run when you compare them to everything else, even more so when you consider that shipping messes everything up.

Hi,
now I had my first go at a library for the arduino. I love the little thingy, even library-creation
is quite simple!

The question now is , how much memory is one willing to trade for conveniance in software development.
My current implementation will cost you about 1.2 kB of memory and here is what will get for it.

    /* Create a new device 
     * Params :
     * int dataPin      The pin on the Arduino where data gets shifted out
     * int clockPin      The pin for the clock
     * int csPin      The pin for selecting the device when data is to be sent
     * int pos            Devices can be chained to a single SPI-Line. This is the position
     *                  of the device on the line
     * int numDigits      The number of digits (or rows) attached to this device
     */
    LedControl(int dataPin, int clockPin, int csPin, int pos, int numDigits);

    /* Set the shutdown (power saving) mode for the device
     * Params :
     * boolean b      If true the device goes into power-down mode. If false
     *                  device goes into normal operation
     */
    void shutdown(bool b);

    /* Set the number of digits (or rows) to be displayed.
     * See datasheet for sideeffects of the scanlimit on the brightness
     * of the display.
     * Params :
     * int limit The number of digits to be displayed
     * Returns:
     * boolean false if you try to set the limit to something smaller
     * the numDigits param in the constructor. 
     * true if scan-limit is set to the new value
     */
    boolean setScanLimit(int limit);

    /* Set the brightness of the display.
     * Params:
     * int intensity the brightness of the display. 
     * Only values between 0(darkest) and 15(brightest) are valid.
     * Returns:
     * boolean false if intensity is not a valid value, true on success.
     */
    boolean setIntensity(int intensity);

    /* Switch all Leds on the display off. */
    void clearDisplay();

    /* Set the status for a specific Led.
     * Params :
     * int row            the row in which the led is located 
     *                  Only values between 0 and 7 are valid.
     * int col            the column in which the led is located
     *                  Only values between 0 and 7 are valid.
     * boolean state      If true the led is switched on, if false it is switched off
     * Returns:
     * boolean      false if either the row or column argument was invalid.
     *            true on sucess      
     */
    boolean setLed(int row, int col, boolean state);

    /* Set the 8 Led's in a row to a new state
     * Params:
     * int row            The row on which the led's are to be set
     *                  Only values between 0 and 7 are valid.
     * byte value      A bit set to 1 in this value will light up the
     *                  corresponding led.
     * Returns:
     * boolean false      if the row argumnet was invalid
     */
    boolean setRow(int row, byte value);

    /* Set the 8 Led's in a column to a new state
     * Params:
     * int col            The column on which the led's are to be set
     *                  Only values between 0 and 7 are valid.
     * byte value      A bit set to 1 in this value will light up the
     *                  corresponding led.
     * Returns:
     * boolean false      if the col argumnet was invalid
     */
    boolean setColumn(int col, byte value);

    /* Display a hexadecimal digit on a 7-Segment Display
     * Params:
     * int digit      the position of the digit on the display
     *                  Only values between 0 and the numDigits argument
     *                  from the constructor are valid.
     * byte value      the value to be displayed. 
     *                  Only values between 0x00 and 0x0F are valid.
     * boolean dp      If true also switches on the decimal point.
     * Returns:
     * boolean      false if the digit or value argument are invalid.
     */
    boolean setDigit(int digit, byte value, boolean dp);

    /* Display a character on a 7-Segment display.
     * The char that can be acutally displayed are obviously quite limited.
     * Here is the whole set :      
     *      '0','1','2','3','4','5','6','7','8','9','0','A','b','c','d','E','F','.','-' 
     * Params:
     * int digit      the position of the character on the display
     *                  Only values between 0 and the numDigits argument
     *                  from the constructor are valid.
     * byte value      the character to be displayed. (See the limited set above!) 
     * boolean dp      If true also switches on the decimal point.
     * Returns:
     * boolean      false if the digit or value argument are invalid.
     */
    boolean setChar(int digit, char value, boolean dp);

All comments on the function-declaration are very welcome.
Do you think the memory-consumption is way too much for your projects?
Do miss a function for a specific problem?

please speak up!

Status:
The lib already works fine when only a single MAX7221 is hooked up to the board. I ordered 2 more of these today.
I want to do some tests with more than one device before a public release.
But I will send you the code on e-mail request.

Eberhard

I already sent you a PM about this Wayoda, but you really should put the above in its own post so everyone can see!

I already sent you a PM about this Wayoda, but you really should put the above in its own post so everyone can see!

Thanks krylon , I read your PM.
Here is my timetable:
Two more max7221 will arrive today, so I will be able to test my code with cascaded devices.
Once I got that working too, Iwill create a request for comments topic and wait for replys.

Eberhard

hej,

if you come to some nice results (creating nice library, etc.) please post it at the wiki, so it will not be lost, there is already a area reservt for LED matrix stuff:

http://www.arduino.cc/playground/Main/LEDMatrix

vi ses
tomek

Hi,
I just uploaded my first release documentation and source-code for the LedControl-library to
http://www.wayoda.org/arduino/ledcontrol/index.html
and also put the annoucement and link into the playgrounds section on LedMatrix.
Eberhard

thanks, i've been looking for something like this :slight_smile:

I'm running some experiments to 'rig and power' multiple LEDs. In my project there are about 230 SMD leds, that have to be illuminated in 8 groups of about 15-25 LEDs each (so 8 arrays of 15-25 parallel LEDs). Everything should be battery-powered (regular 4xAA NiMH), so power efficiency is crucial.

I'm using a ULN2803a 8 channel darlington array IC to drive each group. Each channel is rated 500mA (continous) and I guess that should be on the edge of sufficient to drive 25 LEDs (each drawing about 20mA, so 20x25=500mA).

I didn't want to solder a resistor to each LED or small group of LEDs (since it's a lot of work and since they would waste a lot of energy) and I didn't want to give each group (each LED color) its own bulky voltage regulator. (These were the only solutions I could think of.. I'm not an electronics engineer..)
What I tried was to put LEDs directly to the 6V of the 4 AA batteries (without resistors or anything) and to put a PWM wave on the ULN2803's steering channel, using the Arduino's analogWrite function. I built the PWM value up very slowly, while measuring the current running through the array and while watching the LEDs to reach a satisfying brightness. The PWM value I had to use with the analogWrite function was fairly low (about 15), so dimming the array goes in only 16 steps...

I kept the LEDs running for a long time (a few hours) and they still work fine. The ULN2803 hums very quietly, don't know if that's normal (it's switching 490 times a second..) Nothing gets hot or anything, so I guess it's pretty efficient.
I'm not sure what the long-term consequences are of this solution, but I'll surely find out.... Of course the risk is that if I would accidentally put the pin through which the LED array is steering high instead of the PWM wave (e.g. using digitalWrite) I would ruin all the LEDs instantly..... Luckily the ULN2803's channels are turned off by default.

I hope someone with a bit more experience with electronics can give some comments on my solution....

Hi

if the pwm works on the steering channel (by that do you mean input pin?), then hey, it works.

For protection I would add a single resistor per channel from each ULN output; something like 4 ohms, 2 watts is a rough guess for the resistor to drop 2V at a half amp. Maybe get the flame-proof kind, since you like to max-out the design parameters. ;D

The bigger problem you have is that you're asking the chip to drive 4 Amps if all channels are turned on full. The TI data sheet says this:

Total substrate-terminal current [ch8722]2.5 A.

So the chip can sink 2.5A before the silicon melts. You will have to limit the current a bit, perhaps with a slightly higher value (8 ohms?) output resistor for each channel.

D

(I meant input pin by 'steering channel'. I'm quite a newbie to all this...)

What if I'd put the channels of two ULN's in parallel ('bundle' channel 1 with channel 1 on the other, etc.)? Then I would be able to sink 5A in total, right?

I guess I won't run into timing problems since the turn-on/off delay is 1 micro second max. (The PWM rate is about 490 Hz I believe.)

What if I'd put the channels of two ULN's in parallel ('bundle' channel 1 with channel 1 on the other, etc.)? Then I would be able to sink 5A in total, right?

Yes two chips could sink 5A, but the 2.5 A value is the point where the chip melts, not the recommended design value. Usually a design does not get close to the maximum values.

Why not just use a transistor for each channel, like the TIP102? That gives you 8A per channel.

Mosfets are also good. Something like an MPT10 logic-level Mosfet will switch 10A of led current effortlessly, for about 60 cents. Mosfets are better than transistors since they have a very low on resistance, and their resistance goes up as they get hotter. Transistors conduct more electricity when subjected to more heat, giving rise to "thermal runaway", i.e. catastophic meltdown.

D

Thanks for the suggestion D,
I'll take a safety margin into account next time :wink: always trying to push the limits huh..
I figured that not all the 230 LEDs are on simultaneously, about only half of it, theoretically drawing about 260mA.
So I guess I'll go for the 2x ULN anyway since I have one already and getting one extra is a cheaper deal than getting 8 MOSFETs or alike.

I have a question though. I hooked up a small array of 7 LEDs and put 6V PWM (14/256 duty(?)).
The LEDs seem to glow as bright as if they are fully powered.
I measure only 30mA (average) flowing through the whole array (shouldn't it measure around 140mA? or a bit higher at least?) And my meter says the voltage is only 0,35V (average). Shouldn't these averages be higher? So is the average power consumption then only 30x0,35=10,5mW?

Is there something strange going on inside my meter? Or why are they so extremely low, while the LEDs are still super bright?