Driving RGB LEDs with an Arduino

On Mon, 26 Sep 2011 23:54:11 -0700, fungus wrote:

Yes. I've been reading up some more and the thing people
seem to worry about with MOSFETS is gate capacitance
(the gate acts like a capacitor).

Seems that to get it to switch quickly you have to fill/drain
the gate as fast as possible.
Yes. This is an issue for e.g. switched-mode PSUs, where you may have
large MOSFETs with significant gate capacitance, and you're switching at
hundreds of kHz.

When using a MOSFET as a switch, the power dissipation is low when it's
fully off (low current) or fully on (low voltage drop), but high when it's
in between (both current and voltage drop are significant). Consequently,
when switching large currents, you want to spend as little time in the
linear region as possible, which means charging and discharging the gate
capacitance as quickly as possible.

So while an idealised MOSFET has infinite gate resistance (and a practical
MOSFET isn't far from that), the combination of significant capacitance
and fast switching times mean that power-MOSFET drivers are designed to
source/sink pulses of several amps to/from the gate.

However, this isn't something you necessarily need to worry about for
driving an LED. Even if you're using PWM to vary the brightness, the
switching frequency doesn't need to be more than a few hundred Hz. And a
MOSFET designed for less than 1A will have much lower gate capacitance
than one rated at 50A or more. Finally, efficiency is less of a
consideration; if a 1kW PSU is "only" 95% efficient, that's still 50W of
heat which needs to be removed.

The main consideration for using an FET with a microcontroller is that you
want one which will saturate (turn fully on) at a sufficiently low gate
voltage. These are normally termed "logic level" FETs, meaning that the
output from a (nominally) 5V device will be sufficient to drive the gate
directly. The data sheet for a device will normally have a graph of
channel resistance (Rds(on)) against gate voltage (Vds).
 
On Sep 27, 7:58 pm, John Fields <jfie...@austininstruments.com> wrote:
---
My pleasure! :)
Now I just need to decide how to power it,
connect a microphone for sound sensing,
make a prototype on breadboard, do the
programming and figure out how to cram
the result into little black boxes.

For power I'm leaning towards three batteries
and a boost board. I guess the next step is
to get hold of one to play with...
 
On Tue, 27 Sep 2011 14:54:42 -0700 (PDT), fungus
<openglMYSOCKS@artlum.com> wrote:

On Sep 27, 9:42 pm, Nobody <nob...@nowhere.com> wrote:

A MOSFET designed for less than 1A will have much lower gate
capacitance than one rated at 50A or more.

I looked at the datasheets for some TO-220s to
compare with the surface mount MOSFETs
on the little Sparkfun shield. The surface mount
MOSFETS switching times are much faster
(eg. 140ns->40ns for switch on time)

The main consideration for using an FET with a microcontroller is that you
want one which will saturate (turn fully on) at a sufficiently low gate
voltage. These are normally termed "logic level" FETs, meaning that the
output from a (nominally) 5V device will be sufficient to drive the gate
directly. The data sheet for a device will normally have a graph of
channel resistance (Rds(on)) against gate voltage (Vds).

Yes, I saw those.

A 3.3V Arduino would struggle to switch normal
FETs because the gate voltage is so high.
---
But would have absolutely no problem switching BJT's.

--
JF
 
On Tue, 27 Sep 2011 14:59:37 -0700 (PDT), fungus
<openglMYSOCKS@artlum.com> wrote:

On Sep 27, 7:35 pm, fungus <openglMYSO...@artlum.com> wrote:

B  2.81V   3.23V   3.45V


Thinking a bit more...

The value for blue at 150mA was a bit lower
then I expected. Now I think about it the
battery was only putting out 3.88V so there
wasn't much left over to play with.
---
That doesn't matter since if you managed to get 150 mA through the
LED, the voltage measurement you made across it was valid and the
leftover 430 millivolts was dropped across the collector-to-emitter
junction of the transistor, and wasted as heat.

Just for grins, how much?

Since the current through the transistor was 150mA and the voltage
_not_ dropped across the LED was 0.43 volts, the power dissipated in
the collector-to-emitter junction was:

P = IE = 0.15A * 0.43V = 64.5 milliwatts.

Hardly enough to make it flinch.

---

The voltage adjustment on the base of the
transistor would have to be very fine for it to
work at all...lucky I had my mega-pot!
---
That 1k resistor between the wiper and the base of the transistor
should have made finding the sweet spot easy.

Did you find any excessive sensitivity or hysteretic issues with the
circuit?

--
JF
 
On Sep 27, 9:42 pm, Nobody <nob...@nowhere.com> wrote:
A MOSFET designed for less than 1A will have much lower gate
capacitance than one rated at 50A or more.
I looked at the datasheets for some TO-220s to
compare with the surface mount MOSFETs
on the little Sparkfun shield. The surface mount
MOSFETS switching times are much faster
(eg. 140ns->40ns for switch on time)

The main consideration for using an FET with a microcontroller is that you
want one which will saturate (turn fully on) at a sufficiently low gate
voltage. These are normally termed "logic level" FETs, meaning that the
output from a (nominally) 5V device will be sufficient to drive the gate
directly. The data sheet for a device will normally have a graph of
channel resistance (Rds(on)) against gate voltage (Vds).
Yes, I saw those.

A 3.3V Arduino would struggle to switch normal
FETs because the gate voltage is so high.
 
On Sep 27, 7:35 pm, fungus <openglMYSO...@artlum.com> wrote:
B  2.81V   3.23V   3.45V
Thinking a bit more...

The value for blue at 150mA was a bit lower
then I expected. Now I think about it the
battery was only putting out 3.88V so there
wasn't much left over to play with.

The voltage adjustment on the base of the
transistor would have to be very fine for it to
work at all...lucky I had my mega-pot!
 
On Sep 28, 12:21 am, John Fields <jfie...@austininstruments.com>
wrote:
But would have absolutely no problem switching BJT's.
:)

I just ordered a couple of booster boards on ebay.

When they arrive I'll need to torture-test them
to see how much current I get to play with...
 
On Sep 28, 1:25 am, John Fields <jfie...@austininstruments.com> wrote:
the power dissipated in
the collector-to-emitter junction was:

P = IE = 0.15A * 0.43V = 64.5 milliwatts.
Yes, of course.

I'm just surprised that it worked so well down
in the very-close-to-cutoff area. I would have
expected it to be very sensitive to tiny
changes there, but it wasn't.

Hardly enough to make it flinch.
The red LED is more risky, that was dissipating
a quarter of a Watt at 150mA (1.67*0.15). I don't
know the specs for a 2N2222 but I don't think it
will be much more than that.

(update: I just checked and it's half a Watt
so we were OK...!)

Did you find any excessive sensitivity or hysteretic issues with the
circuit?
Nope.

Some of the adjustments were very fine though,
I think it would have been tricky with a normal pot.

One other thought I had is that I should really do
this with a couple more LEDs and take the average.
 
On Wed, 28 Sep 2011 04:58:57 -0700 (PDT), fungus
<openglMYSOCKS@artlum.com> wrote:

On Sep 28, 1:25 am, John Fields <jfie...@austininstruments.com> wrote:
the power dissipated in
the collector-to-emitter junction was:

P = IE = 0.15A * 0.43V = 64.5 milliwatts.


Yes, of course.

I'm just surprised that it worked so well down
in the very-close-to-cutoff area. I would have
expected it to be very sensitive to tiny
changes there, but it wasn't.

Hardly enough to make it flinch.


The red LED is more risky, that was dissipating
a quarter of a Watt at 150mA (1.67*0.15). I don't
know the specs for a 2N2222 but I don't think it
will be much more than that.

(update: I just checked and it's half a Watt
so we were OK...!)

Did you find any excessive sensitivity or hysteretic issues with the
circuit?


Nope.

Some of the adjustments were very fine though,
I think it would have been tricky with a normal pot.

One other thought I had is that I should really do
this with a couple more LEDs and take the average.
---
Not a bad idea.

BTW, if you use this circuit with 5V from your booster, some
interesting numbers come out:


.. +5 R G B
.. | -+----+----+----+-
.. +---E1 E1,V 5.0 5.0 5.0
.. |
.. [RS] E2,V 2.51 3.58 3.75
.. |
.. +---E2 E3,V 0.3 0.3 0.3
.. |
.. [LED] RS,R 18 9.1 8.2
.. |
.. +---E3 I(RS),mA 138 156 152
.. |
.. R1 C Q1 PD(RS),mW 344 222 183
..PWM>--[270]--B PN2222A
.. E PD(LED),mW 305 512 524
.. |
.. GND PD(Q1),mW 58 64 63

PD(R1),mW 54 54 54

PD(TOTAL),mW 761 852 824

I used an 18 ohm resistor for the red LED in order to keep the current
below 150mA, but 15 ohms would get you a little extra brightness at
166mA and increase the resistor's dissipation to 413 milliwatts.

--
JF
 
On Tue, 27 Sep 2011 14:54:42 -0700 (PDT), fungus <openglMYSOCKS@artlum.com>
wrote:

On Sep 27, 9:42 pm, Nobody <nob...@nowhere.com> wrote:

A MOSFET designed for less than 1A will have much lower gate
capacitance than one rated at 50A or more.

I looked at the datasheets for some TO-220s to
compare with the surface mount MOSFETs
on the little Sparkfun shield. The surface mount
MOSFETS switching times are much faster
(eg. 140ns->40ns for switch on time)

The main consideration for using an FET with a microcontroller is that you
want one which will saturate (turn fully on) at a sufficiently low gate
voltage. These are normally termed "logic level" FETs, meaning that the
output from a (nominally) 5V device will be sufficient to drive the gate
directly. The data sheet for a device will normally have a graph of
channel resistance (Rds(on)) against gate voltage (Vds).

Yes, I saw those.

A 3.3V Arduino would struggle to switch normal
FETs because the gate voltage is so high.
Logic-level FETs are pretty commonplace. 3.3V isn't a problem.
 
On Sep 28, 5:43 pm, John Fields <jfie...@austininstruments.com> wrote:
BTW, if you use this circuit with 5V from your booster, some
interesting numbers come out:
You ran the numbers? That's useful.

The bad news is it takes 500mA @ 5V to run it
if I go with 150mA.

The booster is claimed to be 90% efficient "on
average" but we'll see...

If we assume the booster is 80% efficient that's
846mA @ 3.6V - not going to happen according
to the Duracell page.

OTOH it's software driven and I don't think all
LEDs would ever be on at full power. I could
even put a limiter in the code to keep it below
a certain output power.

If I do that then rhe only way it would ever go
to full power would be a program crash or a
faulty Arduino. Maybe I could add a thermistor
to the battery pack and cut the power if they
overheat.
 
On Wed, 28 Sep 2011 09:26:25 -0700 (PDT), fungus
<openglMYSOCKS@artlum.com> wrote:

On Sep 28, 5:43 pm, John Fields <jfie...@austininstruments.com> wrote:

BTW, if you use this circuit with 5V from your booster, some
interesting numbers come out:


You ran the numbers? That's useful.

The bad news is it takes 500mA @ 5V to run it
if I go with 150mA.
---
500mA * 5V = 2.5 watts
---

The booster is claimed to be 90% efficient "on
average" but we'll see...

If we assume the booster is 80% efficient that's
846mA @ 3.6V - not going to happen according
to the Duracell page.
---
If the booster's 80% efficient, then to supply 2.5 watts it'll need
3.125 watts in.

Using three Duracell MN1500 AA cells in series will give 4.5V, and to
get 3.125 watts out of that battery, the booster will suck 625mA out
of it.

Looking at the constant current discharge curve on page 5 of:

http://www1.duracell.com/oem/Pdf/others/ATB-5.pdf

Shows that the MN1500 cells can supply 700mA for just under 2 hours
before they go "flat" at 0.8V leaving the battery with a 2.4V output.

However, your booster will keep working until the battery voltage
drops to 1.2V.

That's even more time, so it seems like you ought to get substantially
more than the hour you said you wanted out of it.

--
JF
 
On Sep 28, 9:01 pm, John Fields <jfie...@austininstruments.com> wrote:
On Wed, 28 Sep 2011 09:26:25 -0700 (PDT), fungus

openglMYSO...@artlum.com> wrote:
On Sep 28, 5:43 pm, John Fields <jfie...@austininstruments.com> wrote:

BTW, if you use this circuit with 5V from your booster, some
interesting numbers come out:

You ran the numbers? That's useful.

The bad news is it takes 500mA @ 5V to run it
if I go with 150mA.

---
500mA * 5V = 2.5 watts
---

The booster is claimed to be 90% efficient "on
average" but we'll see...

If we assume the booster is 80% efficient that's
846mA @ 3.6V - not going to happen according
to the Duracell page.

---
If the booster's 80% efficient, then to supply 2.5 watts it'll need
3.125 watts in.

Using three Duracell MN1500 AA cells in series will give 4.5V
Only when they're fresh...

The 1.5V from batteries is a bit of a myth.
Batteries drop down to about 1.25V very
quickly then go down slowly from there.

See graphs on this page:

http://www.powerstream.com/AA-tests.htm

I figure they'll be down to about 3.6V after a few
minutes and that puts the current draw on the
borderline of what Alkalines can manage. They
could overheat and die very quickly...
 
On Wed, 28 Sep 2011 12:21:58 -0700 (PDT), fungus
<openglMYSOCKS@artlum.com> wrote:

On Sep 28, 9:01 pm, John Fields <jfie...@austininstruments.com> wrote:
On Wed, 28 Sep 2011 09:26:25 -0700 (PDT), fungus

openglMYSO...@artlum.com> wrote:
On Sep 28, 5:43 pm, John Fields <jfie...@austininstruments.com> wrote:

BTW, if you use this circuit with 5V from your booster, some
interesting numbers come out:

You ran the numbers? That's useful.

The bad news is it takes 500mA @ 5V to run it
if I go with 150mA.

---
500mA * 5V = 2.5 watts
---

The booster is claimed to be 90% efficient "on
average" but we'll see...

If we assume the booster is 80% efficient that's
846mA @ 3.6V - not going to happen according
to the Duracell page.

---
If the booster's 80% efficient, then to supply 2.5 watts it'll need
3.125 watts in.

Using three Duracell MN1500 AA cells in series will give 4.5V

Only when they're fresh...
---
So you're planning on running this thing with old batteries??? ;)
---

The 1.5V from batteries is a bit of a myth.
---
Indeed.

Fresh alkaline cells start out at about 1.6V and, in order to keep
from blowing stuff up, that needs to be taken into account.

Measure one.
---

Batteries drop down to about 1.25V very
quickly then go down slowly from there.
---
None of that matters if, at the end of its life, the battery has
supplied the energy needed for the time required, e.g., it's just
another dead soldier.

In your case, since the boost converter you've chosen needs 3.125
watts in to run your circuit for one hour, that energy is 3.125
watt-hours, and the question is: "Can that much energy be extracted
from a three-cell AA alkaline battery before its terminal voltage
decays to 1.2V.

If not, your project, in its current state, is doomed.
---

See graphs on this page:

http://www.powerstream.com/AA-tests.htm

I figure they'll be down to about 3.6V after a few
minutes and that puts the current draw on the
borderline of what Alkalines can manage. They
could overheat and die very quickly...
---
"I figure"...
"on the borderline"...
"They could"...

Got some numbers instead of just conjecture?

--
JF
 
On Sep 29, 12:49 am, John Fields <jfie...@austininstruments.com>
wrote:
In your case, since the boost converter you've chosen needs 3.125
watts in to run your circuit for one hour, that energy is 3.125
watt-hours, and the question is: "Can that much energy be extracted
from a three-cell AA alkaline battery before its terminal voltage
decays to 1.2V.

If not, your project, in its current state, is doomed.
Yep.

....except that:
a) It should never be on full power

b) The current being drawn is really under software
control. With an Arduino I could actually measure
the battery voltage and dim the LEDs as it drops.

If it turns out that it won't run at full power I can
either add a failsafe mechanism (to prevent bad
things happening in case of Arduino crashes)
or drop the current to 100mA.

With a good failsafe mechanism I could even
increase the maximum current per color and
get extra brightness when only one LED is lit.

(This is the great thing about software...)

Got some numbers instead of just conjecture?
I need to get a boost board and see how efficient
it really is under my conditions. Maybe they really
are 90% efficient as claimed.

There's a couple in the post as I write this...
 
fungus wrote:
On Sep 27, 2:11 pm, John Fields <jfie...@austininstruments.com> wrote:

rearrange to solve for the end-to-voltage, like this:



So the 2W is end-to end, not what can come
out of the wiper thingy?
Correct. The power rating is what can be dissipated over the
full length of the wire in the pot. If you set the pot such
that current flows through less than the full length of wire,
then less power can be dissipated. For example, say you
set the wiper at 1/2 the total resistance:
P=I^2*(R/2) instead of P=I^2*R

Ed
 

Welcome to EDABoard.com

Sponsor

Back
Top