Presentation is loading. Please wait.

Presentation is loading. Please wait.

DSP C5000 Chapter 16 Adaptive Filter Implementation Copyright © 2003 Texas Instruments. All rights reserved.

Similar presentations


Presentation on theme: "DSP C5000 Chapter 16 Adaptive Filter Implementation Copyright © 2003 Texas Instruments. All rights reserved."— Presentation transcript:

1 DSP C5000 Chapter 16 Adaptive Filter Implementation Copyright © 2003 Texas Instruments. All rights reserved.

2 ESIEE, Slide 2Outline Adaptive filters and LMS algorithm Adaptive filters and LMS algorithm Implementation of FIR filters on C54x Implementation of FIR filters on C54x Implementation of FIR filters on C55x Implementation of FIR filters on C55x

3 Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 3 Generalities of Adaptive Filters  The coefficients of Adaptive filters are variable with time in order to optimize a given criterion.  The most commonly used algorithm to adapt the coefficients is the LMS (Least Mean Square) algorithm.  Most adaptive filters are implemented as FIR filters, because they are inherently stable.  They are widely used in digital communications:  Echo cancellation, equalizers...

4 Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 4 Diagram and Notations of Adaptive Filters

5 Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 5 Mean Square Error Solution

6 Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 6 Gradient Algorithm  Gradient of criterion J vs b:  Gradient algorithm: iterative solution  Converges if: Adaptation step Max Eigenvalue of R x

7 Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 7 Stochastic Gradient Algorithm: LMS  The mean values E(e(n)x(n-i)) are not known.  In the stochastic gradient algorithm, they are replaced by e(n)x(n-i).  The algorithm converges if the adaptation step is small enough.  Algorithm named: LMS (Least Mean Square) or Widrow algorithm:

8 Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 8 LMS Algorithm  For each sample, the LMS algorithm:  Filters the input using b i  Updates the b i coefficients.

9 Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 9 LMS Algorithm at Each Sample Time  FIR Filtering equation:  Coefficient updating equation:

10 Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 10 Fixed Point Implementation  When LMS adaptive filter is implemented on a fixed point DSP:  The precision of calculation is important:  If rnd(e i *x n-i ) is smaller than the used precision, no adaptation is performed.  The precision of convergence depends on:  Adaptation step  : the largest , the fastest convergence but the worst precision.  The number of coefficients N: the residual error is proportional to N.  When N is too large, it may be worth considering using block adaptive filtering.

11 Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 11 LMS steps  Each time iteration (only once):  Calculates error e n =r n -y n  Scale error by adaptation step  : e’ n =  e n.  Each time iteration, for each coefficient:  Multiply error with signal: e i = e’ n x n-i  Multiply x n-i b i and accumulate  Calculate new coefficients: newb i = b i +e i  Update coefficients: b i = newb i.

12 Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 12 Implementing LMS Algorithm on C54x  LMS specific instruction to realize:  Filter and coefficient updating.  B = B + (b i *x n-i ); A = rnd(e i +b i )  Rounding is important because  may be very small.  Filter and coefficients updating equations:  To be done at each sample time n:

13 Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 13 LMS instruction  With LMS instruction, LMS FIR:  2N Cycles per tap.  LMS Xmem, Ymem  (A) + (Xmem)<<16+2 15  A  (B) + (Xmem) x (Ymem)  B  Uses both ACCUs A and B.  This instruction does not modify T.  Xmem points on b i, Ymem on x n-i  Data x are stored in a circular buffer.

14 Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 14 Example of LMS adaptive filter on C54x  Defines 2 sections for data and coefficients

15 Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 15 Implementing LMS Algorithm on C54x  Initializations

16 Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 16 Implementing LMS Algorithm on C54x  LMS adaptive filter program:

17 Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 17 Implementating LMS algorithm on C55x  LMS specific instruction to realize:  Filter and coefficicent updating.  ACy = ACy + (b i *x n-i ); ACx = rnd(e i +b i )  Rounding is important because  may be very small.  Filter and coefficients updating equations:  To be done at each sample time n:

18 Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 18 Example of LMS adaptive filter on C55X Pre-calculate  *e(n).... AR3 pts to coeff table: a[n] AR4 pts to data table: x[n] T3 holds error step amount... while loading BRCO AC0=error*oldestsample: x(n-N) …while clearing AC1 (run FIR) Overwrite x(n-N) with x(n) Start FIR, update oldest coef… … and start repeat block Store update coefficient......while calc. next update term Calc FIR, update coefficient Store final coefficient... …while storing FIR output

19 Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 19 Follow on Activities  Application 10 for TMS320C5416 DSK  Implements a guitar tuner using an adaptive filter. Here the desired note is used as the reference. The LEDs on the DSK indicate when the guitar is tune.


Download ppt "DSP C5000 Chapter 16 Adaptive Filter Implementation Copyright © 2003 Texas Instruments. All rights reserved."

Similar presentations


Ads by Google