filtre_cic
Création d'un filtre CIC, opérant sur des vecteurs de type T, et travaillant en interne avec le type Ti.
Espace de nom : tsd::filtrage
Prototype
sptr<FiltreGen<T>> filtre_cic(const CICConfig &config, char mode='d')
Paramètres
config | Paramètres principaux (voir CICConfig) |
mode | 'd' for decimation or 'u' for upsampling. |
Description
- Note
- Pour le type interne, il faut absolument choisir un type entier, car la façon dont le filtre est implémenté fait que les calculs ne fonctionneront pas avec un type flottant.
Exemple pour l'interpolation
// Upsample by 16
soit R = 16, N = 4;
// Input sampling frequency = 10 MHz / 16
soit fe = (10e6f) / R;
// Test signal frequency
soit f = 50e3;
// Creation of the CIC filter:
// - input / output type = float
// - internal registers = entier
soit cic = filtre_cic<float,entier>({R, N, 1}, 'u' );
// Build a signal pure sine wave at 50 KHz
soit t = linspace(0, 1e-4, fe*1e-4); // 0.1 ms time slot
soit x = sin(2*π*f*t);
// Scale the signal by 2^15, because internal computing inside
// CIC filter will be done in integer format.
x *= 32768;
// Use the CIC filter to upsample by a ratio of R
soit xu = cic->step(x);

Exemple pour la décimation
// Input sampling frequency = 10 MHz
soit fe = 10e6f;
// Decimate by 16 (e.g. output sample frequency = 625 KHz)
soit R = 16, N = 4;
// Creation of the CIC filter
soit cic = filtre_cic<float,entier>({R, N});
// Build a signal which is the superposition of 2 pure sine waves:
// - one at 2 MHz
// - one at 20 KHz
soit f1 = 2e6f/2, f2 = 20e3f/2;
// 1 ms time slot
soit t = intervalle_temporel( /*10000*/ 2000, fe);
soit x = sin(t*2*π_f*f1) + sin(t*2*π_f*f2);
// Scale the data to 16 bit precision
x *= 32768;
// Decimation by ratio 1/R
soit xd = cic->step(x);
