Professional Documents
Culture Documents
Abstract
Application of the Fourier Transform for analyzing the time waveforms of sensor data is
a well-established method for characterizing the behavior of industrial equipment. The
implementation can take on a number of different structures based on the desired
performance. This analysis compares various implementations and develops an operation
minimizing approach for observing spectral frequency bins with excellent resolution and
minimal operations.
Disclaimer
This is a technical report generated by the author as a record of personal research interest and activity.
Western Michigan University makes no representation that the material contained in this report is correct,
error free or complete in any or all respects. Thus, Western Michigan University, it’s faculty, it’s
administration, or students make no recommendation for the use of said material and take no responsibility
for such usage. Therefore, persons or organizations who choose to use this material do so at their own risk.
1 Fourier Transform Processing
Desired frequency response for sensors having a bandpass filter response characteristics
is shown in Fig. 1. The radio frequency (RF) or intermediate frequency (IF) passband is
centered after demodulation at one quarter of the sampling rate (fs/4). The filter
transitions bands are then allowed to “evenly” change through the remainder of the
available Nyquist sampling spectral region and alias or fold back into the non-passband
transition region. As a goal, the “folded” transition band should be sufficiently attenuated
by the time it enters the RF or IF passband as to be inconsequential, preferably with
70 dB or more attenuation. As a note, these spectral characteristics may be centered at
any multiple of fs/2 if an ADC converter capable of wide bandwidth input and
subsampling is used.
IF Passband
fs = ADC clock rate
0 dB
Filter
Transition
Band
"Folded" Alias
-80 dB
Component
where
WNnk exp i 2nk
N
If the number of samples, N, in a data set is a power of 2, then a Fast Fourier Transform
(FFT) algorithm can be employed. While Equ. 1 requires N complex by real multiplies
and accumulations for every frequency bin computed (nominally N), a butterfly FFT
algorithm could perform the same function in order N log 2 N operations, a significant
savings. This is one example of algorithm and implementation manipulations that can
greatly reduce the computation burden of spectral analysis and/or provide additional
frequency and dynamic range resolution.
N 1
X k W2nN xn WNnk (3)
n 0
0 fs
Digital IF
FFT
Analysis Cells
OFFT
Analysis Cells
When performing a DFT or OFFT on real, band-limited signal spectral symmetry exists
that can greatly reduce the number of bins that need to be computed. For real input data,
the resulting spectrum have a real output that is symmetric and an imaginary output that
is anti-symmetric. The mathematical derivation of this property follows.
The symmetry of an FFT is defined between K and N-k frequency bins. Taking the
original FFT equation and substituting a change in variables for the frequency k we have
N 1 N 1
X N k WNn N k xn WNnN WN nk xn (4)
n 0 n 0
N 1 N 1
conjX N k conj WNnk xn WNnk xn (6)
n 0 n 0
and
X N k X k
*
(7)
As a result of this symmetry, a logical extension is to suggest that either only half of the
frequency bins need to be computed (0 to N/2) or that there is some other method of
utilizing the “unnecessary” processing. Because the bins 0 and N/2 are unique in the
processing, algorithms to only process the “first half” of the bins are not very efficient.
real X k real Z k Z N k 2
(10)
real Y k imag Z k Z N k 2
imag X k imag Z k Z N k 2
(11)
imag Y k real Z k Z N k 2
X N 2 real Z N 2
(12)
Y N 2 imag Z N 2
The symmetry of an OFFT is defined between K and N-k-1 frequency bins. Taking the
original OFFT equation and substituting a change in variables for the frequency k we
have
N 1
X N k 1 xn W2nN WNn N k 1 (13)
n 0
N 1
X N k 1 xn W2Nn 1 WN nk (15)
n 0
N 1 N 1
conj X N k 1 conj xn W2Nn WN nk xn W2nN WNnk (16)
n 0 n 0
and
(17)
X * N k 1 X k
With this symmetry, only half of the frequencies bins need to be computed (0 to N/2-1).
While the FFT required bins 0 to N/2, the OFFT requires exactly half and can be further
manipulated to form an efficient implementation. Assume that we break the real data into
two sets, the first N/2 and the second N/2 as follows
N 2 1 N 2 1
X k xn W2nN WNnk xn N 2 W n N 2
2N WNn N 2 k (18)
n 0 n 0
N 2 1
X k W WNnk xn i 1 xn N 2 (21)
n k
2N
n 0
Based on the symmetrical properties, only one half the points need to be computed. In
this case, the even points result in
N 2 1
X 2k W WN2 nk xn i xn N 2 1
2k
n
2N
(22)
n 0
N 2 1
X 2k W n
2N WNnk2 xn i xn N 2 (23)
n 0
This equation allows the spectral bins of an OFFT to be computed by combining the first
half of the real data with the negative imaginary second half of the real data,
premultiplying by the complex coefficients previously defined and performing an N/2
length DFT or FFT.
To “fill in” every other bin, conjugate symmetry is applied to the “second half” of the
spectral results as follows.
(25)
X 2k 1 X * N 2k 2
For this implementation, the operation counts of the derived algorithms for real input data
and Radix-2 FFT implementation of the DFTs can be derived. In general, the FFT of a
complex data input sequence required
5 N log 2 N (26)
The dual-real FFT algorithm performs one FFT for two real input data sets and then has
additional operations to separate the two results. The resulting operations per transform is
approximately
For an OFFT, data processing uses the first half of the samples as real data and the
second half as negative imaginary data. Next, a complex multiplication is done on the
N/2 points followed by an N/2 point complex FFT. Finally, data reordering and
conjugation is required to finalize the result.
The total operations required involve N/2 complex multiplies and N/2 point FFT or the
total of adds, subtracts and multiplies of
6 N 5 N log 2 N
2 2 2
(29)
This technique provides additional savings over the dual-real FFT implementation.
The OFFT provides an additional advantage when implemented on a fixed point or block
floating point processor (fixed point mantissas with one exponent for the data block). The
dual-real algorithm combines two distinct data sequences. As a consequence, high
dynamic range in one sequence can dominate the numerical precision of the computation
and reduce the resulting resolution of the second sequence. For the OFFT, only one data
set is being processed, so other data sequences will have no effect on the precision of the
computation.
From transform theory, multiplication in the time domain is the equivalent of convolution
in the spectral domain. By considering a sample set of data as being collected by a
rectangular window function, the resulting convolved spectrum “smears” the correct
spectral response by the transform of an all-one, rectangular function (a sinc function
with a spectral width dependent upon the number of samples). By applying a data
window that is not all-ones the spectral “smearing” can be shaped to provide improved
frequency resolution, greatly reducing the impact of adjacent or near frequency bin
energy.
In all transform processing, energy from adjacent spectral bins will leak in and be with
any single bin. If there are sufficient spectral bins, there may be a sufficient number of
bins between frequencies that must be resolved, but this may require very large
transforms. After processing, the unwanted spectral bins can be ignored and those
appropriately spaced can be retained and analyzed. By employing a window the spacing
of useable bins can be closer, but some bins will still not be of interest.
A mathematical technique exists to support this concept, where the equivalent of a large
windowed sample set transform is processed but only regularly spaced bins at a desired
spacing are maintained. A mathematical derivation based on keeping every m-th bin of a
mN length data set and using symmetry to compute every other spectral bin follows
N 1 m
m 2 n 2 mk
X 2mk
2
wn xn W
n 0
mN
2
...
s 1 N 2 1 m
n 2 mk
wn xn W mN
2
... (35)
n s N
2
mN 1 m
n 2 mk
wn xn W mN
2
n 2 m 1 N
2
N 1 m
m 2 n 2 mk
X 2mk
2
wn xn W
n 0
mN
2
...
2 xn s N 2 W
N 1 m
2 n s N 2 mk
2
n 0
w n sN mN
2
... (36)
2 xn 2m 1 N 2 W
N 1 m
2 n 2 m 1 N 2 mk
2
w n 2m 1 N mN
2
n 0
n
m
w n s 2 x n s 2 WmN WmN2
N 1 N N 2 mkn
m 2 2 m 1
X 2mk
2
(38)
s 0
m
n 0 2 mks N s N
WmN 2 WmN 2 2
N 1
m 2
2 m 1 s
X 2mk
2
n 0
w n s N 2 x n s N 2 WN W2 N W1 W4
s 0
nk
2
n sk
(39)
N 1
m 2 2 m 1
X 2mk WNnk W2nN i w n s N x n s N
s
(40)
2 s 0 2 2
n 0 2
The above equation must be solved. Note that the equation in braces either adds or
subtracts certain weighted and multiplied samples while assigning the real values as
either real or complex elements for further processing. The bracketed multiplication is a
“twiddle factor” premultiplication prior to an N/2 point FFT as indicated by the
summation and FFT “twiddle factor”. To form the N/2 spectral elements not directly
calculated, use conjugate symmetry to access the appropriate bin results.
(42)
X 2k 1 X * N 2k 2
For m=4, the total operations required involve 4N real multiplies, 2N real data
subtractions, an N/2 length complex multiplication and an N/2 length FFT
6 N N N
4 N 2 N 5 log 2 (43)
2 2 2
As a comparison, a 4N length windowed FFT would require 4N real multiplies and a dual
real 4N length FFT requiring
18 N 10 N log 2 N (48)
From this analysis, the windowed precombiner has a significant advantage over direct
data processing by nearly a factor of four and allows an N/2 length FFT to provide the
bin resolution capability of a 4N length equivalent transformation.
The software simulation generates a desired window function or filter. A special window
function was selected for the demonstration to provide a smooth equivalent spectral
response for a precombiner bin with a 3dB rolloff at the band edges, greater than 55 dB
attenuation at the center of the adjacent bin and greater than 75 dB attenuation from all
other bins. The equivalent spectral plot of the filter is shown in Fig. 3 assuming a signal
sample rate of 25.6 Msps resulting in OFFT spectral bins of 50 kHz bandwidth. The band
edge is at 25 kHz and adjacent bin centers are located at 75 kHz, 125 kHz, etc.
Filter interpolated from QMF_weights6:
Order = 2048
0
-10
-20
-30
Magnitude (dB)
-40
-50
-60
-70
-80
-90
Next the number of signals that are present in the spectrum is selected with their relative
signal-to-white-noise rations (SWNR). The signal time samples are then defined based on
the type of waveform desired. A list of available waveforms is shown in Table 1.
Random noise can be added to the combined input signal as desired.
For this test, two 100 dB SWNR signals are generated. The first is a linear frequency
ramp or chirp (type 9) and the second is a sine wave (type 2). The chirp signals ramps
through 6 frequency bins during the test while the sine wave is placed in another part of
the processed signal spectrum. A complete test signal description as output from the
simulation is provided in Table 2.
TDM #2:
Complex Sine Wave
SWNR = 100 dB.
Tone = 128 Phase = 293.834 deg
For each of these transformations a 3-D plot of the resulting power spectrum versus time
has been generated as shown in Fig. 4. The sine wave spectrum can be seen as a constant
signal power across all bins in time. The frequency ramp or chirp is readily visible in the
windowed precombiner as each successive frequency bin is entered and exited and less so
in the windowed FFT and equivalent non-windowed FFT. The windowed FFT has
considerable overlap in frequency bins since the nominal window bandwidth is 50 kHz
and the bin spacing is 12.5 kHz. If the frequency bins were decimated by a factor of 4
(saving only every 4th bin after processing), an identical plot to that of the windowed
precombiner results. Finally, the non-windowed FFT spectrum shows the considerable
adjacent bin energy present when a simple FFT is performed.
Another means of performance analysis involves observing all the spectral bins
simultaneously across the time samples as shown in Fig. 5 for the windowed precombiner
and non-windowed FFT. These plots clearly show the frequency ramps signal power in
time as it moves through adjacent bins. The windowed precombiner provides excellent
resolution while the FFT clearly peaks at bin centers but has poor transition bands to
adjacent bins and significant adjacent channel responses. The sine wave spectrum can be
readily observed as a constant signal in both plots. The simulated signal power levels for
the sine wave and frequency ramp are identical. The FFT plot clearly shows this as the
frequency ramp power peaks at the center of each bin at an equivalent power to the sine
wave. In the windowed precombiner, the sine wave level is below the frequency bin
peaks. For this simulation, the sine wave frequency is half way between two frequency
bins resulting in two adjacent bins each containing 50% of the signal power or –3 dB
from the bin center peaks.
The MATLAB code that performs the specific signal performance demonstration and
analysis is provided in the following sections, including the OFFT_ANALYSIS and
OFFT functions that are specifically required for correct operation.
FFT Transform
FFT Length 512
0 0
-10 -10
-20 -20
-30 -30
-40 -40
-50 -50
-60 -60
-70 -70
-80 -80
-90 -90
-100 -100
0 20 40 60 80 100 120 140 160 180 200 0 20 40 60 80 100 120 140 160 180 200
%
% Author:
% Bradley J. Bazuin, Ph.D.
% 17 May 2002
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear
load chan_parms
Filter_size=DFT_size*poly_taps;
TDM_proc = 0;
test=1;
plot_mesh=1;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Load filter type %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% load chan_filt_data
load chan_filt_data
fprintf(sfilter)
fprintf('\n')
Afilter=filter1/sum(filter1);
Sfilter=flipud(Afilter);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Load Test Signal %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% load CHANTSG_data
load CHANTSG_data
fprintf(sTSG)
fprintf(sTSG_title)
fprintf(sTSG_label)
sTSG_data=[sTSG sTSG_title sTSG_label];
[num_samples,num_cols] = size(signal);
blocks=fix(num_samples/DFT_size);
fprintf('\nThere are %g processing blocks.\n\n',blocks)
t_start=clock;
flops(0)
for ii=1:num_cols
s_sel = 1 + mod(ii-1,Num_sigs);
SOI_type =SOI_types(s_sel);
SOI_carrier=SOI_carriers(s_sel);
Freq_inv =SOI_Freq_inv(s_sel);
TDM_signal = signal(:,ii);
waveform = zeros(DFT_size/2,2*poly_taps);
waveform2= zeros(DFT_size,poly_taps);
fprintf('Block\n');
for i = 1:(2*blocks)
fprintf('%3i',i);
if (mod(i,20)==0); fprintf('\n'); end;
waveform = waveform * col_sh;
waveform(:,2*poly_taps) = ...
real(signal( ((i-1)*DFT_size/2+1):i*DFT_size/2));
waveform2 = reshape(waveform,DFT_size,poly_taps);
[channels(:,i,ii),p_elements(:,i)] = ...
offt_analysis(waveform2,poly_taps,Afilter);
channels(:,i,ii) = channels(:,i,ii) .* (exp(-sqrt(-
1)*pi*i*(0.5:1:DFT_size)'));
waveform3 = reshape(waveform,poly_taps*DFT_size,1);
channels2(:,i,ii) = fft(waveform3 .* Afilter);
channels3(:,i,ii) = fft(waveform3(1:DFT_size));
end
%
% Plot the cummulative power in each bin
%
figure(1)
chan_mesh = psdg(channels(1:DFT_size/2,:,ii)/sum(Afilter))';
spec1=dB(sum(chan_mesh(poly_taps:blocks,:))/(blocks-poly_taps+1));
plot(spec1)
title_var = sprintf('Cumulative OFFT Power Spectrum: Antenna #%g',ii);
title(title_var)
xlabel('Frequency Cells');
ylabel('Power (dB)');
grid;
tempaxis=axis;
axis([ 0 DFT_size/2 tempaxis(3:4)])
figure(2)
chan_mesh2 = psdg(channels2(1:DFT_size*poly_taps/2,:,ii)/sum(Afilter))';
spec2=dB(sum(chan_mesh2(poly_taps:blocks,:))/(blocks-poly_taps+1));
plot(spec2)
title_var = sprintf('Cumulative W-FFT Power Spectrum: Antenna #%g',ii);
title(title_var)
xlabel('Frequency Cells');
ylabel('Power (dB)');
grid;
tempaxis=axis;
axis([ 0 DFT_size*poly_taps/2 tempaxis(3:4)])
figure(4)
chan_mesh4 =
psdg(channels2((1+poly_taps/2):poly_taps:DFT_size*poly_taps/2,:,ii) ...
/sum(Afilter))';
spec4=dB(sum(chan_mesh4(poly_taps:blocks,:))/(blocks-poly_taps+1));
plot(spec4)
title_var = sprintf('Cumulative Decimated W-FFT Power Spectrum: Antenna
#%g',ii);
title(title_var)
xlabel('Frequency Cells');
ylabel('Power (dB)');
grid;
tempaxis=axis;
axis([ 0 DFT_size/2 tempaxis(3:4)])
drawnow; pause
figure(1);
plot(dB(chan_mesh));
axis([0 200 -100 0]);
grid;
figure(2);
plot(dB(chan_mesh2));
axis([0 200 -100 0]);
grid;
figure(3);
plot(dB(chan_mesh3));
axis([0 200 -100 0]);
grid;
figure(4);
plot(dB(chan_mesh4));
axis([0 200 -100 0]);
grid;
drawnow; pause
figure(2)
spec_full3=dB((abs( channels2(1:DFT_size*poly_taps/2,:,ii) )).^2);
spec_full4=spec_full3-max(max(spec_full3));
spec_frame2=(spec_full4>=-100);
spec_full4=spec_full4 .* spec_frame2 + (~spec_frame2) * (-100);
%pause
mesh(spec_full4)
title('Channelizer Output Power (in dB), -100 dB floor')
clear spec_full3 spec_full4 spec_frame2
figure(3)
spec_full=dB((abs( channels3(1:DFT_size/2,:,ii) )).^2);
spec_full2=spec_full-max(max(spec_full));
spec_frame=(spec_full2>=-100);
spec_full2=spec_full2 .* spec_frame + (~spec_frame) * (-100);
%pause
mesh(spec_full2)
title('Channelizer Output Power (in dB), -100 dB floor')
clear spec_full spec_full2 spec_frame
end
[wrow,wcol]=size(waveform);
num_samples = wrow*wcol;
if (length(filter_coef) ~= num_samples)
error('PP_analysis: filter and signal length mismatch')
end
DFT_size = num_samples/poly_taps;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Polyphase Filter %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Form a DFT_size x poly_samples matrix of the points
x_matrix = ((waveform));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Perform the OFFT %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
sample = offt(poly_elements,DFT_size);
if (nargin==1)
xform = length(x);
end
if (rem(log(xform)/log(2),1) ~= 0)
error('OFFT: The transform size is not a power of 2')
end
if (max(abs(imag(x)))) ~= 0
fprintf('OFFT: Taking the real part of the input data\n')
end
data=real(x);
% Odd-point packing
datapk = data(1:(xform/2)) - sqrt(-1)*data(((xform/2)+1):xform);
[2] P.P. Vaidyanathan, "Multirate Systems and Filter Banks," Prentice-Hall, Inc.,
Englewood Cliffs, N.J., 1993.