You are on page 1of 9

SPECTRUM ESTIMATION

Tudor AVRAM

Madalina MOISA

Universitatea Tehnic din Cluj-Napoca, Bulevardul 21 Decembrie 1989 128-130, Cluj-Napoca


Tel. 0264-401223
Fax: 0264-591689 e-mail: Dan.Pitica@ael.utcluj.ro
Abstract: The goal of this project is to present the DSK6713 and its uses in spectrum
estimation. The spectrum is estimated using three methods, The Burg method, The modified
covariance method and the periodogram method and to compare the results with a reference
.spectrum

1. Introduction

an autoregressive (AR) model to the signal by

In this chapter we will use the DSK6713 for

minimizing the forward and backward prediction

spectrum estimation. Three estimation methods will

errors in the least squares sense. The order of the

be implemented:

all-pole model is the value specified by the

i.

Periodogram

Estimation order parameter. To guarantee a valid

ii. Burg

output, you must set the Estimation order parameter

iii. M-Cov

to be less than or equal to two thirds the input


vector length. The spectrum is computed from the

1.1.

Periodogram

FFT of the estimated AR model parameters.

1.3.Burg Method

The Periodogram block computes a nonparametric


estimate of the spectrum. The block averages the

The Burg Method block estimates the power

squared magnitude of the FFT computed over

spectral density (PSD) of the input frame using the

windowed sections of the input and normalizes the

Burg method. This method fits an autoregressive

spectral average by the square of the sum of the

(AR) model to the signal by minimizing (least

window samples.

squares) the forward and backward prediction


errors while constraining the AR parameters to

1.2.The Modified Covariance


Method

The Modified Covariance Method block estimates


the power spectral density (PSD) of the input using
the modified covariance method. This method fits

satisfy the Levinson-Durbin recursion.

2. Simulation

3.

Double click on the random source object,


and configure its parameters to fit the white

2.1.The Environment

noise characteristics we want to achieve:

Figure 1 shows the data flow for the Estimation


simulation. The input signal for the estimator is an
AR process generated by feeding an all-poles filter
with white noise. The AR coefficients generate the
reference spectrum to be compared against the
estimated one.

Figure 3- The Random Source Object


Configuration
4.

Add a new digital filter to the model:

Figure 1- Spectrum Estimation Simulation

2.2.The Procedure
1.

Create a new model in Simulink and name


it: SpectrumEstimation.mdl

2.

Open the Simulink library browser and add a


random source object:
Figure 4- The Digital Filter Block

Figure 2- The Random Source Object

5.

Double-click on the filter and fill in the


following parameters1

Figure 7- FFT Length Configuration for Spectrum


Estimation2
8.

Add a new constant to your model:

Figure 5- The Digital Filter Block Parameters


6.

Add the 3 estimators: Periodogram, Burg and


Modified-Covariance to your model:

Figure 8- The "DSP Constant" Block


9.

This constant will have the AR coefficients


values:

Figure 6- The Burg Method Block

7.

Configure the FFT length of the three models


to 128:

Figure 9- The AR coefficients values

1 The Auto-Regressive process is represented by an allpole IIR filter. The AR coefficients are the ones in the
Denominator coefficients label.

The same configuration parameters apply for the three 2


.models

10. Add a magnitude FFT block in order to get


the spectrum from the AR coefficients:

13.

Add a new gain to your model (to

represent the white noise variance in the


reference spectrum generation) and set its
value to 0.1:

Figure 10- The FFT Block


11. Set the FFT length to 128:
Figure 14- The Gain Block
14. In order to display the Real and Estimated
spectra simultaneously, you need to add a
new concatenate object:

Figure 11- The FFT Length


12. Add a new math function object:

Figure 15- The "Matrix Concatenate" Block


and set the number of inputs of the concatenation
object to 4:
Figure 12- The Math Function Block
The Math Function block should be configured
to calculate the reciprocal:

Figure 13- The Math Function Block Configuration

Figure 16- The "Matrix Concatenate" Block


Configuration

15. The various spectra will be displayed in a

16. Connect the blocks as shown in Figure 19:

vector scope:

Figure 17- The "Vector Scope" Block


Select frequency as its input domain:
Figure 19 Spectrum Estimation Simulation Model
17. When running the model3, you should see the
get the following display:

Figure 20 Comparing the various spectrum


estimators

Figure 18- The "Vector Scope" Block


Configuration

You should select a different color for each channel 3

3. Real Time Implementation


3.1.The Environment
Figure 21 shows the block-diagram for the real
time implementation. The DSP will deliver two
outputs. The first is the reference spectrum; the
second is an estimated spectrum of the output of
the all-pole filter. Three real-time models will be
created, each one corresponding to an estimator.
The user will be able to select the desired estimator
through a Graphic User Interface (GUI).
Figure 22- Spectrum Estimation Equipment

3.2.Creating the Models


1

Open the simulation model


SpectrumEstimation.mdl.

1. Remove the Burg and MCov AR


estimators.
Figure 21- Real Time Implementation Environment

2. Add the C6713DSK target to the model

The real-time implementation model will be


created from the simulation model, after the
following changes:

The noise generator block will be replaced


by the CODEC of the DSK6713

The virtual scope will be replaced also by


the CODEC

A target definition block (DSK6713) will


be added.

Equipment Used:

DSK6713

Dual Channel Oscilloscope

Signal Generator

Figure 23- The C6713DSK target Block


3. Replace the vector scope by the Digital to
Analog converter (DAC)

Figure 24- The DAC Block


4. Configure the DAC block to a sampling rate to
8 KHZ and 16-bit samples.

Figure 25- The DAC Block Configuration


Figure 27- The ADC Block Configuration
5. Double- click on the concatenation object and
change the number of inputs from 4 to 2.

The final model should look as follows:

6. Replace the white noise generator by the


Analog to Digital converter (ADC).

Figure 28 Periodogram Real-Time Model


Figure 26- The ADC Block
7. Configure the ADC blocks to a sampling rate
to 8 KHZ and 16-bit samples.

8. Set the AR-coefficients data type to single.

9. Configure the Model to generate and build


(without executing) the CCS code as shown:

19.

Build the model (CTRL-B)

20.

Replace the Burg estimator block

by the MCov AR estimator


21.

The final model should look as

follows:

Figure 31 MCov ARBurg Real-Time Model


22.

Save the model as

MCcov_AR.mdl
Figure 29 Model Configuration

14. Build the model (CTRL-B)

10. Save the model as Periodogram.mdl


11. Build the model (CTRL-B)
12. Replace the Periodogram estimator block by

At this step youll have three .out files to be


loaded to the DSK. Each one corresponding to an
estimator.

the Burg estimator


13. The final model should look as follows:

3.3.The Graphic User Interface


(GUI)
The GUI shown in Figure 32 will be used to select
the model. Upon selecting a model, its
correspondent load file will be loaded to the DSP.

Figure 30 Burg Real-Time Model


18.

Save the model as Burg.mdl


Figure 32- GUI

7
1

Enter GUIDE in the MATLAB command


line.

Choose a new GUI, and name it Spectrum

Add a list-box to your GUI with the string:

Periodogram
Burg
M-Cov
4

A script file spectrum.m will open, when


you press the play button. Name the
script spectrum.m

5
i.

The GUI will perform two tasks:

Selecting a new model:

%1. halts the current model


%2. loads the current model
%inputs:
%m - 3 levels flag that tells which
model to load.
%CCS_Obj - the target object
function ChangeModel(m,CCS_Obj)
CCS_Obj.halt;
switch m
case 1
model='Periodogram';
case 2
model='Burg';
case 3
model= 'MCov_AR';
end
CodegenDir = fullfile(pwd, [model
'_c6000_rtw']);
OutFile = fullfile(CodegenDir, [model
'.out']);
CCS_Obj.load(OutFile,20);
CCS_Obj.run;
if last_y~=15000
r.writemsg(chan_struct(2).name,1/last
_y);

Upon activating the GUI, the

end

default model is loaded to the DSP.


ii.

When the user selects a new


model, it is loaded to the DSP.
6

When the user changes the model, the list-box


handler function is invoked:

function listbox1_Callback(
handles.last_
ChangeModel(handles.

The initialization routine


Spectrum_OpeningFcn will be:

function Spectrum_OpeningFcn(hObject, eventdata, handles, varargin)

The handler saves the new model as the current


CodegenDir = fullfile(pwd,
[ invokes
model and
OutFile = fullfile(CodegenDir, [

the change model function we

described above.
Now you can run the model, and observe the results
.in the oscilloscope for the various estimators

You might also like