📄 exp8.html
字号:
<p style='margin-right:72.0pt;margin-left:72.0pt'> </p><p style='margin-right:72.0pt;margin-left:72.0pt'><strong><spanstyle='font-size:13.5pt;color:blue'>Experiment 8B - Self-tuned Leaky LMS AdaptiveSystem </span></strong></p><p style='margin-right:72.0pt;margin-left:72.0pt'>Figure E8-3 shows the blockdiagram of an adaptive linear predictor using the leaky LMS algorithm. As shownin Figure E8-3, the input to the system contains a wide band signal <spanstyle='font-family:"Courier New"'>s(n)</span>and a narrow band signal <spanstyle='font-family:"Courier New"'>v(n)</span>. The system has two outputs, thewide band output <span style='font-family:"Courier New"'>e(n)</span> and thenarrow band output <span style='font-family:"Courier New"'>y(n)</span>.</p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'><imgborder=0 width=639 height=376 id="_x0000_i1030" src="exp8/fe8-3.jpg"></p><p style='margin-right:72.0pt;margin-left:72.0pt'> </p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'>FigureE8-3 Block diagram of an adaptive linear predictor</p><p style='margin-right:72.0pt;margin-left:72.0pt'>The signal source isgenerated by the function <a href="exp8/signal.c"><span style='font-family:"Courier New"'>signal.c</span></a><span style='font-family:"Courier New"'>, </span>listedin Table E8-6. </p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'>TableE8-6 List of function <span style='font-family:"Courier New"'>singal.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="signal.c">/* 	signal.c - Sinewave plus additive zero-mean random noise */ #define USE_DATA 1 #if USE_DATA /* Use noise data file */ #pragma CODE_SECTION(cos_rand, "lms_code"); #pragma DATA_SECTION(noise, "lms_data"); #pragma DATA_SECTION(i, "lms_data"); #include "noise.dat" static unsigned int i=0; void cos_rand(int *x, unsigned int Ns) { unsigned int t; for (t=Ns; t>0; t--) { 	*x++ = noise[i]; 	i++; 	if (i == 10000) 	 i = 0; } } #else /* Generate noise samples */ #include <math.h> #include <intrindefs.h> #pragma CODE_SECTION(cos_rand, "lms_code"); #pragma DATA_SECTION(i, "lms_data"); #define PI	3.1415962 #define K	(Ns>>6) #define a1	0x4000 #define a2	0x4000 static unsigned int i=0; void cos_rand(int *x, unsigned int Ns) { unsigned int t; float two_pi_K_Ns; int temp; long ltemp; two_pi_K_Ns=2.0*PI*K/Ns; for (t=Ns; t>0; t--) { temp = (int)(0x7fff*cos(two_pi_K_Ns*i)); ltemp = _lsmpy(a1,temp); 	 temp = rand(0x228)-0x4000; *x++ = _smac(ltemp,a2,temp)>>16; 	 i++; 	 i%=(Ns>>1); } } #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'>The experiment is managed byfunction <a href="exp8/exp8b.c"><span style='font-family:"Courier New"'>exp8b.c</span></a>,see Table E8-7. Because of using the white noise, the delay is chosen to be 1.The same initialization function <span style='font-family:"Courier New"'>init.c</span>is used to initialize the adaptive filter. </p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'>TableE8-7 List of <span style='font-family:"Courier New"'>exp8b.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="exp8b.c">/* exp8b.c - Experiment 8B - Adaptive noise canceller */ #define N 48 /* Adaptive FIR filter order */ #define Ns	256 /* Number of input signal per block */ #pragma DATA_SECTION(e, "lms_err"); #pragma DATA_SECTION(y, "lms_out"); #pragma DATA_SECTION(x, "lms_in"); #pragma DATA_SECTION(d, "lms_data"); #pragma DATA_SECTION(w, "lms_coef"); #pragma DATA_SECTION(index, "lms_data"); #pragma CODE_SECTION(main, "lms_code"); int e[Ns], /* Error signal buffer */ y[Ns], /* Ouptut signal buffer */ in[Ns], /* Input signal buffer */ w[N], /* Adaptive filter coefficients */ x[N], /* Filter delayline buffer */ index; extern void init(int *, unsigned int); extern unsigned int alp(int *, int *, int *, int *, int *, unsigned int, unsigned int, unsigned int); extern void cos_rand(int *, unsigned int); void main(void) { init(x,N); /* Initialize d[] to zero */ init(w,N); /* Initialize w[] to zero */ index=0; for (;;) { cos_rand(in,Ns); /* Generate samples */ index=alp(in,y,e,x,w,Ns,N,index); /* Adaptive system */ } } </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 experiment result isplotted and shown in Figure E8-4. The input is a wide band (white noise) and aperiodic signal (sinewave). The adaptive filter separates the narrow bandsignal from the wide band signal.</p><p style='margin-right:72.0pt;margin-left:72.0pt'><img border=0 width=888height=611 id="_x0000_i1031" src="exp8/fe8-4.jpg"></p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'>FigureE8-4. Adaptive linear predictor experiment result</p><p style='margin-right:72.0pt;margin-left:72.0pt'>The adaptive linear predictor<a href="exp8/alp.asm"><span style='font-family:"Courier New"'>alp.asm</span></a>is listed in Table E8-8. We choose the leaky factor to be 0.998 and the stepsize 2u=96/32768.</p><p style='margin-right:72.0pt;margin-left:72.0pt'> </p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'>TableE8-8 Adaptive linear predictor.</p><form><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'><TEXTAREA ROWS="7" COLS="70" NAME="S1">; ; alp.asm - Self-tuned Adaptive linear predictor (Leaky LMS) ; ; Prototype: unsigned int anc_lms(int *in, int *y, int *e, int *d, int *w, ; unsigned int Ns, unsigned int N, unsigned int index) ; ; Entry: in[]- input buffer contains wide & narrow band signals ; y[] - output of the filter narrow band signal ; e[] - output of the filter wide band signal ; d[] - adaptive filter delay-line buffer ; w[] - adaptive filter coefficient buffer ; Ns - number of samples per block ; N - order of the adaptive filter ; index - index to d[] ; ; Return: T0 = Adaptive filter delay-line buffer index ; TWOMU .set 0x70 ; 2*MU ALPHA .set 0x7ff0 ; Leaky factor ; ; Declare local variables in SP address mode for C-callable ; ARGS .set 1 ; Number of variables passed via stack ANC_var .struct ; Define local variable structure d_ST1 .int ; Used to save content of ST1 d_ST2 .int ; Used to save content of ST2 d_ST3 .int ; Used to save content of ST3 return_addr .int ; Return address d_index .int ; Function argument passed via stack Size .endstruct anc .set 0 anc .tag ANC_var .def _alp 	 .sect "lms_code" 	 _alp aadd #(ARGS-Size+1),SP ; Adjust SP for local vars 	 mov mmap(AR4),BSA45 ; Configure for circular buffers mov mmap(T1),BK47 mov mmap(AR3),BSA23 mov mmap(T1),BK03 mov anc.d_index,AR3 ; AR3 -> x[] as circular buffer mov #0,AR4				; AR4 -> w[] as circular buffer 				 mov mmap(ST1_55),AC0 ; Save ST1, ST2, and ST3 mov AC0,anc.d_ST1 mov mmap(ST2_55),AC0 mov AC0,anc.d_ST2 mov mmap(ST3_55),AC0 mov AC0,anc.d_ST3 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		 mov #ALPHA,T0 ; T0=leaky alpha || rptblocal loop-1 ; for (n=0; n<Ns; n++) mpym *AR3+,*AR4+,AC0 ; temp = w[0]*x[0] || rpt CSR ; for (i=0; i<N-1; i++) macm *AR3+,*AR4+,AC0 ; temp = w[i]*x[i] mov rnd(hi(AC0)),*AR1 ; y[t] = temp; sub *AR0,*AR1+,AC0 mov rnd(hi(AC0)),*AR2+ ; e[n]=in[n]-y[n] || mpyk #TWOMU,AC0 mov rnd(hi(AC0)),mmap(T1); T1=2*mu*e[n] mpym *AR4,T0,AC0 || rptblocal lms_loop-1 ; for(j=0; i<N-2; i++) macm *AR3+,T1,AC0 ; w[i]=alpha*w[i]+2*mu*e*x[i] mov rnd(hi(AC0)),*AR4+ mpym *AR4,T0,AC0 lms_loop macm *AR3,T1,AC0 ; w[N-1]=alpha*w[N-1]+2*mu*e[n]*x[N-1] mov rnd(hi(AC0)),*AR4+ ; Store the last w[i] mov *AR0+,*AR3 ; x[n]=in[n] loop mov anc.d_ST1,AR4 ; Restore ST1, ST2, and ST3 mov ar4,mmap(ST1_55) mov anc.d_ST2,AR4 mov ar4,mmap(ST2_55) mov anc.d_ST3,AR4 mov AR4,mmap(ST3_55) aadd #(Size-ARGS-1),SP ; Reset SP mov AR3,T0 ; Retrun T0=index || ret 	 .end </TEXTAREA></p></form><p style='margin-right:72.0pt;margin-left:72.0pt'>For Experiment 8B, go throughthe following steps:</p><p style='margin-right:72.0pt;margin-left:108.0pt;text-indent:-18.0pt;mso-list:l1 level1 lfo3;tab-stops:list 36.0pt'><![if !supportLists]>1.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>Createthe project <span style='font-family:"Courier New"'>epx8b</span> to include <spanstyle='font-family:"Courier New"'>exp8.cmd</span>, <span style='font-family:"Courier New"'>expt8b.c</span>, <span style='font-family:"Courier New"'>init.c</span>,<span style='font-family:"Courier New"'>alp.asm</span>, and <spanstyle='font-family:"Courier New"'>singal.c</span>. These files can be foundfrom the experiment software package.</p><p style='margin-right:72.0pt;margin-left:108.0pt;text-indent:-18.0pt;mso-list:l1 level1 lfo3;tab-stops:list 36.0pt'><![if !supportLists]>2.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>Build,debug, and run the experiment using the CCS.</p><p style='margin-right:72.0pt;margin-left:108.0pt;text-indent:-18.0pt;mso-list:l1 level1 lfo3;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 output of the adaptive filter<span style='font-family:"Courier New"'>y[]</span>, the output of the system <spanstyle='font-family:"Courier New"'>e[]</span>, the input of the signal, <spanstyle='font-family:"Courier New"'>in[]</span>, and the adaptive filtercoefficients <span style='font-family:"Courier New"'>w[] </span>at a block byblock basis. </p><p style='margin-right:72.0pt;margin-left:108.0pt;text-indent:-18.0pt;mso-list:l1 level1 lfo3;tab-stops:list 36.0pt'><![if !supportLists]>4.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>Verifythe adaptive linear predictor, and compare the result with Figure E8-4.</p><p style='margin-right:72.0pt;margin-left:108.0pt;text-indent:-18.0pt;mso-list:l1 level1 lfo3;tab-stops:list 36.0pt'><![if !supportLists]>5.<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 response of the adaptive filter.</p><p style='margin-right:72.0pt;margin-left:108.0pt;text-indent:-18.0pt;mso-list:l1 level1 lfo3;tab-stops:list 36.0pt'><![if !supportLists]>6.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>Changethe order of the adaptive filter, and observe system performance.</p><p style='margin-right:72.0pt;margin-left:108.0pt;text-indent:-18.0pt;mso-list:l1 level1 lfo3;tab-stops:list 36.0pt'><![if !supportLists]>7.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>Adjustadaptation step size, and observe system performance. </p><p style='margin-right:72.0pt;margin-left:108.0pt;text-indent:-18.0pt;mso-list:l1 level1 lfo3;tab-stops:list 36.0pt'><![if !supportLists]>8.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>Changethe leaky factor, and observe system performance. </p><p style='margin-right:72.0pt;margin-left:108.0pt;text-indent:-18.0pt;mso-list:l1 level1 lfo3;tab-stops:list 36.0pt'><![if !supportLists]>9.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>Canyou obtain a similar result without using leaky LMS (by setting leaky factor to0x7fff)? Find the steady-state adaptive filter coefficients <spanstyle='font-family:"Courier New"'>w[] </span>by running the adaptive system fora period of time, and compare the frequency response with the one obtained instep 5.</p><p style='margin-right:72.0pt;margin-left:108.0pt;text-indent:-18.0pt;mso-list:l1 level1 lfo3;tab-stops:list 36.0pt'><![if !supportLists]>10.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>Select the beststep size and leaky factor that will minimize order of the adaptive filter.</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><p><i><u><span style='font-size:7.5pt'>copyright
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -