From b464d0b7e16abe2e1a2ff9aad73409c2b42228dd Mon Sep 17 00:00:00 2001 From: Piotr Krysik Date: Wed, 6 May 2009 13:54:03 +0200 Subject: resampler causes that frequency estimate is getting lower for higher osr --- src/lib/gsm_receiver_cf.cc | 31 ++++++++++++++++++++++++------- src/python/gsm_findfcch.py | 13 ++++++------- 2 files changed, 30 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/lib/gsm_receiver_cf.cc b/src/lib/gsm_receiver_cf.cc index 045c639..8e4670b 100644 --- a/src/lib/gsm_receiver_cf.cc +++ b/src/lib/gsm_receiver_cf.cc @@ -208,7 +208,7 @@ bool gsm_receiver_cf::find_fcch_burst(const gr_complex *in, const int nitems) fcch_search_state = init; //DCOUT("hit_count: " << hit_count << " miss_count: " << miss_count << " d_counter: " << d_counter); continue; - } else if ((miss_count >= FCCH_MAX_MISSES * d_OSR) && (hit_count > FCCH_HITS_NEEDED * d_OSR)) { + } else if (((miss_count >= FCCH_MAX_MISSES * d_OSR) && (hit_count > FCCH_HITS_NEEDED * d_OSR)) || (hit_count > 2 * FCCH_HITS_NEEDED * d_OSR)) { fcch_search_state = fcch_found; continue; } else if ((miss_count < FCCH_MAX_MISSES * d_OSR) && (hit_count > FCCH_HITS_NEEDED * d_OSR)) { @@ -239,6 +239,7 @@ bool gsm_receiver_cf::find_fcch_burst(const gr_complex *in, const int nitems) } phase_diff = compute_phase_diff(in[sample_number], in[sample_number-1]); +// std::cout << phase_diff << "\n"; phase_diff_buffer.push_back(phase_diff); fcch_search_state = found_something; @@ -302,7 +303,7 @@ bool gsm_receiver_cf::find_sch_burst(const gr_complex *in, const int nitems , fl bool result = false; int sample_nr_near_sch_start = d_fcch_start_pos + (FRAME_BITS - SAFETY_MARGIN) * d_OSR; vector_complex correlation_buffer; - list_float power_buffer; + vector_float power_buffer; vector_float window_energy_buffer; int strongest_window_nr; @@ -315,7 +316,7 @@ bool gsm_receiver_cf::find_sch_burst(const gr_complex *in, const int nitems , fl int chan_imp_length = 4; float energy = 0; bool loop_end = false; - list_float::iterator iter; + vector_float::iterator iter; while (!end) { switch (sch_search_state) { @@ -350,34 +351,50 @@ bool gsm_receiver_cf::find_sch_burst(const gr_complex *in, const int nitems , fl } //compute window energies + +// std::cout << "\nkorelacje wybrane do liczenia energii\n"; iter = power_buffer.begin(); + while (iter != power_buffer.end()) { - list_float::iterator iter_ii = iter; + vector_float::iterator iter_ii = iter; energy = 0; - for (int ii = 0; ii < chan_imp_length; ii++, iter_ii++) { + for (int ii = 0; ii < chan_imp_length; ii++) { if (iter_ii == power_buffer.end()) { loop_end = true; break; } +// std::cout << iter_ii - power_buffer.begin() << "\n"; energy += (*iter_ii); + iter_ii = iter_ii+d_OSR; } +// std::cout << "\n"; if (loop_end) { break; } iter++; -// std::cout << energy << "\n"; +// std::cout << energy << "\n"; window_energy_buffer.push_back(energy); } strongest_window_nr = max_element(window_energy_buffer.begin(), window_energy_buffer.end()) - window_energy_buffer.begin(); d_channel_imp_resp.clear(); - for (int ii = 0; ii < chan_imp_length; ii++) { + std::cout << "\nOdp impulsowa:\n"; + for (int ii = 0; ii < chan_imp_length+1; ii++) { gr_complex correlation = correlation_buffer[strongest_window_nr + (ii * d_OSR)]; + std::cout << correlation << "\n"; d_channel_imp_resp.push_back(correlation); } + std::cout << "\nBurst:\n"; + + for (int ii = 0; ii < 156; ii++) { + gr_complex correlation = in[strongest_window_nr + (ii * d_OSR) - 42* d_OSR + SYNC_POS * d_OSR]; + std::cout << correlation << "\n"; + d_channel_imp_resp.push_back(correlation); + } + std::cout << "\n\n"; DCOUT("strongest_window_nr: " << strongest_window_nr); sch_search_state = sch_found; diff --git a/src/python/gsm_findfcch.py b/src/python/gsm_findfcch.py index 7ab9c18..5f85dc2 100755 --- a/src/python/gsm_findfcch.py +++ b/src/python/gsm_findfcch.py @@ -16,12 +16,11 @@ class tune(gr.feval_dd): def __init__(self, top_block): gr.feval_dd.__init__(self) self.top_block = top_block - self.center_freq = 0 + # self.center_freq = 0 def eval(self, freq_offet): - self.center_freq = self.center_freq - freq_offet - self.top_block.set_frequency(self.center_freq) - return self.center_freq - + # self.center_freq = self.center_freq - freq_offet + self.top_block.set_frequency(freq_offet) + return freq_offet class gsm_receiver_first_blood(gr.top_block): def __init__(self): @@ -57,13 +56,13 @@ class gsm_receiver_first_blood(gr.top_block): self.clock_rate = clock_rate self.input_rate = clock_rate / options.decim self.gsm_symb_rate = 1625000.0 / 6.0 - self.sps = self.input_rate / self.gsm_symb_rate + self.sps = self.input_rate / self.gsm_symb_rate / self.options.osr def _ustaw_filtr(self): filter_cutoff = 145e3 filter_t_width = 10e3 offset = 0 - print "input_rate:", self.input_rate, "sample rate:", self.sps, " filter_cutoff:", filter_cutoff, " filter_t_width:", filter_t_width + #print "input_rate:", self.input_rate, "sample rate:", self.sps, " filter_cutoff:", filter_cutoff, " filter_t_width:", filter_t_width filter_taps = gr.firdes.low_pass(1.0, self.input_rate, filter_cutoff, filter_t_width, gr.firdes.WIN_HAMMING) filtr = gr.freq_xlating_fir_filter_ccf(1, filter_taps, offset, self.input_rate) return filtr -- cgit v1.2.3