# PWM + LC filter - voltage value non linear with duty cycle

I'm experimenting with PWM and LC filter and I think it works correctly when it comes to smoothing signal, but for some reason voltage on the output is not linear with duty cycle. I use 56uH inductor and 220uF capacitor (from 1 / (2 * PI * sqrt(L * C)) it's 1433Hz). The PWM signal has 20kHz frequency. Smoothing looks like that on the oscilloscope with 50mV/div:

The problem is that the voltage doesn't raise linearly with duty cycle. I use 5V output from arduino with a 1k resistor with an LED, which gives me a little less than 2V going through the LED. After connecting an inductor and a capacitor, the voltage on 100% duty cycle is still little less than 2V and it correctly drops to 0 for 0%. But what happens in between is unexpected. The voltage is almost maximum at about 33% duty cycle and changes only a little when going up to 100%.

Is it something normal? If that's correct, how do I calculate voltage based on duty cycle? If that's not expected, what should I look for in my circuit?

Here is a schematic:

And also an overview of how I connect it to arduino, just in case:

• Schematic, please. – Eugene Sh. Mar 18 '15 at 20:40
• Sorry, I should have added it in the first place. It's in the post now. – Piotr Sarnacki Mar 18 '15 at 21:05
• Is the PWM output push pull from the MCU? – Andy aka Mar 18 '15 at 21:40
• @Andyaka I'm not sure what you mean by that. The PWM is generated by arduino. Frequency is set by PWM frequency library. I could paste a photo of a PWM without filtering, but basically it's what you would expect - square wave with a 20kHz frequency. – Piotr Sarnacki Mar 18 '15 at 21:54

## 2 Answers

With the resistor in series with the inductor and your scope across the LED you will get a rising voltage with rising duty cycle then the LED starts conducting at about 2 or 3 volts and you won't see any increase in voltage rise. Try putting the resistor in series with the LED and measuring across R and LED not just across the LED: -

As you can see, to raise the voltage across the LED to about 1.6 volts requires virtually zero current from the MCU pin. To raise it to 2volts requires 20mA and that will be around the limit from your device. Hey, even if it could supply 50mA the LED voltage would rise only to about 2.37 volts. See this if you want more clarification.

Also, make sure your MCU output is capable of handling the kick-back from the inductor without causing problems. Normally a fly-back diode is used or a heavier-duty push-pull stage.

Also, get rid of those meaningless scope images - we know they'll be showing a dc voltage because of the 220uF cap - just tell us what the voltage is by measuring it with a multimeter.

• Thanks, it works correctly now! Sorry for excess images from oscilloscope, I thought it may be of use. – Piotr Sarnacki Mar 18 '15 at 22:04
• Regarding the kickback, in the real circuit I'll be using mosfets, so that will be a bit different story. I wanted to check filtering without any mosfets first to see if I it works correctly on a simpler circuit. – Piotr Sarnacki Mar 18 '15 at 22:07
• Intuitively, the inductor has zero ohms dc resistance (or near enough) therefore the average DC output is the same as the average DC input even under quite severe load conditions. Bound to work!! – Andy aka Mar 18 '15 at 22:15

I cant know for certain without seeing the circuit diagram, but it appears that you have created an RC circuit, that is attenuating the voltage of the PWM circuit.

LED's work in DC, so what is likely happening (again depending on the cirucit) is you are charging the capacitor, and it is normalizing the voltage.

• Yeah. To the OP, move the resistor so it is directly in series with D1 and try again. Note that diodes do not make a good load for voltage regulators, because they will start to conduct very large currents once they become forward biased and you try to increase the voltage. – mkeith Mar 18 '15 at 21:20
• I moved resistor to be in series with D1 and it didn't change anything. I'm also not sure if you're looking at a right problem - I added a few more photos from oscilloscope to show the real problem, the first photo was just to show that smoothing works. – Piotr Sarnacki Mar 18 '15 at 21:36