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!

Reply by DougB●July 21, 20142014-07-21

>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

> [...]
> 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

Reply by mnentwig●July 21, 20142014-07-21

>> 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

Reply by glen herrmannsfeldt●July 21, 20142014-07-21

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

Reply by rickman●July 21, 20142014-07-21

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

Reply by ●July 20, 20142014-07-20

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

Reply by Piergiorgio Sartor●July 20, 20142014-07-20

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

Reply by Bob Masta●July 20, 20142014-07-20

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!