PWM current controle

Hello, I was wondering how it is possible to control current with PWM. I have heard (and read) many people that say that if you are running off of a battery for higher loads, it is better to use PWM rather than resistors due to efficiency, and the heat used up by resistors eg. (Electronic Basics #2: Dimming all kinds of LEDs!? - YouTube).

However, I just don't understand how this is a good idea. In this example, it seems to me something has to burn up eventually if he does not use the resistor to limit current anyway, since whenever the transistor (or any digital switch) is closed, his circuit (in this case just an LED) should be drawing infinite current. Is the PWM only to dim more efficiently than a rheostat does? Because he still needs a resistor, so the closer he gets to max brightness, the less it matters?

So I was wondering, what is the proper way to do it? How is PWM correctly used in order to limit current? Is it used in series with an inductor which resists the change in current so you don't have infinite current when the loop is closed? Or is there another trick I am not aware of?

Or maybe there is a more simple way to do it based on the transistor used, in which case I am guessing you could use a resistor on the Base to limit a small current, which would then affect the current that can flow from the collector to the emitter?

PS. I do realize that the safest and simplest way is to use resistors, but I am wondering if this PWM stuff is just folklore, or there is an actual proper way of doing it, since all PWM does is turn a signal on off really rapidly.

So to sum it up: Is there a way to use PWM to efficiently limit current in a circuit without the resistor?
or: Is PWM just coupled with a resistor to make the dimming more efficient than a rheostat, which changes nothing on full power? (actually less efficient since you need to power the PWM circuit too)

PWM doesn't limit current, it reduces average current by turning it off regularly.

Resistors can only throw power away as heat, that's all they can do, and big high power resistors are
not variable like PWM is.

So for all power electronics pretty much, PWM is used (heating elements, motor control), either
as is (so the supply sees the pulsing), or via a switch-mode supply which hides the pulsing from
its supply using inductors and capacitors as energy stores.

The peak current, as you rightly worry, should not be excessive. Normally the load is happy to run at
100% duty cycle, which is full power, from its supply. PWM just controls that percentage without
wasting power (except for a few percent in the switching device).

If the load cannot handle the full supply voltage, you have to voltage convert using a switch-mode
supply. LEDs are a poor example here really since they require current drive really, not voltage.
An LED in series with a current limiting resistor is safe to power from a voltage source, and you can
PWM that voltage source, but the LED should not be overdriven during the pulses.

So at 100% duty cycle the PWM is totally useless, even more inificient than using simply as resistor, but where it comes in handy is that it is more efficient than relying on a variable resistor at lower duty cycles?

So at 100% duty cycle the PWM is totally useless, even more inificient than using simply as resistor, but where it comes in handy is that it is more efficient than relying on a variable resistor at lower duty cycles?

Technically, if the duty cycle is 100% then it is steady state and not PWM.

True, but say at ninety nine point nine five or something near 100 percent

True, but say at ninety nine point nine five or something near 100 percent

The Arduino PWM is 8-bits, so it goes from 0 - 255. 255 is 100% and that's constant DC (no pulsing). 254/255 is 99.6%. There is also no pulsing at zero.

...Back to your original topic - Switching constant-current (or controlled current) power supplies (commonly used for high-power LEDs) use PWM internally. The PWM does NOT come-out to the outside world.* Since the current is controlled-limited by the power supply we don't need a current-limiting resistor.

Regular (constant voltage) switching (AKA "switchmode") power supplies and voltage regulators also use PWM internally.*

However, when we dim a regular LED with PWM directly from the Arduino, the PWM IS coming-out and through the LED and the LED is flickering faster than we can see. The total energy is less, since it's off part of the time it appears dim to our eyes. A current limiting resistor is still needed to limit the current during the on-cycle.

  • In a switching power supply the PWM is controlled via a feedback loop to keep the current (or voltage) constant. The PWM is almost always changing as-necessary to keep the current (or voltage) constant. It's usually controlled with an analog circuit... There is no microcontroller or software in the "average" switching power supply.
1 Like

True, but say at ninety nine point nine five or something near 100 percent

That's academic. Once you approach 100% it ceases to be PWM (by simple definition) and becomes a steady state signal. In general practice, the full duty range is not utilized.

Normally no one (with any experience anyway) would use anything over 50% duty cycle, for a multitude of reasons, not the least of which is mosfet heating . Typically the range is closer to 10 to 30%, with 10%
allowing higher current (I believe 10X the device rating ) for a duty cycle of <= 10%.

Let's take your post one section at a time:

However, I just don't understand how this is a good idea. In this example, it seems to me something has to burn up eventually if he does not use the resistor to limit current anyway, since whenever the transistor (or any digital switch) is closed, his circuit (in this case just an LED) should be drawing infinite current. Is the PWM only to dim more efficiently than a rheostat does? Because he still needs a resistor, so the closer he gets to max brightness, the less it matters?

First off, I would say that only amateurs use potentiometers to dim leds. The entire rest of the world uses PWM. (end of story)

Second, most hobbyists don't use coin cells for led power because it's too expensive.
The recommended method is to use the arduino 3.3 V and a Dropping Resistor
(where) | R = (Vin-VLED)/ILED

Let ILED = 0.020 A (20 mA)
Let Vin = 3.3V
Let VLED) = 3.2V (Technically , you SHOULD read the VF from the datasheet)

Then (Vin-VLED) = 3.3V-3.2V = 0.1V
and RDropping = 0.1V/0.020A
RDropping = 5 Ohms (4.7 ohms)
This should be in series with the led.used to limit led current
> So I was wondering, what is the proper way to do it? How is PWM correctly used in order to limit current? Is it used in series with an inductor which resists the change in current so you don't have infinite current when the loop is closed? Or is there another trick I am not aware of?
Series inductors are only used for specialized applications. An example is an impedance matching choke
in series with a 3-phase motor lead. The chokes we used at Tesla for the Tesla motor during bench testing were very large (5 to 10 lbs each) and there was one for each phase. This was necessary to
match the motor impedance to the VFD used for lab testing. The same principle applies on a smaller
scale. Inductors are used with motors because motors are inductive. Simple as that.
Leds, however are NOT inductive so an inductor would never be used with a led.
> Or maybe there is a more simple way to do it based on the transistor used, in which case I am guessing you could use a resistor on the Base to limit a small current, which would then affect the current that can flow from the collector to the emitter?
No, transistors are NOT use for limiting current in leds. The current limiting is accomplished by averaging
the current with PWM. Plain and simple.
> PS. I do realize that the safest and simplest way is to use resistors, but I am wondering if this PWM stuff is just folklore, or there is an actual proper way of doing it, since all PWM does is turn a signal on off really rapidly.
With or without PWM, there should still be a current limiting resistor because it only takes a nanosecond
to fry an led, sol averaging is not a replacement for the current limiting resistor.
And no, PWM is not folklore. It's how things are done in this day and age. Period.
> So to sum it up: Is there a way to use PWM to efficiently limit current in a circuit without the resistor?
> or: Is PWM just coupled with a resistor to make the dimming more efficient than a rheostat, which changes nothing on full power? (actually less efficient since you need to power the PWM circuit too)
Please don't mention rheostats or potentiometers again in the same sentence with leds. I'll pretend
you didn't say that.
Yes, there is a way:
AnalogWrite
And no, PWM is NOT a substitute for the resistor. Please stop talking about eliminating the resistor.
> However, when we dim a regular LED with PWM directly from the Arduino, the PWM IS coming-out and through the LED and the LED is flickering faster than we can see. The total energy is less, since it's off part of the time it appears dim to our eyes. A current limiting resistor is still needed to limit the current during the on-cycle.
FYI, the comment by DVDDoug about not needing a resistor for high power leds is because they use
TDuty Cycle <= 10%
This allows the led junction to cool for the other 90% of the cycle.

Yes you can control current with PWM. However it is normally used in voltage mode. If you want a motor to spin faster do you give it more current or more voltage?

LEDs are a poor example. For a given brightness the losses in the unavoidable and avoidable resistors are the same. But PWM is controllable. You can change brightness in software.

But the losses aren't in the switching transistors. A modern MOSFET has almost zero resistance, usually measured in milli-ohms. Equivalent to a few inches of wire; less than the resistance of a relay contact.

For more advanced switching power supplies, start from a tutorial like https://www.electronics-tutorials.ws/power/switch-mode-power-supply.html. These kinds of supplies use an inductor so current can flow even when the switch is off.

You might try reading this

JasonLabrecque:
Hello, I was wondering how it is possible to control current with PWM.

There are two things being asked for here.

  1. Use of PMW
  2. Having that PWM control current.

Inherently PWM controls voltage so JasonLabrecque is correct, if one used a PWM voltage into an LED display that required a certain current the outcome would likely be burning up the LEDs.

The key here is to convert the voltage into current without burning anything up. The typical method is to use an inductor and capacitor with a small current sensing resistor to generate a feedback signal. Basically a current mode switching regulator.

Perhaps it might be a good idea to look on ebay for an adjustable current supply and then try to figure out how to control it with your arduino.

Or perhaps something like this: Sparkfun Femtobuck

The key here is to convert the voltage into current without burning anything up. The typical method is to use an inductor and capacitor with a small current sensing resistor to generate a feedback signal. Basically a current mode switching regulator.

Can you present one example case of this method being applied to leds (as opposed to inductive loads) ?

First off as a clarification, I don't understand why there is so much talk about LED lights, I only mentioned them once, and it was a reference to the example. I am more interested in a possible circuit for any load, and the techniques involved, than a particular instance (aka leds)

raschemmel:
That's academic. Once you approach 100% it ceases to be PWM (by simple definition) and becomes a steady state signal. In general practice, the full duty range is not utilized.

Yes you are correct, I was just trying to say that using a PWM circuit (usually a transistor or a mosfet) is more inefficient the closer you get to full power if the resistor is still required, since you have to add the energy used to drive it, to the energy loss of the resistor.

raschemmel:
Second, most hobbyists don't use coin cells for led power because it's too expensive.
The recommended method is to use the arduino 3.3 V and a Dropping Resistor
(where) | R = (Vin-VLED)/ILED

Let ILED = 0.020 A (20 mA)
Let Vin = 3.3V
Let VLED) = 3.2V (Technically , you SHOULD read the VF from the datasheet)

Then (Vin-VLED) = 3.3V-3.2V = 0.1V
and RDropping = 0.1V/0.020A
RDropping = 5 Ohms (4.7 ohms)
This should be in series with the led.used to limit led current

Yes, so just a series resistor, this works pretty well for very low power leds, but for higher power demands, you will need a very high power resistor to dissipate all the power that goes through it (which is inefficient). But I do not see the connection with my question about PWM

raschemmel:
Series inductors are only used for specialized applications. An example is an impedance matching choke
in series with a 3-phase motor lead. The chokes we used at Tesla for the Tesla motor during bench testing were very large (5 to 10 lbs each) and there was one for each phase. This was necessary to
match the motor impedance to the VFD used for lab testing. The same principle applies on a smaller
scale. Inductors are used with motors because motors are inductive. Simple as that.

Very interesting! Although I must admit to not understanding all that is here, adding an inductor to a motor in series is just basically making a bigger inductor is it not? However, If you put a non inductive load (say a power resistor) in series with your PWM say at 50% cycle and an inductor, the inductor should gradually let more and more current pass while the transistor is on, and then when the transistor is off for the other 50% percent of the cycle, the magnetic field will collapse, and you will get a diminishing current until (if you time it right) the load uses the last ounce of energy in the coil, and the on cycle of the transistor is repeated. In this case the coil will resist the chaneg in current during the short on phase, and then release some of that energy back to the led during the off phase. If you use the right size inductor, you should never have current higher than your max power requires. Do you mind explaining where the flaw in this logic is (if there is one), and why this is not a good idea? (I am sure I could be missing something huge here)

raschemmel:
And no, PWM is not folklore. It's how things are done in this day and age. Period.

I meant how it could be used in high efficiency areas and on high loads without a resistor in series with the load to limit peak current as you previously explained.

raschemmel:
FYI, the comment by DVDDoug about not needing a resistor for high power leds is because they use
TDuty Cycle <= 10%

This allows the led junction to cool for the other 90% of the cycle.

Ok, that makes sens, but it only takes a fraction of a moment to fry an LED (you mentioned the LED not me ;)) if you have enough current flowing through in that 10% on time.

MorganS:
For more advanced switching power supplies, start from a tutorial like Switch Mode Power Supply and Switching Regulators. These kinds of supplies use an inductor so current can flow even when the switch is off.

Very interesting and informative article, thanks. So basically what you are saying is that these higher efficiency power supplies use PWM to control voltage rather than current, which means you will still need a resistor, but not nearly as high power of a resistor since you can boost voltage, and decrease current, but still get the same power output since VI=P?

(if you time it right)

There is the magic.

You are describing a switchmode power supply. While it may resemble PWM, it is different. The main difference is the timing. PWM is fixed-frequency whereas a power supply chip will change frequency to get the timing right and to improve efficiency.

A switchmode power supply does not use resistance to control current. It may use a small (0.01 ohm) resistor as a current sensor.

JohnRob:
The typical method is to use an inductor and capacitor with a small current sensing resistor to generate a feedback signal. Basically a current mode switching regulator.

Ok, that sounds like what I am looking for, so basically, I want to understand how this works :slight_smile: Or as you said, it will probably be cheaper for my time to go buy one on ebay and just control it with the arduino rather than try to build one.

MorganS:
There is the magic.

You are describing a switchmode power supply. While it may resemble PWM, it is different. The main difference is the timing. PWM is fixed-frequency whereas a power supply chip will change frequency to get the timing right and to improve efficiency.

A switchmode power supply does not use resistance to control current. It may use a small (0.01 ohm) resistor as a current sensor.

I see, I thought if the load was relatively stable and you had a linear regulator on the input to make sure the voltage stayed constant, you could do it without a feedback loop. Guess I should look into how a switchmode power supply can keep current from reaching infinite without resistance, plus with arduino it should be possible to get a feedback loop :slight_smile:

After reading that article I linked, you should search for datasheets for switchmode control chips. Reading their descriptions and modes of operation will be more informative than textbooks.

The manufacturers usually put a lot of detail in the datasheet and they want to let you know about all the clever things their chip can do.

Very interesting! Although I must admit to not understanding all that is here, adding an inductor to a motor in series is just basically making a bigger inductor is it not?

It's called impedance matching . It makes more sense when you do the math:

Xl=2Pif*L | X(L) is in Ohms
| Pi = 3.14159265359
| f is in Hz
| L is in Henrys

Example:
3-phase motor inductance (from here)
I took the readings with LCR meter as described above. The motor specification as under siemens motor with two pole 50 HP, 0.89 PF, 2960 RPM, 400 volt, three phase, 50 Hz.

The readings as under
Phase A-B B-C A-c
0 degree 6.14mH 7.38 6.79
90 7.30 6.20 7.11
180 6.22 7.41 6.77
270 7.16 6.16 7.20

Let L = 6.14mH
Let f = 50 Hz.

Xc = ] 2*(3.14159265359)500.00614 H
Xc = 1.9289 ohms

Let V = 400V
Let RWinding = 0.55 ohms

I = E/Z = V/(Rwinding+Xc)
I = 400/(1.9289+0.55 ohms)

I = 161.36A

Icoil = 161.36A/sqrt(3) = 161.36A/1.732
Icoil= 93.16A


NOW add 1.73mH choke in series with each winding, solve for impedance & current

Let L = 6.14mH + 1.73mh = 7.87mh (0.00787 H)
Let f = 50 Hz.

Xc = ] 2*(3.14159265359)500.00787 H

Xc = 2.47

Let V = 400V
Let RWinding = 0.55 ohms

I = E/Z = V/(Rwinding+Xc
I = 400/(2.47+0.55 ohms)

I = 400/3.02 ohms

I = 132.3 A

Icoil= 132.3A/sqrt(3) = 132.3A/1.732

Icoil= 76.40A

Reduction in current = (Iafter)/(Ibefore) * Ibefore]

= 100% -( (76.40/93.16) *100)
= 17.98 %