Added TA and beta options to PRACH example

master
ismagom 10 years ago
parent 0cdfabccfd
commit f63244afb7

@ -65,6 +65,9 @@ typedef struct {
int force_N_id_2;
uint16_t rnti;
uint32_t file_nof_prb;
float beta_prach;
float ta_usec;
float beta_pusch;
char *uhd_args;
float uhd_rx_freq;
float uhd_tx_freq;
@ -78,6 +81,9 @@ void args_default(prog_args_t *args) {
args->rnti = SIRNTI;
args->force_N_id_2 = -1; // Pick the best
args->file_nof_prb = 6;
args->beta_prach = 0.2;
args->beta_pusch = 1.5;
args->ta_usec = -1.0;
args->uhd_args = "";
args->uhd_rx_freq = 2112500000.0;
args->uhd_tx_freq = 1922500000.0;
@ -87,12 +93,15 @@ void args_default(prog_args_t *args) {
}
void usage(prog_args_t *args, char *prog) {
printf("Usage: %s [agfFrlnv]\n", prog);
printf("Usage: %s [agfFbrlnv]\n", prog);
printf("\t-a UHD args [Default %s]\n", args->uhd_args);
printf("\t-g UHD TX/RX gain [Default %.2f dB]\n", args->uhd_rx_gain);
printf("\t-G UHD TX/RX gain [Default %.2f dB]\n", args->uhd_tx_gain);
printf("\t-f UHD RX freq [Default %.1f MHz]\n", args->uhd_rx_freq/1000000);
printf("\t-F UHD TX freq [Default %.1f MHz]\n", args->uhd_tx_freq/1000000);
printf("\t-b beta PRACH (transmission amplitude) [Default %f]\n",args->beta_prach);
printf("\t-B beta PUSCH (transmission amplitude) [Default %f]\n",args->beta_pusch);
printf("\t-t TA usec (time advance, -1 from RAR) [Default %f]\n",args->ta_usec);
printf("\t-r RNTI [Default 0x%x]\n",args->rnti);
printf("\t-l Force N_id_2 [Default best]\n");
printf("\t-n nof_subframes [Default %d]\n", args->nof_subframes);
@ -102,11 +111,20 @@ void usage(prog_args_t *args, char *prog) {
void parse_args(prog_args_t *args, int argc, char **argv) {
int opt;
args_default(args);
while ((opt = getopt(argc, argv, "agGfFrlnv")) != -1) {
while ((opt = getopt(argc, argv, "agGfFrlnvbBt")) != -1) {
switch (opt) {
case 'a':
args->uhd_args = argv[optind];
break;
case 'b':
args->beta_prach = atof(argv[optind]);
break;
case 'B':
args->beta_pusch = atof(argv[optind]);
break;
case 't':
args->ta_usec = atof(argv[optind]);
break;
case 'g':
args->uhd_rx_gain = atof(argv[optind]);
break;
@ -181,7 +199,7 @@ cf_t *sf_buffer = NULL;
int generate_prach_sequences(){
for(int i=0;i<NOF_PRACH_SEQUENCES;i++){
if(prach_gen(&prach, i, 0, prach_buffers[i])){
if(prach_gen(&prach, i, 0, prog_args.beta_prach, prach_buffers[i])){
fprintf(stderr, "Error generating prach sequence\n");
return -1;
}
@ -533,6 +551,9 @@ int main(int argc, char **argv) {
uint32_t n_ta = lte_N_ta_new_rar(rar_msg.timing_adv_cmd);
printf("ta: %d, n_ta: %d\n", rar_msg.timing_adv_cmd, n_ta);
float time_adv_sec = ((float) n_ta+15)/(15000.0*lte_symbol_sz(cell.nof_prb));
if (prog_args.ta_usec >= 0) {
time_adv_sec = prog_args.ta_usec*1e-6;
}
#define N_TX 5
const uint32_t rv[N_TX]={0,2,3,1,0};
for (int i=0; i<N_TX;i++) {
@ -545,7 +566,7 @@ int main(int argc, char **argv) {
exit(-1);
}
vec_sc_prod_cfc(ul_signal, 1.5, ul_signal, SF_LEN_PRB(cell.nof_prb));
vec_sc_prod_cfc(ul_signal, prog_args.beta_pusch, ul_signal, SF_LEN_PRB(cell.nof_prb));
/*
for (int i=0;i<7680;i++) {
if (i < 100) {

@ -95,6 +95,7 @@ LIBLTE_API int prach_init(prach_t *p,
LIBLTE_API int prach_gen(prach_t *p,
uint32_t seq_index,
uint32_t freq_offset,
float beta_prach,
cf_t *signal);
LIBLTE_API int prach_detect(prach_t *p,

@ -317,14 +317,14 @@ int prach_init(prach_t *p,
return LIBLTE_ERROR;
}
dft_plan_set_mirror(p->zc_fft, false);
dft_plan_set_norm(p->zc_fft, true);
dft_plan_set_norm(p->zc_fft, false);
p->zc_ifft = (dft_plan_t*)vec_malloc(sizeof(dft_plan_t));
if(dft_plan(p->zc_ifft, p->N_zc, BACKWARD, COMPLEX)){
return LIBLTE_ERROR;
}
dft_plan_set_mirror(p->zc_ifft, false);
dft_plan_set_norm(p->zc_ifft, true);
dft_plan_set_norm(p->zc_ifft, false);
// Generate our 64 sequences
p->N_roots = 0;
@ -371,6 +371,7 @@ int prach_init(prach_t *p,
int prach_gen(prach_t *p,
uint32_t seq_index,
uint32_t freq_offset,
float beta_prach,
cf_t *signal)
{
int ret = LIBLTE_ERROR;
@ -401,7 +402,7 @@ int prach_gen(prach_t *p,
}
// Normalize
vec_sc_prod_cfc(signal, 1.0/sqrtf(p->N_ifft_prach*2), signal, (p->N_cp + p->N_seq));
vec_sc_prod_cfc(signal, beta_prach, signal, (p->N_cp + p->N_seq));
ret = LIBLTE_SUCCESS;
}

@ -77,6 +77,7 @@ int main(int argc, char **argv) {
prach_gen(p,
seq_index,
frequency_offset,
0.2,
preamble);
uint32_t prach_len = p->N_seq;

@ -97,7 +97,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
return;
}
bzero(signal, sizeof(cf_t) * nof_samples);
if (prach_gen(&prach, seq_idx, frequency_offset, signal)) {
if (prach_gen(&prach, seq_idx, frequency_offset, 0.2, signal)) {
mexErrMsgTxt("Error generating PRACH\n");
return;
}

@ -84,6 +84,7 @@ int main(int argc, char **argv) {
prach_gen(p,
seq_index,
frequency_offset,
0.2,
preamble);
for(int i=0;i<p->N_cp+p->N_seq;i++)

@ -1,11 +1,12 @@
ueConfig=struct('NCellID',0,'NULRB',25,'NSubframe',4,'RNTI',122,'CyclicPrefixUL','Normal','NTxAnts',1);
ueConfig=struct('NCellID',0,'NULRB',25,'NSubframe',4,'RNTI',109,'CyclicPrefixUL','Normal','NTxAnts',1);
puschConfig=struct('NLayers',1,'OrthCover','Off','PRBSet',(19:22)','Modulation','QPSK','RV',0,'Shortened',0);
subframe_rx=lteSCFDMADemodulate(ueConfig,x.*transpose(exp(-1i*2*pi*0.04*(1:length(x))/512)));
subframe_rx=lteSCFDMADemodulate(ueConfig,x.*transpose(exp(-1i*2*pi*0.18*(1:length(x))/512)));
idx=ltePUSCHIndices(ueConfig,puschConfig);
pusch_rx=subframe_rx(idx);
[hest, noiseest] = lteULChannelEstimate(ueConfig,puschConfig,subframe_rx);
ce=hest(idx);
[cws,symbols] = ltePUSCHDecode(ueConfig,puschConfig,pusch_rx,ce,noiseest);
[trblkout,blkcrc,stateout] = lteULSCHDecode(ueConfig,puschConfig,88,cws);
disp(blkcrc)
disp(blkcrc)
scatter(real(symbols),imag(symbols))
Loading…
Cancel
Save