Skip to content Skip to navigation Skip to collection information

Connexions

You are here: Home » Content » From MATLAB and Simulink to Real-Time with TI DSP's » Spectrum Estimation

Navigation

Lenses

What is a lens?

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

This content is ...

Affiliated with (What does "Affiliated with" mean?)

This content is either by members of the organizations listed or about topics related to the organizations listed. Click each link to see a list of all content affiliated with the organization.

Also in these lenses

  • Lens for Engineering

    This module and collection are included inLens: Lens for Engineering
    By: Sidney Burrus

    Click the "Lens for Engineering" link to see all content selected in this lens.

Recently Viewed

This feature requires Javascript to be enabled.

Tags

(What is a tag?)

These tags come from the endorsement, affiliation, and other lenses that include this content.
Download
x

Download collection as:

  • PDF
  • EPUB (what's this?)

    What is an EPUB file?

    EPUB is an electronic book format that can be read on a variety of mobile devices.

    Downloading to a reading device

    For detailed instructions on how to download this content's EPUB to your specific device, click the "(what's this?)" link.

  • More downloads ...

Download module as:

  • PDF
  • EPUB (what's this?)

    What is an EPUB file?

    EPUB is an electronic book format that can be read on a variety of mobile devices.

    Downloading to a reading device

    For detailed instructions on how to download this content's EPUB to your specific device, click the "(what's this?)" link.

  • More downloads ...
Reuse / Edit
x

Collection:

Module:

Add to a lens
x

Add collection to:

Add module to:

Add to Favorites
x

Add collection to:

Add module to:

 

Spectrum Estimation

Module by: Jacob Fainguelernt. E-mail the author

Summary: This module describe the use of the DSK6713 for Spectrum Estimation. Simulink simulation models for different spectrum estimation methods. Those models are used afterwards to generated the DSP code. The user interfaces with the DSK6713 operation through a Graphic User Interface (GUI) running in a PC.

Introduction

In this module the DSK6713 will be used for spectrum estimation. Three estimation methods will be implemented:

  1. Periodogram
  2. Burg
  3. M-Cov

Periodogram

Figure 1
Figure 1 (periodogram_block.png)

The Periodogram block computes a nonparametric estimate of the spectrum. The block averages the squared magnitude of the FFT computed over windowed sections of the input and normalizes the spectral average by the square of the sum of the window samples.

The Modified Covariance Method

Figure 2
Figure 2 (modcovariancemethodicon.png)

The Modified Covariance Method block estimates the power spectral density (PSD) of the input using the modified covariance method. This method fits an autoregressive (AR) model to the signal by minimizing the forward and backward prediction errors in the least squares sense. The order of the all-pole model is the value specified by the Estimation order parameter. To guarantee a valid output, you must set the Estimation order parameter to be less than or equal to two thirds the input vector length. The spectrum is computed from the FFT of the estimated AR model parameters.

Burg Method

Figure 3
Figure 3 (burgmethodicon.png)

The Burg Method block estimates the power spectral density (PSD) of the input frame using the Burg method. This method fits an autoregressive (AR) model to the signal by minimizing (least squares) the forward and backward prediction errors while constraining the AR parameters to satisfy the Levinson-Durbin recursion.

Related Files

Simulation

The Environment

Figure 4 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 4: Spectrum Estimation Simulation
Figure 4 (graphics1.png)

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 5: The Random Source Object
    Figure 5 (graphics2.png)
  3. Double click on the random source object, and configure its parameters to fit the white noise characteristics we want to achieve:
    Figure 6: The Random Source Object Configuration
    Figure 6 (graphics3.png)
  4. Add a new digital filter to the model:
    Figure 7: The Digital Filter Block
    Figure 7 (graphics4.png)
  5. Double-click on the filter and fill in the following parameters1
    Figure 8: The Digital Filter Block Parameters
    Figure 8 (graphics5.png)
  6. Add the 3 estimators: Periodogram, Burg and Modified-Covariance to your model:
    Figure 9: The Burg Method Block
    Figure 9 (graphics6.png)
  7. Configure the FFT length of the three models to 1282:
    Figure 10: FFT Length Configuration for Spectrum Estimation
    Figure 10 (graphics7.png)
  8. Add a new constant to your model:
    Figure 11: The "DSP Constant" Block
    Figure 11 (graphics8.png)
  9. This constant will have the AR coefficients values:
    Figure 12: The AR coefficients values
    Figure 12 (graphics9.png)
  10. Add a magnitude FFT block in order to get the spectrum from the AR coefficients:
    Figure 13: The FFT Block
    Figure 13 (graphics10.png)
  11. Set the FFT length to 128:
    Figure 14: The FFT Length
    Figure 14 (graphics11.png)
  12. Add a new math function object:
    Figure 15: The Math Function Block
    Figure 15 (graphics12.png)
  13. The “Math Function” block should be configured to calculate the reciprocal:
    Figure 16: The "Math Function" Block Configuration
    Figure 16 (graphics13.png)
  14. 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 17: The Gain Block
    Figure 17 (graphics14.png)
  15. In order to display the Real and Estimated spectra simultaneously, you need to add a new concatenate object:
    Figure 18: The "Matrix Concatenate" Block
    Figure 18 (graphics15.png)
  16. Set the number of inputs of the concatenation object to 4:
    Figure 19: The "Matrix Concatenate" Block Configuration
    Figure 19 (graphics16.png)
  17. The various spectra will be displayed in a vector scope:
    Figure 20: The "Vector Scope" Block
    Figure 20 (graphics17.png)
  18. Select frequency as its input domain
    Figure 21: The "Vector Scope" Block Configuration
    Figure 21 (graphics18.png)
  19. Connect the blocks as shown:
    Figure 22: Spectrum Estimation Simulation
    Figure 22 (graphics19.png)
  20. When running the model3, you should see the get the following display:
    Figure 23: Comparing the various spectrum estimators
    Figure 23 (graphics20.png)

Real Time Implementation

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 24: Real Time Implementation Environment
Figure 24 (graphics21.png)

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 25: Real Spectrum Estimation Equipment
Figure 25 (graphics22.jpg)

Creating the Models

  1. Open the simulation model “SpectrumEstimation.mdl”.
  2. Remove the “Burg” and “MCov AR” estimators.
  3. Add the C6713DSK target to the model
    Figure 26: The C6713DSK target Block
    Figure 26 (graphics23.png)
  4. Replace the vector scope by the “Digital to Analog” converter (DAC)
    Figure 27: The DAC Block
    Figure 27 (graphics24.png)
  5. Configure the DAC block to a sampling rate to 8 KHZ and 16-bit samples.
    Figure 28: The DAC Block Configuration
    Figure 28 (graphics25.png)
  6. Double- click on the concatenation object and change the number of inputs from 4 to 2.
  7. Replace the white noise generator by the “Analog to Digital” converter (ADC).
    Figure 29: The ADC Block
    Figure 29 (graphics26.png)
  8. Configure the ADC blocks to a sampling rate to 8 KHZ and 16-bit samples.
    Figure 30: The ADC Block Configuration
    Figure 30 (graphics27.png)
  9. The final model should look as follows:
    Figure 31: Periodogram Real-Time Model
    Figure 31 (graphics28.png)
  10. Set the AR-coefficients data type to single.
  11. Configure the Model to generate and build (without executing) the CCS code as shown:
    Figure 32: Model Configuration
    Figure 32 (graphics29.jpg)
  12. Save the model as “Periodogram.mdl”
  13. Build the model (CTRL-B)
  14. Replace the Periodogram estimator block by the Burg estimator
  15. The final model should look as follows:
    Figure 33: Burg Real-Time Model
    Figure 33 (graphics30.png)
  16. Save the model as “Burg.mdl”
  17. Build the model (CTRL-B)
  18. Replace the Burg estimator block by the MCov AR estimator
  19. The final model should look as follows:
    Figure 34: MCov AR Burg Real-Time Model
    Figure 34 (graphics31.png)
  20. Save the model as “MCcov_AR.mdl”
  21. Build the model (CTRL-B)At this step you’ll have three .out files to be loaded to the DSK. Each one corresponding to an estimator.

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 35: Graphic User Interface (GUI)
Figure 35 (graphics32.png)
  1. Enter GUIDE in the MATLAB® command line.
  2. Choose a new GUI, and name it Spectrum
  3. 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. The GUI will perform the following tasks:
    • Upon activating the GUI, the default model is loaded to the DSP.
    • When the user selects a new model, it is loaded to the DSP.
  6. The initialization routine “Spectrum_OpeningFcn” will be:
    
    function Spectrum_OpeningFcn(hObject, eventdata, handles, varargin)
    modelName = gcs;
    %connect to target:
    CCS_Obj = connectToCCS(modelName);
    % Identify RTDX channel names/modes
    CodegenDir = fullfile(pwd, ['Periodogram' '_c6000_rtw']);
    OutFile = fullfile(CodegenDir, ['Periodogram' '.out']);
    %load the model to the DSK:
    CCS_Obj.load(OutFile,20);
    handles.CCS_Obj=CCS_Obj;
    handles.output = hObject;
    %remember the current model: 
    handles.last_model=1;
    CCS_Obj.run;     
    % Update handles structure
    guidata(hObject, handles);
    
  7. 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); 
    
    end
    
  8. When the user changes the model, the list-box handler function is invoked:
    
    function listbox1_Callback(hObject, eventdata, handles)
    handles.last_model=get(hObject,'Value') ;
    ChangeModel(handles.last_model,handles.CCS_Obj);
    guidata(hObject, handles);
    

The handler saves the new model as the current model and invokes the change model function we described above.

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

Footnotes

  1. The Auto-Regressive process is represented by an all-pole IIR filter. The AR coefficients are the ones in the “Denominator coefficients” label.
  2. The same configuration parameters apply for the three models.
  3. You should select a different color for each channel

Collection Navigation

Content actions

Download:

Collection as:

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

Module as:

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

Add:

Collection to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks

Module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks

Reuse / Edit:

Reuse or edit collection (?)

Check out and edit

If you have permission to edit this content, using the "Reuse / Edit" action will allow you to check the content out into your Personal Workspace or a shared Workgroup and then make your edits.

Derive a copy

If you don't have permission to edit the content, you can still use "Reuse / Edit" to adapt the content by creating a derived copy of it and then editing and publishing the copy.

| Reuse or edit module (?)

Check out and edit

If you have permission to edit this content, using the "Reuse / Edit" action will allow you to check the content out into your Personal Workspace or a shared Workgroup and then make your edits.

Derive a copy

If you don't have permission to edit the content, you can still use "Reuse / Edit" to adapt the content by creating a derived copy of it and then editing and publishing the copy.