📄 exp8.html
字号:
system identification system using LMS algorithm.</p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'><imgborder=0 width=554 height=384 id="_x0000_i1027" src="exp8/fe8-1.jpg"></p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'>FigureE8-1 Block diagram of an LMS adaptive system identification</p><p style='margin-right:72.0pt;margin-left:72.0pt'>Our experiment uses anlowpass filter as the unknown system. This lowpass filter is identical to theone used in Chapter 5. It is defined by the filter coefficients <ahref="exp8/lp_coef.dat"><span style='font-family:"Courier New"'>LP_coef.dat</span></a>and implemented in C55x assembly language, <a href="exp8/fir_filt.asm"><spanstyle='font-family:"Courier New"'>fir_filt.asm</span></a>. </p><p style='margin-right:72.0pt;margin-left:72.0pt'>The LMS adaptive filter <ahref="exp8/adaptive.asm"><span style='font-family:"Courier New"'>adaptive.asm</span></a>is implemented in the C55x assembly language. It consists of two blocks, ablock FIR filter and the LMS adaptation algorithm, see Table E8-2.</p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'>TableE8-2 List of <span style='font-family:"Courier New"'>adaptive.asm</span></p><form><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'><TEXTAREA ROWS="7" COLS="70" NAME="adaptive.asm">; ; adaptive.asm - Adaptive filter for system identification ; ; Prototype: unsigned int adaptive(int *in, int *d, int *x, int *w, ;		 unsigned int Ns, unsigned int N, unsigned int index) ; ; Entry: in[] - input signals ; d[] - reference signal ; x[] - adaptive filter delay-line buffer ; w[] - adaptive filter coefficient array ; Ns - number of samples per block ; N - order of the adaptive filter ; index - index to x[] ; ; Return: T0 = Adaptive filter delay-line buffer index ; TWOMU .set 0x1000 ; 2*MU .def _adaptive .sect "lms_code" 	 _adaptive: pshm ST1_55 ; Save ST1, ST2, and ST3 pshm ST2_55 pshm ST3_55 	 mov mmap(AR3),BSA45 mov mmap(T1),BK47 mov mmap(AR2),BSA23 mov mmap(T1),BK03 mov AR4,AR3 ; AR3 -> x[] as circular buffer mov #0,AR4 ; AR4 -> w[] as circular buffer 			 or #0x340,mmap(ST1_55); Set FRCT,SXMD,SATD or #0x18,mmap(ST2_55) ; Enable circular addressing mode bset SATA ; Set SATA sub #1,T0 mov mmap(T0),BRC0 ; Set Sample block loop counter sub #2,T1 mov mmap(T1),BRC1 ; Counter for LMS update loop mov mmap(T1),CSR ; Counter for FIR filter loop		 rptblocal loop-1 ; for (n=0; n<Ns; n++) mov *AR0+,*AR3 ; x[n]=in[n] mpym *AR3+,*AR4+,AC0 ; temp = w[0]*d[0] || rpt CSR ; for (i=0; i<N-1; i++) macm *AR3+,*AR4+,AC0 ; y += w[i]*x[i] sub *AR1+ <<#16,AC0 ; AC0=-e=y-d[n], AR1 points to d[n] mpyk #-TWOMU,AC0 mov rnd(hi(AC0)),mmap(T1); T1=2*mu*e[n] rptblocal lms_loop-1 ; for(j=0; i<N-2; i++) mpym *AR3+,T1,AC0 ; AC0=2*mu*e*x[i] add *AR4<<#16,AC0 ; w[i]+=2*mu*e*x[i] mov rnd(hi(AC0)),*AR4+ lms_loop mpym *AR3,T1,AC0 ; w[N-1]+=2*mu*e*x[N-1] add *AR4<<#16,AC0 mov rnd(hi(AC0)),*AR4+ ; Store the last w[N-1] loop popm ST3_55 ; Restore ST1, ST2, and ST2 popm ST2_55 popm ST1_55	 mov AR3,T0 ; Return T0=index || ret 	 .end </TEXTAREA></p></form><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'> </p><p style='margin-right:72.0pt;margin-left:72.0pt'>Table E8-3 sows the excitingsignal source used for the experiment is a random number generator <ahref="exp8/random.c"><span style='font-family:"Courier New"'>random.c</span></a>.The input signal is fed into the unknown system and the adaptive filter at thesame time. The output of the unknown system is used as the desired signal forthe adaptive filter. </p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'>TableE8-3 Random number generator</p><form><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'><TEXTAREA ROWS="7" COLS="70" NAME="random.c">/* 	random.c - Zero-mean random noise */ #define USE_DATA 0 #if USE_DATA /* Use random data file as input */ #pragma CODE_SECTION(random, "lms_code"); #pragma DATA_SECTION(randdata, "lms_data"); #pragma DATA_SECTION(i, "lms_cinit"); #include "randdata.dat" static unsigned int i=0; void random(int *x, unsigned int N) { unsigned int t; for (t=N; t>0; t--) { *x++ = randdata[i]; i++; if (i == 10000) i=0; } } #else /* Use random function for input */ #include <math.h> #pragma CODE_SECTION(random, "lms_code"); void random(int *x, unsigned int N) { unsigned int t; for (t=N; t>0; t--) *x++ = rand(0x1955)-0x4000; } #endif </TEXTAREA></p></form><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'> </p><p style='margin-right:72.0pt;margin-left:72.0pt'>After the adaptive systemreaches its steady-state, the adaptive filter coefficients <spanstyle='font-family:"Courier New"'>w[]</span> can be used to approximate theimpulse response of the unknown system. The experiment is controlled by the Cfunction <a href="exp8/exp8a.c"><span style='font-family:"Courier New"'>exp8a.c</span></a>,listed in Table E8-4.</p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'>TableE8-4 List of <span style='font-family:"Courier New"'>exp8.c</span></p><form><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'><TEXTAREA ROWS="7" COLS="70" NAME="exp8a.c">/* exp8a.c - Experiment 8A System identification using LMS adaptive filter */ #include "LP_coef.dat" #define N0 48 /* Adaptive filter order */ #define N1 48 /* Unknown filter order */ #define Ns 128 /* Number of input signal */ #pragma CODE_SECTION(main, "lms_code"); #pragma DATA_SECTION(fir_index, "lms_data"); #pragma DATA_SECTION(sys_index, "lms_data"); #pragma DATA_SECTION(w, "lms_coef"); #pragma DATA_SECTION(d_sys, "lms_data"); #pragma DATA_SECTION(d_fir, "lms_data"); #pragma DATA_SECTION(in, "lms_in"); #pragma DATA_SECTION(d, "lms_out"); extern unsigned int fir_filt(int *, unsigned int, int *, unsigned int, int *, int *, unsigned int); extern unsigned int adaptive(int *, int *, int *, int *, unsigned int, unsigned int, unsigned int); extern void init(int *, unsigned int); extern void random(int *, unsigned int); int w[N0], /* Adaptive filter coefficients */ d_sys[N0], /* Adaptive filter delayed sample buffer */ d_fir[N1], /* Unknown system delayed sample buffer */ in[Ns], /* Input sample buffer */ d[Ns]; /* Unknown system output buffer */ unsigned int fir_index,sys_index; void main() { init(w,N0); /* Initialize adaptive filter coefficients */ init(d_sys,N0); /* Initialize adaptive filter delay-line */ init(d_fir,N1); /* Initialize unknown filter delay-line */ fir_index=0; /* Init the unknown filter delay-line index */ sys_index=0; /* Init the adaptive filter delay-line index */ for (;;) /* Generate samples to both filter and */ { /* identify unknown system */ random(in,Ns); fir_index=fir_filt(in,Ns,LP_coef,N1,d,d_fir,fir_index); sys_index=adaptive(in,d,d_sys,w,Ns,N0,sys_index); } } </TEXTAREA></p></form><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'> </p><p style='margin-right:72.0pt;margin-left:72.0pt'>The initialization of thecoefficients array and filter delayline is done using the C function <ahref="exp8/init.c"><span style='font-family:"Courier New"'>init.c</span></a>,as shown in Figure E8-5.</p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'>TableE8-5 List of <span style='font-family:"Courier New"'>init.c</span></p><form><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'><TEXTAREA ROWS="7" COLS="70" NAME="init.c">/* init.c - Initialize an array to zero */ #pragma CODE_SECTION(init, "lms_code"); void init(int *ptr, unsigned int N) { unsigned int i; for (i=N; i>0; i--) *ptr++ = 0;				 } </TEXTAREA></p></form><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'> </p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'> </p><p style='margin-right:72.0pt;margin-left:72.0pt'>For Experiment 8A, completethese steps:</p><p style='margin-right:72.0pt;margin-left:108.0pt;text-indent:-18.0pt;mso-list:l0 level1 lfo2;tab-stops:list 36.0pt'><![if !supportLists]>1.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>Thisexperiment uses the following files: <span style='font-family:"Courier New"'>exp8.cmd</span>,<span style='font-family:"Courier New"'>expt8a.c</span>, <spanstyle='font-family:"Courier New"'>init.c</span>, <span style='font-family:"Courier New"'>random.c</span>,<span style='font-family:"Courier New"'>adaptive.asm</span>, <spanstyle='font-family:"Courier New"'>fir_flt.asm</span>, <span style='font-family:"Courier New"'>LP_coef.dat</span>, and <span style='font-family:"Courier New"'>randdata.dat</span>,where the assembly routine <span style='font-family:"Courier New"'>fir_flt.asm</span>and its coefficients <span style='font-family:"Courier New"'>LP_coef.dat</span>are identical of those used for the experiment in Chapter 5.</p><p style='margin-right:72.0pt;margin-left:108.0pt;text-indent:-18.0pt;mso-list:l0 level1 lfo2;tab-stops:list 36.0pt'><![if !supportLists]>2.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>Createthe project <span style='font-family:"Courier New"'>epx8a</span>, to include <spanstyle='font-family:"Courier New"'>exp8.cmd</span>, <span style='font-family:"Courier New"'>expt8a.c</span>, <span style='font-family:"Courier New"'>init.c</span>,<span style='font-family:"Courier New"'>random.c</span>, <spanstyle='font-family:"Courier New"'>adaptive.asm</span>, and <spanstyle='font-family:"Courier New"'>fir_flt.asm</span>. Build, debug, and run theexperiment using the CCS.</p><p style='margin-right:72.0pt;margin-left:108.0pt;text-indent:-18.0pt;mso-list:l0 level1 lfo2;tab-stops:list 36.0pt'><![if !supportLists]>3.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>Configurethe CCS, and set animation option for viewing the coefficients of the adaptivefilter <span style='font-family:"Courier New"'>w[]</span>, the unknown thesystem <span style='font-family:"Courier New"'>LP_coef[]</span> in both timedomain and frequency domain.</p><p style='margin-right:72.0pt;margin-left:108.0pt;text-indent:-18.0pt;mso-list:l0 level1 lfo2;tab-stops:list 36.0pt'><![if !supportLists]>4.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>Verifythe adaptation process by viewing how the adaptive coefficients are adjusted.Record the steady-state value of <span style='font-family:"Courier New"'>w[]</span>,and plot the frequency responses of the adaptive filter and the unknown system.Save the adaptive filter coefficients, and compare them with the unknown systemcoefficients given in the file <span style='font-family:"Courier New"'>LP_coef.dat</span>.</p><p style='margin-right:72.0pt;margin-left:108.0pt;text-indent:-18.0pt;mso-list:l0 level1 lfo2;tab-stops:list 36.0pt'><![if !supportLists]>5.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>Adjustadaptation step size, and repeat the system identification process. Observe howdoes the system performance change. </p><p style='margin-right:72.0pt;margin-left:108.0pt;text-indent:-18.0pt;mso-list:l0 level1 lfo2;tab-stops:list 36.0pt'><![if !supportLists]>6.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>Increasethe number of the adaptive filter coefficients to N0=64, and observe systemperformance. </p><p style='margin-right:72.0pt;margin-left:108.0pt;text-indent:-18.0pt;mso-list:l0 level1 lfo2;tab-stops:list 36.0pt'><![if !supportLists]>7.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>Reducethe number of the adaptive filter coefficients to N0=32, and observe systemperformance. </p><p style='margin-right:72.0pt;margin-left:72.0pt'>The experiment result is plottedin Figure E8-2.</p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'><imgborder=0 width=918 height=589 id="_x0000_i1028" src="exp8/fe8-2.jpg"></p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'>FigureE8-2 System identification experiment results</p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'> </p><p><a href="#top"><span style='font-size:7.5pt'>Back to Top</span></a> <input type=button value="go back" onclick="history.go(-1)"></p><div class=MsoNormal align=center style='text-align:center'><hr size=3 width="100%" align=center></div>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -