From 5b4ffb9d0b5dcca27d4fdcd86b4609b2fda3cd92 Mon Sep 17 00:00:00 2001 From: Gastd Date: Tue, 18 Jul 2017 18:21:30 -0300 Subject: [PATCH] Add Glonass signal for tests --- .../gnuradio_blocks/signal_generator_c.cc | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/src/algorithms/signal_generator/gnuradio_blocks/signal_generator_c.cc b/src/algorithms/signal_generator/gnuradio_blocks/signal_generator_c.cc index 86f488588..026b47352 100644 --- a/src/algorithms/signal_generator/gnuradio_blocks/signal_generator_c.cc +++ b/src/algorithms/signal_generator/gnuradio_blocks/signal_generator_c.cc @@ -34,11 +34,13 @@ #include #include #include "gps_sdr_signal_processing.h" +#include "glonass_l1_signal_processing.h" #include "galileo_e1_signal_processing.h" #include "galileo_e5_signal_processing.h" #include "Galileo_E1.h" #include "Galileo_E5a.h" #include "GPS_L1_CA.h" +#include "Glonass_L1_CA.h" /* * Create a new instance of signal_generator_c and return @@ -107,6 +109,14 @@ void signal_generator_c::init() num_of_codes_per_vector_.push_back(galileo_signal ? 4 * static_cast(Galileo_E1_C_SECONDARY_CODE_LENGTH) : 1); data_bit_duration_ms_.push_back(1e3 / GPS_CA_TELEMETRY_RATE_BITS_SECOND); } + else if (system_[sat] == "R") + { + samples_per_code_.push_back(round(static_cast(fs_in_) + / (GLONASS_L1_CA_CODE_RATE_HZ / GLONASS_L1_CA_CODE_LENGTH_CHIPS))); + + num_of_codes_per_vector_.push_back(galileo_signal ? 4 * static_cast(Galileo_E1_C_SECONDARY_CODE_LENGTH) : 1); + data_bit_duration_ms_.push_back(1e3 / GLONASS_CA_TELEMETRY_RATE_BITS_SECOND); + } else if (system_[sat] == "E") { if (signal_[sat].at(0) == '5') @@ -160,6 +170,28 @@ void signal_generator_c::generate_codes() } } + // Concatenate "num_of_codes_per_vector_" codes + for (unsigned int i = 0; i < num_of_codes_per_vector_[sat]; i++) + { + memcpy(&(sampled_code_data_[sat][i * samples_per_code_[sat]]), + code, sizeof(gr_complex) * samples_per_code_[sat]); + } + } + else if (system_[sat] == "R") + { + // Generate one code-period of 1G signal + glonass_l1_ca_code_gen_complex_sampled(code, /*PRN_[sat],*/ fs_in_, + static_cast(GLONASS_L1_CA_CODE_LENGTH_CHIPS) - delay_chips_[sat]); + + // Obtain the desired CN0 assuming that Pn = 1. + if (noise_flag_) + { + for (unsigned int i = 0; i < samples_per_code_[sat]; i++) + { + code[i] *= sqrt(pow(10,CN0_dB_[sat] / 10) / BW_BB_); + } + } + // Concatenate "num_of_codes_per_vector_" codes for (unsigned int i = 0; i < num_of_codes_per_vector_[sat]; i++) { @@ -261,6 +293,8 @@ int signal_generator_c::general_work (int noutput_items __attribute__((unused)), unsigned int out_idx = 0; unsigned int i = 0; unsigned int k = 0; + // the intermediate frequency must set by the user + unsigned int freq = 9540000; for (out_idx = 0; out_idx < vector_length_; out_idx++) { @@ -311,6 +345,45 @@ int signal_generator_c::general_work (int noutput_items __attribute__((unused)), } } + else if (system_[sat] == "R") + { + phase_step_rad = -static_cast(GPS_TWO_PI) * (freq + (DFRQ1_GLO * GLONASS_PRN.at(PRN_[sat])) + doppler_Hz_[sat]) / static_cast(fs_in_); + // std::cout << "sat " << PRN_[sat] << " SG - Freq = " << (freq + (DFRQ1_GLO * GLONASS_PRN.at(PRN_[sat]))) << " Doppler = " << doppler_Hz_[sat] << std::endl; + _phase[0] = -start_phase_rad_[sat]; + volk_gnsssdr_s32f_sincos_32fc(complex_phase_, -phase_step_rad, _phase, vector_length_); + + unsigned int delay_samples = (delay_chips_[sat] % static_cast(GLONASS_L1_CA_CODE_LENGTH_CHIPS)) + * samples_per_code_[sat] / GLONASS_L1_CA_CODE_LENGTH_CHIPS; + + for (i = 0; i < num_of_codes_per_vector_[sat]; i++) + { + for (k = 0; k < delay_samples; k++) + { + out[out_idx] += sampled_code_data_[sat][out_idx] + * current_data_bits_[sat] + * complex_phase_[out_idx]; + out_idx++; + } + + if (ms_counter_[sat] == 0 && data_flag_) + { + // New random data bit + current_data_bits_[sat] = gr_complex((uniform_dist(e1) % 2) == 0 ? 1 : -1, 0); + } + + for (k = delay_samples; k < samples_per_code_[sat]; k++) + { + out[out_idx] += sampled_code_data_[sat][out_idx] + * current_data_bits_[sat] + * complex_phase_[out_idx]; + out_idx++; + } + + ms_counter_[sat] = (ms_counter_[sat] + static_cast(round(1e3*GLONASS_L1_CA_CODE_PERIOD))) + % data_bit_duration_ms_[sat]; + } + } + else if (system_[sat] == "E") { if(signal_[sat].at(0)=='5')