Pilani Campus
DSP Lecture 14
RKTiwary
Goertzel Algorithm for Frequency Detection
3
4
The Goertzel Algorithm
think
Given a signal x[n] with corresponding 8-point DFT X[k], what is the
most efficient way, in terms of total multiplications required, to
compute X[5] from x[n]?
Calculating X[5] =
FFT algorithms may be useful for a wide class of problems, they are by
no means the most efficient choice in all situations.
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
The Goertzel Algorithm
H(z)=
7
Instead of performing the computation of the DFT as in via
convolution. we can use the difference equation corresponding to the
filter given by to compute yk(n) recursively, Thus we have
8
The transfer function contains a denominator which is well
known from the oscillating sine wave generators. It operates
as a frequency selective bandpass filter.
11
figure(1)
freqz(1,[1 -a 1]);
% Goertzel filter power output: evaluation of difference
equation
for l=1:M % IIR transposed form II output with NM input
samples
[v,z]=filter(0.004,[1 -a 1],x((l-1)*N+1:l*N));
Pk(l)=k2dN*1*((250*(v(N)+br*(a*v(N)-
z(1))))^2+(250*(bi*(a*v(N)-z(1))))^2);
% decimated power output
end
figure(2)
[v,z]=filter(0.004,[1 -a 1],x);
plot(t,v);axis([ts te 1.1*min(v) 1.1*max(v)]), grid
12
figure(3)
%input x and output Pk stairs plot
subplot(2,1,1),
plot(t,x), axis([ts te 1.1*min(x) 1.1*max(x)]), grid
title(['Signal x, f1= ',num2str(f1),' Hz, xa1= ',num2str(xa1),...
', f2= ',num2str(f2),' Hz, xa2= ',num2str(xa2),...
', Xrms= ',num2str(Xrms),', fs= ',num2str(fs),' Hz'])
tG=0:N*T:M*N*T; % M intervalls with NT width
subplot(2,1,2), stairs(tG,[0 Pk]); % M+1 Pk values
axis([ts te -0.1*max(Pk) 1.1*max(Pk)]), grid
title(['Output Pk, M= ',num2str(M),', N= ',num2str(N),', fk=
',num2str(fk),...
' Hz, fs= ',num2str(fs),' Hz']); xlabel('Time in seconds');
13
DFT Estimation with the Goertzel Algorithm
dspdtmf
Generate and plot a DTMF signal for each button on the telephone
pad. Each signal has a sample rate of 8 Khz and a duration of 100ms
val = abs(Fx);
stem (k,val); grid; xlabel('k');
ylabel('|X[K]|');
limit= 80;
for s= 5:8;
if val(s)> limit, break, end
end
for r= 1:4;
if val(r)> limit, break, end
end
disp(['Touch-tone symbol = ',setstr(tm(r,s-
4))])
20
Compute and display the magnitude response of the third-order
IIR lowpass filter described by the following transfer function:
21
Plot the magnitude response expressed in decibels.
plot(w/pi,20*log10(abs(h)))
ax = gca;
ax.YLim = [-100 20];
ax.XTick = 0:.5:2;
xlabel('Normalized Frequency (\times\pi rad/sample)')
ylabel('Magnitude (dB)')
b = fir1(80,0.5,kaiser(81,8));
freqz(b,1)
25