Sunday 29 April 2012

Low-Pass filter math

I was trying to calculate the curve of a simple low-pass filter when feeding it with a square-wave signal, for example from a PWM. Later I also made some equations where duty cycle was a variable, but they are maybe lost now or still saved somewhere... There are some complicated laplace transforms in this, I used Wolfram Alpha for making the laplace transforms, it would take too much time for me to solve manually :)

Calculations below are locked to 50% Duty Cycle.

The square wave signal can be represented with a function in time like this.




Here is an example of a curve with some iterations in the sum, and frequency 120Hz.


The Circuit looks like this



And the output of the filter is calculated like this, represented in the complex plane.You should understand what this equation means, otherwise the rest will be pretty cryptic :P



Now we can laplace transform the square wave signal, and replace that with Vin in the formula above.

First I take the the inside of the sum from the square wave function.




And also this



Now, for the inverse laplace transform, take the laplace result from above and replace with Vout in the low-pass filter equation. This is complicated :)



This results in:



And we will not forget the small sum in the beginning, that can be calculated separetely.



This becomes a long and complicated function of time, this could maybe be simplified.



Here is an example, displaying the input square wave, and the output signal, the circuit is C=47uF, R=5k and the frequency is 120Hz square signal from 0-5V.