Can switching regulators and transistors be smoothly PWM'd?

Using a 5V Attiny, I want to control the full brightness range on some 1.8V and 2.8V LEDs. If I set up two switching regulators leading to transistors and then PWM a transistor for each light, can I expect smooth variable output? Or is there a better solution?

They're part of a $15 switch, so I'm afraid to PWM at the full 5V. Thanks for reading!

LED are fast and do not have the lag of incandescent bulbs.
Pwm basically switches them on and off instantly, do it fast enough and the eye percieves this as a change in intensity,

So yes it is possible to get the full range of brightness as far as the eye can discriminate.

You will however need a current limiting resistor you cannot drive 5V directly into the led.

Transistors are capable of faster switching speeds than the Arduino can even send commands.

If you want to switch the input of switchmode PSU with PWM - probably NOT! they're designed to have a (fairly) slowly varying input voltage and deliver a constant output voltage..

Switch the LED's with pwm on the output as mentioned above.

And "LED are fast and do not have the lag of incandescent bulbs." actually makes things easier for an incandescant bulb if you want apparently constant light - they smooth out the light variations by the thermal time constant of the filament....

regards

Allan

Sorry for not being clear - the idea is that two switching regulator will always be powered, with transistors on the 2.8/1.8V outputs. My microcontroller will PWM (using the built-in PWM functions) those transistors to light up the LEDs.

Regulator (constant) -> transistor (PWM'd) -> LED

I don't trust myself to PWM the lights directly - if I put the duty cycle a bit too high and an LED burns, ordering another switch will be $25. If I'm only playing with a safe voltage like 2.8, I can't screw it up. Limiting resistors are also out, they waste too much power.

The voltage drop across an LED is pretty fixed - so you must drive them with a current-limited source - or you WILL burn either the LED or the driver out.

So you must use either a resistor or a clever current controlled power source

regards Allan

Even if it has only the exact rated voltage available? One is 20mA at 2.8V, I can't just use it with the 2.8V regulator?

Edit: Oh, okay. I guess I need a current limiting resistor in case the voltage out fluctuates a little bit. I'll add one. But I'm still okay to PWM the transistors as planned, right?

Thanks for the help, everyone

A LED may have a nominal voltage of 2.8 V but it varies from led to led , current is what kills them.

Normal practice is to drive them from a higher voltage and employ a suitable value of series current limiting reasister.

EDIT

Can you explain what you wish to do.

At 20 mA it is possible to drive an LED directly from the pin of an arduino with a series resistor, without an external supply or transistor.

More than one LED however you could exceed the capacity of the arduino in which case external PSU and transistors are needed.

It seems you want to use a constant voltage supply, set to the Vf (working voltage) of the LEDs.
And then PWM the supply for brightness control.
Can’t do that.

LEDs are better used with constant current, because Vf varies with temp, brightness and age.
A constant voltage supply could damage the LEDs.

The LEDs must be small, because “part of a switch” is mentioned.
An Arduino pin can drive/PWM small (<=20mA) LEDs directly through a current limiting resistor.
Post the link to the switch, so we can advise the resistor value.
Leo…

OK… the LED takes 20mA at about 2.8V

The arduino supply is 5V.

So the resistor you need = (5 - 2.8)/0.02 == > 110 ohms .

100 or 120 would be fine if you’ve only got E12 values

regards
Allan.

(2.8) or ( 2.8 ) 8) 8) 8)

Red LEDs have a lower Vf of ~2volt. CL resistor = (5 - 2) / 0.02 = 150ohm.

All other colours/white are ~3volt. CL resistor = (5 - 3) / 0.02 = 100ohms.

These are minimum values, and ok if you PWM the LEDs. 20mA could be too bright without PWM.

Watch the total current rating of the chip if you use more than a few LEDs. Leo..

Hi Leo....

All other colours/white are ~3volt. (2 - 3) / 0.02 = 100ohm.

are you sure?

regards(?!)

Allan

allanhurst: are you sure?

No. This was a general answer. Red/green/yellow 3mm/5mm indicator LEDs could all be ~2volt. The high-brightness green/yellow, and blue/white are usually ~3.3volt. High-brightness red is usually ~2.4volt. To be sure, you have to look at the datasheet. Or measure it yourself with a curent source. I would just use 220ohm for all, and PWM to the needed brightness. 20mA through a red LED and 10mA through a green LED does not mean that the red LED will be seen brighter. Leo..

Hi Leo..

I was just wondering where you could buy a

All other colours/white are ~3volt. (2 - 3) / 0.02 = 100ohm.

resistor

  • I make that -100 ohms.

Be a handy device if you could get one.................

regards

Allan.

Ahhh. I see now. Typo corrected.
Leo…

I mentioned 20 mA. That's rather bright for a switch indicator. 2 -3 mA should be enough. Try using a 470 ohm resistor to start with.

OP wants PWM brightness control, so 10-20mA is ok. Maybe this switch has to be seen in sunlight as well as in the dark. Maybe wise to post a link to these switches. They could already have inbuild current limiting resistors. Leo..

Hi, I really think we need;

A copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

So we know exactly what the OP nw has in mind.

Thanks.. Tom.. :)

Hi,

I don't trust myself to PWM the lights directly - if I put the duty cycle a bit too high and an LED burns, ordering another switch will be $25. If I'm only playing with a safe voltage like 2.8, I can't screw it up. Limiting resistors are also out, they waste too much power.

Edit: Oh, okay. I guess I need a current limiting resistor in case the voltage out fluctuates a little bit. I'll add one. But I'm still okay to PWM the transistors as planned, right?

Have you thought of this? http://www.ebay.com/itm/5-pcs-3W-5-35V-LED-Driver-700mA-PWM-Dimming-DC-to-DC-Step-down-Constant-Current-/252056674079

google led driver pwm input

Tom.... :)

What are the specs of your LED? What is its current?

Are we actually discussing to use a constant current LED driver for a 0.05W indicator LED (that is inconveniently stuffed in a relatively expensive package) now? Come on, guys. Put a current limiting resistor in series with the LED on you PWM capable Arduino pin and be done with it. 5V/250Ohm=20mA, so put 280Ohm in there and there is no way whatsoever you LED burns. You will get less than 20mA, of course, but for an indicator LED, that should be fine - from want you write, I get that you are afraid for your LED, not want to drive it to it's limit.