Hi Jamesh,
yes I use C language.
Here is the function which does computations :
In SignalXOscillateurLocal(), each samples (6000 samples) are multiplied by a "local oscillator" (it's an array with sine and cosine pre-computed values), cumulated by 10 samples. Then, 600 cumulated value pairs (In phase/ Quadrature) are filtered with a low-pass filter in function FiltrerEtCalculerPhase(). finally a phase is computed with atan2f().
This takes about 70ms which is too long.
Here is an extract of the code :
yes I use C language.
Here is the function which does computations :
In SignalXOscillateurLocal(), each samples (6000 samples) are multiplied by a "local oscillator" (it's an array with sine and cosine pre-computed values), cumulated by 10 samples. Then, 600 cumulated value pairs (In phase/ Quadrature) are filtered with a low-pass filter in function FiltrerEtCalculerPhase(). finally a phase is computed with atan2f().
This takes about 70ms which is too long.
Here is an extract of the code :
Code:
double_t FiltrerEtCalculerPhase(double_t Icum, double_t Qcum, bool debutLot) { double_t phase; static double_t IcumPrec1; // Filtre passe-bas composante I : à multiplier par a1 static double_t IcumPrec2; // Filtre passe-bas composante I : à multiplier par a2 static double_t IFiltre; // résultat courant de la composante I static double_t IFiltrePrec1; // Filtre passe-bas composante I : à multiplier par b1 static double_t IFiltrePrec2; // Filtre passe-bas composante I : à multiplier par b2 static double_t QcumPrec1; // Filtre passe-bas composante Q : à multiplier par a1 static double_t QcumPrec2; // Filtre passe-bas composante Q : à multiplier par a2 static double_t QFiltre; // résultat courant de la composante I static double_t QFiltrePrec1; // Filtre passe-bas composante Q : à multiplier par b1 static double_t QFiltrePrec2; // Filtre passe-bas composante Q : à multiplier par b2 //////////////////////////////////////////// // filtre Chebyshev passe-bas 2 pôles //////////////////////////////////////////// // coefficients pour une fréquence de 500kHz et une fréquence de coupure à 10% // coefficients identiques pour une fréquence de 312,5kHz et une fréquence de coupure à 1% static const double_t a0=0.005943; static const double_t a1=-0.007193; static const double_t a2=0.005943; static const double_t b1=1.9055333; static const double_t b2=-0.9102498; if (debutLot) { IcumPrec1 = 0; IcumPrec2 = 0; IFiltrePrec1 = 0; IFiltrePrec2 = 0; QcumPrec1 = 0; QcumPrec2 = 0; QFiltrePrec1 = 0; QFiltrePrec2 = 0; } ////////////////////////////////////////////////////////////////////////// ////////////////////////// FILTRE PASSE-BAS ////////////////////////////// ////////////////////////////////////////////////////////////////////////// IFiltre = Icum * a0 + IcumPrec1 * a1 + IcumPrec2 * a2 + IFiltrePrec1 * b1 + IFiltrePrec2 * b2; QFiltre = Qcum * a0 + QcumPrec1 * a1 + QcumPrec2 * a2 + QFiltrePrec1 * b1 + QFiltrePrec2 * b2; // Filtre passe-bas : sauvegarde de IFiltre et QFiltre et décalage IcumPrec2 = IcumPrec1; IcumPrec1 = Icum; IFiltrePrec2 = IFiltrePrec1; IFiltrePrec1 = IFiltre; QcumPrec2 = QcumPrec1; QcumPrec1 = Qcum; QFiltrePrec2 = QFiltrePrec1; QFiltrePrec1 = QFiltre; // calcul de la phase à partir des valeur I/Q filtrées atan2f(Y, X) phase = atan2f(QFiltre, IFiltre); return(phase);}float_t * SignalXOscillateurLocal(bool init) { uint8_t minEchantillon = 128; uint8_t maxEchantillon = 128; static double_t Icum, Qcum; static uint16_t i = 0; // Pour sample_array uint16_t j = 0; // Pour aIQcumules float_t phase; Icum = 0.0; Qcum = 0.0; for (i=0; i<NB_ECHANTILLONS; i++) { if (sample_array[i] < minEchantillon) minEchantillon = sample_array[i]; if (sample_array[i] > maxEchantillon) maxEchantillon = sample_array[i]; Icum += (double_t)sample_array[i] * aOscillateurLocal[i].cosinus; Qcum += (double_t)sample_array[i] * aOscillateurLocal[i].sinus; // on pousse le cumul vers FIFO pour chaque de groupe de "tailleSousLot" échantillons soit NB_ECHANTILLONS / NB_ENVOIS if ((i>0) && (i%tailleSousLot == 0)) { aPhases[j] = FiltrerEtCalculerPhase(Icum, Qcum, false); Icum = 0.0; Qcum = 0.0; j++; } } if ((maxEchantillon - minEchantillon) < 5) pasDePorteuse = true; else pasDePorteuse = false; if (pasDePorteuse) printf("Dans SignalXOscillateurLocal() - pas de porteuse détectée !\r"); return(&aPhases[0]);}
Statistics: Posted by Franck34 — Fri Feb 02, 2024 1:57 pm