Go Down

Topic: Tons of breathing LEDs on single PWM pin (Read 2247 times) previous topic - next topic

Hello,

I'm doing a project which is essentially a lighted cube, that communicates status through different colors. So when the light goes below a certain level it turns a certain color, when temp goes above a certain level it turns another color, etc. I'm figuring I'll probably need anywhere from 2 to 4 LEDs per color to get a nice intensity, and the colors would breathe, which is pretty easy with PWM on the arduino.

What I'm thinking is that I'm going to leave all the colors in phase. So that the intensity ramp on red is the same as yellow, is the same as green, etc. That would require only a single PWM output and most importantly, a single section in the code, which would make writing easier.

The solution I've come up with is to have the PWM pin drive a MOSFET, and give it the modulation, and the MOSFET would repeat the "breathing" pulse to all the LEDs. Then each color gets switched on or off through a transistor by other pins on the arduino that simply go high or low. Something like this:

http://img594.imageshack.us/img594/5388/ledctrl.jpg

Sorry about the symbols, I think I put a P gate instead of an N gate on the diagram. It's an N gate. And the LEDs, of course, would be multiple per color if necessary, with the resistor value altered to give them the adequate current.

I figure an IRF630, which has an insanely high drain current for this purpose should be more than enough for whatever I might plug into it. And for the switching of each color, maybe an N2222, 4 LEDs will go at about 80 mA max anyway.

So, why not just drive each color from a PWM output? Coding. Handling and monitoring one PWM output in code is a little easier than handling 4 or 5. And since I have the MOSFET laying around, might as well.

Any thoughts on the circuit? Sound like it could work?

Osgeld

I am sure there is something I dont see, but the fundamental idea sounds fine
http://arduino.cc/forum/index.php?action=unread;boards=2,3,4,5,67,6,7,8,9,10,11,66,12,13,15,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,86,87,89,1;ALL

Grumpy_Mike

#2
Jan 13, 2013, 10:39 am Last Edit: Jan 13, 2013, 10:41 am by Grumpy_Mike Reason: 1
If that is an N channel FET then it will not work. Ths is because to turn it on you have to have a 5V difference between source and gate. As the source is connected to the LEDs then it is not stating at zero volts but the forward voltage drop of the LED plus what is dropped across the resistor.
You will not get more than 4.3V on the transistor's emitter as well.
Yo need a P type FET and base resistors and to put the LED and resistor in the collector of the transistor and not the emitter.

However when you have done all that you will still have trouble because the PWM signals will beat with each other, some work at diffrent frequencies so they will not add up like you hope they will.

EVP

Did mike just say this.. You need resistors on the base of the transistors

Osgeld

me and fets dont agree, silly voltage devices
http://arduino.cc/forum/index.php?action=unread;boards=2,3,4,5,67,6,7,8,9,10,11,66,12,13,15,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,86,87,89,1;ALL

Grumpy_Mike


Did mike just say this.. You need resistors on the base of the transistors

Yes because I said that the LED and resistor had to be in the collector not the emitter, so when you make this change you need a resistor in the base.

EVP

#6
Jan 13, 2013, 11:48 am Last Edit: Jan 13, 2013, 11:51 am by EVP Reason: 1
Oh, so if you don't change it and leave the led and resistor on the emitter it doesn't need a resistor on the base?
For some reason i thought they always needed a resistor on the base.

Grumpy_Mike

The configuration with the load in the emitter is called an emitter follower. The voltage on the emitter is 0.7V lower than on the base. You don't need a resistor to limit the current in this case because the emitter voltages rises as the transistor turns on and acts as negitave feedback preventing more current from being drawn.

dhenry

What is a "breathing" led?

If you want to use one pwm bus to drive multiple fading, check into the driver design for Aura (?) led. The smartest I have seen.


If that is an N channel FET then it will not work.
Yo need a P type FET and base resistors and to put the LED and resistor in the collector of the transistor and not the emitter.

However when you have done all that you will still have trouble because the PWM signals will beat with each other, some work at diffrent frequencies so they will not add up like you hope they will.


Hmm. So, what would be a better solution? Hook each color up to a PWM output and tackle the software code?

Grumpy_Mike

Quote
Hook each color up to a PWM output and tackle the software code?

Yes that is one way where you don't have two PWM signals fighting each other.

Go Up