# How to calculate, *for a square wave input*, the cut-off frequency point for a basic RC low pass filter with

I am applying low pass filter for a pcb circuit I am trying to design (picture below). I have managed to calculate the cutoff for a sine wave input since I can insert a frequency (i.e. f_c = 720 Hz ) and get RC out of the equation: f_c = 1/(2*\pi*RC).

My question is:

How to do the same analysis as above (i.e. finding cutoff point) for a square input. I mean, what should I insert as f_c? doesn't square wave contain all frequencies?

I need to know how my circuit will behave with square input. What will be the time delay created by the filter under different square-wave inputs.

Thanks!

• It's impossible to get an output that looks like that from a square wave fed into that circuit. I suggest you have a play with a simulator. – Finbarr May 14 '18 at 14:40
• Just use the fundamental frequency of the square wave, and realise the harmonics will be attenuated differently. – user16324 May 14 '18 at 14:41
• One common rule of thumb is to put the cutoff frequency at 6x the square wave frequency. But it really depends on what you are doing. Putting it at 10x might also be a good choice. There are different ways to measure delay. In either case, it should not cause too much delay. But it would help if you could explain why you are filtering it. Do you even need a filter? If you put the cutoff at the square wave frequency, you will lose some signal amplitude, so the output will not go all the way up to VCC or all the way down to GND. – mkeith May 15 '18 at 0:53

I think this question has some merit. Even though it is asked from the standpoint of not understading harmonic Fourier decomposition, it serves for a few mental exercises. First of all, to address the true goal of the question:

I need to know how my circuit will behave with square input.

Square waves can be given by the summation of all odd harmonics of a fundamental sine wave. If the square wave is input to a linear system, then superposition principle applies, and the output signal can be reconstructed with the appropriate gain/attenuation and phase shift of each individual harmonic component.

For a matlab example, here is how to build a square wave using harmonic components up to 99th order:

t = 0:.01:20;
x = zeros(1,length(t));
for i = 1:2:99
h = (1/i)*sin(i*t);
x = x+h;
end
plot(t,x)


To find the output signal, if this wave is to be input of a RC filter, one could use the bode plot of the filter, find the attenuation and phase delay for every single harmonic component, and reconstruct the signal. A bode plot for an example filter:

sys = zpk([],-1,1);
bode(sys)


And the related system output:

lsim(sys,x,t)


Let's attempt to reconstruct the output using data from the bode diagram:

y = zeros(1,length(t));
for i = 1:2:99
[MAG,PHASE] = bode(sys,i);
PHASE = pi*PHASE/180;
h = (MAG/i)*sin(i*t+PHASE);
y = y+h;
end
plot(t,y)


Hope this covers the aspects of Fourier decomposition and Bode analysis. Now, to explain why the question has more merit than first meets the eye:

How to do the same analysis as above (i.e. finding cutoff point) for a square input. I mean, what should I insert as f_c? Doesn't square wave contain all frequencies?

Cutoff point can be defined as the frequency in which the output signal has half the power of the input signal. For sine inputs, this equals the -3dB frequency. Sine power is proportional to amplitude squared, and -3dB equals a $.707$ attenuation, which when squared equals $.5$. But what is the power of a square wave? And at which frequency is the output signal half the power of the input? This stands as a separate question which is tangential to the problem, but can serve as a "fun" mathematical exercise.

• Thank you! helped so much. Regarding cutoff, I was thinking of applying Laplace on a (not continuous) step function. Is it what you meant? If not, can I get a hint? Thanks again. – user135172 May 15 '18 at 13:13
• @user135172 I would approach this with Parseval's theorem. Calculate the spectrum for input and output, and find out under which conditions the total power is halved. Even though you may find an answer, it will serve little to no practical purpose. – Vicente Cunha May 15 '18 at 19:53

The cut of frequency does NOT depend on your input signal. Your filter doesn't know how the signal you're feeding it with looks like. An input signal like yours has a frequency spectrum of a sin(x)/x function. After passing the lowpass filter it's still sin(x)/x but with the higher frequency band cut off. So depending on your cut-off frequency the resulting signal will look like the input signal with more or less distortion.

• Why is my inputs frequency spectrum like sin(x)/x? What is the connection between a square input to sin(x)/x ? – user135172 May 14 '18 at 14:58
• That's just how it is. If you try to build a square wave out of single sine functions you'll get a frequency spectrum of sin(x)/x... you can proof it using Fourier – po.pe May 14 '18 at 15:05