Electronic – Rc network placing R before C vs after

filtermicrocontrollerNetworkpwmremote control

schematic

simulate this circuit – Schematic created using CircuitLab

Using a rc network to smooth a PWM signal from a microcontroller, to a true analogue voltage.

What will be the effect of having the resistor on the source (microcontroller) side of the capacitor vs the load side?

What would be the effect of having the resistor in series with the capacitor but parallel to the load and source?

Best Answer

To get a good understanding of all that goes on here, you really need to draw. Maybe some issues might be clearer just by the picture:

schematic

simulate this circuit – Schematic created using CircuitLab

To handle the last one first:

In this case, you are just increasing the load to the capacitor, so that's not very useful in most cases (there are exceptions, but in general, why would you increase the drain?)

In the second drawing the signal source can supply a fixed amount of current, or drain it away. Often with MCUs the current it can supply or drain is enough to make a very large ripple on the capacitor of 1uF. So in this case, you are not really limiting the ripple current, but you are limiting the amount of power the LOAD can take out the capacitor. So you would need a quite large capacitor, and most MCUs don't really like that.

The first is the best solution, especially if your LOAD is very light, in fact, lighter than I drew it. The R and C will limit the current the MCU can supply into the capacitor and take out of it. This means that the voltage on the capacitor will go up and down much more slowly than without the resistor. So, if the frequency is high enough, you will not see much ripple at all.

But I did take an equivalent LOAD of 250 Ohm on purpose, because you can see, that if your LOAD is quite heavy, this solution will give your device much less power. Now, because an MCU can't supply too much current and doesn't really like really large capacitors on its output, it's better to make the LOAD light and the R and C small. So if you want to drive something heavy, it's better to amplify the signal (with an Audio Op-Amp, for example, if your resulting/filtered analogue signal isn't too high frequency.)

But if you want to use it in a light LOAD, such as an op-amp or something else with more than 100kOhm input impedance, you can very easily create a smooth signal from an MCU PWM with components like these:

schematic

simulate this circuit

The RC-time of the components is high enough for most of the PWM range in 10kHz (if you expect a lot of 0% to 2%, you might need to increase the resistor a bit), but doesn't annoy your MCU too much. The 1M LOAD doesn't really do enough to mention, but higher is better. If that LOAD is the input to a normal Op-Amp such as the LM358 types, you can easily ignore its effect.