Added support for reduced sampling rates

master
ismagom 9 years ago
parent d725d73511
commit cb61ff4009

@ -62,6 +62,7 @@ void init_plots();
pthread_t plot_thread; pthread_t plot_thread;
sem_t plot_sem; sem_t plot_sem;
uint32_t plot_sf_idx=0; uint32_t plot_sf_idx=0;
bool plot_track = true;
#endif #endif
#define PLOT_CHEST_ARGUMENT #define PLOT_CHEST_ARGUMENT
@ -323,10 +324,12 @@ int main(int argc, char **argv) {
/* set sampling frequency */ /* set sampling frequency */
int srate = srslte_sampling_freq_hz(cell.nof_prb); int srate = srslte_sampling_freq_hz(cell.nof_prb);
if (srate != -1) { if (srate != -1) {
/* Modify master clock rate for 15 Mhz */ if (srate < 10e6) {
if (cell.nof_prb == 75) { cuhd_set_master_clock_rate(uhd, 4*srate);
cuhd_set_master_clock_rate(uhd, 23.04e6); } else {
cuhd_set_master_clock_rate(uhd, srate);
} }
printf("Setting Sampling frequency %.2f MHz\n", (float) srate/1000000);
cuhd_set_rx_srate(uhd, (double) srate); cuhd_set_rx_srate(uhd, (double) srate);
} else { } else {
fprintf(stderr, "Invalid number of PRB %d\n", cell.nof_prb); fprintf(stderr, "Invalid number of PRB %d\n", cell.nof_prb);
@ -530,6 +533,7 @@ int main(int argc, char **argv) {
if (!prog_args.disable_plots) { if (!prog_args.disable_plots) {
if ((sfn%4) == 0 && decode_pdsch) { if ((sfn%4) == 0 && decode_pdsch) {
plot_sf_idx = srslte_ue_sync_get_sfidx(&ue_sync); plot_sf_idx = srslte_ue_sync_get_sfidx(&ue_sync);
plot_track = true;
sem_post(&plot_sem); sem_post(&plot_sem);
} }
} }
@ -538,6 +542,13 @@ int main(int argc, char **argv) {
printf("Finding PSS... Peak: %8.1f, FrameCnt: %d, State: %d\r", printf("Finding PSS... Peak: %8.1f, FrameCnt: %d, State: %d\r",
srslte_sync_get_peak_value(&ue_sync.sfind), srslte_sync_get_peak_value(&ue_sync.sfind),
ue_sync.frame_total_cnt, ue_sync.state); ue_sync.frame_total_cnt, ue_sync.state);
#ifndef DISABLE_GRAPHICS
if (!prog_args.disable_plots) {
plot_sf_idx = srslte_ue_sync_get_sfidx(&ue_sync);
plot_track = false;
sem_post(&plot_sem);
}
#endif
} }
sf_cnt++; sf_cnt++;
@ -646,12 +657,21 @@ void *plot_thread_run(void *arg) {
plot_real_setNewData(&pce, tmp_plot2, 4*12*ue_dl.cell.nof_prb); plot_real_setNewData(&pce, tmp_plot2, 4*12*ue_dl.cell.nof_prb);
if (!prog_args.input_file_name) { if (!prog_args.input_file_name) {
int max = srslte_vec_max_fi(ue_sync.strack.pss.conv_output_avg, ue_sync.strack.pss.frame_size+ue_sync.strack.pss.fft_size-1); if (plot_track) {
srslte_vec_sc_prod_fff(ue_sync.strack.pss.conv_output_avg, int max = srslte_vec_max_fi(ue_sync.strack.pss.conv_output_avg, ue_sync.strack.pss.frame_size+ue_sync.strack.pss.fft_size-1);
1/ue_sync.strack.pss.conv_output_avg[max], srslte_vec_sc_prod_fff(ue_sync.strack.pss.conv_output_avg,
tmp_plot2, 1/ue_sync.strack.pss.conv_output_avg[max],
ue_sync.strack.pss.frame_size+ue_sync.strack.pss.fft_size-1); tmp_plot2,
plot_real_setNewData(&p_sync, tmp_plot2, ue_sync.strack.pss.frame_size); ue_sync.strack.pss.frame_size+ue_sync.strack.pss.fft_size-1);
plot_real_setNewData(&p_sync, tmp_plot2, ue_sync.strack.pss.frame_size);
} else {
int max = srslte_vec_max_fi(ue_sync.sfind.pss.conv_output_avg, ue_sync.sfind.pss.frame_size+ue_sync.sfind.pss.fft_size-1);
srslte_vec_sc_prod_fff(ue_sync.sfind.pss.conv_output_avg,
1/ue_sync.sfind.pss.conv_output_avg[max],
tmp_plot2,
ue_sync.sfind.pss.frame_size+ue_sync.sfind.pss.fft_size-1);
plot_real_setNewData(&p_sync, tmp_plot2, ue_sync.sfind.pss.frame_size);
}
} }

@ -43,6 +43,8 @@
#include "srslte/config.h" #include "srslte/config.h"
#define USE_REDUCED_SAMPLING_RATES
#define SRSLTE_NSUBFRAMES_X_FRAME 10 #define SRSLTE_NSUBFRAMES_X_FRAME 10
#define SRSLTE_NSLOTS_X_FRAME (2*SRSLTE_NSUBFRAMES_X_FRAME) #define SRSLTE_NSLOTS_X_FRAME (2*SRSLTE_NSUBFRAMES_X_FRAME)
@ -95,8 +97,8 @@ typedef enum {SRSLTE_CP_NORM, SRSLTE_CP_EXT} srslte_cp_t;
#define SRSLTE_CP_LEN_NORM(symbol, symbol_sz) ((symbol==0)?SRSLTE_CP_LEN((symbol_sz),SRSLTE_CP_NORM_0_LEN):SRSLTE_CP_LEN((symbol_sz),SRSLTE_CP_NORM_LEN)) #define SRSLTE_CP_LEN_NORM(symbol, symbol_sz) ((symbol==0)?SRSLTE_CP_LEN((symbol_sz),SRSLTE_CP_NORM_0_LEN):SRSLTE_CP_LEN((symbol_sz),SRSLTE_CP_NORM_LEN))
#define SRSLTE_CP_LEN_EXT(symbol_sz) (SRSLTE_CP_LEN((symbol_sz),SRSLTE_CP_EXT_LEN)) #define SRSLTE_CP_LEN_EXT(symbol_sz) (SRSLTE_CP_LEN((symbol_sz),SRSLTE_CP_EXT_LEN))
#define SRSLTE_SLOT_LEN(symbol_sz) (480*((symbol_sz)/64)) #define SRSLTE_SLOT_LEN(symbol_sz) (symbol_sz*15/2)
#define SRSLTE_SF_LEN(symbol_sz) (2*SRSLTE_SLOT_LEN(symbol_sz)) #define SRSLTE_SF_LEN(symbol_sz) (symbol_sz*15)
#define SRSLTE_SF_LEN_MAX (SRSLTE_SF_LEN(SRSLTE_SYMBOL_SZ_MAX)) #define SRSLTE_SF_LEN_MAX (SRSLTE_SF_LEN(SRSLTE_SYMBOL_SZ_MAX))
#define SRSLTE_SLOT_LEN_PRB(nof_prb) (SRSLTE_SLOT_LEN(srslte_symbol_sz(nof_prb))) #define SRSLTE_SLOT_LEN_PRB(nof_prb) (SRSLTE_SLOT_LEN(srslte_symbol_sz(nof_prb)))

@ -197,6 +197,21 @@ int srslte_symbol_sz(uint32_t nof_prb) {
if (nof_prb<=0) { if (nof_prb<=0) {
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
#ifdef USE_REDUCED_SAMPLING_RATES
if (nof_prb<=6) {
return 128;
} else if (nof_prb<=15) {
return 256;
} else if (nof_prb<=25) {
return 384;
} else if (nof_prb<=50) {
return 768;
} else if (nof_prb<=75) {
return 1024;
} else if (nof_prb<=100) {
return 1536;
}
#else
if (nof_prb<=6) { if (nof_prb<=6) {
return 128; return 128;
} else if (nof_prb<=15) { } else if (nof_prb<=15) {
@ -210,6 +225,7 @@ int srslte_symbol_sz(uint32_t nof_prb) {
} else if (nof_prb<=100) { } else if (nof_prb<=100) {
return 2048; return 2048;
} }
#endif
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }

@ -140,7 +140,7 @@ int main(int argc, char **argv) {
init_plots(); init_plots();
#endif #endif
flen = 4800*(fft_size/64); flen = fft_size*15*5;
buffer = malloc(sizeof(cf_t) * flen * 2); buffer = malloc(sizeof(cf_t) * flen * 2);
if (!buffer) { if (!buffer) {
@ -200,7 +200,7 @@ int main(int argc, char **argv) {
exit(-1); exit(-1);
} }
if (n < flen - peak_offset) { if (n < flen - peak_offset) {
fprintf(stdout, "End of file\n"); fprintf(stdout, "End of file (n=%d, flen=%d, peak=%d)\n", n, flen, peak_offset);
break; break;
} }
@ -337,7 +337,7 @@ plot_real_t pssout;
plot_real_t psss1;//, psss2; plot_real_t psss1;//, psss2;
float tmp[100000]; float tmp[1000000];
cf_t tmpce[SRSLTE_PSS_LEN]; cf_t tmpce[SRSLTE_PSS_LEN];

@ -148,8 +148,27 @@ int main(int argc, char **argv) {
if (!disable_plots) if (!disable_plots)
init_plots(); init_plots();
#endif #endif
float srate = 15000.0*fft_size;
flen = 4800*(fft_size/64); flen = srate*5/1000;
printf("Opening UHD device...\n");
if (cuhd_open(uhd_args, &uhd)) {
fprintf(stderr, "Error opening uhd\n");
exit(-1);
}
if (srate < 10e6) {
cuhd_set_master_clock_rate(uhd, 4*srate);
} else {
cuhd_set_master_clock_rate(uhd, srate);
}
printf("Set RX rate: %.2f MHz\n", cuhd_set_rx_srate(uhd, srate) / 1000000);
printf("Set RX gain: %.1f dB\n", cuhd_set_rx_gain(uhd, uhd_gain));
printf("Set RX freq: %.2f MHz\n", cuhd_set_rx_freq(uhd, uhd_freq) / 1000000);
cuhd_rx_wait_lo_locked(uhd);
buffer = malloc(sizeof(cf_t) * flen * 2); buffer = malloc(sizeof(cf_t) * flen * 2);
if (!buffer) { if (!buffer) {
@ -177,16 +196,8 @@ int main(int argc, char **argv) {
srslte_sss_synch_set_N_id_2(&sss, N_id_2); srslte_sss_synch_set_N_id_2(&sss, N_id_2);
printf("Opening UHD device...\n");
if (cuhd_open(uhd_args, &uhd)) {
fprintf(stderr, "Error opening uhd\n");
exit(-1);
}
printf("N_id_2: %d\n", N_id_2); printf("N_id_2: %d\n", N_id_2);
printf("Set RX rate: %.2f MHz\n", cuhd_set_rx_srate(uhd, flen*2*100) / 1000000);
printf("Set RX gain: %.1f dB\n", cuhd_set_rx_gain(uhd, uhd_gain));
printf("Set RX freq: %.2f MHz\n", cuhd_set_rx_freq(uhd, uhd_freq) / 1000000);
cuhd_rx_wait_lo_locked(uhd);
cuhd_start_rx_stream(uhd); cuhd_start_rx_stream(uhd);
printf("Frame length %d samples\n", flen); printf("Frame length %d samples\n", flen);

Loading…
Cancel
Save