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.
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.
Intermediate - Assumes prior knowledge of MATLAB and Simulink. It also requires a theoretical understanding of matrices and the LMS algorithm.
This laboratory was originally developed using the following hardware and software:
You will now start with a simple Simulink model and run it to see how it works.
Open the AcousticNoiseCancellation.mdl
![]() |
Run the model.
The output from the LMS Filter starts at zero and grows slowly. Initially, some of the sine wave information is lost as LMS Error.
![]() |
The LMS Filter Weights all start at zero and take several iterations to reach their final values.
![]() |
The critical variable in the LMS Filter is the “Step size (mu)”. This sets the rate of convergence of the LMS filter.
![]() |
Double-click on the “LMS Filter” block and change the “Step size (mu) to 0.1
Run the model.
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.
![]() |
Note that the filter weights (coefficients) do not attain smooth values, as would be the case for smaller values of Step size (mu).
![]() |
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.
![]() |
Experiment with different values of delay to see how it effects the operation of the LMS Filter.
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.
![]() |
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.
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.
![]() |
Alternatively, you can use computer loudspeakers.
Start Code Composer Studio for DSK6713 and use Debug -> Connect
Start MATLAB 7.3.0 R2006b:
![]() |
Click on “Demos”. The following screen will appear:
![]() |
Highlight “Embedded Target for TI C6000 DSP” then “Audio”. Click on “Wavelet Denoising”. We are going to use this as our template.
The “Wavelet Denoising” model is now displayed.
![]() |
For convenience, save the model to the MATLAB “Work” directory, where most models are stored.
![]() |
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.
![]() |
Double-click on the “function()” box. The “Wavelet Noise Reduction Algorithm” model is now displayed.
![]() |
Delete the blocks and connect the input directly to the output. Add a title.
![]() |
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.
![]() |
Double-click on the blue box to the left marked “DSK6713 ADC”. The following screen will appear.
![]() |
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 need to match those of the ADC. Check that it uses the same sampling rates. Click on “OK”.
![]() |
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.
![]() |
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.
![]() |
From the “Signal Processing Blockset”, highlight “Signal Operations”. Drag-and-drop the “Delay”1 block onto the model.
![]() |
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.
![]() |
So we can hear the difference without LMS denoising and with LMS noise reduction, we will use a DIP switch of the DSK6713.
![]() |
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.
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”.
![]() |
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.
![]() |
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”.
![]() |
Click on the “Signal Data Types” tab. Set the “Output data type mode” to “int16”. This is compatible with the DAC on the DSK6713.
![]() |
Double click on the “Relational Operator” block. Change the “Relational operator” to “==”. Click on the “Signal Data Types” tab.
![]() |
Set the “Output data type mode” to “Boolean”. Click on “OK”.
![]() |
Move the blocks and join them as shown in the Figure below.
![]() |
From the Toolbar, select the “Up Arrow” icon. This returns you to the next higher level.
![]() |
Select Tools -> Real-Time Workshop -> Build Model.
![]() |
When built, the single lines are replaced by double lines. This shows frames.
![]() |
From the folders on the left, select the source code for the project.
![]() |
To check out the microphone and loudspeakers, set the DIP switches on the DSK6713 as follows:
![]() |
The microphone is fed directly to the loudspeakers. There is no LMS noise reduction.
To run the “LMS Noise Reduction” subsystem, set the DIP switch to 1.
![]() |
You may wish to experiment with different settings. Here are some suggestions.
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.
![]() |
Try different value of “Filter Length”. What is the minimum value that will allow the filter to work correctly?
Inside the “Adaptive Filters” are different LMS types. Which are suitable for LMS denoising and which are not?
![]() |
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.