Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A failed attempt to build a case of QPSK modulation and demodulation case #1

Open
hydrogen0392 opened this issue Apr 20, 2024 · 0 comments

Comments

@hydrogen0392
Copy link

I tried to use these functions to build a QPSK modulation and demodulation case, but the demodulation results and the input data are very different, the main program is as follows, I think it is the function parameter setting problem, hope the author can point out the error or provide a correct QPSK modulation and demodulation case, thank you very much!

`#include <stdlib.h>
#include <stdint.h>
#include <math.h>
#include "butterworth_filter.h"
#include "rrc_filter.h"
#include "qpsk_modulator.h"
#include "bytes_symbols_converter.h"
#include "file_reader.h"
#include "qpsk_demodulator.h"
#include "pll.h"
#include "butterworth_filter.h"

int main() {

read_file();
uint32_t bytes_length = file_len;
uint32_t start_silence_length = 10;
uint32_t preamble_length = 10;
uint8_t add_iq_sync_byte = 1;
uint32_t end_silence_length = 10;

uint8_t* symbols = bytes_to_symbols(file_buf, bytes_length, start_silence_length, preamble_length, add_iq_sync_byte, end_silence_length);

uint32_t symbols_length = bytes_to_symbols_calculate_length(bytes_length, start_silence_length, preamble_length, add_iq_sync_byte, end_silence_length);

//初始化QPSK调制器
qpsk_modulator_s* qpsk_modulator = qpsk_modulator_init(10000,5000,2000,2,100.0);

// 计算所需的样本数
uint32_t samples_length = qpsk_modulator_calculate_samples_chunk_length(qpsk_modulator, symbols_length);

// 为 IQ 样本序列分配内存
float* samples_chunk = malloc(samples_length * sizeof(float));

// 调制符号
qpsk_modulator_modulate_chunk(qpsk_modulator, symbols, symbols_length, samples_chunk, 1);

// 初始化 QPSK 解调器
uint8_t* symbols_demodulate = malloc(samples_length * sizeof(uint8_t));

qpsk_demodulator_s* qpsk_demodulator = qpsk_demodulator_init(10000, 5000, 2000, 2, -1, 1, 1e4, 1e-6);

qpsk_demodulator_demodulate_chunk(qpsk_demodulator, samples_chunk, samples_length, symbols_demodulate, 1);

uint8_t* symbols_demodulate2 = malloc(symbols_length * sizeof(uint8_t));

symbols_demodulate2 = symbols_remove_empty(symbols_demodulate2, symbols_length);

symbols_demodulate2 = symbols_to_bytes(symbols_demodulate, symbols_length);

return 0;

}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant