design_cic_comp
Design of a compensation FIR filter for a CIC filter.
Namespace: dsp::filter
Prototype
CICComp design_cic_comp(const CICConfig &config, float Fin, int R2, float fc, int ncoefs)
Parameters
config | Paramètres principaux (voir CICConfig) |
Fin | input frequency |
R2 | compensation filter decimation ratio |
fc | cutoff frequency for the compensation FIR filter |
ncoefs | number of taps of the FIR filter |
Returns
compensation FIR filter coefficients
Description
This function will try to design a compensation filter for the specified CIC filter. The global decimation chain will be composed of two stages:
- The first stage is the CIC filter, and decimate by the ratio \(R\).
- The second stage is the compensation filter, and decimate by the ratio \(R_2\).
So, the global decimation ratio will be \(R\cdot R_2\).
The compensation filter is generated through the frequency sampling technique. This function will do the FIR compensation design, plot the frequency responses, and output (output parameter cfir
) the compensation filter coefficients.
// Input signal frequency: Fin = 6.4 KHz
// CIC decimation factor: R = 1/16 (freq at output of CIC: 400 Hz)
// Compensation FIR decimation factor: R2 = 1/2
// Output signal frequency: 6400/(R*R2) = 200 Hz
// Cut-off frequency for FIR filter: 80 Hz
int R = 16, N = 4, M = 1;
float fin = 6400, fcut=80;
int ntaps = 61, R2 = 2;
lets h = design_cic_comp(R,N,M,fin,R2,fcut,ntaps);
// h is the array of coefficents of the FIR compensation filter.