# RC Low-pass Filter Design for PWM

Hi,

I wonder how to design a RC low-pass filter for PWM.

I was suggested to use one piece of 10k ohm resister and one piece of 4.7 uF capacitor.

To be honest, I am not familiar with electronic knowledge and I have two questions:

1. I have such a capacitor (Electrolytic Capacitor, MCNP Series, 4.7 µF, ± 20%, 16 V, 5 mm, Radial Leaded), is it a proper one to use?

2. Why do I use 4.7 uF capacitor? Can I use other capacitance? What is the difference of using other capacitance?

Thanks a lot.

(deleted)

1. yes you can use this
2. changing the capacitor or the resistor value changes the break frequency of the filter.

The proper design of the filter depends on what frequency you change the PWM to and what you want to do with the voltage you get out of the filter.

Why do I use 4.7 uF capacitor? Can I use other capacitance? What is the difference of using other capacitance?

It all comes out in the wash. RC LPF means RC , so time constant t=RC. Do the math
If you don't have a 4.7 uF, substitute the value you have in the equation and solve for
R, using 4.7 k ohm for the resistor value.

R = t/C

Let R = 10 k
C = 4.7 uF
then,
t= 10000*4.7E-6 = 0.047 S

C = 10 uF

R = ?

R = 0.047/10E-6 = 4700 ohms (4.7 k ohm)

if you are doing the RC because the device pwm input is analog, you can directly connect a square wave pwm signal with no RC and it most likely will work. If the device accepts digital pwm input, then it will not accept analog pwm, but the other way usually works without RC. I connect arduino pwm directly to speed controllable motors without RC and it works just fine.

0.047

I don't know where you get your information but PWM stands for Pulse Width Modulation.
Clearly digital, not analog.

There is no such thing as "analog pwm" . that is an oxymoron.

It's either analog or PWM.

Maybe you are referring to an analog to PWM converter

which is a circuit that accepts true analog (like the output of a DAC) and outputs PWM with a duty cycle relative to the input voltage. It is neither analog nor pwm , it a circuit that converts one type of signal to the other.

LTC6992

raschemmel:
I don't know where you get your information but PWM stands for Pulse Width Modulation.
Clearly digital, not analog.

There is no such thing as "analog pwm" . that is an oxymoron.

It's either analog or PWM.

Anyone who has ACTUALLY worked on this would understand what I just described.

But, yes, for this matter, I will agree with you is should just be analog control.
The typical application will have PWM square wave and then passed to RC filter to convert to analog, hence the parlance analog pwm (be it right or wrong). But to the receiving circuit, the square wave average will be a voltage proporionate to the square wave duty cycle, hence RC circuit is usually not needed by most device that receives 0-Xvolt control signal.

Anyone who has ACTUALLY worked on this would understand what I just described.

Anyone with any Professional electronics experience wouldn't use an RC LPF because their cheap microcontroller didn't come with a DAC. They would simply BUY a cheap DAC.

RC LPFs are something you resort to because you lack the proper tools, (either out of ignorance, laziness, or financial considerations). It's just lame to use an RC LPF with an arduino if you can get a 12-bit DAC for \$5.

The typical application will have PWM square wave and then passed to RC filter to convert to analog, hence the parlance analog pwm (be it right or wrong). But to the receiving circuit, the square wave average will be a voltage proporionate to the square wave duty cycle, hence RC circuit is usually not needed by most device that receives 0-Xvolt control signal.

I realize you have some electronics and software experience and you are clearly not a noob, but I would discourage you from using the term "squarewave" and "PWM" in the same sentence, since they are clearly NOT the same thing, as any technician or engineer would know. Squarewaves tend not to change their duty cycle because they are usually clock signals. While if you wanted to get "technical" you could make a case that a squarewave is ACTUALLY a 50% duty cycle PWM signal, but this would be nonsense since clock signals are not pwm. By the same token PWM signals tend NOT to be 50% duty cycle , except maybe for a fleeting moment. Describing PWM signals to newbies calling them "squarewaves" is poor tutorial form because they might pick up your bad habits and repeat this "PWM square wave" nonsense in front of others who will look at each other and wonder "where did he get HIS electronics training ?".
What's my point ?
1- analog is analog and pwm is pwm
2-pwm is pwm and NOT a "squarewave" (a "squarewave is SO CALLED because both sides have the same length, the duty cycle is 50% , giving it a "half square " appearance, unlike a 5% duty cycle waveform. The term "squarewave should ONLY be used when you are referring to a 505 duty cycle signal that DOES NOT CHANGE DUTY CYCLE . All OTHER signals, that are 0 to 5V , that are NOT 50% and are NOT PWM, are simply called TLL signals because the pulse width could be anything. A servo signal , for example is a "TTL " signal which is a form of PWM but is not generally called PWM. It is usually called PPM , despite the fact that it behaves like special class of PWM. Any OTHER signal, that is NOT a servo signal, squarewave, or pwm is going to be referred to as a "TTL LEVEL " signal , denoting the fact that it is a 0 to 5V signal, as opposed to your so called 0 to "X" signal, which , frankly I have no idea what that is supposed to mean. Any equipment that comes with an analog control input is typically going to be a 0 to 10V analog input signal, NOT 0 to "X" V signal. This would include high end VFDs (Variable Frequency Drives) used for controlling large expensive servo motors 3 feet long and 2 feet wide, with a shaft the size of your arm. If you had an arduino and wanted to control one of those VFDs, using the 0 to 10 V analog input, you most certainly could use analogWrite() with the RC LPF . I never said you couldn't. I simply wouldn't do that if I had a 12-bit DAC.
Could you tell the difference in a double-blind test with two people controlling such a drive, one using the RC LPF and the other using a DAC ? Probably not. So then WHY would I prefer a 12-bit DAC to an 8-bit pwm signal ? Obviously because the DAC has 4 bits better resolution than the 8-bit pwm. Is that reason enough for a simple hobbyist to use a DAC ? Well it is if the DAC only costs him \$5 . If it cost him \$50 or \$100 then of course it wouldn't make sense and I would recommend the RC LPF. I saw your other post

Hi Bruce,

You can use the components you have to filter the square wave from the PWM into DC with just a small ripple. For most applications it will be just fine. Notice however, that your circuit now runs through a large resistor. This will severely limit the current you can get from that pin! If all you need tis to supply a voltage to another part of the circuit, and it does not need to doany work, that will be just fine.

On the other hand, if you want to light a LED, or anything else, you will need to amplify the current. My favorite way to do this is with a 'rail-to-rail' op-amp. this is for sure, the amateurish way to do this, but hey, it works!

Here's a picture:

@Chris,
Thanks for reminding me. I forgot to mention that while arduino GPIO could correctly be described as "TTL level " signals it would require clarifying that the "fanout" spec is only 1 to 3 gates, unlike "true" TTL" which typically is capable of driving 10 TTL gates. Add to that the RC LPF and the "drive" capability goes out the window.. Your op amp " buffer" is a great way to boost it back up. I suppose it would be debatable whether the OP needs to know that is called a "voltage follower" configuration.

ChrisTenone:
Hi Bruce,

You can use the components you have to filter the square wave from the PWM into DC with just a small ripple. For most applications it will be just fine. Notice however, that your circuit now runs through a large resistor. This will severely limit the current you can get from that pin! If all you need tis to supply a voltage to another part of the circuit, and it does not need to doany work, that will be just fine.

On the other hand, if you want to light a LED, or anything else, you will need to amplify the current. My favorite way to do this is with a 'rail-to-rail' op-amp. this is for sure, the amateurish way to do this, but hey, it works!

Here's a picture:

@ChrisTenone

Hi Chris,

For my case, I want to apply the filtered voltage to a bioreactor and a 10 ohm resistor like circuit below. The ideal operation voltage of the bioreactor is up 2 volt. One the one hand, I monitor the voltage over the bioreactor using a multi-meter. One the other hand, I intend to read the voltage over the 10 ohm resistor using ANALOG IN pin.

I am not sure if I will need to amplify the current or not. If I do, I notice that the OPA 4342 amplifier you mentioned has a supply voltage range from 2.7 volt to 5 volt, which is higher than the voltage I need to apply to the bioreactor. Could you please recommend some other amplifiers?

I am looking forward to hearing some more advice from you.

[/quote]

raschemmel:
@Chris,
Thanks for reminding me. I forgot to mention that while arduino GPIO could correctly be described as "TTL level " signals it would require clarifying that the "fanout" spec is only 1 to 3 gates, unlike "true" TTL" which typically is capable of driving 10 TTL gates.

What makes you think the fanout is 1 to 3 gates? If that were true then you couldn't drive more than 1 to 3 shift registers which is not the case. I make it with the current / voltage spec that the fanout is more like 20 from an Arduino.

The maximum value of this input current is about 1.6 mA for a standard TTL gate.

40 mA/1.6 mA/gate = 25 gates

Yes , you are correct . In fact I way underestimated the drive current.
TTL

Can you post a link for your " bioreactor" (whatever that is). Your schematic doesn't look correct. The op amp output is connected to a different part of the "bioreactor" . Can you label the pins on the bioreactor that you connected to the circuit ? Why do you have 10 ohms to GND ?

raschemmel:
Why do you have 10 ohms to GND ?

That looks like a current sense.

raschemmel:
@Chris,
Thanks for reminding me. I forgot to mention that while arduino GPIO could correctly be described as "TTL level " signals it would require clarifying that the "fanout" spec is only 1 to 3 gates, unlike "true" TTL" which typically is capable of driving 10 TTL gates. Add to that the RC LPF and the "drive" capability goes out the window.. Your op amp " buffer" is a great way to boost it back up. I suppose it would be debatable whether the OP needs to know that is called a "voltage follower" configuration.

Any CMOS output capable of 40mA has a fanout a lot larger than 3. CMOS inputs take no current and
you only have to drive the input capacitance. At full 74HCxx family datarates the fanout would be
less, but the Arduino can only drive upto 8MHz, so I'd expect it to cope with dozens of standard CMOS loads.

Any CMOS output capable of 40mA has a fanout a lot larger than 3. CMOS inputs take no current and
you only have to drive the input capacitance. At full 74HCxx family datarates the fanout would be
less, but the Arduino can only drive upto 8MHz, so I'd expect it to cope with dozens of standard CMOS loads.

As I said, the TTL FANOUT is 25, so the CMOS FANOUT , as you point out , must be quite a bit more than that.

raschemmel:
40 mA/1.6 mA/gate = 25 gates

Yes , you are correct . In fact I way underestimated the drive current.
TTL

Can you post a link for your " bioreactor" (whatever that is). Your schematic doesn't look correct. The op amp output is connected to a different part of the "bioreactor" . Can you label the pins on the bioreactor that you connected to the circuit ? Why do you have 10 ohms to GND ?

@raschemmel

You may consider it as resistor and its resistance varies depending on its inside condition. And I want to read the voltage over the 10 ohm resistor using ANALOG IN pin, so that I can calculate the current through my bioreactor.

You may consider it as resistor and its resistance varies depending on its inside condition. And I want to read the voltage over the 10 ohm resistor using ANALOG IN pin, so that I can calculate the current through my bioreactor.

For one thing , I read through this thread and could not find any mention of the current expected which determines the voltage drop across the resistor. 5V/10 ohms = 0.5V (500 mA)

That means if the current is less than HALF that , you would need (or at least WANT) to insert a non-inverting op amp amplifier before the analog input to boost the voltage up. Moreover, for \$15 , you can get a 16-bit 4 channel ADC which (ADS1115) which would increase your resolution by 6 bits. (from 10-bits to 16-bits). Depending on how important this measurement is you may want to do that.