⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 exp8.html

📁 (Ebook-Pdf) Dsp - Real Time Digital Signal Processing (Usando Tms320-55Xx). 有书
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<p style='margin-right:72.0pt;margin-left:72.0pt'>&nbsp;</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'>&nbsp;</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">/*&#13;&#10;&#9;signal.c - Sinewave plus additive zero-mean random noise &#13;&#10;*/                                       &#13;&#10;&#13;&#10;#define USE_DATA 1&#13;&#10;&#13;&#10;#if USE_DATA   /* Use noise data file */&#13;&#10;&#13;&#10;#pragma CODE_SECTION(cos_rand, &quot;lms_code&quot;); &#13;&#10;#pragma DATA_SECTION(noise, &quot;lms_data&quot;); &#13;&#10;#pragma DATA_SECTION(i, &quot;lms_data&quot;); &#13;&#10;&#13;&#10;#include &quot;noise.dat&quot;&#13;&#10;&#13;&#10;static unsigned int i=0;        &#13;&#10;        &#13;&#10;void cos_rand(int *x, unsigned int Ns)&#13;&#10;{&#13;&#10;    unsigned int t;&#13;&#10;    &#13;&#10;    for (t=Ns; t&gt;0; t--)&#13;&#10;    {                         &#13;&#10;   &#9;*x++ = noise[i];  &#13;&#10;   &#9;i++;&#13;&#10;   &#9;if (i == 10000)&#13;&#10;   &#9;    i = 0;&#13;&#10;   }&#13;&#10;}&#13;&#10;&#13;&#10;#else   /* Generate noise samples */&#13;&#10;&#13;&#10;#include &lt;math.h&gt;&#13;&#10;#include &lt;intrindefs.h&gt; &#13;&#10;&#13;&#10;#pragma CODE_SECTION(cos_rand, &quot;lms_code&quot;); &#13;&#10;#pragma DATA_SECTION(i, &quot;lms_data&quot;); &#13;&#10;&#13;&#10;#define PI&#9;3.1415962&#13;&#10;#define K&#9;(Ns&gt;&gt;6)&#13;&#10;#define a1&#9;0x4000&#13;&#10;#define a2&#9;0x4000&#13;&#10;             &#13;&#10;static unsigned int i=0;        &#13;&#10;        &#13;&#10;void cos_rand(int *x, unsigned int Ns)&#13;&#10;{&#13;&#10;    unsigned int t;&#13;&#10;    float   two_pi_K_Ns;   &#13;&#10;    int     temp;&#13;&#10;    long    ltemp;     &#13;&#10;    &#13;&#10;    two_pi_K_Ns=2.0*PI*K/Ns;&#13;&#10;    for (t=Ns; t&gt;0; t--)&#13;&#10;    {                         &#13;&#10;        temp = (int)(0x7fff*cos(two_pi_K_Ns*i));&#13;&#10;        ltemp = _lsmpy(a1,temp);  &#13;&#10;   &#9;  temp = rand(0x228)-0x4000;&#13;&#10;        *x++ = _smac(ltemp,a2,temp)&gt;&gt;16;  &#13;&#10;   &#9;  i++;&#13;&#10;   &#9;  i%=(Ns&gt;&gt;1);&#13;&#10;   }&#13;&#10;}&#13;&#10;&#13;&#10;#endif&#13;&#10;</TEXTAREA></p></form><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'>&nbsp;</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">/*&#13;&#10;    exp8b.c - Experiment 8B - Adaptive noise canceller &#13;&#10;*/&#13;&#10;&#13;&#10;#define N   48       /* Adaptive FIR filter order */&#13;&#10;#define Ns&#9;256      /* Number of input signal per block */&#13;&#10;&#13;&#10;#pragma DATA_SECTION(e, &quot;lms_err&quot;);     &#13;&#10;#pragma DATA_SECTION(y, &quot;lms_out&quot;); &#13;&#10;#pragma DATA_SECTION(x, &quot;lms_in&quot;); &#13;&#10;#pragma DATA_SECTION(d, &quot;lms_data&quot;); &#13;&#10;#pragma DATA_SECTION(w, &quot;lms_coef&quot;); &#13;&#10;#pragma DATA_SECTION(index, &quot;lms_data&quot;); &#13;&#10;#pragma CODE_SECTION(main, &quot;lms_code&quot;); &#13;&#10; &#13;&#10;int e[Ns],           /* Error signal buffer */ &#13;&#10;    y[Ns],           /* Ouptut signal buffer */  &#13;&#10;    in[Ns],          /* Input signal buffer */&#13;&#10;    w[N],            /* Adaptive filter coefficients */&#13;&#10;    x[N],            /* Filter delayline buffer */  &#13;&#10;    index;&#13;&#10;&#13;&#10;extern void init(int *, unsigned int);&#13;&#10;extern unsigned int alp(int *, int *, int *, int *, int *, unsigned int, unsigned int, unsigned int);&#13;&#10;extern void cos_rand(int *, unsigned int);&#13;&#10;                 &#13;&#10;void main(void)&#13;&#10;{  &#13;&#10;    init(x,N);       /* Initialize d[] to zero */&#13;&#10;    init(w,N);       /* Initialize w[] to zero */&#13;&#10;    index=0;&#13;&#10;&#13;&#10;    for (;;)&#13;&#10;    {                      &#13;&#10;        cos_rand(in,Ns); /* Generate samples */&#13;&#10;        index=alp(in,y,e,x,w,Ns,N,index); /* Adaptive system */&#13;&#10;    }      &#13;&#10;}&#13;&#10;</TEXTAREA></p></form><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'>&nbsp;</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'>&nbsp;</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">;&#13;&#10;;    alp.asm - Self-tuned Adaptive linear predictor (Leaky LMS)&#13;&#10;;                                  &#13;&#10;;    Prototype: unsigned int anc_lms(int *in, int *y, int *e, int *d, int *w,&#13;&#10;;               unsigned int Ns, unsigned int N, unsigned int index)&#13;&#10;;&#13;&#10;;    Entry: in[]- input buffer contains wide &amp; narrow band signals&#13;&#10;;           y[] - output of the filter narrow band signal&#13;&#10;;           e[] - output of the filter wide band signal&#13;&#10;;           d[] - adaptive filter delay-line buffer&#13;&#10;;           w[] - adaptive filter coefficient buffer&#13;&#10;;           Ns  - number of samples per block&#13;&#10;;           N   - order of the adaptive filter&#13;&#10;;           index - index to d[]&#13;&#10;;&#13;&#10;;    Return: T0 = Adaptive filter delay-line buffer index         &#13;&#10;;&#13;&#10;&#13;&#10;TWOMU    .set 0x70    ; 2*MU&#13;&#10;ALPHA    .set 0x7ff0  ; Leaky factor&#13;&#10;&#13;&#10;;&#13;&#10;;    Declare local variables in SP address mode for C-callable&#13;&#10;;&#13;&#10;ARGS  .set  1                 ; Number of variables passed via stack&#13;&#10;&#13;&#10;ANC_var     .struct           ; Define local variable structure  &#13;&#10;d_ST1       .int              ; Used to save content of ST1&#13;&#10;d_ST2       .int              ; Used to save content of ST2&#13;&#10;d_ST3       .int              ; Used to save content of ST3 &#13;&#10;return_addr .int              ; Return address&#13;&#10;d_index     .int              ; Function argument passed via stack&#13;&#10;Size        .endstruct&#13;&#10;anc         .set 0&#13;&#10;anc         .tag ANC_var  &#13;&#10;&#13;&#10;    .def    _alp&#13;&#10;&#9;&#13;&#10;    .sect &quot;lms_code&quot;  &#13;&#10;&#9;&#13;&#10;_alp                       &#13;&#10;    aadd #(ARGS-Size+1),SP    ; Adjust SP for local vars  &#13;&#10;&#9;&#13;&#10;    mov  mmap(AR4),BSA45      ; Configure for circular buffers&#13;&#10;    mov  mmap(T1),BK47   &#13;&#10;    mov  mmap(AR3),BSA23&#13;&#10;    mov  mmap(T1),BK03&#13;&#10;    mov  anc.d_index,AR3      ; AR3 -&gt; x[] as circular buffer&#13;&#10;    mov  #0,AR4&#9;&#9;&#9;&#9;; AR4 -&gt; w[] as circular buffer&#13;&#10;&#9;&#9;&#9;&#9;&#13;&#10;    mov  mmap(ST1_55),AC0     ; Save ST1, ST2, and ST3&#13;&#10;    mov  AC0,anc.d_ST1&#13;&#10;    mov  mmap(ST2_55),AC0&#13;&#10;    mov  AC0,anc.d_ST2&#13;&#10;    mov  mmap(ST3_55),AC0&#13;&#10;    mov  AC0,anc.d_ST3&#13;&#10;&#13;&#10;    or   #0x340,mmap(ST1_55); Set FRCT,SXMD,SATD&#13;&#10;    or   #0x18,mmap(ST2_55) ; Enable circular addressing mode&#13;&#10;    bset SATA&#9;&#9;&#9;&#9;; Set SATA&#13;&#10; &#9;&#13;&#10;    sub&#9; #1,T0&#13;&#10;    mov  mmap(T0),BRC0      ; Set Sample block loop counter  &#13;&#10;    sub  #2,T1&#13;&#10;    mov  mmap(T1),BRC1      ; Counter for LMS update loop &#13;&#10;    mov  mmap(T1),CSR       ; Counter for FIR filter loop&#9;&#9;&#13;&#10;&#13;&#10;    mov  #ALPHA,T0          ; T0=leaky alpha&#13;&#10;||  rptblocal loop-1        ; for (n=0; n&lt;Ns; n++)&#13;&#10;    mpym *AR3+,*AR4+,AC0    ; temp = w[0]*x[0] &#13;&#10;||  rpt  CSR                ; for (i=0; i&lt;N-1; i++)&#13;&#10;    macm *AR3+,*AR4+,AC0    ;   temp = w[i]*x[i]&#13;&#10;    mov  rnd(hi(AC0)),*AR1  ; y[t] = temp;        &#13;&#10;    sub  *AR0,*AR1+,AC0&#13;&#10;    mov  rnd(hi(AC0)),*AR2+ ; e[n]=in[n]-y[n]&#13;&#10;||  mpyk #TWOMU,AC0&#13;&#10;    mov  rnd(hi(AC0)),mmap(T1); T1=2*mu*e[n]&#13;&#10;    mpym *AR4,T0,AC0&#13;&#10;||  rptblocal lms_loop-1    ; for(j=0; i&lt;N-2; i++)&#13;&#10;    macm *AR3+,T1,AC0       ;   w[i]=alpha*w[i]+2*mu*e*x[i]     &#13;&#10;    mov  rnd(hi(AC0)),*AR4+&#13;&#10;    mpym *AR4,T0,AC0    &#13;&#10;lms_loop &#13;&#10;    macm *AR3,T1,AC0        ; w[N-1]=alpha*w[N-1]+2*mu*e[n]*x[N-1]&#13;&#10;    mov  rnd(hi(AC0)),*AR4+ ; Store the last w[i]&#13;&#10;    mov  *AR0+,*AR3         ; x[n]=in[n]&#13;&#10;loop                              &#13;&#10;&#13;&#10;    mov  anc.d_ST1,AR4      ; Restore ST1, ST2, and ST3&#13;&#10;    mov  ar4,mmap(ST1_55)  &#13;&#10;    mov  anc.d_ST2,AR4&#13;&#10;    mov  ar4,mmap(ST2_55)&#13;&#10;    mov  anc.d_ST3,AR4&#13;&#10;    mov  AR4,mmap(ST3_55)&#13;&#10;    aadd #(Size-ARGS-1),SP  ; Reset SP&#13;&#10;    mov  AR3,T0             ; Retrun T0=index&#13;&#10;||  ret&#13;&#10;&#9;&#13;&#10;   .end&#13;&#10;</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"'>&nbsp;&nbsp;&nbsp;&nbsp; </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"'>&nbsp;&nbsp;&nbsp;&nbsp; </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"'>&nbsp;&nbsp;&nbsp;&nbsp; </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"'>&nbsp;&nbsp;&nbsp;&nbsp; </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"'>&nbsp;&nbsp;&nbsp;&nbsp; </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"'>&nbsp;&nbsp;&nbsp;&nbsp; </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"'>&nbsp;&nbsp;&nbsp;&nbsp; </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"'>&nbsp;&nbsp;&nbsp;&nbsp; </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"'>&nbsp;&nbsp;&nbsp;&nbsp; </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"'>&nbsp; </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 + -