I have voltage and currents in the form of PWM Signals. the goal is to measure those voltages and currents with an Arduino. the idea is to use a lowpass filter to get the average value. in other words, the PWM Signals are going to be converted into DC. the frequency of PWM is 16HZ. I know that there is a rule that says that the cutoff frequency should be at least 10 times less than the PWM Frequency. is there a mathematical method to prove that in order to convert PWM to DC the cutoff frequency should be 10 times or 100 times less than the frequency of the PWM
It depends on the filter characteristics. A "basic" RC filter has a slope of 6dB per octave.
If you don't have to measure a lot of fast-changes then a very low-frequency filter is fine.... If you are making a display (like a voltmeter) you want a very "slow" filter (maybe 1Hz or less) so you can read it.
Current measurement is a different challenge if you don't have a constant load. But once it's converted to voltage it can be filtered similarly.
You can also use additional software filtering/smoothing.
Exactly I want to measure the averages.
why is 1HZ the value to go with. when I do the simulation I can see that 1HZ works really well when trying to convert 16HZ PWM into a DC. how can it be proven that in order to have a DC (with no too much ripple) we should set the cutoff frequency to be 1 Hz
unfortunately the task is to come up with a hardware solution that is why I sdtayed away from software solutions
There is no real proof. You can calculate that the ripple will be less than so many % if you take the cutoff frequency a factor 10 lower than the frequency of the wave you are measuring.
Another factor 10 will further reduce the ripple. An infinite capacitor will have no ripple at all.
With this factor 10 you will be able to do reasonably good measurements at low costs (infinite capacitors are expensive).
Keep in mind that an infinite capacitor takes forever to charge, so you cannot keep track of any changes that way.
So, it is a trade off...
Where the optimum is, depends on your needs (high accuracy vs. fast response).
I do not think this is true . if we have a PWM with 50 percent duty cycle and the peak voltage is 5V. then the average voltage is 5V * 50percnt which is 2.5 V
6dB is a factor of two and an octave is a factor of two. And, you are 3dB down at the cutoff frequency.
You can make a steeper filter with inductors & capacitors or you can make an active filter with capacitors. It's really a question of how fast you need to read it can be a compromise.
I'm not saying it is... But 1Hz is slow enough for LOTS of filtering without having to do calculations or "proof" and it's slow enough that your eyes & brain can keep-up with a changing display. If the numbers change too fast the display just looks like a mess. And of course the stability of the display depends on the resolution. If your display is showing millivolts the least-significant digits might be jumping around too fast to read or too fast to mentally average.
If your PWM is changing moment-to-moment and you need to read those changes 1Hz might be too slow.
My Fluke multimeter seems to stabilize in less than 1 second... Maybe 1/4 of a second.
Yes, it is exactly the same relation...
If you filter out anything faster than 1 Hz you cannot expect a faster response than 1 sec ...
Your response will take more like 10s...
Yes there is, though it isn't a "proof" as such. Actually the question really is what degree of ripple can you tolerate and how quickly do you want to respond. It is fairly easy to work out a formula for the average voltage and ripple on a capacitor fed through a resistor with a pulse train of a given voltage and frequency, just basic algebra. Then you can show the relationship between the RC time constant, the pulse period, ripple and average. You can only achieve exact averaging and zero ripple with infinite time constant which takes literally forever to respond! As everything in engineering, it's a trade-off. You can get lower ripple, better averaging, and quicker response by using an R-C-10xR-C/10 circuit.
The idea is crazy. You will turn a digital signal into analog, then turn that analog signal back into digital, which makes no sense. Keep the signal digital. Measure the pulse widths, as suggested by @Wawa and @johnerrington
yeah the PWM is really 16 HZ. it is a PWM charge controller for a solar Panel. U high = 40V and U low = 0V
could you please forget about measuring it with arduino , my goal is to get a DC signal out of this PWM Signal
as you can see PWM is in grey and after using lowpass filter it looks DC (the blue line)
the question should be : how to theoretically calculate R and C to obtain the DC Signal with ripple value smaller than 10 percent
Assume that the lowest voltage in equilibrium is V1 and the highest V2 and the charging voltage V (your 40v). So the ripple is V2-V1. From V1 to V2 the capacitor charges as (V-V1)(1-exp(-t1/T)) where T is the time constant RC and t1 is the "high" time. From V2 to V1 it discharges as V2exp(-t2/T) where t2 is the low time. You can solve for V1 and V2 in terms of V, T, t1 and t2. Set V2-V1 to 10% of their average and it gives you T for that ripple. When you know T choose a cap and resistor to suit. I'll leave the derivation to you.