1 Star2 Stars3 Stars4 Stars5 Stars (4 votes, average: 5.00 out of 5)
Loading ... Loading ...
Print Print

Zero-order hold and first-order hold based interpolation

by Krishna Sankar on March 25, 2007

In problem 9.14 of DSP-Proakis, the objective is to analyze the effect of zero-order interpolation and first-order interpolation to double the number of samples in the sinusoidal

while keeping the sampling frequency unchanged.

My take:

The first part of the problem (a) is to generate the sequence having half the frequency of . For zero-order interpolation, the interpolated samples can be generated by holding the current sample till the new sampling instant (Ref: Section 9.3.1 -Sample and Hold [1]). The impulse response of such a system is a rectangular function.

For first-order interpolation with delay, the interpolated samples are generated by piece wise linear interpolation between the current sample and the previous sample. As the prediction based on current sample and previous sample can have ‘jumps’ at the next sampling instant, delay of one sample is provided (Ref: Section 9.3.3 – Linear interpolation with delay [1]). The impulse response of such a system is a triangular function.

For constructing these sample from MATLAB, let us use the technique provided in part (c) of the problem i.e. add zeros and pass it through a filter for obtaining the interpolated samples.

For zero-order interpolation, the filter function is a rectangular function i.e. .

For the delayed first-order interpolation, the filter function is a triangular function i.e. . The factor of 1/2 is for normalization.

% interpolation
N = 32;
x = cos(2*pi*(1/N)*[0:2*N-1]);
xu = [ x ; zeros(size(x))];
xu = xu(:).'; % upsampled version of x 

h_zoh = [1 1];
h_foh = [1 2 1]/2;
y_zoh = conv(xu, h_zoh); % zero-order hold
y_foh = conv(xu, h_foh); % delayed first order hold
y_pfct = cos(2*pi*(1/(2*N))*[0:2*N-1]); % perfect sine

y_zoh = y_zoh(1:64); % taking one period of the cosine
y_foh = y_foh(2:65); % % one period of cosine with delay removed

plot(y_pfct,'r');
hold on; grid on
plot(y_zoh,'b');
plot(y_foh,'m');
legend('pfct', 'zoh', 'foh')
xlabel('sample index, n')
ylabel('y(n)')
title('one period of the sinusoidal')

For the first-order interpolation case, note that the effect of delay is removed and plotted.

Let us further analyze the harmonic distortion from the generated sinusoidal’s.

% compute the fourier series coefficients
k = [0:N-2]';
refF = exp(-j*2*pi*k*[0:2*N-1]*(1/(2*N)));
hd_y_pfct = mean((ones(N -1,1)*y_pfct).*refF,2);
hd_y_zoh = mean((ones(N-1,1)*y_zoh(1:64)).*refF,2);
hd_y_foh = mean((ones(N -1,1)*y_foh(1:64)).*refF,2); 

% THD from perfect cosine function
THD_y_pfct = 1 - 2*abs(hd_y_pfct(2)).^2/sum(y_pfct.^2/length(y_pfct))
% THD from zero-order hold based cosine function
THD_y_zh = 1 - 2*abs(hd_y_zoh(2)).^2/sum(y_zh.^2/length(y_zoh))
% THD from first-order holds based cosine function
THD_y_fh = 1 - 2*abs(hd_y_foh(2)).^2/sum(y_fh.^2/length(y_foh))

As can be seen from the simulations, the harmonic distortion from zero-order hold is higher than the distortion observed from the first-order hold. The probable explanation can be as follows:

% analyzing the transfer functions
h_zoh = [1 1 ];
h_foh = [1 2 1]/2;
H_zoh = fft(h_zoh, 1024); % 1024 pt fft of zero order hold filter
H_foh = fft(h_foh, 1024); % 1024 pt fft of first order hold filter

figure
plot([-512:511]/1024,fftshift(abs(H_zoh)));
hold on
plot([-512:511]/1024,fftshift(abs(H_foh)),'r');
grid on
xlabel('normalized frequency');
ylabel('amplitude');
title('freuqency response')
legend('zoh', 'foh')

From the frequency domain transfer functions, it can be seen that zero-order interpolation has a slightly relaxed transfer function for high frequency components when compared to the transfer function of first-order interpolation.

Analytically, for the zero-order interpolation, the transfer function is a shaped function whereas for the first order hold, , the transfer function is a shaped function.

As for all , it can be argued that thought the desired frequency in first-order hold is slightly more attenuated when compared to the zero-order hold, the higher frequency components are more significantly attenuated first-order interpolation. Hence the better performance.

From a time domain perspective, it can be seen that the waveform obtained from first-order interpolation has a closer match with the ‘perfect wave’ when compared with the waveform obtained from zero-order interpolation.

For part (e) of the problem, when the input samples having a triangular spectrum is to be passed first through the zero insertion block to generate followed by the filtering operation to generate .

With the sampling frequency kept unchanged, insertion of zeros causes the signal bandwidth to be half the original spectrum, additionally the spectrum gets aliased to be around .

Note that, typically no one would want to distort the original spectrum and hence sampling frequency typically gets doubled when zeros are inserted (over-sampled). In that scenario, shape of the original spectrum centered around-dc remained unchanged, however with the spectrum gets aliased to around . The high frequency components present around need to be removed by a digital filter. Sauch a circuit having “over sampling followed by digital filtering” is used in typical transmitter implementation.

References:

[1] Digital Signal Processing – Principles, Algorithms and Applications, John G. Proakis, Dimitris G. Manolakis

D id you like this article? Make sure that you do not miss a new article by subscribing to RSS feed OR subscribing to e-mail newsletter. Note: Subscribing via e-mail entitles you to download the free e-Book on BER of BPSK/QPSK/16QAM/16PSK in AWGN.

{ 15 comments… read them below or add one }

David November 25, 2012 at 5:22 pm

Dear Krishna,

thanks a lot for your explications. I added some lines to your code to proof the analytic solution:

f = [-512:511]/1024;
plot(f,2*sinc(f*2),’k')
plot(f,2*sinc(f*2).^2,’c')

and I expected that the lines will coincide with your lines. But they are different. Do you know, why?

Thanks,
David.

Reply

Krishna Sankar November 27, 2012 at 5:43 am

@David: Well, true. I too was trying to play with it and get the lines to overlap with each other – but they are not.
Let me explore this bit more and revert.

Reply

Krishna Sankar November 27, 2012 at 6:19 am

@David: When playing with it and comparing the frequency response of a wider rectangular pulse, could see that for frequencies close to dc, the responses are overlapping. However, the deviation starts showing up for higher frequencies. Is it something related to do with digital representation?

close all; clear all;
h_zoh = [ones(1,8)]/8;
H_zoh = fft(h_zoh, 1024);
f = [-512:511]/1024;
h1 = sinc(f*8);
plot([-512:511]/1024,(fftshift(abs(H_zoh))))
hold on; plot(f,abs(h1),’k')

Reply

Raghavan July 27, 2012 at 6:06 pm

If you have a zero order hold system that holds the data for ‘q’ time periods what would its transfer function be? Also for a zero order hold the TF= (1-1/z)/s … If we assume a system with no hold, the TF =1 … How will you proceed from the former case to the latter? by substituting s=0? in that case, the TF becomes 0/0 =1?

Reply

Krishna Sankar August 1, 2012 at 6:17 am

@Raghavan: Holding the data for ‘q’ time periods is equivalent to passing the data through a filter having a rectangular pulse shape.

Reply

usman warraich May 30, 2010 at 10:23 am

What is the transfer function of zero-order hold?

Reply

Krishna Sankar June 24, 2010 at 4:05 am

@usman: Zero order hold has a rectangular response in time domain.

Reply

VA April 2, 2010 at 10:52 am

[1 2 1] are the filter coefficients in first order hold…..the normalization factor should have been sqrt(6)……why it is 2??
Thanks for the reply in advance!!

Reply

Krishna Sankar April 4, 2010 at 3:19 am

@VA: 1^2 + 2^2 + 1^2 = 6. Agree?

Reply

MOHIT November 28, 2009 at 7:29 pm

What is the shape of impulse response of ZOH? pl

Reply

Krishna Sankar December 7, 2009 at 4:43 am

@Mohit: Zero order hold has a rectangular response in time domain.

Reply

Kanhe Ram K March 18, 2009 at 8:33 am

I want to implement the zero order predictor ,first order Preditor the zero order Interpolator ,first order Interpolator ECG

Reply

Krishna Pillai March 21, 2009 at 9:09 am

@ Kanhe Ram K: I am not familiar with the ‘zero-order predictor’ aspect. Is it same as zero-order hold? If it is same as zero-order hold, its just keep the previous sample before the new sample comes.

Reply

Krishna Pillai January 8, 2009 at 5:16 pm

@Pinar: The zero order hold in frequency domain is a sinc() shaped function. You may plot the frequency response by using the following simple Matlab code snippet:
close all
h_zoh = [1 1 1 1 1];
H_zoh = fft(h_zoh, 1024); % 1024 pt fft of zero order hold filter
plot([-512:511]/1024,fftshift(abs(H_zoh)));
grid on
xlabel(‘normalized frequency’);
ylabel(‘amplitude’);
title(‘freuqency response’)

Hope this helps.

Reply

Kürşat PINAR January 7, 2009 at 10:25 pm

i want to learn whats the Zero order hold transfer function characteristics…

for a now
thanks

Reply

Leave a Comment

Previous post:

Next post: