Driving camera LEDs with MOSFET through PWM

Hi everybody,

This is my first post on Arduino forum ...
hope my question will make sense and will find many answers :slight_smile:

I need to fade the 4 LEDs of a USB camera so I'm using one of the arduino nano pins to output PWM on the wire handling LEDs.
This is working pretty well except that when duty cycle is around 100% the output voltage only reaches 4V since I guess the board can't supply more than 40mA.
I think it would be a good idea to used a MOSFET there that would be triggered by the PWM.
However I don't have the slightest idea of what kind of MOSFET I shoud use and what would be the schematics.

As the LEDs are embedded in the camera I don't know what would be the maximum required current but I suppose that 100mA would be enough ...

Any proposals for the MOSFET type and the schematics?

Thanks in advance

At 9 cents a pop, one should always have some 2n7000's lying around.

Hi bigred1212,

Thanks for your quick reply.
I forgot to mention that I have very few space to add some components.
I guess this one would also do the job ...

I found this schematics and I suppose it would work for me ...
http://www.microbuilder.eu/Tutorials/LPC2148/GPIO/GPIOMOSFET.aspx

What about the resistor value?
Is 150 ohm ok?

Thanks

gpio_mosfet.png

You have a schematic for one LED but talk about four. No indication of color but we will guess white.

Basic online LED resistance calculator via Google:
http://led.linear1.org/1led.wiz

3.3v source, LED with a 3v+ voltage drop, gives a 1 ohm resistor.

If you are going to drive 4 at that voltage and try to switch them (PWM), I would guess they'll need to be done individually (4 individual setups). You could try 1 transistor and 4 resistors, but certainly don't want a parallel setup with one resistor(bad setup) or the LEDs in series(insufficient voltage). Which may become a space issue.

Sorry, I should have been a little more precise.
There are indeed 4 white LEDs in the camera (see picture attached)

However the only thing I got from the camera is 2 wires (1 for the ground and one for the LED supply)
I guess those LED are in series into the camera.

I used the LED calculator link you gave me but could not find the way to calculate with 4 LED in series and not in parallel.
Did I miss something?

Thanks

With a deal like that, I would bet the resistors and whatever are already in that housing and you just need to power it up. I would be tempted to treat that whole thing as a single load, switch it with a transistor, and see what happens.

Hi,

I think I need to be more precise again since I did not mention an important thing.

In fact, the original circuit that is in charge of fading the 4LEDS is just a 10K potentiometer that is between the Vbus of the USB and the wire that goes to the camera.

As I needed to fade LEDS through the Arduino, I thought I could bypass the potentiometer and directly send a variable voltage with PWM.

In fact it seems there is no resistor embedded in the camera but just LEDS.
I suppose I would still need a resistor and use it in the MOSFET circuit then ...

Hope it is a little bit clearer now ...

In fact, the original circuit that is in charge of fading the 4LEDS is just a 10K potentiometer that is between the Vbus of the USB and the wire that goes to the camera.

Has the pot all 3 pins connected ?
If either a 10k voltage divider or a 4 .. 6 k resistor connected to USB 5V results in about half way dimmed LED,
then this controls the camera LED only indirectly.

I'd rather measure the voltage at that wire, relative to the GND wire at various pot settings, and I guess you won't need to supply any MOSFET driven LED power there but rather a variable voltage without much current.
Question is, if PWM will do or if you need an RC filter.

Only 2 pins of the pot are connected, one goes to the Vbus and the other one goes to the camera.
With the original circuit (using the pot) the brightness of the LEDs is ok since the voltage ranges from 0 to 5V.
The problem I have is when I bypass this pot and make the voltage vary with PWM instead.
In that case, the voltage only reaches max 4V on the camera wire so I don't have full brightness.

As I wrote in my first post, it seems 40mA max output for PWM is not enough for the load that why I wanted to use a mosfet ...

bigred1212:
With a deal like that, I would bet the resistors and whatever are already in that housing and you just need to power it up. I would be tempted to treat that whole thing as a single load, switch it with a transistor, and see what happens.

I wouldn't, there will probably just be 4 white LEDs in parallel. You'll need to check
whether a series resistor is needed - if you have a bench power supply just set the
current to 80mA (4 x 20mA) and see what voltage you get - if ~5V its got resistor(s),
if 3.5V or so it hasn't.

Its common practice in cheap LED fittings to parallel LEDs which isn't ideal but
works because they are all from the same manufacturing batch and held at the
same temperature via a shared metal body or heatsink - the current matching
is adequate in such circumstances. You can't normally get away with doing this for
unmatched LEDs that are thermally separate. The same applies to any semiconductor
diodes paralleled - severely unequal current sharing can occur.

Only 2 pins of the pot are connected, one goes to the Vbus and the other one goes to the camera.
With the original circuit (using the pot) the brightness of the LEDs is ok since the voltage ranges from 0 to 5V.

If you have about 2.5V when the pot is in a middle position (~ 5k), a current of 0.5mA is flowing.
And if the leds are at "about half" brightness, they are certainly not fed by the remaining 2.5 V @ 0.5mA
More important: the whole led dimming thing looks voltage driven, not current driven as it were, if you directly fed the leds.

Sure, an Arduino Output won't have the 5V as a fully open pot might have, but the difference shouldn't be that significant.
I measure far more than 4V on a HIGH output, especially with a current in the < 1mA range.

using voltage to manipulate LED brightness?
you get slightly different color on different voltage, tho...

and why don't you actually measure the voltage output. or POT resistance @ min (usually 0)/max?

if the power supply is:

  • 3.3v or lower: the LEDs are probably parallel with no resistors.
  • 3.3v ~ 5v: the LEDs are probably parallel with seperated resistors or shares a common resistor.
  • 5v ~ 8v: the LEDs are probably 2x2 (2 in series, then parallel, VCC & ((LED1 & LED2) | (LED3 & LED4)) & GND)
  • 8v+: the LEDs are probably in series (with or without resistor).

just a guess...

MarkT:
Its common practice in cheap LED fittings to parallel LEDs which isn't ideal but
works because they are all from the same manufacturing batch and held at the
same temperature via a shared metal body or heatsink - the current matching
is adequate in such circumstances.

Didn't know that. Guess I should have figured that nowadays they would take any cheap shortcut they could.

As suggested, I made a few tests with the bench power supply.
I set the voltage to 5V (as it would be with USB Vbus) and set the current limitation at different values.

Here are the results:
Limitation = 20mA => Voltage = 4v / Current = 20mA
Limitation = 40mA => Voltage = 5v / Current = 40mA
Limitation = 60mA => Voltage = 5v / Current = 40mA
Limitation = 80mA => Voltage = 5v / Current = 40mA

So it seems that current consumption is max 40mA and there is a resistor.
As Vd is arround 2V, this would mean that I have 2 LED in series with 2 other LED in series and the whole being in parallel.

What I will try to do for now is just put a pull-up resistor between Vbus and Vcamera to get more current.
The problem I see compared to using a mosfet is that it will consume some current during the low phases of the PWM ...

Jeppy:
when duty cycle is around 100% the output voltage only reaches 4V since I guess the board can't supply more than 40mA

How are you measuring this ? You cannot measure the PWM output with a standard multimeter - you need an oscilloscope to see the waveform on the output of the PWM-pin.

// Per.

Hi,

sorry for late reply ... I've been on holidays for 2 weeks :wink:

How are you measuring this ? You cannot measure the PWM output with a standard multimeter - you need an oscilloscope to see the waveform on the output of the PWM-pin.

I do measure it with an oscilloscope.
max level of the PWM output is 4V when connected to the LEDs.

As it was not very conclusive with pull-up resistor, I think I will try using mosfet ...

Hi,

I finally used a mosfet (TN0200) to solve the problem and it is seems to work quite well now!

Thanks to everybody who contributed to this post :wink: