Forums

Nyquist and rectangular waveforms

Started by Bob Masta July 18, 2014
glen herrmannsfeldt <gah@ugcs.caltech.edu> writes:
> [...] > A few days ago, I was thinking about a different problem for > a different reason. > > Say you have an DAC followed by an appropriate anti-aliasing > filter. You want the closest to a square wave that you can get > out of that filter, what should go into the DAC? > > More specifically, assume an real, imperfect, filter.
I don't know that you can. The input signal X(w) that produces the closest square wave signal you can get out of that filter, when the filter response |H(w)| > 0 when |w| > pi*Fs, may have have |X(w)| > 0 when |w| > pi*Fs, which is not going to be representable by a digital signal unless |X(w + 2*pi*FS)| = |X(w)|, an unlikely situation. -- Randy Yates Digital Signal Labs http://www.digitalsignallabs.com
>This is prompted by the discussion of aliasing in the thread >"Higher upsampling with minimum phase downsampling produces >more aliasing" by 'jungledmnc'. > >My question is based on the observation that sampled >rectangular waveforms can be reproduced exactly, using a >trivial D/A converter (strobed latch), with no need for an >anti-alias / anti-image filter. The only requirement is >that the sample edges align with the waveform transitions. > >We know that rectangular waveforms have lots of harmonics >that can run way above the supposed Nyquist limit, but in >this case we can ignore that, with no fear of aliases or >images, because the output is the exact waveform, edges and >all, so it has to have the same spectrum. > >How can this be? My supposition is that the aliased >components must align in such a way that they all cancel. >Rather than risk my remaining few brain cells trying to >compute this <g>, I figure that someone here has already >done it. It seems like such an obvious question that it may >even be a 'classic' demonstration, somewhere. Can someone >point me in the right direction? > >Thanks, and best regards, > > > >Bob Masta >
Discrete-time signals have periodic spectra so there is nothing unusual about frequency content above the Nyquist frequency. Also note that a real DAC holds the value over the sample period whereas an ideal discrete-time to continuous-time converter does not - it outputs only impulses at the sample times, thus you get the sin(x)/x distortion. So if you were to consider a +1, -1, +1, -1 signal at fs/2 then in the discrete-time you have a sinusoid at fs/2 and converted to continuous-time you have a sinusoid at n*fs/2, n = 1, 3, 5, ..., brickwall filtered results in a sinusoid at fs/2. Coming out of a real DAC you have sinusoid at n*fs/2, n = 1, 3, 5, ... where amplitudes attenuate as sin(x)/x, which is a continuous-time squarewave. So it is a consequence of the hold that a real squarewave results - imperfect continuous-time to discrete-time conversion. -Doug _____________________________ Posted through www.DSPRelated.com
On Mon, 21 Jul 2014 05:15:20 -0500, "mnentwig"
<24789@dsprelated> wrote:

>>> Say you have an DAC followed by an appropriate anti-aliasing >filter. You want the closest to a square wave that you can get >out of that filter, what should go into the DAC? > >I guess a conventional equalizer would be a starting point (a >sample-and-hold DAC has sinc(f) frequency response with zeros at multiples >of the sampling rate). >The usual "gotchas" for equalization apply - correcting large gain errors >eats up dynamic range. > >But the result could look completely different, depending on the definition >of "closest". >- Least-squares-optimal for rectangular pulse (Dirichlet) leads to heavy >overshoot (Gibbs) and ringing. >- A different target pulse shape (i.e. flat top, raised cosine) would give >more stable levels, but slower transitions. > >If the requirement is given as a mask for the time domain function, I'd >probably use numeric methods (i.e. IRLS - it's basically a FIR design >problem with time- and frequency domain switched).
Speaking of Gibbs, not long ago I ran into a very puzzling phenomenon while using rectangular pulses on Windows sound cards. At 16-bit full-scale output levels, I encountered a "peak ducking" effect (as viewed on a conventional benchtop scope) whenever the Gibbs peaks would have caused the waveform to clip... the whole waveform amplitude was reduced so that the Gibbs peaks "just fit". After extensive testing and measuring the time constant of this ducking effect, I finally concluded that it was from the "new" Windows output scheme (Vista and later), whereby the outputs of multiple apps are mixed in software before going to the actual sound card D/A. It only happened on 16-bit devices (that would have clipped at +/-32K counts), not 24-bit devices. Clearly, this wasn't about Gibbs as such, just a conventional soft limiter. With Windows, nothing is transparent! Best regards, Bob Masta DAQARTA v7.60 Data AcQuisition And Real-Time Analysis www.daqarta.com Scope, Spectrum, Spectrogram, Sound Level Meter Frequency Counter, Pitch Track, Pitch-to-MIDI FREE Signal Generator, DaqMusiq generator Science with your sound card!
Randy Yates <yates@digitalsignallabs.com> writes:

> which is not going to be representable by a digital signal unless > > |X(w + 2*pi*FS)| = |X(w)|,
Correction: |X(w + n*2*pi*FS)| = |X(w)|, -- Randy Yates Digital Signal Labs http://www.digitalsignallabs.com