# Choice of resistor and capacitor for low-pass filter

#### Hendrik Bleus

Joined Feb 22, 2017
1
Hi folks!

I have a PIC microcontroller which is generating a PWM signal of 5 kHz. It has a varying dutycycle so I can draw an analog signal, which has to be smoothened. For that I need a low-pass filter, but I dont know which values to pick for R and C. Can you guys help?

#### Papabravo

Joined Feb 24, 2006
14,868
It sounds like you want a steady DC value from a PWM with a period of 200 μsec.
You should choose a corner frequency for your RC filter at a frequency that is a maximum of 10% of the PWM frequency. So 500 Hz. would be the maximum corner frequency.
You want to choose the resistance R and the capacitor with reactance Xc, such that the Xc is equal to the resistance at the corner frequency.

Example: suppose the resistance, R should be 150 Ω. Then Xc would be 150 Ω @ 500 Hz.
Therefore:

$C\;=\;\frac{1}{2\pi \cdot 150 \cdot 500}\;=\;2.12\mu \text f$

You then look for a capacitor you can use and see that 2.2 μf is a standard value.

If you want you can recompute the reactance of the 2.2 μf capacitor ay 500 Hz. and adjust the resistor if required. Since the capacitor is a bit bigger the reactance will be a bit smaller at 500 Hz. so the resistor can be adjusted to a lower value. If this produces acceptable results, then you are done. If not you can shoot for a lower corner frequency. If you need a higher voltage output you can use an operational amplifier to make an active filter with gain to get the required output.

#### fourtytwo

Joined May 2, 2017
80
Ahh I was in the middle of answering and see a better one has appeared above BUT
To avoid loading the PIC to heavily and use a smaller capacitor I suggest you change the above slightly in ratio-metric proportion such as increasing R from 150R to 1K5 and reducing C from 2.2uF to 220nF etc.
Beware the load impedance of what you are using to measure your results

#### Ian0

Joined Aug 7, 2020
1,172
What bandwidth do you require of your output signal? And how much remaining 5kHz can you tolerate in your output signal?

#### Audioguru again

Joined Oct 21, 2019
2,406
A single resistor and single capacitor make a very simple filter that does not do much.
Many class-D audio amplifiers use a PWM frequency of hundreds of kHz and a digital filter.

#### Ian0

Joined Aug 7, 2020
1,172
An RCRC filter is very effective.

#### Audioguru again

Joined Oct 21, 2019
2,406
I was also going to ask which power amplifier will be used to drive the very low value 150 ohms resistor.

#### Papabravo

Joined Feb 24, 2006
14,868
The problem as stated does not have a unique solution. The TS did not specify any additional information, and I did not assume that this was an application that required a power amplifier. Without any additional information the numbers don't matter, it is the method of arriving at the solution that is important. I did suggest using a different corner frequency. I also suggested an operational amplifier for two reasons:
1. To make the choice of a specific value of the resistor unimportant
2. To provide some gain for duty cycles near 100%
With a Vcc for the PIC of 3.3V driving 300 Ω you need 11 mA. That doesn't seem like it would require a power amplifier. What have y'all been smoking?
Yeah..OK. He didn't specify a load impedance either.

Last edited:

#### fourtytwo

Joined May 2, 2017
80
Lolo I think the OP said a PIC and I don't recall them talking about class-D at all..... Chinese whispers hahaha

#### Audioguru again

Joined Oct 21, 2019
2,406
Lolo I think the OP said a PIC and I don't recall them talking about class-D at all..... Chinese whispers hahaha
He said for an analog signal which might be a sub-woofer class-D audio signal. Wouldn't the very low PWM of 5kHz make a very noisy or slow reacting motor speed controller?

#### Ian0

Joined Aug 7, 2020
1,172
With a Vcc for the PIC of 3.3V driving 300 Ω you need 11 mA. That doesn't seem like it would require a power amplifier. What have y'all been smoking?
Yeah..OK. He didn't specify a load impedance either.
Output impedance of a PIC is about 40Ω, so whilst it can drive 300Ω there will be quite some signal loss.

#### Papabravo

Joined Feb 24, 2006
14,868
He said for an analog signal which might be a sub-woofer class-D audio signal. Wouldn't the very low PWM of 5kHz make a very noisy or slow reacting motor speed controller?
The original post said nothing of the kind. You must have your imagineering hat on.

#### Papabravo

Joined Feb 24, 2006
14,868
Output impedance of a PIC is about 40Ω, so whilst it can drive 300Ω there will be quite some signal loss.
There is going to be substantial insertion loss from a passive filter regardless of any other consideration.

#### crutschow

Joined Mar 14, 2008
26,044
There is going to be substantial insertion loss from a passive filter regardless of any other consideration.
That's what you want.
Significant insertion loss for the PWM frequency, but little insertion loss for the modulating frequency (which has not been established).

#### Papabravo

Joined Feb 24, 2006
14,868
That's what you want.
Significant insertion loss for the PWM frequency, but little insertion loss for the modulating frequency (which has not been established).
The insertion loss affects the entire passband including the modulating frequency for a single RC stage.
Required voltage levels have only been implied, not explicitly stated so it is a bit difficult to satisfy a set of unspecified requirements.