aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPiotr Krysik <ptrkrysik@gmail.com>2017-01-18 21:53:17 +0100
committerPiotr Krysik <ptrkrysik@gmail.com>2017-01-18 21:53:17 +0100
commit9bc0fc0c59367a39dbba33736c7803de7423c82d (patch)
tree9fad342b47b4385a03af3ce32d2e72488442ab15 /lib
parent01f9c1975e5999a51980e502bfd2c9e90bc33c68 (diff)
Changed frequency estimator to the old one that worked better
Diffstat (limited to 'lib')
-rw-r--r--lib/receiver/receiver_impl.cc59
-rw-r--r--lib/receiver/receiver_impl.h6
2 files changed, 8 insertions, 57 deletions
diff --git a/lib/receiver/receiver_impl.cc b/lib/receiver/receiver_impl.cc
index f55d613..f43f6e0 100644
--- a/lib/receiver/receiver_impl.cc
+++ b/lib/receiver/receiver_impl.cc
@@ -82,10 +82,6 @@ receiver_impl::receiver_impl(int osr, const std::vector<int> &cell_allocation, c
d_last_time(0.0)
{
int i;
-
- unsigned int alignment = volk_get_alignment();
- d_freq_estim_vector = (lv_32fc_t*)volk_malloc(sizeof(lv_32fc_t)*160, alignment);
- d_freq_estim_result = (lv_32fc_t*)volk_malloc(sizeof(lv_32fc_t)*1, alignment);
//don't send samples to the receiver until there are at least samples for one
set_output_multiple(floor((TS_BITS + 2 * GUARD_PERIOD) * d_OSR)); // burst and two gurad periods (one gurard period is an arbitrary overlap)
gmsk_mapper(SYNC_BITS, N_SYNC_BITS, d_sch_training_seq, gr_complex(0.0, -1.0));
@@ -106,8 +102,6 @@ receiver_impl::receiver_impl(int osr, const std::vector<int> &cell_allocation, c
*/
receiver_impl::~receiver_impl()
{
- volk_free(d_freq_estim_vector);
- volk_free(d_freq_estim_result);
}
int
@@ -294,7 +288,7 @@ receiver_impl::work(int noutput_items,
dummy_burst_start = get_norm_chan_imp_resp(input, &channel_imp_resp[0], &dummy_corr_max, TS_DUMMY);
normal_burst_start = get_norm_chan_imp_resp(input, &channel_imp_resp[0], &normal_corr_max, d_bcc);
-
+
if (normal_corr_max > dummy_corr_max)
{
d_c0_burst_start = normal_burst_start;
@@ -545,59 +539,20 @@ double receiver_impl::estim_freq_norm(const gr_complex * input, unsigned first_s
unsigned ii;
- gr_complex sum = 0;
+ double sum = 0;
- for (ii = first_sample; ii < last_sample-d_OSR; ii=ii+d_OSR)
+ for (ii = first_sample; ii < last_sample-1; ii++)
{
- sum += input[ii+d_OSR] * conj(input[ii]);
+ sum += fast_atan2f(input[ii+1] * conj(input[ii]));
}
-
- return fast_atan2f(imag(sum), real(sum))/(2*M_PI);
+ int N = last_sample-1-first_sample;
+ return sum/(2*M_PI)/N * d_OSR;
}
-double receiver_impl::estim_freq_norm2(const gr_complex * input, unsigned first_sample, unsigned last_sample) //another frequency estimator - faster one
-{
-
- unsigned ii;
-
- int N = (last_sample-first_sample)/d_OSR;
-
- for (unsigned ii = 0; ii < N; ii++)
- {
- d_freq_estim_vector[ii] = input[first_sample+ii*d_OSR];
- }
-
- volk_32fc_x2_conjugate_dot_prod_32fc(d_freq_estim_result, d_freq_estim_vector+1, d_freq_estim_vector, N-1);
-
- return fast_atan2f(imag(d_freq_estim_result[0]), real(d_freq_estim_result[0]))/(2*M_PI);
-}
-
-
double receiver_impl::compute_freq_offset(const gr_complex * input, unsigned first_sample, unsigned last_sample)
{
- float freq_norm = estim_freq_norm2(input, first_sample, last_sample);
-
-// using namespace std;
-// clock_t begin = clock();
-//
-// for(int ii=0;ii<500;ii++){
-// float dupa = estim_freq_norm2(input, first_sample, last_sample);
-// }
-// clock_t end = clock();
-// double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
-// std::cout << "elapsed_secs " << elapsed_secs << std::endl;
-
-// begin = clock();
-//
-// for(int ii=0;ii<500;ii++){
-// float dupa = estim_freq_norm(input, first_sample, last_sample);
-// }
-// end = clock();
-// elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
-// std::cout << "elapsed_secs_old " << elapsed_secs << std::endl;
-
+ float freq_norm = estim_freq_norm(input, first_sample, last_sample);
float freq_offset = (freq_norm - 0.25) * 1625000.0/6.0;
-
return freq_offset;
}
diff --git a/lib/receiver/receiver_impl.h b/lib/receiver/receiver_impl.h
index eb406f3..251cf55 100644
--- a/lib/receiver/receiver_impl.h
+++ b/lib/receiver/receiver_impl.h
@@ -37,9 +37,6 @@ namespace gr {
unsigned int d_c0_burst_start;
float d_c0_signal_dbm;
- lv_32fc_t* d_freq_estim_vector;// = (lv_32fc_t*)volk_malloc(sizeof(lv_32fc_t)*160, alignment);
- lv_32fc_t* d_freq_estim_result;// = (lv_32fc_t*)volk_malloc(sizeof(lv_32fc_t)*1, alignment);
-
/**@name Configuration of the receiver */
//@{
const int d_OSR; ///< oversampling ratio
@@ -112,8 +109,7 @@ namespace gr {
*/
double compute_freq_offset(const gr_complex * input, unsigned first_sample, unsigned last_sample);
- double estim_freq_norm(const gr_complex * input, unsigned first_sample, unsigned last_sample); //another frequency estimator
- double estim_freq_norm2(const gr_complex * input, unsigned first_sample, unsigned last_sample); //another frequency estimator
+ double estim_freq_norm(const gr_complex * input, unsigned first_sample, unsigned last_sample); //normalized frequency estimator
/** Computes angle between two complex numbers
*
* @param val1 first complex number