Skip to content

Commit 8fa5bc6

Browse files
author
Jiao Xianjun(Ryan)
committed
minor tuning on threshold and default ppm setting
1 parent 56104d0 commit 8fa5bc6

19 files changed

+178
-15
lines changed

Matlab/regression_test_result/find_optimal_Z_th1.m

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
% load simple_resv1_2_4_pss_period_try1_max_peak_all_improved_record_more/CellSearch_test1to33_twist0_fo-140to140_resv2_numPtry1_Prange160_parTh15_numPth0.5.mat;
66
% load simple_resv1_2_4_pss_period_try1_max_peak_all_improved_record_more_ex_gain2.4/CellSearch_test1to33_twist0_fo-140to140_resv2_numPtry1_Prange160_parTh15_numPth0.5.mat;
77
% load simple_resv1_2_4_pss_period_try1_max_peak_all_improved_record_more_ex_gain2/CellSearch_test1to33_twist0_fo-140to140_resv2_numPtry1_Prange160_parTh15_numPth0.5.mat;
8-
load simple_resv1_2_4_pss_period_try1_max_peak_all_improved_record_more_ex_gain2_peak_range-1/CellSearch_test1to33_twist0_fo-140to140_resv2_numPtry1_Prange-1_parTh8_numPth0.5.mat;
8+
% load simple_resv1_2_4_pss_period_try1_max_peak_all_improved_record_more_ex_gain2_peak_range-1/CellSearch_test1to33_twist0_fo-140to140_resv2_numPtry1_Prange-1_parTh8_numPth0.5.mat;
9+
load par_explore/CellSearch_test1to33_twist0_fo-140to140_resv2_numPtry1_Prange-1_parTh8_numPth0.5.mat;
910

1011
idx_raw = [];
1112
z_th1_store_raw = [];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
2+
clear all; close all;
3+
4+
format_str = {'r', 'b.', 'gs', 'k'};
5+
load par_explore/CellSearch_test1to33_twist0_fo-140to140_resv2_numPtry1_Prange-1_parTh8_numPth0.5.mat;
6+
7+
idx_raw = [];
8+
z_th1_store_raw = [];
9+
pow_store_raw = [];
10+
z_th1_store = [];
11+
pow_store = [];
12+
top_idx = [];
13+
sub_idx = [];
14+
try_idx = [];
15+
par_valid = [];
16+
par_invalid = [];
17+
par_combined_max_valid = [];
18+
par_combined_max_invalid = [];
19+
par_max_max_valid = [];
20+
par_max_max_invalid = [];
21+
for i = 1 : length(cell_info)
22+
a = cell_info{i};
23+
for k = 1 : length(a)
24+
z_th1_store_raw = [z_th1_store_raw a(k).Z_th1];
25+
pow_store_raw = [pow_store_raw a(k).pow];
26+
flag = 0;
27+
if ~isnan(a(k).n_id_cell)
28+
flag = 1;
29+
z_th1_store = [z_th1_store a(k).Z_th1];
30+
try_idx = [try_idx a(k).extra_info.try_idx];
31+
par_valid = [par_valid a(k).extra_info.par];
32+
par_combined_max_valid = [par_combined_max_valid a(k).extra_info.par_combined_max];
33+
par_max_max_valid = [par_max_max_valid a(k).extra_info.par_max_max];
34+
pow_store = [pow_store a(k).pow];
35+
top_idx = [top_idx i];
36+
sub_idx = [sub_idx k];
37+
else
38+
par_invalid = [par_invalid a(k).extra_info.par];
39+
par_combined_max_invalid = [par_combined_max_invalid a(k).extra_info.par_combined_max];
40+
par_max_max_invalid = [par_max_max_invalid a(k).extra_info.par_max_max];
41+
end
42+
idx_raw = [idx_raw flag];
43+
end
44+
end
45+
46+
figure; plot(try_idx, 'b.-');
47+
48+
figure; plot(par_valid, 'b'); hold on; plot(par_invalid, 'r');
49+
figure; plot(par_combined_max_valid, 'b'); hold on; plot(par_combined_max_invalid, 'r');
50+
figure; plot(par_max_max_valid, 'b'); hold on; plot(par_max_max_invalid, 'r');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
% function merge_result
2+
clear all; close all;
3+
4+
load CellSearch_test1to4_twist0_fo-140to140_resv2_numPtry1_Prange-1_parTh8_numPth0.5.mat
5+
cell_info_save = cell_info;
6+
7+
load CellSearch_test5to8_twist0_fo-140to140_resv2_numPtry1_Prange-1_parTh8_numPth0.5.mat
8+
cell_info_save(test_sp:test_ep) = cell_info(test_sp:test_ep);
9+
10+
load CellSearch_test9to12_twist0_fo-140to140_resv2_numPtry1_Prange-1_parTh8_numPth0.5.mat
11+
cell_info_save(test_sp:test_ep) = cell_info(test_sp:test_ep);
12+
13+
load CellSearch_test13to16_twist0_fo-140to140_resv2_numPtry1_Prange-1_parTh8_numPth0.5.mat
14+
cell_info_save(test_sp:test_ep) = cell_info(test_sp:test_ep);
15+
16+
load CellSearch_test17to20_twist0_fo-140to140_resv2_numPtry1_Prange-1_parTh8_numPth0.5.mat
17+
cell_info_save(test_sp:test_ep) = cell_info(test_sp:test_ep);
18+
19+
load CellSearch_test21to24_twist0_fo-140to140_resv2_numPtry1_Prange-1_parTh8_numPth0.5.mat
20+
cell_info_save(test_sp:test_ep) = cell_info(test_sp:test_ep);
21+
22+
load CellSearch_test25to28_twist0_fo-140to140_resv2_numPtry1_Prange-1_parTh8_numPth0.5.mat
23+
cell_info_save(test_sp:test_ep) = cell_info(test_sp:test_ep);
24+
25+
load CellSearch_test29to33_twist0_fo-140to140_resv2_numPtry1_Prange-1_parTh8_numPth0.5.mat
26+
cell_info_save(test_sp:test_ep) = cell_info(test_sp:test_ep);
27+
28+
cell_info = cell_info_save;
29+
30+
test_sp = 1;
31+
test_ep = 33;
32+
33+
clear cell_info_save;
34+
35+
save CellSearch_test1to33_twist0_fo-140to140_resv2_numPtry1_Prange-1_parTh8_numPth0.5.mat
36+

Matlab/sampling_ppm_f_search_set_by_pss.m

+24-5
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@
5757
pss_period = 19200/2;
5858

5959
num_half_radioframe = floor( len_short./pss_period );
60-
peak_to_avg = zeros(1, num_fo_pss);
60+
% peak_to_avg = zeros(1, num_fo_pss);
61+
peak_to_avg_combined_max = zeros(1, num_fo_pss);
6162

6263
corr_store_tmp = corr_store(1:pss_period, : );
6364
for j=2:num_half_radioframe
@@ -66,6 +67,14 @@
6667
corr_store_tmp = corr_store_tmp + corr_store(sp:ep, : );
6768
end
6869

70+
% peak_to_avg_max_max_tmp = zeros(num_half_radioframe, num_fo_pss);
71+
% for j=1:num_half_radioframe
72+
% sp = (j-1)*pss_period + 1;
73+
% ep = j*pss_period;
74+
% peak_to_avg_max_max_tmp(j,:) = (max(corr_store(sp:ep, : ), [], 1)./mean(corr_store(sp:ep, : ), 1));
75+
% end
76+
% peak_to_avg_max_max = 10.*log10( max(peak_to_avg_max_max_tmp, [], 1) );
77+
6978
[~, max_idx_all] = max(corr_store_tmp, [], 1);
7079
for j=1:num_fo_pss
7180
tmp_max_idx = max_idx_all(j);
@@ -80,7 +89,8 @@
8089
% tmp_avg = mean(tmp_avg);
8190

8291
tmp_avg = (sum(corr_store_tmp(:, j)) - tmp_peak)/(pss_period - 2*num_half_radioframe -1 );
83-
peak_to_avg(j) = 10*log10(tmp_peak/tmp_avg);
92+
% peak_to_avg(j) = 10*log10(tmp_peak/tmp_avg);
93+
peak_to_avg_combined_max(j) = 10*log10(corr_store_tmp(tmp_max_idx, j)/tmp_avg);
8494
end
8595

8696
max_peak_all = max(corr_store, [], 1);
@@ -93,9 +103,18 @@
93103
% [~, sort_idx] = sort(peak_to_avg, 'descend');
94104

95105
% max_reserve = 1;
96-
above_par_idx = (peak_to_avg(sort_idx(1:max_reserve)) > par_th);
97-
disp(['Hit PAR ' num2str(peak_to_avg(sort_idx(1:max_reserve))) 'dB']);
98-
extra_info.par = peak_to_avg(sort_idx(1:max_reserve));
106+
% above_par_idx = (peak_to_avg(sort_idx(1:max_reserve)) > par_th);
107+
% disp(['Hit PAR ' num2str(peak_to_avg(sort_idx(1:max_reserve))) 'dB']);
108+
109+
above_par_idx = (peak_to_avg_combined_max(sort_idx(1:max_reserve)) > par_th);
110+
disp(['Hit PAR ' num2str(peak_to_avg_combined_max(sort_idx(1:max_reserve))) 'dB']);
111+
112+
% disp(['Hit PAR ' num2str(peak_to_avg_max_max(sort_idx(1:max_reserve))) 'dB']);
113+
114+
% extra_info.par = peak_to_avg(sort_idx(1:max_reserve));
115+
extra_info.par_combined_max = peak_to_avg_combined_max(sort_idx(1:max_reserve));
116+
% extra_info.par_max_max = peak_to_avg_max_max(sort_idx(1:max_reserve));
117+
99118
extra_info.sort_idx = sort_idx(1:max_reserve);
100119
a_tmp = [fo_search_set fo_search_set fo_search_set];
101120
extra_info.fo_raw = a_tmp(sort_idx(1:max_reserve));

Matlab/test_CellSearch.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
num_pss_period_try = 1;
2525
% combined_pss_peak_range = 160;
2626
combined_pss_peak_range = -1; % set it to -1 to use complementary range of peak.
27-
par_th = 16;
27+
par_th = 8.5;
2828
num_peak_th = 1/2; % originally is 2/3;
2929

3030
filename = ['CellSearch_test' num2str(test_sp) 'to' num2str(test_ep) '_twist' num2str(sampling_carrier_twist) '_fo' num2str(min(f_search_set)/1e3) 'to' num2str(max(f_search_set)/1e3) '_resv' num2str(pss_peak_max_reserve) '_numPtry' num2str(num_pss_period_try) '_Prange' num2str(combined_pss_peak_range) '_parTh' num2str(par_th) '_numPth' num2str(num_peak_th) '.mat'];

include/searcher.h

+7
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,13 @@ class lte_opencl_t {
128128
};
129129
#endif
130130

131+
void filter_my_fft(
132+
//Inputs
133+
const itpp::vec & coef,
134+
//Inputs&Outputs
135+
itpp::cvec & capbuf
136+
);
137+
131138
// FIR 6RB filter
132139
void filter_my(
133140
//Inputs
Binary file not shown.

src/CellSearch.cpp

+20-4
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ void print_usage() {
108108
cout << "'c' is the correction factor to apply and indicates that if the desired" << endl;
109109
cout << "center frequency is fc, the RTL-SDR dongle should be instructed to tune" << endl;
110110
cout << "to freqency fc*c so that its true frequency shall be fc. Default: 1.0" << endl << endl;
111-
cout << "'ppm' is the remaining frequency error of the crystal. Default: 120" << endl;
111+
cout << "'ppm' is the remaining frequency error of the crystal. Default: - (search -140kHz to 135kHz)" << endl;
112112
cout << "" << endl;
113113
cout << "If the crystal has not been used for a long time, use the default values for" << endl;
114114
cout << "'ppm' and 'c' until a cell is successfully located. The program will return" << endl;
@@ -155,7 +155,7 @@ void parse_commandline(
155155
freq_end=-1;
156156
num_try=1; // default number
157157
sampling_carrier_twist=false;
158-
ppm=120;
158+
ppm=0;
159159
correction=1;
160160
save_cap=false;
161161
use_recorded_data=false;
@@ -856,14 +856,24 @@ int main(
856856
cmat pss_fo_set;// pre-generate frequencies offseted pss time domain sequence
857857
vec f_search_set;
858858
if (sampling_carrier_twist) { // original mode
859-
const uint16 n_extra=floor_i((fc_search_set(0)*ppm/1e6+2.5e3)/5e3);
859+
uint16 n_extra=0;
860+
if (ppm!=0)
861+
n_extra=floor_i((fc_search_set(0)*ppm/1e6+2.5e3)/5e3);
862+
else
863+
n_extra=28;
864+
860865
f_search_set=to_vec(itpp_ext::matlab_range( -n_extra*5000,5000, (n_extra-1)*5000));
861866
// for graphic card which has limited mem, you should turn num_loop on if OpenCL reports -4: CL_MEM_OBJECT_ALLOCATION_FAILURE
862867
// if (num_loop == 0) // it is not so useful
863868
// num_loop = length(f_search_set)/2;
864869
} else {
865870
if (length(fc_search_set)==1) {//when only one frequency is specified, whole PPM range should be covered
866-
const uint16 n_extra=floor_i((fc_search_set(0)*ppm/1e6+2.5e3)/5e3);
871+
uint16 n_extra=0;
872+
if (ppm!=0)
873+
n_extra=floor_i((fc_search_set(0)*ppm/1e6+2.5e3)/5e3);
874+
else
875+
n_extra=28; //-140kHz to 135kHz
876+
867877
f_search_set=to_vec(itpp_ext::matlab_range( -n_extra*5000,5000, (n_extra-1)*5000));
868878
} else {
869879
// since we have frequency step is 100e3, why not have sub search set limited by this regardless PPM?
@@ -985,7 +995,13 @@ int main(
985995
// 6RB filter to improve SNR
986996
// tt.tic();
987997
#ifdef USE_OPENCL
998+
// tt.tic();
988999
lte_ocl.filter_my(capbuf); // be careful! capbuf.zeros() will slow down the xcorr part pretty much!
1000+
// cout << "1 cost " << tt.get_time() << "s\n";
1001+
//
1002+
// tt.tic();
1003+
// filter_my_fft(coef, capbuf);
1004+
// cout << "2 cost " << tt.get_time() << "s\n";
9891005
#else
9901006
filter_my(coef, capbuf);
9911007
#endif

src/searcher.cpp

+38-4
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#include <itpp/itbase.h>
5252
#include <itpp/signal/transforms.h>
5353
#include <itpp/stat/misc_stat.h>
54+
#include <itpp/signal/freq_filt.h>
5455
#include <math.h>
5556
#include <list>
5657
#include <iomanip>
@@ -1883,6 +1884,39 @@ void normalize(
18831884
s = sqrt(len)*s/sqrt(acc);
18841885
}
18851886

1887+
// FIR 6RB filter
1888+
void filter_my_fft(
1889+
//Inputs
1890+
const vec & coef,
1891+
//Inputs&Outputs
1892+
cvec & capbuf
1893+
) {
1894+
uint32 len = length(capbuf);
1895+
uint16 len_fir = length(coef);
1896+
uint16 len_half = (len_fir-1)/2;
1897+
1898+
vec tmpbufin_re(len+len_fir-1);
1899+
vec tmpbufin_im(len+len_fir-1);
1900+
1901+
tmpbufin_re.set_subvector(0, real(capbuf));
1902+
tmpbufin_im.set_subvector(0, imag(capbuf));
1903+
tmpbufin_re.set_subvector(len, len+len_fir-1, 0);
1904+
tmpbufin_im.set_subvector(len, len+len_fir-1, 0);
1905+
1906+
Freq_Filt<double> FF(coef, len+len_fir-1);
1907+
1908+
// Real_Timer tt;
1909+
// tt.tic();
1910+
vec tmpbufout_re = FF.filter(tmpbufin_re);
1911+
vec tmpbufout_im = FF.filter(tmpbufin_im);
1912+
// cout << "2 cost " << tt.get_time() << "s\n";
1913+
// cout << tmpbufout_re(len_half, len_half+7) << "\n";
1914+
1915+
for(uint32 i=0; i<len; i++) {
1916+
capbuf(i) = complex<double>(tmpbufout_re(i+len_half), tmpbufout_im(i+len_half));
1917+
}
1918+
}
1919+
18861920
// FIR 6RB filter
18871921
void filter_my(
18881922
//Inputs
@@ -2248,7 +2282,7 @@ void sampling_ppm_f_search_set_by_pss(
22482282
const uint32 pss_period = 19200/2;
22492283

22502284
const uint32 num_half_radioframe = len_short/pss_period;
2251-
vec peak_to_avg(num_fo_pss);
2285+
vec peak_to_avg_combined_max(num_fo_pss);
22522286
mat corr_store_tmp(num_fo_pss, pss_period);
22532287
corr_store_tmp = corr_store.get_cols(0, pss_period-1);
22542288
for (uint16 j=1; j<num_half_radioframe; j++) {
@@ -2278,7 +2312,7 @@ void sampling_ppm_f_search_set_by_pss(
22782312
tmp_peak = sum( corr_store_tmp_col.get(sum_range) );
22792313

22802314
tmp_avg_val = (sum(corr_store_tmp_col) - tmp_peak)/((double)pss_period-(2.0*(double)num_half_radioframe+1.0));
2281-
peak_to_avg(j) = tmp_peak/tmp_avg_val;
2315+
peak_to_avg_combined_max(j) = corr_store_tmp(j, tmp_max_idx)/tmp_avg_val;
22822316

22832317
// tmp_store = corr_store.get_row(j);
22842318
// logical_tmp = tmp_store > (max_peak_all(j)*2/3);
@@ -2287,9 +2321,9 @@ void sampling_ppm_f_search_set_by_pss(
22872321

22882322
ivec sort_idx = sort_index(max_peak_all);
22892323
sort_idx = reverse(sort_idx); // from ascending to descending
2290-
cout << "Hit PAR " << 10.0*log10( peak_to_avg.get( sort_idx(0, max_reserve-1) ) ) << "dB\n";
2324+
cout << "Hit PAR " << 10.0*log10( peak_to_avg_combined_max.get( sort_idx(0, max_reserve-1) ) ) << "dB\n";
22912325

2292-
ivec above_par_idx = to_ivec( peak_to_avg.get( sort_idx(0, max_reserve-1) ) > pow(10.0, 16/10.0) );
2326+
ivec above_par_idx = to_ivec( peak_to_avg_combined_max.get( sort_idx(0, max_reserve-1) ) > pow(10.0, 8.5/10.0) );
22932327
uint16 len_sort_idx = sum(above_par_idx);
22942328

22952329
if (len_sort_idx==0) {

0 commit comments

Comments
 (0)