PLL
This commit is contained in:
File diff suppressed because it is too large
Load Diff
2512
QAM/pll_error.dat
2512
QAM/pll_error.dat
File diff suppressed because it is too large
Load Diff
16
QAM/qam.c
16
QAM/qam.c
@ -377,7 +377,7 @@ int main () {
|
|||||||
init_constellation(&qam);
|
init_constellation(&qam);
|
||||||
|
|
||||||
// Conversion du texte en bits
|
// Conversion du texte en bits
|
||||||
char* texte = "Vif juge, trempez ce blond whisky aqueux, Vif juge, trempez ce blond whisky aqueux, Vif juge, trempez ce blond whisky aqueux, Vif juge, trempez ce blond whisky aqueux, Vif juge, trempez ce blond whisky aqueux";
|
char* texte = "Vif juge, trempez ce blond whisky aqueux, Vif juge, trempez ce blond whisky aqueux, Vif juge, trempez ce blond whisky aqueux, Vif juge, trempez ce blond whisky aqueux, Vif juge, trempez ce blond whisky aqueux, Vif juge, trempez ce blond whisky aqueux, Vif juge, trempez ce blond whisky aqueux, Vif juge, trempez ce blond whisky aqueux, Vif juge, trempez ce blond whisky aqueux, Vif juge, trempez ce blond whisky aqueux, Vif juge, trempez ce blond whisky aqueux, Vif juge, trempez ce blond whisky aqueux, Vif juge, trempez ce blond whisky aqueux, Vif juge, trempez ce blond whisky aqueux, Vif juge, trempez ce blond whisky aqueux, Vif juge, trempez ce blond whisky aqueux, Vif juge, trempez ce blond whisky aqueux, Vif juge, trempez ce blond whisky aqueux, Vif juge, trempez ce blond whisky aqueux, Vif juge, trempez ce blond whisky aqueux, Vif juge, trempez ce blond whisky aqueux, Vif juge, trempez ce blond whisky aqueux, Vif juge, trempez ce blond whisky aqueux, Vif juge, trempez ce blond whisky aqueux, Vif juge, trempez ce blond whisky aqueux";
|
||||||
int nb_chars = strlen(texte);
|
int nb_chars = strlen(texte);
|
||||||
int nb_bits = nb_chars * 8;
|
int nb_bits = nb_chars * 8;
|
||||||
int nb_symbols = (nb_bits + qam.k - 1) / qam.k;
|
int nb_symbols = (nb_bits + qam.k - 1) / qam.k;
|
||||||
@ -389,7 +389,7 @@ int main () {
|
|||||||
bits_to_symbols(&qam, input_bits, nb_bits, symbols);
|
bits_to_symbols(&qam, input_bits, nb_bits, symbols);
|
||||||
|
|
||||||
// Initialisation du préambule
|
// Initialisation du préambule
|
||||||
int L = 16;
|
int L = 15;
|
||||||
int total_samples = qam.N * (nb_symbols + L);
|
int total_samples = qam.N * (nb_symbols + L);
|
||||||
|
|
||||||
double complex* preamble = malloc(sizeof(double complex) * L);
|
double complex* preamble = malloc(sizeof(double complex) * L);
|
||||||
@ -404,17 +404,17 @@ int main () {
|
|||||||
double complex* s_with_preamble = concat_preamble_signal(preamble_mod, L, s_mod, nb_symbols, qam.N);
|
double complex* s_with_preamble = concat_preamble_signal(preamble_mod, L, s_mod, nb_symbols, qam.N);
|
||||||
|
|
||||||
// Ajout du bruit
|
// Ajout du bruit
|
||||||
add_noise(s_with_preamble, total_samples, 24);
|
add_noise(s_with_preamble, total_samples, 20);
|
||||||
|
|
||||||
FILE *fp_ref = fopen("constellation_ref.dat", "w");
|
FILE *fp_ref = fopen("constellation_ref.dat", "w");
|
||||||
fill_constellation_data(&qam, fp_ref);
|
fill_constellation_data(&qam, fp_ref);
|
||||||
fclose(fp_ref);
|
fclose(fp_ref);
|
||||||
|
|
||||||
// Ajout de dephasage
|
// Ajout de dephasage
|
||||||
add_dephasage(s_with_preamble, M_PI / 6.0 , total_samples);
|
add_dephasage(s_with_preamble, M_PI / 2.0 , total_samples);
|
||||||
|
|
||||||
// AJout de decalage de fréquence
|
// AJout de decalage de fréquence
|
||||||
add_freq(&qam, s_with_preamble, 50, total_samples);
|
add_freq(&qam, s_with_preamble, 100, total_samples);
|
||||||
|
|
||||||
// Estimation / correction du CFO
|
// Estimation / correction du CFO
|
||||||
cfo(s_with_preamble, qam.N, L, qam.Fs, total_samples, qam.Fc);
|
cfo(s_with_preamble, qam.N, L, qam.Fs, total_samples, qam.Fc);
|
||||||
@ -425,15 +425,13 @@ int main () {
|
|||||||
|
|
||||||
// PLL
|
// PLL
|
||||||
double complex* s_corrected = malloc(sizeof(double complex) * total_samples);
|
double complex* s_corrected = malloc(sizeof(double complex) * total_samples);
|
||||||
double Kp = 0.5;
|
double Kp = 0.03;
|
||||||
double Ki = 0.01;
|
double Ki = 0.002;
|
||||||
double alpha = 0.1;
|
double alpha = 0.1;
|
||||||
FILE *fp_pll_error = fopen("pll_error.dat", "w");
|
FILE *fp_pll_error = fopen("pll_error.dat", "w");
|
||||||
pll(&qam, s_with_preamble, s_corrected, L, total_samples, nb_symbols, Kp, Ki, alpha, fp_pll_error);
|
pll(&qam, s_with_preamble, s_corrected, L, total_samples, nb_symbols, Kp, Ki, alpha, fp_pll_error);
|
||||||
fclose(fp_pll_error);
|
fclose(fp_pll_error);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Démodulation
|
// Démodulation
|
||||||
FILE *fp_constel = fopen("constellation.dat", "w");
|
FILE *fp_constel = fopen("constellation.dat", "w");
|
||||||
uint8_t* output_bits = (uint8_t*)malloc(nb_bits * sizeof(uint8_t));
|
uint8_t* output_bits = (uint8_t*)malloc(nb_bits * sizeof(uint8_t));
|
||||||
|
|||||||
Reference in New Issue
Block a user