# Can LEDs or optocouplers be used without a resistor if PWM is used?

LEDs are often connected through a resistor and the purpose of this seems to be to lower the voltage across the LED to around 1.8V. Can PWM be used to lower the voltage instead of a resistor? If so, what is a reasonable frequency to avoid burning out the LED?

My actual application is to connect an optocoupler directly to a micro controller but I figured that most people will be more familiar with LEDs and the answer will be the same.

This "experiment" would answer my question but he never posted his results.

The current drawn by an LED (or any diode) rises exponentially as a function of voltage, with the typical forward voltage being the onset of exponential growth. Because of this, it's more important to think of your LEDs or optocouplers as devices that require a constant current, rather than a specific voltage. You want to stay away from that exponential curve, not just to protect the LED, but also to protect your microcontroller from sourcing or sinking too much current.

Sometimes, you get lucky and the microcontroller's internal output pin resistance is just enough to limit current through a particular LED. Sometimes it works out better in current sinking configuration. Check your datasheets.

Resistors are used to set a current limit. Higher power LEDs, particularly those used for illumination, may be driven by a constant current regulator to avoid flicker due to slight variations in the voltage supply. The exponential function magnifies small changes.

Resistors are cheaper than dirt, so it's easier to put them in where they are needed than find a workaround. If your time is worth anything, you could buy several hundred resistors by the time you've set up your PWM test. The experiment you reference is not really thought out. Rather than guess at arbitrary PWM values, it would seem reasonable to conjecture that if the total energy delivered to the LED is less than the forward voltage * maximum sustained LED current per PWM cycle,

$${1 \over T}\int_0^T V_{pwm}(t)I_{pwm}(t)\,\mathrm{d}t < {V_{forward} I_{max}}$$

it's probably safe(-ish), but there still may be problems from the brief high current peaks.

If someone told me they did that experiment in a job interview, I'd show him/her the door. It's not worth the trouble.

By the way, neither PWMs nor their frequency lower voltages. The duty cycle reduces the power transmitted. Increasing frequency allows more precise control, but it's really the duty cycle that does the work.

• LED's can be approximated within 10% by the threshold voltage and ESR.. same with CMOS drivers and BJT drivers above saturation so using PWM is OK on discrete LEDs but not specified and hence not OK in this part. This 300 LED string using small Rs in seris with ESR of LED is an example of linear V vs I above threshold. not exponential due to ESR. which is significantly more linear than PN junction variation.. also it is why LED's make better Zeners than silicon due to lower ESR... compare with any Zener V vs I if you wish to understand and any LED V vs I curve beyond average I rated. Dec 20 '12 at 16:13
• It is a steep linear curve above threshold voltage. until loss of efficacy of LED for IV...is reached. and self heating affects Voltage drop as it did with the spikes and negative delta slope (ESR) in OP's VI curve.. Dec 20 '12 at 16:16
• The obvious reason for a PWM current regulated design without resistors is that resistors waste power. In a battery powered device, that is to be minimized. Dec 20 '12 at 16:30

In general, NO. The current without a resistor (or other current limiting) is 'out of control', and some PWM-ed fraction of 'out of control' is still 'out of control'.

Side note: the peak current allowed for normal LEDs is often only a little above the rated current (for instance 30 mA versus 20 mA), so even when you do PWM with a controlled current do check the LED datasheet, both for the allowed average currrent and for the allowed maximum (peak) current.

And DO NOT use the absolute maxima section! The only section for normal operation is het 'normal operating conditions' section or something similarly named.

Not easily. The resistor gives immediate and automatic control of the LED current. PWM effectively controls mean voltage, so it would require you to measure the actual current (how? by measuring the voltage across a ... ah, resistor!) and controlling the PWM ratio to set the current. Much more complex!

You could use a low value resistor to limit the current to a reasonable value - say 20ma (the upper limit for a typical LED) and PWM down from that...

• Not too complex if you can measure the effective linear resistance (ESR) of driver and LED to estimate current limit is linear with voltage above threshold... I can prove with sufficent space & time... but..that's why most engineers use CC sources for LED's but CV sources with tolerance control can be used with controlled ESR. ( elaboration required to specify parts and limits.) Dec 20 '12 at 16:18
• Would that be good enough (say, better than 2:1 current ratio) without taking temperature dependent effects and LED self-heating into consideration? Dec 20 '12 at 16:50

Contrary to all previous answers here, I would answer YES, and say that this can even be a useful circuit in some applications.

Using a limiting resistor dissipates power. If your output circuit is at (say) 5V and the LED is at 2V, then 60% of your power is dissipated by the resistor. In a battery-powered circuit, this is bad.

Instead, PWM can be converted to analog through the use of a low-pass filter. (Yet another possibility would be to replace the resistor by a buck converter, but access to the microcontroller can replace this).

Another advantage of this is that by controlling PWM in software, you have soft control over the current through the LED.

How to choose the resistor and capacitor values for the low-pass filter? first, when initially turning the system on, the capacitor is unloaded, so that the microcontroller pin will have an output current of $$\V_{\mathrm{cc}}/R.\$$ This must be below the allowed peak current, which determines a minimum value for $$\R\$$. On the other hand, given a duty cycle of $$\t\$$, the resistor dissipates (on average) power $$\((1-t)V_{\mathrm{cc}})^2 / R\$$, which is another reason to pick a large $$\R\$$. And finally the time constant of the filter is $$\\tau = RC\$$ which needs to be (a) larger than the PWM frequency to limit the ripple effect, and (b) also gives the response time for your circuit (and you probably want this to be low).

I looked up the values for a typical Atmel MCU driven at $$\V_{\mathrm{cc}} = 5 \mathrm{V}\$$: maximum allowed current is 40 mA, so you want a resistor of at least 100Ω; you could use about 1 kΩ. Since these chips can drive PWM at about 16 MHz, you also need $$\RC \geqslant 10^{-6} \mathrm{s}\$$; you could for example use $$\C \simeq\$$ 10 nF.

• When dropping 5V to 2V by feeding a 40% duty cycle PWM to a RC filter, you're still dissipating 60% of the energy in the resistor "R" of the "RC" filter. To eliminate that resistive loss you have to use an inductor (yielding a LC filter) instead of a resistor, which is equivalent to a buck converter.
– jms
Oct 26 '19 at 13:28
• This method doesn't control the current through the LED, the duty factor instead controls the average voltage applied to the LED. This is not a good way to drive an LED because the current will vary exponentially with voltage. Oct 27 '19 at 22:16