DSPRelated.com
Forums

Spectrum compensation for zero-order hold DAC

Started by Brian Willoughby February 3, 2012
Perhaps I should state some of my requirements so that we're all on the 
same page.

I am interested in the response of the zero-order hold DAC -WITHOUT- the 
following analog reconstruction filter. I realize that this is an almost 
useless circuit, but I have actually worked with unfiltered DAC output. 
Apart from that, though, I am still interested in the frequency response 
of the zero-order hold without considering the combined response of the 
zero-order hold followed by the reconstruction filter. I suppose it's 
obvious that the reconstruction filter can vary wildly in response, 
depending upon the choices made when designing the filter. I'm 
interested in just the zero-order hold (and I suppose there is even some 
variation from ideal possible here, since no analog hold circuit is 
absolutely instantaneous or perfect).

I also realize that I need to step back and do some of the math 
necessary to calculate the response of a zero-order hold processing 
block, and I believe that the answers so far have mentioned everything 
needed (everything needed except the time for me to carry out the math :-)


Related questions based on the answers so far is this:

If I have a zero-order hold DAC (basically, a DAC with an analog 
Sample-and-Hold stage after it, implemented as a CMOS analog 
multiplexer/switch followed by low self-discharge caps and JFET op-amps 
with 10 Teraohm input resistance), then how would this -4 dB response at 
Nyquist appear?  If I output pure cosine waves at full-scale, should I 
expect a 4 dB drop in amplitude for frequencies at or near Nyquist?  Or 
is it actually that I should expect 4 dB gain at frequencies 
sufficiently below Nyquist? In either case, I'm talking about pure 
cosine wave data feeding the DAC with full scale samples (which is why I 
use cosine, not sine, so as to guarantee that frequencies at or near 
Nyquist actually have a non-zero amplitude) and no following filter stage.

I will say that I have measured the actual output of a high-speed DAC 
with pure cosine full-scale data, and no subsequent analog filtering 
besides the S&H stage, and I do not see the amplitude variation 
suggested by a -4 dB response at Nyquist. Even with an analog 'scope, 4 
dB should be fairly apparent, since even 3 dB is quite visible.  In 
other words, it seems to mean upon examining a real circuit that 
zero-order hold is flat from 0 Hz to the 62.5 kHz Nyquist, for a 125 kHz 
sample rate. Maybe there is something I missed, though.

On 2/5/12 2:42 AM, Brian Willoughby wrote:
> Perhaps I should state some of my requirements so that we're all on the > same page.
i don't think that is necessary.
> I am interested in the response of the zero-order hold DAC -WITHOUT- the > following analog reconstruction filter.
and we have spelled it out for you. you need to read the responses. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
On Fri, 03 Feb 2012 04:44:45 -0800, Brian Willoughby
<Sound_Consulting-RM-@Sounds-dot-wa.com> wrote:

   [Snipped by Lyons]

Hello Brian,
    Congratulations on having a copy of the Rabiner 
& Gold book.  It's absolutely packed with all manner 
of DSP theory and implementation material.  You could 
spend the rest of your signal processing career 
studying the material in that book.

Your 'zero-order hold & DAC' questions lead to 
truly fascinating discussions regarding both signal 
processing theory and signal processing implementation.
Such discussions are best held by a half dozen guys 
in a room with a whiteboard and two large pots of coffee.
(Notice that I said coffee, not pitchers of Irish whisky.) 

>Not only am I curious about this, and suspect that I could learn >something fundamental by pursuing an understanding of what Rabiner and >Gold are alluding to, but this also seems related to a debate I had some >years back about which is more correct in digital-to-digital sample rate >conversion. I tend to understand the insertion of zeroes between samples >when increasing the sample rate, perhaps being biased by the fact that >this allows the filter code to be optimized. But the mathematician that >I was debating was convinced that digital upsampling would require what >was basically the digital equivalent of zero-order hold. At a minimum, I >thought this would increase the signal level on the output of the SRC >filter, or worse it would create an incorrect waveform that was the sum >of several phase-shifted copies of the original.
I'm not sure I know exactly what you and the mathematician were saying, but I thought I'd 'throw my two cents down on the table' here. Think of a lowpass input discrete sequence, call it "x(n)", that we want to interpolate by four. We could stuff three zero-valued samples in between each x(n) sample, creating a new sequence we'll call "x1(n)." The spectrum of x1(n) will contain three spectral 'images' that we want to attenuate by passing x1(n) through a lowpass filter. You know all of this. Now, start from the beginning again. Instead of zero-stuffing x(n), think about inserting three replicated samples after each x(n) sample, creating a new sequence we'll call "x2(n)." That is, the replicated samples after each x(n) sample are equal to the x(n)th sample. For example, if x(n) = [1,5,2,etc.], then x2(n) = [1,1,1,1,5,5,5,5,2,2,2,2, etc.]. This what I think you meant when you wrote, "...digital equivalent of zero-order hold." If we think of the spectral images of sequence x1(n) and sequence x2(n) as 'noise', then the signal to noise ratio (the 'quality', if you will) of x2(n) will be greater than that of x1(n). Stated in different words, we can say that x2(n) is more similar (closer) to an ideal 'interpolated- by-four' x(n) than is x1(n). That's because the spectral images (noise) in x2(n) are reduced in magnitude relative the images in x1(n). Given all of this, a DSP beginner might ask, "If x2(n) is a more accurate interpolated version of x(n) than x1(n), then why don't we create x2(n) and pass it through the lowpass filter, rather than passing x1(n) through the filter?" The answer is, and I'll stick my neck out here, in most real-world interpolation applications we use polyphase lowpass digital filters because such filters are so darned computationally efficient. And, when using polyphase lowpass filters neither the x1(n) nor the x2(n) are created at all. So the entire question of creating an x1(n) sequence versus creating an x2(n) sequence doesn't exist in most interpolation applications. See Ya', [-Rick-] PS. In case anyone's interested, below is a snippet of Matlab code I threw together to demonstrate the above simple ideas: % Zero-stuffing versus zero-order hold interpolation % [R. Lyons, Feb., 2012] clear, clc N = 64; n = 0:N-1; Fs = 32000; X = sin(2*pi*(6*Fs/N)*n/Fs) +... 0.5*sin(2*pi*(7*Fs/N)*n/Fs) +... 0.25*sin(2*pi*(8*Fs/N)*n/Fs); figure(1) subplot(3,1,1) plot(X, '-bo', 'markersize', 2) axis([0, N, -2.5, 2.5]) ylabel('x(n)'), title('Time Sequences') grid on, zoom on Spec_Mag = abs(fft(X)); figure(2) subplot(3,1,1) plot(Spec_Mag, '-bo', 'markersize', 2) ylabel('X(m)'), title('Spec Mag (Linear)') grid on, zoom on % Zero stuff by a factor of 4 U = 4; % Upsample factor X_zero_stuff = zeros(size(1:U*length(X))); X_zero_stuff([1:U:length(X_zero_stuff)]) = X; figure(1) subplot(3,1,2) plot(X_zero_stuff, '-bo', 'markersize', 2) axis([0, 4*N, -2.5, 2.5]) ylabel('x1(n)'), grid on, zoom on Spec_Mag = abs(fft(X_zero_stuff)); figure(2) subplot(3,1,2) plot(Spec_Mag, '-bo', 'markersize', 2) ylabel('X1(m)'), grid on, zoom on % Repeat samples (zero-order hold interpolation) by 4 X_zero_order_hold = []; % Init output variable for K = 1:length(X) X_zero_order_hold = [X_zero_order_hold, X(K)*ones(1,4)]; end figure(1) subplot(3,1,3) plot(X_zero_order_hold, '-bo', 'markersize', 2) axis([0, 4*N, -2.5, 2.5]) ylabel('x2(n)'), grid on, zoom on Spec_Mag = abs(fft(X_zero_order_hold)); figure(2) subplot(3,1,3) plot(Spec_Mag, '-bo', 'markersize', 2) ylabel('X2(m)'), grid on, zoom on
On Sat, 04 Feb 2012 23:42:46 -0800, Brian Willoughby
<Sound_Consulting-RM-@Sounds-dot-wa.com> wrote:

>Perhaps I should state some of my requirements so that we're all on the >same page. > >I am interested in the response of the zero-order hold DAC -WITHOUT- the >following analog reconstruction filter. I realize that this is an almost >useless circuit, but I have actually worked with unfiltered DAC output. >Apart from that, though, I am still interested in the frequency response >of the zero-order hold without considering the combined response of the >zero-order hold followed by the reconstruction filter. I suppose it's >obvious that the reconstruction filter can vary wildly in response, >depending upon the choices made when designing the filter. I'm >interested in just the zero-order hold (and I suppose there is even some >variation from ideal possible here, since no analog hold circuit is >absolutely instantaneous or perfect). > >I also realize that I need to step back and do some of the math >necessary to calculate the response of a zero-order hold processing >block, and I believe that the answers so far have mentioned everything >needed (everything needed except the time for me to carry out the math :-)
Yes, you need to do the math, because the responses that you've gotten previously were considering the DAC without the reconstruction filter, just like you're asking now.
>Related questions based on the answers so far is this: > >If I have a zero-order hold DAC (basically, a DAC with an analog >Sample-and-Hold stage after it, implemented as a CMOS analog >multiplexer/switch followed by low self-discharge caps and JFET op-amps >with 10 Teraohm input resistance), then how would this -4 dB response at >Nyquist appear? If I output pure cosine waves at full-scale, should I >expect a 4 dB drop in amplitude for frequencies at or near Nyquist?
It's approximately a 4dB drop in power, or a 2dB drop in amplitude. Just calculate the value of sinx/x at pi/2.
> Or >is it actually that I should expect 4 dB gain at frequencies >sufficiently below Nyquist?
As explained previously, the response is a sinx/x with the zeros (nulls) at integer multiples of the sample rate. The main lobe of the sinx/x doesn't slope very much near DC, but it can be problematic if you care about things near fs/2 or, worse yet, are generating sampled IF or using images above fs/2 for the desired output. Then it can make a huge difference.
> In either case, I'm talking about pure >cosine wave data feeding the DAC with full scale samples (which is why I >use cosine, not sine, so as to guarantee that frequencies at or near >Nyquist actually have a non-zero amplitude) and no following filter stage.
This statement suggests you need to back up a bit and start with some more fundamental math. The difference between continuous sin and cos waves is only the relative phase, and the response doesn't care about that at all, i.e., a cosine will be treated exactly the same as a sine wave, because the "filter" can't tell the difference.
>I will say that I have measured the actual output of a high-speed DAC >with pure cosine full-scale data, and no subsequent analog filtering >besides the S&H stage, and I do not see the amplitude variation >suggested by a -4 dB response at Nyquist. Even with an analog 'scope, 4 >dB should be fairly apparent, since even 3 dB is quite visible. In >other words, it seems to mean upon examining a real circuit that >zero-order hold is flat from 0 Hz to the 62.5 kHz Nyquist, for a 125 kHz >sample rate. Maybe there is something I missed, though.
The amplitude drop will be half the power drop (in dB). Again, sinx/x at pi/2. If your unfiltered DAC output is completely flat out to Nyquist, then there is compensation being done somewhere. Also, if your DAC output is truly a zero-order hold with no reconstruction filter, then it should be VERY easy to see the sinx/x response by watching the amplitudes of the aliased tones above fs/2 where the attenuation is more dramatic. Eric Jacobsen Anchor Hill Communications www.anchorhill.com
On Sat, 04 Feb 2012 23:42:46 -0800, Brian Willoughby wrote:

> Perhaps I should state some of my requirements so that we're all on the > same page. > > I am interested in the response of the zero-order hold DAC -WITHOUT- the > following analog reconstruction filter. I realize that this is an almost > useless circuit, but I have actually worked with unfiltered DAC output.
Rarely used in the problems that you have worked on, perhaps, but it's almost universally used in closed-loop control systems, where the cost of the delay of a reconstruction filter far exceeds any advantages gained by using it.
> Apart from that, though, I am still interested in the frequency response > of the zero-order hold without considering the combined response of the > zero-order hold followed by the reconstruction filter. I suppose it's > obvious that the reconstruction filter can vary wildly in response, > depending upon the choices made when designing the filter. I'm > interested in just the zero-order hold (and I suppose there is even some > variation from ideal possible here, since no analog hold circuit is > absolutely instantaneous or perfect). > > I also realize that I need to step back and do some of the math > necessary to calculate the response of a zero-order hold processing > block, and I believe that the answers so far have mentioned everything > needed (everything needed except the time for me to carry out the math > :-) > > > Related questions based on the answers so far is this: > > If I have a zero-order hold DAC (basically, a DAC with an analog > Sample-and-Hold stage after it, implemented as a CMOS analog > multiplexer/switch followed by low self-discharge caps and JFET op-amps > with 10 Teraohm input resistance)
Or just a plain old DAC, because plain old DACs implement the "sample and hold" stage digitally.
>, then how would this -4 dB response at > Nyquist appear? If I output pure cosine waves at full-scale, should I > expect a 4 dB drop in amplitude for frequencies at or near Nyquist? Or > is it actually that I should expect 4 dB gain at frequencies > sufficiently below Nyquist?
Your question is meaningless, because you are not taking the effective gain of the DAC into account. Whatever scaling you apply, there's a 4dB drop from 0Hz to Nyquist.
> In either case, I'm talking about pure > cosine wave data feeding the DAC with full scale samples (which is why I > use cosine, not sine, so as to guarantee that frequencies at or near > Nyquist actually have a non-zero amplitude) and no following filter > stage. > > I will say that I have measured the actual output of a high-speed DAC > with pure cosine full-scale data, and no subsequent analog filtering > besides the S&H stage, and I do not see the amplitude variation > suggested by a -4 dB response at Nyquist. Even with an analog 'scope, 4 > dB should be fairly apparent, since even 3 dB is quite visible. In > other words, it seems to mean upon examining a real circuit that > zero-order hold is flat from 0 Hz to the 62.5 kHz Nyquist, for a 125 kHz > sample rate. Maybe there is something I missed, though.
You have not measured correctly, then. Just looking at the peak-peak amplitude isn't enough -- you need to look at the amount that the signal is attenuated, without allowing yourself to be distracted by the aliased energy that's holding the p-p amplitude up. -- Tim Wescott Control system and signal processing consulting www.wescottdesign.com
On 2/5/2012 2:42 AM, Brian Willoughby wrote:
> Perhaps I should state some of my requirements so that we're all on the > same page. > > I am interested in the response of the zero-order hold DAC -WITHOUT- the > following analog reconstruction filter. I realize that this is an almost > useless circuit, but I have actually worked with unfiltered DAC output. > Apart from that, though, I am still interested in the frequency response > of the zero-order hold without considering the combined response of the > zero-order hold followed by the reconstruction filter. I suppose it's > obvious that the reconstruction filter can vary wildly in response, > depending upon the choices made when designing the filter. I'm > interested in just the zero-order hold (and I suppose there is even some > variation from ideal possible here, since no analog hold circuit is > absolutely instantaneous or perfect). > > I also realize that I need to step back and do some of the math > necessary to calculate the response of a zero-order hold processing > block, and I believe that the answers so far have mentioned everything > needed (everything needed except the time for me to carry out the math :-) > > > Related questions based on the answers so far is this: > > If I have a zero-order hold DAC (basically, a DAC with an analog > Sample-and-Hold stage after it, implemented as a CMOS analog > multiplexer/switch followed by low self-discharge caps and JFET op-amps > with 10 Teraohm input resistance), then how would this -4 dB response at > Nyquist appear? If I output pure cosine waves at full-scale, should I > expect a 4 dB drop in amplitude for frequencies at or near Nyquist? Or > is it actually that I should expect 4 dB gain at frequencies > sufficiently below Nyquist? In either case, I'm talking about pure > cosine wave data feeding the DAC with full scale samples (which is why I > use cosine, not sine, so as to guarantee that frequencies at or near > Nyquist actually have a non-zero amplitude) and no following filter stage. > > I will say that I have measured the actual output of a high-speed DAC > with pure cosine full-scale data, and no subsequent analog filtering > besides the S&H stage, and I do not see the amplitude variation > suggested by a -4 dB response at Nyquist. Even with an analog 'scope, 4 > dB should be fairly apparent, since even 3 dB is quite visible. In other > words, it seems to mean upon examining a real circuit that zero-order > hold is flat from 0 Hz to the 62.5 kHz Nyquist, for a 125 kHz sample > rate. Maybe there is something I missed, though.
Slow down. Draw a graph of sin(x)/x -- x in radians -- from zero to pi. Pi is the sample rate. Pi/2 is the Nyquist rate. Sin(x)/x =0 when x = pi. Sin(pi/2)/(pi/2) = 2/pi =.637 = -3.92 dB. What more do you need to calculate? At half Nyqist, the gain is sin(pi/4)/(pi/4) = 2*sqrt(2)/pi = .900 = -.912 dB. What's bugging you? Jerry -- Engineering is the art of making what you want from things you can get. &macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;
On 2/5/2012 12:27 PM, Eric Jacobsen wrote:

   ...

> It's approximately a 4dB drop in power, or a 2dB drop in amplitude. > Just calculate the value of sinx/x at pi/2.
...
> The amplitude drop will be half the power drop (in dB). Again, > sinx/x at pi/2.
When is a dB not a dB? 20*log(V1/V2) = 10*(P1/P2). Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
On Sun, 05 Feb 2012 14:01:34 -0500, Jerry Avins <jya@ieee.org> wrote:

>On 2/5/2012 12:27 PM, Eric Jacobsen wrote: > > ... > >> It's approximately a 4dB drop in power, or a 2dB drop in amplitude. >> Just calculate the value of sinx/x at pi/2. > > ... > >> The amplitude drop will be half the power drop (in dB). Again, >> sinx/x at pi/2. > >When is a dB not a dB? 20*log(V1/V2) = 10*(P1/P2).
Right. But the OP keeps mentioning amplitude rather than power, and 10*log(V1/V2) = 1/2 * 20*log(V1/V2). The power ratio is ~4 dB, and the OP says he's not seeing a 4dB drop. He'll see a 2dB drop if he's just taking the amplitude ratios, which might explain why he's not seeing 4dB. Eric Jacobsen Anchor Hill Communications www.anchorhill.com
On 2/5/2012 3:14 PM, Eric Jacobsen wrote:
> On Sun, 05 Feb 2012 14:01:34 -0500, Jerry Avins<jya@ieee.org> wrote: > >> On 2/5/2012 12:27 PM, Eric Jacobsen wrote: >> >> ... >> >>> It's approximately a 4dB drop in power, or a 2dB drop in amplitude. >>> Just calculate the value of sinx/x at pi/2. >> >> ... >> >>> The amplitude drop will be half the power drop (in dB). Again, >>> sinx/x at pi/2. >> >> When is a dB not a dB? 20*log(V1/V2) = 10*(P1/P2). > > Right. But the OP keeps mentioning amplitude rather than power, and > 10*log(V1/V2) = 1/2 * 20*log(V1/V2). The power ratio is ~4 dB, and > the OP says he's not seeing a 4dB drop. He'll see a 2dB drop if he's > just taking the amplitude ratios, which might explain why he's not > seeing 4dB.
I think it's better to teach him how to calculate dBs than to keep him happy by fudging the numbers. He'll see a 4 dB drop if he calculates 20*log(amplitude_ratio) Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
On Feb 5, 7:42=A0am, Brian Willoughby <Sound_Consulting-...@Sounds-dot-
wa.com> wrote:
> besides the S&H stage, and I do not see the amplitude variation > suggested by a -4 dB response at Nyquist. Even with an analog 'scope, 4 > dB should be fairly apparent, since even 3 dB is quite visible. =A0In > other words, it seems to mean upon examining a real circuit that > zero-order hold is flat from 0 Hz to the 62.5 kHz Nyquist, for a 125 kHz > sample rate. Maybe there is something I missed, though.
Try a 62.499KHz tone. You are observing a complex signal not a pure tone. You would need to use a spectrum analyzer to separate the actual tone from the harmonics.