DSPRelated.com
Forums

Nyquist and rectangular waveforms

Started by Bob Masta July 18, 2014
> >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. >
Actually at some point we were considering using simple wireless modem based on sending qpsk symbols directly through io of fpga. This was to avoid the need for shaping,upsampling or DAC device. The spectrum looked promising but with slow slope on either side like a hump and I believe it was due to sample hold effect of io lowering power of higher frequencies. Of course this may violate other's signals but was considered for our case of short distance wireless modem. At the rx side we ran into trouble with timing recovery carrier tracking and had to abandon the scheme. I still believe it is possible... The sample hold effect lowers tx images and a simple filter can work as anti alias at Rx but such system requires a lot of work to get reliable rx front end. _____________________________ Posted through www.DSPRelated.com
On Fri, 18 Jul 2014 07:10:14 -0500, "jungledmnc"
<34728@dsprelated> wrote:

>I don't think that's true. First of all nothing you sample will be exactly >the same after D/A. Also the D/A convertors (at least for audio) contain an >oversampling filter internally, so they actually do it for you. Similarly >when sampling A/D convertors contain a LP filter. So you basically sample >it and reconstruct it with oversampling without you knowing it. > >My previous question was about synthesis - if you synthesize something >purely in digital domain, there you have the aliasing, because you are >basically creating a signal with unlimited harmonic expansion in a discrete >(limited) domain.
Actually, I was thinking about synthesis here (since otherwise it would be difficult to synchronize sampling with the waveform edges, unless both processes shared the same clock), but of course the same math has to apply in both input and output cases.
>Anyway I don't think anything like "alias cancellation" exists (or that's >what I got from your post).
See other's responses. (Thanks, guys!) As Mark says, the harmonics all align, so I assumed that they must have alternating signs or something, and that even though they are decreasing in amplitude with frequency, they still (somehow) managed to cancel. (As Tim says, it's obvious that this must be true since we know we can get a perfect output waveform.) Maybe the key is that harmonic images are mirrored about the sample rate, with aliases of upper images having opposite signs? Thanks to all who replied. This is one of those things that has come up every now and then for many years (since I make signal generator software), but that I've never tried to sit down and work out properly... even though I was sure it *had* to be true. 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!
On Sat, 19 Jul 2014 12:22:25 +0000, Bob Masta wrote:

<< snip >>
 
> Maybe the key is that harmonic images are mirrored about the sample > rate, with aliases of upper images having opposite signs? >
It has to be weirder than that, because depending on where in the square wave you sample, you can shift the phase by almost +/- 90 degrees. So when you're all perfectly lined up you're just subtracting out the images, but at other times the images are ganging up on the "real" components to change their phase. (Note: computation done in my head in the time domain, without going through the -- no doubt character-building -- frequency-domain exercise.) -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
On 7/18/2014 11:15 AM, makolber@yahoo.com wrote:
> >> >> >> 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? > > one way to look at it is..... > > becasue the signal and the sampling rate are synchronized, all the alisas fall on top of the signal and/or its harmonics. Therefore no new frequencies are created.
I think this is the issue the OP was asking about. He is imagining a waveform that aligns perfectly with the sampling so that there is no lost information and the digital signal contains all the info of the original signal. He was simply confused about what happens with the harmonics. -- Rick
On Sat, 19 Jul 2014 21:06:45 -0400, rickman
<gnuarm@gmail.com> wrote:

>On 7/18/2014 11:15 AM, makolber@yahoo.com wrote: >> >>> >>> >>> 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? >> >> one way to look at it is..... >> >> becasue the signal and the sampling rate are synchronized, all the alisas fall on top of the signal and/or its harmonics. Therefore no new frequencies are created. > >I think this is the issue the OP was asking about. He is imagining a >waveform that aligns perfectly with the sampling so that there is no >lost information and the digital signal contains all the info of the >original signal. He was simply confused about what happens with the >harmonics.
True, I knew that the alias frequencies landed on the signal and harmonic frequencies. But the question is really how the combination manages to have the identical spectrum to the unsampled rectangular wave. Clearly, to keep the *amplitudes* of all the resulting components the same as the originals, some aliased components must be exactly cancelling others. 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!
On 2014-07-18 13:48, Bob Masta wrote:
> 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?
Nyquist theorem talks about sampling *and* reconstruction in a *general* case. So, it is required both actions *and* no apriori information on the signal. Otherwise you will fall outside the scope of the theorem and find cases like this one. Your supposition seems correct to me. bye, pg
> Thanks, and 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! >
-- piergiorgio
Ok, i understand your  question now and i think the answer is this...

In the situation you described, you are not really sampling and reconstructing a square wave, you are simply creating a new square wave at the same frequency as the original.  Because they are both square waves, they have the same harmonic levles.  Consider if the original square wave had a slower rise time.  Its harmonics would drop faster.  The new square wave would thennot have the same harmonic levles.

No information about the original wave is captured except one number .  The ratio of the frequency to the sampling frequency.  I don't think then that this qualifies as sampling and reconstruction, therefore nyquists rules do not apply.

Also consider that this works only for square wave, not sawtooth or any other waveform.  You are simply creating a new square wave.

Mark


On 7/20/2014 8:08 AM, Bob Masta wrote:
> On Sat, 19 Jul 2014 21:06:45 -0400, rickman > <gnuarm@gmail.com> wrote: > >> On 7/18/2014 11:15 AM, makolber@yahoo.com wrote: >>> >>>> >>>> >>>> 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? >>> >>> one way to look at it is..... >>> >>> becasue the signal and the sampling rate are synchronized, all the alisas fall on top of the signal and/or its harmonics. Therefore no new frequencies are created. >> >> I think this is the issue the OP was asking about. He is imagining a >> waveform that aligns perfectly with the sampling so that there is no >> lost information and the digital signal contains all the info of the >> original signal. He was simply confused about what happens with the >> harmonics. > > True, I knew that the alias frequencies landed on the signal > and harmonic frequencies. But the question is really how > the combination manages to have the identical spectrum to > the unsampled rectangular wave. Clearly, to keep the > *amplitudes* of all the resulting components the same as the > originals, some aliased components must be exactly > cancelling others.
I don't think anything "cancels". The point is that when you sample the out of band energy ends up aliased into the band. So to make the waveforms match perfectly the entire energy has to be there with nothing "canceling". Were the input square wave run through a brick wall anti-alias filter before sampling by the ADC you would clearly see the results of the missing frequencies. I think you are getting hung up by the nature of the sampling process. Ignoring the realities of the real hardware, the sampling process does not lose any information. It just seems counter intuitive sometimes. When out of band frequencies alias into the band of interest they still produce the same result in the time domain signal they would if you had a higher sample rate where they didn't alias. They can look goofy in the frequency domain but in this case they line up with the other signals you expect to see. -- Rick
Bob Masta <N0Spam@daqarta.com> wrote:

(snip)

> 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.
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.
> 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.
-- glen
>> 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). _____________________________ Posted through www.DSPRelated.com