RRC impulsion response
This commit is contained in:
42
QAM/qam.c
42
QAM/qam.c
@ -352,7 +352,7 @@ void pll(qam_system* qam, double complex* s_with_preamble, double complex* r_cor
|
||||
phase_est += Kp * filtered_error + integrator;
|
||||
|
||||
if (fp_error) {
|
||||
fprintf(fp_error, "%d % .8f\n", k, 100 * filtered_error);
|
||||
fprintf(fp_error, "%d % .8f\n", k, 5 * filtered_error);
|
||||
fflush(fp_error);
|
||||
}
|
||||
|
||||
@ -413,7 +413,7 @@ void muller_muller_sync(qam_system* qam, double complex* s_data, int nb_symbols,
|
||||
d_k_minus_1 = d_k;
|
||||
|
||||
if (fp_error) {
|
||||
fprintf(fp_error, "%d % .8f\n", k, 5 * timing_offset);
|
||||
fprintf(fp_error, "%d % .8f\n", k, 3 * timing_offset);
|
||||
fflush(fp_error);
|
||||
}
|
||||
}
|
||||
@ -466,6 +466,41 @@ void demodulate_carrier(qam_system* qam, double complex* s_input, double complex
|
||||
}
|
||||
}
|
||||
|
||||
// Réponse impulsionnelle du filtre RRC
|
||||
void rrc_impulse_response(qam_system* qam, int N_taps, double alpha, double* rrc_taps) {
|
||||
double Ts_symbol = qam->N / qam->Fs;
|
||||
double t;
|
||||
int k;
|
||||
|
||||
for (int i = 0; i < N_taps; i++) {
|
||||
t = ((double)i - (N_taps - 1.0) / 2.0) / qam->Fs;
|
||||
k = i;
|
||||
|
||||
double t_norm = t / Ts_symbol;
|
||||
|
||||
if (fabs(t) < 1e-9) { // t = 0
|
||||
rrc_taps[k] = (1.0 / Ts_symbol) * (1.0 + alpha * (4.0 / M_PI) * (1.0 / 4.0));
|
||||
} else if (fabs(fabs(t_norm) - 1.0 / (4.0 * alpha)) < 1e-9) {
|
||||
rrc_taps[k] = (1.0 / Ts_symbol) * (alpha / M_PI) * ( (M_PI / 4.0) * (1.0 / alpha) + 1.0) * sin(M_PI / (4.0 * alpha)) + (1.0 / Ts_symbol) * (alpha / M_PI) * ( (M_PI / 4.0) * (1.0 / alpha) - 1.0) * cos(M_PI / (4.0 * alpha));
|
||||
} else {
|
||||
double num = sin(M_PI * t_norm * (1.0 - alpha)) + (4.0 * alpha * t_norm) * cos(M_PI * t_norm * (1.0 + alpha));
|
||||
double den = (M_PI * t_norm * (1.0 - (4.0 * alpha * t_norm) * (4.0 * alpha * t_norm)));
|
||||
rrc_taps[k] = (1.0 / Ts_symbol) * num / den;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Séquence d'impulsions de Dirac en base band
|
||||
void generate_baseband_pulses(qam_system* qam, double complex* symbols, int L_symbols, double complex* s_pulses) {
|
||||
int total_samples = L_symbols * qam->N;
|
||||
memset(s_pulses, 0, total_samples * sizeof(double complex));
|
||||
|
||||
for (int k = 0; k < L_symbols; k++) {
|
||||
int idx = k * qam->N;
|
||||
s_pulses[idx] = symbols[k];
|
||||
}
|
||||
}
|
||||
|
||||
int main () {
|
||||
// Initialisation du system qam
|
||||
qam_system qam;
|
||||
@ -538,7 +573,7 @@ int main () {
|
||||
demodulate_carrier(&qam, s_corrected + L * qam.N, s_bande_base, nb_symbols * qam.N);
|
||||
|
||||
double complex* r_mm_out = malloc(sizeof(double complex) * nb_symbols);
|
||||
double Kp_mm = 0.5;
|
||||
double Kp_mm = 0.6;
|
||||
double Ki_mm = 0.01;
|
||||
FILE *fp_mm_error = fopen("mm_timing_error.dat", "w");
|
||||
muller_muller_sync(&qam, s_bande_base, nb_symbols, Kp_mm, Ki_mm, r_mm_out, fp_mm_error);
|
||||
@ -571,6 +606,5 @@ int main () {
|
||||
free(s_with_preamble);
|
||||
free(texte_recup);
|
||||
free_constellation(&qam);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user