Skip to content Skip to navigation Skip to collection information

OpenStax-CNX

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

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.
 

Acoustic Noise Cancellation

Module by: Jacob Fainguelernt. E-mail the author

Summary: The Least Mean Squares (LMS) Algorithm can be used in a range of Digital Signal Processing applications such as echo cancellation and acoustic noise reduction. This laboratory shows how to design a model of LMS Noise Cancellation using Simulink and run it on a Texas Instruments C6000 DSP.

Introduction

The Least Mean Squares (LMS) Algorithm can be used in a range of Digital Signal Processing applications such as echo cancellation and acoustic noise reduction.

This laboratory shows how to design a model of LMS Noise Cancellation using Simulink and run it on a Texas Instruments C6000 DSP.

Objectives

  • Design a model of LMS Noise Reduction for the Texas Instruments C6000 family of DSP devices using MATLAB® and Simulink®.
  • Modify an existing Simulink demonstration model for use as a template.
  • Run the project on the Texas Instruments DSK6713 with a microphone and computer loudspeakers / headphones.

Level

Intermediate - Assumes prior knowledge of MATLAB and Simulink. It also requires a theoretical understanding of matrices and the LMS algorithm.

Hardware and Software Requirements

This laboratory was originally developed using the following hardware and software:

  • MATLAB R2006b with Embedded Target for TI C6000 and the Signal Processing Toolbox.
  • Code Composer Studio (CCS) v3.1
  • Texas Instruments DSK6713 hardware.
  • Microphone and computer loudspeakers / headphones.

Related Files

Simulation

You will now start with a simple Simulink model and run it to see how it works.

Opening the Acoustic Noise Cancellation Model

Open the AcousticNoiseCancellation.mdl

Figure 1: Opening the AcousticNoiseCancellation Model
Figure 1 (graphics1.jpg)

Run the model.

Inputs and Outputs of LMS Filter

The output from the LMS Filter starts at zero and grows slowly. Initially, some of the sine wave information is lost as LMS Error.

Figure 2: LMS Filter Inputs and Outputs
Figure 2 (graphics2.jpg)

LMS Filter Weights (Coefficients)

The LMS Filter Weights all start at zero and take several iterations to reach their final values.

Figure 3: LMS Filter Weights (Coefficients)
Figure 3 (graphics3.jpg)

Tuning the Model

The critical variable in the LMS Filter is the “Step size (mu)”. This sets the rate of convergence of the LMS filter.

Figure 4: Changing the Step size (mu) to 0.1
Figure 4 (graphics4.jpg)

Double-click on the “LMS Filter” block and change the “Step size (mu) to 0.1

Run the model.

Filter Outputs for Step size (mu) = 0.1

When the “Step size (mu)” is increased, LMS algorithm converges more quickly, but at the expense of granularity – the LMS Filter Output is not as smooth.

Figure 5: Input and LMS Filter Outputs for Step size (mu) = 0.1
Figure 5 (graphics5.jpg)

Filter Weights for Step size (mu) = 0.1

Note that the filter weights (coefficients) do not attain smooth values, as would be the case for smaller values of Step size (mu).

Figure 6: LMS Filter Weights for Step size (mu) = 0.1
Figure 6 (graphics6.jpg)

Changing the Delay

Part of the Acoustic Noise Algorithm is the delay. The delay should ideally be at least half a wavelength so the two inputs to the LMS Filter have different random noise.

Figure 7: Changing the Delay
Figure 7 (graphics7.jpg)

Experiment with different values of delay to see how it effects the operation of the LMS Filter.

Changing the Number of Weights

Double-click on the “LMS Block” and change the Filter Size (number of Weights).

If the number of Weights is large, the algorithm will be slow to run.

If the number of Weights is too small, the filter will not remove the noise properly.

Figure 8: Changing the Filter Length
Figure 8 (graphics8.jpg)

Summary

From practical experience, you should now know how to use LMS algorithm and how you can adjust the Step size (mu), the filter delay and the number of weights to obtain optimum performance.

You will now apply this to building a real-time model.

Real-Time Model

You have now run the simulation and understand the operation of the LMS Filter.

You will now implement the Real-Time Acoustic Noise Cancellation Model using the Texas Instrument C6713.

Texas Instruments DSK6713 Setup

Figure 9: Texas Instruments DSK6713 Setup
Figure 9 (fig9.jpg)

Alternatively, you can use computer loudspeakers.

Starting up Code Composer Studio

Connecting the DSK6713

Start Code Composer Studio for DSK6713 and use Debug -> Connect

Figure 10: Startup Screen for Code Composer Studio (CCS)
Figure 10 (fig10.JPG)

Opening an Existing Model

Start MATLAB 7.3.0 R2006b:

Figure 11: Opening an Existing Demo
Figure 11 (graphics11.png)

Click on “Demos”. The following screen will appear:

Figure 12: Selecting the Audio Demo Models
Figure 12 (graphics12.jpg)

Highlight “Embedded Target for TI C6000 DSP” then “Audio”. Click on “Wavelet Denoising”. We are going to use this as our template.

Viewing the Original Model

The “Wavelet Denoising” model is now displayed.

Figure 13: Wavelet Denoising Parent
Figure 13 (graphics13.jpg)

Saving the Model

For convenience, save the model to the MATLAB “Work” directory, where most models are stored.

Figure 14: Saving the Model to the MATLAB “Work” directory
Figure 14 (graphics14.jpg)

Changing the Title

Delete the “Info” box. Change the title to “LMS Noise Reduction”. You may also wish to move the “DSK6713” icon to the left hand side.

Figure 15: LMS Noise Reduction Parent
Figure 15 (graphics15.jpg)

The Original Wavelet Noise Reduction Algorithm

Double-click on the “function()” box. The “Wavelet Noise Reduction Algorithm” model is now displayed.

Figure 16: Wavelet Denoising Algorithm
Figure 16 (graphics16.jpg)

Delete Blocks

Delete the blocks and connect the input directly to the output. Add a title.

Figure 17: LMS Denoising Algorithm Template
Figure 17 (graphics17.jpg)

Overview of the LMS Model

We are going to implement the model shown below.

We will now update the empty model by dragging-and-dropping some library components onto the model.

Figure 18: Overview of the LMS Algorithm
Figure 18 (graphics18.jpg)

Changing the Input to Microphone

Double-click on the blue box to the left marked “DSK6713 ADC”. The following screen will appear.

Figure 19: Setting up the ADC for Mono Microphone Input
Figure 19 (graphics19.jpg)

Change the “ADC source” to “Mic In”.

If you have a quiet microphone, select “+20dB Mic gain boost”.

Set the “Sampling rate (Hz)” to “48 kHz”.

Set the “Samples per frame” to 64.

When done, click on “OK”.

Important: Make sure the “Stereo” box is empty.

The DAC Settings

The DAC settings need to match those of the ADC. Check that it uses the same sampling rates. Click on “OK”.

Figure 20: Setting the DAC Parameters
Figure 20 (graphics20.jpg)

Adding an LMS Block

The Simulink block for LMS is to be found in the “Signal Processing Toolbox”.

Select View -> Library Browser -> Signal Processing Blockset ->Filtering-> Adaptive Filters.

Highlight “Adaptive Filters”. Drag-and-drop the “LMS Filter” block onto the model.

Figure 21: Adding an LMS Filter Block
Figure 21 (graphics21.png)

Setting the LMS Filter Parameters

The most critical variable in an LMS filter is the “Step size (mu)”.

If “mu” is too small, the filter has very fine resolution, but reacts too slowly to the audio signal.

If “mu” is too great, the filter reacts very quickly, but the error also remains large.

We will start with 0.005.

Figure 22: Setting the Parameter “Set size (mu)”
Figure 22 (graphics22.jpg)

Adding a Delay

From the “Signal Processing Blockset”, highlight “Signal Operations”. Drag-and-drop the “Delay”1 block onto the model.

Figure 23: Adding a Delay
Figure 23 (graphics23.png)

Setting the Delay Parameters

Because we are working with frames of 64 samples, it is convenient configure the delay using frames. Double-click on the “Delay” block.

Change the “Delay units” to Frames.

Set the “Delay (frames)” to 1. This makes the delay 64 samples.

Figure 24: Setting the Delay Size
Figure 24 (graphics24.jpg)

Adding a DIP Switch and LED

So we can hear the difference without LMS denoising and with LMS noise reduction, we will use a DIP switch of the DSK6713.

Figure 25: Adding a Switch and LED
Figure 25 (graphics25.png)

Select View -> Library Browser -> Embedded Target for TI C6000 DSP. Highlight “DSK6713 Board Support”.

Drag-and-drop the “Switch” block onto the model. Also drag-and-drop the “LED” block onto the model.

DIP Switch Settings

The DIP switch needs to be configured. Double-click on the “Switch” block.

Select all the boxes and set “Data type” to Integer. The “Sample time” should also be set to “–1”.

Figure 26: Setting up the DIP Switch Values
Figure 26 (graphics26.jpg)

Adding a Constant, Switch and Relational Operator

We now need to setup a way to switch between straight through without noise reduction and with LMS noise reduction.

Select View -> Library Browser -> Simulink. Highlight “Commonly Used Blocks”.

Drag-and-drop a “Constant” onto the model.

Drag-and-drop a “Switch” block onto the model.

Drag-and-drop a “Relational Operator” block onto the model.

Figure 27: Selecting the Commonly Used Blocks
Figure 27 (graphics27.png)

Setting the Constant Value

The switch values lie between 0 and 15. We will use switch values 0 and 1. Double-click on the “Constant” block. Set the “Constant value” to 1 and the “Sample time” to “inf”.

Figure 28: Setting the Echo Delay Gain
Figure 28 (graphics28.jpg)

Setting the Constant Data Type

Click on the “Signal Data Types” tab. Set the “Output data type mode” to “int16”. This is compatible with the DAC on the DSK6713.

Figure 29: Data Type Conversion to 16-bit Integer
Figure 29 (graphics29.jpg)

Setting the Relational Operator Type

Double click on the “Relational Operator” block. Change the “Relational operator” to “==”. Click on the “Signal Data Types” tab.

Figure 30: Changing the Relational Operator
Figure 30 (graphics30.jpg)

Setting the Relational Operator Data Type

Set the “Output data type mode” to “Boolean”. Click on “OK”.

Figure 31: Changing the Output Data Type
Figure 31 (graphics31.jpg)

Joining the Blocks

Move the blocks and join them as shown in the Figure below.

Figure 32: Joining the Blocks
Figure 32 (graphics32.jpg)

Returning to the Parent System

From the Toolbar, select the “Up Arrow” icon. This returns you to the next higher level.

Figure 33: Returning to the Parent System
Figure 33 (graphics33.jpg)

Building the Model

Selecting Real-Time Workshop

Select Tools -> Real-Time Workshop -> Build Model.

Figure 34: Building the Model
Figure 34 (graphics34.jpg)

Frames Displayed on Model

When built, the single lines are replaced by double lines. This shows frames.

Figure 35: Frames
Figure 35 (graphics35.jpg)

The Completed Model Running on Code Composer Studio

From the folders on the left, select the source code for the project.

Figure 36: The Completed Model Running in Code Composer Studio
Figure 36 (fig36.jpg)

Different Settings on the DSK6713

Microphone Straight Through to Loudspeakers

To check out the microphone and loudspeakers, set the DIP switches on the DSK6713 as follows:

Figure 37: Switch Position 0
Figure 37 (fig37.jpg)

The microphone is fed directly to the loudspeakers. There is no LMS noise reduction.

Switch Position for LMS Noise Reduction

To run the “LMS Noise Reduction” subsystem, set the DIP switch to 1.

Figure 38: Switch Position 1 for LMS Noise Reduction
Figure 38 (fig38.jpg)

Some Things to Try

You may wish to experiment with different settings. Here are some suggestions.

Experiment with LMS Filter Settings

Change the value of “Step size (mu)” between 0.0001 and 0.5. This is the critical value.

Low values of mu give good resolution, but a slow reaction time.

High values of mu give less resolution, but faster reaction times.

Find the best value of mu for noise reduction on the TI DSK6713.

Figure 39: Configuring the LMS Filter Block Parameter
Figure 39 (graphics39.jpg)

Experiment with LMS Filter Settings

Try different value of “Filter Length”. What is the minimum value that will allow the filter to work correctly?

Change from LMS Filter to RLS Filter

Inside the “Adaptive Filters” are different LMS types. Which are suitable for LMS denoising and which are not?

Figure 40: Available Adaptive Filter Types
Figure 40 (graphics40.png)

Figure 40 –

MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See www.mathworks.com/trademarks for a list of additional trademarks. Other product or brand names may be trademarks or registered trademarks of their respective holders.

Footnotes

  1. Since we are working with frames, the delay from “Discrete Components” library will not work!

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 | 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