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

📄 dsp.h

📁 PID算法的介绍和应用,在很多场合需要,详细的事例说明
💻 H
📖 第 1 页 / 共 5 页
字号:
* contains the destination samples. The filters are characterized by
* the number of coefficients or taps, and the delay properties. All of
* these data sets are stored in memory as vectors with their elements
* representing Q.15 fractional quantities. Also, the input and output
* sequences to the filtering operation ought to be allocated in default
* RAM memory (X-Data or Y-Data). The coefficients may be allocated either
* in X-Data or program memory, while the delays must be allocated solely
* in Y-Data memory.
*
****************************************************************************/

/* FIR filter operation prototypes. */


typedef struct {
   int numCoeffs;                       /* number of coeffs in filter (M) */
                                        /* (same as filter order if lattice) */
                                        /* (h[m], 0 <= m < M) */
                                        /* (if lattice, k[m], 0 <= m < M) */
   fractional* coeffsBase;              /* base address of filter coeffs */
                                        /* either in X data or program memory */
                                        /* if in X data memory, it points at */
                                        /* h[0] (if lattice, k[0]) */
                                        /* if in program memory, base is the */
                                        /* offset from program page boundary */
                                        /* to address where coeffs located */
                                        /* (inline assembly psvoffset ()) */
                                        /* when indicated, it must be at a */
                                        /* 'zero' power of 2 address (since */
                                        /* in those cases it is implemented */
                                        /* as an increasing circular buffer) */
   fractional* coeffsEnd;               /* end address of filter coeffs */
                                        /* must be an odd number */
                                        /* if in data memory, points at */
                                        /* last byte of coefficients buffer */
                                        /* if in program memory, end is the */
                                        /* offset from program page boundary */
                                        /* to address of last byte of coeffs */
   int coeffsPage;                      /* if in X data memory, set to */
                                        /* defined value COEFFS_IN_DATA */
                                        /* if in program memory, page number */
                                        /* where coeffs are located */
                                        /* (inline assembly psvpage ()) */
   fractional* delayBase;               /* base address of delay buffer, */
                                        /* only in Y data */
                                        /* points at d[0] of d[m], 0 <= m < M */
                                        /* when indicated, it must be at a */
                                        /* 'zero' power of 2 address (since */
                                        /* in those cases it is implemented */
                                        /* as an increasing circular buffer) */
   fractional* delayEnd;                /* end address of delay buffer, */
                                        /* points at last byte of buffer */
   fractional* delay;                   /* current value of delay pointer */
} FIRStruct;


extern void FIRStructInit (             /* Initialize FIR filter structure */
   FIRStruct* FIRFilter,                /* FIR filter structure */
   int numCoeffs,                       /* number of coeffs in filter (M) */
                                        /* (same as filter order if lattice) */
                                        /* (h[m], 0 <= m < M) */
                                        /* (if lattice, k[m], 0 <= m < M) */
   fractional* coeffsBase,              /* base address of filter coeffs */
                                        /* either in X data or program memory */
                                        /* if in X data memory, it points at */
                                        /* h[0] (if lattice, k[0]) */
                                        /* if in program memory, base is the */
                                        /* offset from program page boundary */
                                        /* to address where coeffs located */
                                        /* (inline assembly psvoffset ()) */
                                        /* when indicated, it must be at a */
                                        /* 'zero' power of 2 address (since */
                                        /* in those cases it is implemented */
                                        /* as an increasing circular buffer) */
   int coeffsPage,                      /* if in X data memory, set to */
                                        /* defined value COEFFS_IN_DATA */
                                        /* if in program memory, page number */
                                        /* where coeffs are located */
                                        /* (inline assembly psvpage ()) */
   fractional* delayBase                /* base address of delay buffer, */
                                        /* only in Y data */
                                        /* points at d[0] of d[m], 0 <= m < M */
                                        /* when indicated, it must be at a */
                                        /* 'zero' power of 2 address (since */
                                        /* in those cases it is implemented */
                                        /* as an increasing circular buffer) */
                                        /* upon return, FIR filter structure */
                                        /* is initialized (delay = delayBase) */
);


extern void FIRDelayInit (              /* Zero out dealy in filter structure */
   FIRStruct* filter                    /* filter structure */
                                        /* NOTE: FIR interpolator's delay is */
                                        /* initialized by FIRInterpDelayInit */
);


extern void FIRInterpDelayInit (        /* Zero out dealy in filter structure */
                                        /* for FIR interpolator */
   FIRStruct* filter,                   /* filter structure */
   int rate                             /* rate of interpolation (1 to) R */
);


extern fractional* FIR (                /* FIR filtering */
   int numSamps,                        /* number of input samples (N) */
   fractional* dstSamps,                /* ptr to output samples */
                                        /* (y[n], 0 <= n < N) */
   fractional* srcSamps,                /* ptr to input samples */
                                        /* (x[n], 0 <= n < N) */
   FIRStruct* filter                    /* filter structure: */
                                        /* number of coefficients in filter */
                                        /* same as number of delay elements */
                                        /* (h[m], 0 <= m < M, an increasing */
                                        /*  circular buffer) */
                                        /* (d[m], 0 <= m < M, an increasing */
                                        /*  circular buffer) */

                                        /* returns dstSamps */
);


extern fractional* FIRDecimate (        /* Decimation by R:1 rate */
   int numSamps,                        /* number of _output_ samples (N) */
                                        /* N = R*p (p integer) */
   fractional* dstSamps,                /* ptr to output samples */
                                        /* (y[n], 0 <= n < N) */
   fractional* srcSamps,                /* ptr to input samples */
                                        /* (x[n], 0 <= n < N*R) */
   FIRStruct* filter,                   /* filter structure: */
                                        /* number of coefficients in filter */
                                        /* same as number of delay elements */
                                        /* M = R*q (q integer) */
                                        /* (h[m], 0 <= m < M) */
                                        /* (d[m], 0 <= m < M) */
   int rate                             /* rate of decimation R (to 1) */

                                        /* returns dstSamps */
);


extern fractional* FIRInterpolate (     /* Interpolation by 1:R rate */
   int numSamps,                        /* number of input samples (N) */
                                        /* N = R*p (p integer) */
   fractional* dstSamps,                /* ptr to output samples */
                                        /* (y[n], 0 <= n < N*R) */
   fractional* srcSamps,                /* ptr to input samples */
                                        /* (x[n], 0 <= n < N) */
   FIRStruct* filter,                   /* filter structure: */
                                        /* number of coefficients in filter */
                                        /* M = R*q (q integer) */
                                        /* (h[m], 0 <= m < M) */
                                        /* (d[m], 0 <= m < M/R) */
   int rate                             /* rate of interpolation (1 to) R */

                                        /* returns dstSamps */
);


extern fractional* FIRLattice (         /* FIR Lattice filtering */
   int numSamps,                        /* number of input samples (N) */
   fractional* dstSamps,                /* ptr to output samples */
                                        /* (y[n], 0 <= n < N) */
   fractional* srcSamps,                /* ptr to input samples */
                                        /* (x[n], 0 <= n < N) */
   FIRStruct* filter                    /* filter structure: */
                                        /* number of coefficients in filter */
                                        /* (also known as kappa values) */
                                        /* same as number of delay elements */
                                        /* same as filter order */
                                        /* (k[m], 0 <= m < M) */
                                        /* (d[m], 0 <= m < M) */

                                        /* returns dstSamps */
);

extern fractional* FIRLMS (             /* FIR Least Mean Square filtering */
                                        /* not normalized implementation */
                                        /* y[n] = sum_{m=0:M-1){h[n]*x[n-m]} */
                                        /* 0 <= n < N */
                                        /* h_m[n] = h_m[n-1] + mu*e[n]*x[n-m] */
                                        /* 0 <= n < N, 0 <= m < M */
                                        /* with e[n] = r[n] - y[n] */
                                        /* NOTE: to avoid saturation while */
                                        /* computing error, -1 <= e[n] < 1 */
                                        /* for 0 <= n < N */
   int numSamps,                        /* number of input samples (N) */
   fractional* dstSamps,                /* ptr to output samples */
                                        /* (y[n], 0 <= n < N) */
   fractional* srcSamps,                /* ptr to input samples */
                                        /* (x[n], 0 <= n < N) */
   FIRStruct* filter,                   /* filter structure: */
                                        /* number of coefficients in filter */
                                        /* same as number of delay elements */
                                        /* (h[m], 0 <= m < M, an increasing */
                                        /*  circular buffer) */
                                        /* (d[m], 0 <= m < M, an increasing */
                                        /*  circular buffer) */
   fractional* refSamps,                /* ptr to reference samples */
                                        /* (r[n], 0 <= n < N) */
   fractional muVal                     /* mu value for correction */

                                        /* returns dstSamps */
);

extern fractional* FIRLMSNorm (         /* FIR Least Mean Square filtering*/
                                        /* Normalized implementation */
                                        /* y[n] = sum_{m=0:M-1}(h[n]*x[n-m]) */
                                        /* 0 <= n < N */
                                        /* h_m[n] = h_m[n-1] + nu*e[n]*x[n-m] */
                                        /* 0 <= n < N, 0 <= m < M */
                                        /* with e[n] = r[n] - y[n], and */
                                        /* nu[n] = mu/(mu+E[n]) */
                                        /* E[n]=E[n-1]+(x[n])^2-(x[n-M+1])^2 */
                                        /* is an estimate of input energy */
                                        /* NOTE: to avoid saturation while */
                                        /* computing error, -1 <= e[n] < 1 */
                                        /* for 0 <= n < N */
                                        /* NOTE: to avoid saturation while */
                                        /* computing the estimate, the input */
                                        /* signal values should be bound */
                                        /* so that sum_{m=0:-M+2}(x[n+m]^2}<1 */
   int numSamps,                        /* number of input samples (N) */
   fractional* dstSamps,                /* ptr to output samples */
                                        /* (y[n], 0 <= n < N) */
   fractional* srcSamps,                /* ptr to input samples */
                                        /* (x[n], 0 <= n < N) */
   FIRStruct* filter,                   /* filter structure: */
                                        /* number of coefficients in filter */
                                        /* same as number of delay elements */
                                        /* (h[m], 0 <= m < M, an increasing */
                                        /*  circular buffer) */
                                        /* (d[m], 0 <= m < M, an increasing */
                                        /*  circular buffer) */
   fractional* refSamps,                /* ptr to reference samples */
                                        /* (r[n], 0 <= n < N) */
   fractional muVal,                    /* mu value for correction */
   fractional* energyEstimate           /* energy estimate for input samples */
                                        /* E[-1] = (x[-1])^2+...+(x[-M+1])^2 */
                                        /* on start up... (zero first time) */
                                        /* E[N-1]=(x[N-1])^2+...+(x[N-M+1])^2 */
                                        /* upon return */

                                        /* returns dstSamps */
);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -