1
$\begingroup$

I'm trying to determine whether or not an anti-alias filter is needed for sampling square waves. The goal is to sample square wave pulses from a video detector with an ADC, do some time-domain digital processing on it, and reconstruct it with a DAC.

I do understand that signals with frequencies above the nyquist rate will alias into the "wrong" frequency bin. I guess the best analogy is the camera taking a picture of a car wheel turning at a certain rate, and at certain speeds it looks like the wheel stops or starts spinning backwards (a "misinterpretation" caused by the aliased frequencies). A square wave is made up of an infinite amount of odd harmonics but....

From an ADC perspective, it is just taking a sample of the voltage in time. I fail to see how a "misinterpretation" could be made since there is no "turning car wheel" to take pictures of at the wrong time. Do the harmonics alias in such a way that the wave shape is preserved?

In my mind, adding a filter to the signal will modify the shape of the original signal, getting rid of those upper harmonics. Depending on the filter design, it could add overshoot, ripple, and/or rise/fall time changes. So wouldn't the best representation of the pulse be obtained by direct sampling?

$\endgroup$
  • $\begingroup$ Questions: what's your ADC rate, what's the temporal accuracy with which you'd like to know where the edge(s) of such a square wave happen? $\endgroup$ – Marcus Müller Jan 2 at 15:35
3
$\begingroup$

From an ADC perspective, it is just taking a sample of the voltage in time. I fail to see how a "misinterpretation" could be made since there is no "turning car wheel" to take pictures of at the wrong time. Do the harmonics alias in such a way that the wave shape is preserved?

You can reason this out yourself, in the time domain. Consider a square wave with values -1 and 1; and sample it at exactly five times its period. You'll get something like {+1, +1, -1, -1, -1, +1, +1 ...}.

If you just have to think about this in the frequency domain, you can, after a great deal of work, demonstrate to yourself that not only do the harmonics not alias in a way that preserve the shape, but in fact alias in a way that does not preserve the shape -- you end up with edges aligned with the ADC sample points.

In my mind, adding a filter to the signal will modify the shape of the original signal, getting rid of those upper harmonics. Depending on the filter design, it could add overshoot, ripple, and/or rise/fall time changes. So wouldn't the best representation of the pulse be obtained by direct sampling?

That depends on what you're trying to do. If your goal is to accurately capture the timing of the edges, to something less than the ADC sampling interval, then you need to round those edges out -- because a signal that goes {+1, +1, -1, -1} has less information about the location of the edge than one that goes, e.g. {+1, 0.75, -0.25, -1} or {+1, 0, -1, -1}.

And finally:

I'm trying to determine whether or not an anti-alias filter is needed for sampling square waves.

That depends entirely on your problem at hand. If you need every bit of information contained in the wave (and not just its timing), and if it truly has energy content out to infinity (which is physically impossible) then you need to sample infinitely fast. If you know it's bandlimited, then you know the sampling rate you need to use. If you know that, for example, the edges are super-sharp but what you really care about is their timing, then you can filter and acquire with an ADC, and infer the actual position of the edges from the way that the measured "square-ish" wave transitions.

$\endgroup$
1
$\begingroup$

Square waves in a practical (and analog) video signal should always be bandlimited. May be they seem infinetely sharp at first, but if you zoom in you would see that their edges are actually rounded, indicating bandlimitedness.

So if you use high enough sampling rate then you will avoid aliasing without an anti-aliasing filter. However, for a bandlimited signal a properly implemented aa-filter shall not distort the signal. (yet somehow it may distort due to practical filter design considerations)

Sampling a non bandlimited square wave will have its distortion in the folowing sense; the sample right before the edge and right after the edge will cause jitter error on the duty cycle of the pulse. Furthermore, if you indeed use a very long sampling period you could get totally different pulse lengths (such as completely missing an off period).

$\endgroup$
  • 1
    $\begingroup$ :D exactly what I was about to write! $\endgroup$ – Marcus Müller Jan 2 at 15:43
  • $\begingroup$ yes I saw your comment just before clicking to post, thought for a few seconds, and rushed to click :P... Every answer adds a new perspective... $\endgroup$ – Fat32 Jan 2 at 15:47
  • $\begingroup$ I'm happy you wrote that answer :) Wouldn't have worded it this concisely! $\endgroup$ – Marcus Müller Jan 2 at 15:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.