I have been digging around the forums gaining as much knowledge as I can. I have come to the conclusion my design will require more than the max 200ma the Arduino can provide. To help reducing this I was thinking of offloading all the LEDs (20 total) current requirements to a separate external power supply. I'm wondering if a possible solution would be to place a small Transistor in between each LED with the base connected to an Arduino pin and the Collector to the seperate 5V regulated Wall wart. Is this a sound way to offload current demands?
Alternatively I also came across the TLC5940 IC that looks like I could do the same with and save a bunch of pins too.
Am I out to lunch or on the right track?
Comments much appreciated.
yes transistor will do the job. If you use mosfet (logic level mosfet) then there will be no load on arduini. If you choose to use oldscool bipolat transitor then 'hfe' determines 'load' If it's 10 then 100mA load will result 10mA load on arduinos pin. You can find Hfe in transistors datasheet.
Aoother possible solution is looking at the 74HC05 Inverter with open drain outputs.
Each output is capable of 20ma
One IC has 6 drivers, and would take up less space then the equivalent transistor with base resistor.
Arduino regulator is good for 800mA - saying 200mA is too general. There are limits by port, but if you spread the LEDs out a little you can be higher.
Will the LEDs be operated in groups? Then you wire them in strings and they can share the 20mA per string, limited by the voltage source. With 5V, you may be able to string 2. With 9V, 4. With 12V, 5.
Will the LEDs be operated individually? You can use a shift register with ULN2803 (8 active low pins that can work with 12V source) to save pins and push the current load off to the LEDs, and source the LED anodes from the Vin pin and not use the regulated power, size your current limit resistors accordingly:
R = (Vsource - LED(Vforward) - V(ULN2803))/(desired current)
I know the drop across a ULN2803 is very close to 0.7V from some measurements I made the other night.
So an example might be:
R = (9V - 2V - 0.7V)/0.02 = 315 ohm, use a standard 330 ohm resister.
Resistor power dissipation = IIR = 132mW, use a 1/4W rated resistor.
I think I have examples here using discrete transistors.
A ULN2808 output can be used in place of any transistor and has built in base resistor.
(if not, I will fix the link from home later)
Wow, thanks for all the responses. Some of it is over my head but I will start researching.
Here are some answer to the questions asked:
Will the LEDs be operated individually?
Yes, they are for displaying status of sensors. They could all be on at the same time too (which god forbid never happens)
Arduino regulator is good for 800mA - saying 200mA is too general
My mistake, I kept seeing 200ma but it was most likely me misunderstanding its context. 40ma per pin is the max correct? If it helps I have the Mega 2560.
40mA, only if you want to break things.
Most standard LEDs 3mm & 5mm are only rated for 20mA, driving higher than that shortens their life.
Same for the Arduino - 20mA for long life, drive higher and risk damaging the pins.
So Arduino pin to 220 ohm resistor to LED cathode, LED anode to +5V will do fine, low = LED on.
That will keep 8 LEDs on the same arduino port to 160mA.
Check the datasheet, I think section 28, for limits on which ports can handle similar currents.
Or, use superbright LEDs (like 5,000mCd, see superbrightleds.com) that appear really (Really! don't look directly at them if they are on full 20ma!) bright on much less current.
If you want to drive 20 LEDs individually then a couple of TLC5940 chips is one solution. The LEDs can then be driven from the unregulated supply.
Alternatively, you could multiplex them. For example, use 10 output pins to drive the anodes of 2 LEDs each, with a 220 ohm resistor between each output pin and its 2 LED anodes, and use 2 output pins and 2 npn transistors or n-channel mosfets to drive the cathodes of 10 LEDs each. The 220 ohm resistors will limit the current per LED to around 17mA, giving you 170mA peak current consumption since you will never turn both transistors on at once. Or use 5x4 multiplexing instead of 10x2.
The simplicity of the TLC5940 chips is compelling, but I like where CrossRoads was going with utilizing the Vin Pin by using a 12V ULN2803 as it keeps another wall wart out of the picture. The only problem I see with that is I will need multiple shift registers and ULN2803s.
I also just came across the STP16C596 which looks similar to the TLC5940 but I'm still working through the details.
STP16C596 which looks similar to the TLC5940
These two chips are totally diffrent. The first is a simple shift registervand driver the second is a complex PWM driver.
This was the diagram I actually intended. I can't see them when I post during the day, access is blocked.
Yes, will need a couple of chips if driving 20 LEDs.
If you wanted to do it as 1 chip,
you could use a chip like MAX7219/7221, can control up to 64 LEDs.
Easy to use SPI interface.
I think there are 4-display drivers you can get as well.
That MAX7219 looks great. If I understand Multiplexing correctly I can run 25 LED's at the cost of 5 which I can easily pull from the Arduino Vcc and no longer worry about maxing it out! Plus my local Electronics store has one so it's almost meant to be! Really appreciate the help everyone!
I can run 25 LED’s at the cost of 5
Yes but you take the hit of them not being as bright because they are not on all the time. You can compensate this by upping the current through each LED. As the chip does the driving then you are not looking at an arduino limit anyway.
You could reduce the power in software by ensuring that the LEDs are not all on at the same time. Simply pulse them on/off individually or in banks. Persistence of Vision will make them appear on continuously. This is often done to eliminate the need for limiting resistors, but it will also reduce the instantaneous current needs.
will also reduce the instantaneous current needs
No, it will reduce the average current, but the instatnaneous remains the same.
but the instantaneous remains the same
Hmm, I don't get that. Instead of having two LEDs on at any given instant, we only have one on, wouldn't that reduce BOTH the instantaneous AND average current?
Edit: Oh, I suppose you mean if he ALSO removed the limiting resistors.
The instantaneous current is exactly that - the current measured over a tiny period of time - how could it be reduced?
Re: using PWM to remove the need to fit current-limiting resistors - don't.
It may work for large, under-driven discrete power or signal transistors with lots of thermal inertia, but not the tiny drivers on-chip.
This is often done to eliminate the need for limiting resistors
I don't know why you say that because it doesn't, you still need them.