Electrical – Gibbs phenonemon in real life

bandwidthfilterfourierlow passsquare

If I feed a square wave into a first order, passive, low-pass filter (resistor and capacitor), I get the following results on an oscilloscope (sorry, I don't know how to scale and rotate images):

Input and output of low-pass filter
The low-pass filter circuit

Why does the overshoot only occur on half of the corners of the square wave? Based on Fourier analysis, partial sums of a square wave should look something like this:

enter image description here

This is the Gibbs phenomenon. Here the overshoot occurs on all 'corners' of the square wave, rather than just the ones following a transition. I got some similar results when testing the frequency response of a unity gain buffer op amp:

enter image description here
enter image description here

Hypothetically, the op amp acts as a low-pass filter due to its finite bandwidth, so it's not surprising that it produces similar results to the actual low-pass filter above.

My question is: based on electrical theory, low-pass filtering should produce a square wave with attenuated higher harmonics, which should produce something similar to the Gibbs phenomenon with overshoot at each of the corners. Why doesn't this happen here? For me, it makes MATHEMATICAL sense that the output wave should have overshoot at each corner, but it makes INTUITIVE sense that the output should only have overshoot at the corners that occur after a transition. Why? Because if the 'ringing' (overshoot/undershoot) also occurred BEFORE a transition, it would seem non-causal – it would almost be as if the wave is guessing that it's about to transition!

How can I reconcile my understanding from the perspective of Fourier theory with what actually happens in real life?

Best Answer

I figured it out! I created a MATLAB script which sums the first 1000 terms of the output's Fourier series with a 1Hz square wave input. Here's the answer:

Low-pass filters can cause the Gibbs phenomenon to occur, but these filters are not physically realizable. (This makes sense, otherwise non-causal behavior would be possible). Consider a brick wall filter. This is equivalent to truncating the Fourier series of the input to a certain maximum frequency. The results of the MATLAB script verify this:

enter image description here

As mkeith said in the comments, a perfect first order RC filter does not produce ringing. Instead, the filter just 'rounds off' the square wave:

enter image description here

The filter that I created was a first order filter, but parasitic elements, bad probes, etc. must have produced the ringing/overshoot, since as the result from MATLAB above shows - first order low-pass filters do not produce ringing.

However, second order (RLC) low-pass filter can produce ringing! The MATLAB script verifies this:

enter image description here

You'll notice that there is no non-causal behavior occurring here. This second-order filter is physically realizable (neglecting parasitic elements, but even then this behavior should be able to be approximately reproduced).

This means that the reason I was confused was simply because I didn't do the maths! I assumed that the Gibbs phenomenon would apply to a first order filter despite the fact that phase-shifting and attenuation occur in a first order filter which do not occur when truncating the Fourier series.