Commit 22c5218f authored by Marwan Hammouda's avatar Marwan Hammouda

timing offset algorithm updated during initial sync

    - command line options for timing offset rate and frequency offset at Point A
parent 4724e3bb
......@@ -140,6 +140,9 @@
#define CONFIG_HLP_AMC "flag to use adaptive modulation and coding: 1 = use AMC \n"
#define CONFIG_HLP_SINR_OSET_DL "Additional SINR offset in [dB] applied to the reported SINR from UE for DL AMC \n"
#define CONFIG_HLP_SINR_OSET_UL "Additional SINR offset in [dB] applied to the measured SINR at gNB for UL AMC \n"
#define CONFIG_HLP_TO_Init_Rate "change rate of the timing offset during the initialization phase, in samples/frame \n"
#define CONFIG_HLP_FO_Sync_Offset "frequency offset of point A \n"
/*--------------------------------------------------------------------------------------------------------------------------------*/
/* command line parameters for LOG utility */
/* optname helpstr paramflags XXXptr defXXXval type numelt */
......@@ -206,5 +209,6 @@ extern double TO_PScaling;
extern double TO_IScaling;
extern int commonDoppler;
extern int TO_init_rate;
#endif
......@@ -591,6 +591,7 @@ int tdriftComp = 1;
int TO_IScalingInit = 0;
int32_t fdopplerPrePost = 0; //pre/post compensation of the Doppler shift at the gNB side
int commonDoppler = 0; // common doppler to be compensated at UE, but set here to avoid linking error
int TO_init_rate = 0;
int main( int argc, char **argv ) {
int ru_id, CC_id = 0;
......
......@@ -808,6 +808,8 @@ void *UE_thread(void *arg)
NR_UE_MAC_INST_t *mac = get_mac_inst(0);
int rx_offset_slot = 0; //samples to be shifted for the current slot
int UL_TO_Tx_ofs = 0;
static int acc_UL_To_TX = 0; // acculating samples compensated on UL through timing advance
extern int tshift;
bool syncRunning=false;
const int nb_slot_frame = UE->frame_parms.slots_per_frame;
......@@ -830,6 +832,17 @@ void *UE_thread(void *arg)
if (res) {
syncRunning=false;
if (UE->is_synchronized) {
if (tshift)
{
int diff = TO_init_rate; // shift in two frames
UE->TO_I_Ctrl += diff;
UE->rx_offset_TO = (TO_PScaling*diff) + (UE->TO_I_Ctrl*TO_IScaling); //PI controller
UE->rx_offset_slot = 1;
UE->rx_offset_comp = 0;
int ta_shift = (UE->init_sync_frame + trashed_frames)*2*diff;
UE->timing_advance += ta_shift;
timing_advance = UE->timing_advance;
}
decoded_frame_rx = mac->mib_frame;
LOG_I(PHY,"UE synchronized decoded_frame_rx=%d UE->init_sync_frame=%d trashed_frames=%d\n",
decoded_frame_rx,
......@@ -922,7 +935,8 @@ void *UE_thread(void *arg)
rx_offset_slot = UE->rx_offset_TO * UE->rx_offset_slot / nb_slot_frame - UE->rx_offset_comp;
UE->rx_offset_comp += rx_offset_slot;
UE->rx_offset_slot++;
UL_TO_Tx_ofs += 2*rx_offset_slot; //to adapt the UE's transmission time in order to get aligned at gNB
UL_TO_Tx_ofs = 2*rx_offset_slot; //to adapt the UE's transmission time in order to get aligned at gNB
acc_UL_To_TX += UL_TO_Tx_ofs;
}
readBlockSize=get_readBlockSize(slot_nr, &UE->frame_parms) + rx_offset_slot;
......@@ -963,7 +977,7 @@ void *UE_thread(void *arg)
//timing_advance += 2*rx_offset_slot;
//UE->timing_advance += 1*rx_offset_slot;
UE->timing_advance += 2*rx_offset_slot;
UE->timing_advance += UL_TO_Tx_ofs;
extern uint64_t RFsim_PropDelay;
LOG_D(PHY, "RFsim_PropDelay: %lu, TA: %d, diff: %d, PI_Out: %d, offset_slot: %d, offset_UL: %d\n",
......
......@@ -449,6 +449,7 @@ double TO_IScaling = 0.1;
int TO_IScalingInit = 0;
int commonDoppler = 0; //421528;
int TO_init_rate = 0;
int main( int argc, char **argv ) {
......
......@@ -80,7 +80,10 @@
{"TOI" , CONFIG_HLP_TI_Scaling, 0, .dblptr=&TO_IScaling, .defdblval=0.1, TYPE_DOUBLE, 0}, \
{"TOII", CONFIG_HLP_TO_Iinit, 0, .iptr=&TO_IScalingInit, .defintval=0, TYPE_INT, 0}, \
{"agc", CONFIG_HLP_AGC, PARAMFLAG_BOOL, .iptr=&(nrUE_params.enable_agc), .defintval=0, TYPE_INT, 0},\
{"ulpc", CONFIG_HLP_ULPC, PARAMFLAG_BOOL, .iptr=&(nrUE_params.enable_ulpc), .defintval=0, TYPE_INT, 0}}
{"ulpc", CONFIG_HLP_ULPC, PARAMFLAG_BOOL, .iptr=&(nrUE_params.enable_ulpc), .defintval=0, TYPE_INT, 0},\
{"TOIR", CONFIG_HLP_TO_Init_Rate, 0, .iptr=&TO_init_rate, .defintval=0, TYPE_INT, 0}, \
{"FOPA", CONFIG_HLP_FO_Sync_Offset, 0, .iptr=&commonDoppler, .defintval=0, TYPE_INT, 0}, \
}
// clang-format on
typedef struct {
......
......@@ -385,6 +385,8 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB)
// set the initial frequency offset to 0
ue->DopplerEst = 0;
ue->DopplerEstTot = (float)commonDoppler;
ue->TO_I_Ctrl = 0;
ue->f_pusch = 0;
return 0;
......
......@@ -104,9 +104,9 @@ void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms,
flagInitIScaling = 1;
}
TO_I_Ctrl += diff; //integral of all offsets
ue->TO_I_Ctrl += diff; //integral of all offsets
ue->rx_offset = diff;
ue->rx_offset_TO = (TO_PScaling*diff) + (TO_I_Ctrl*TO_IScaling); //PI controller
ue->rx_offset_TO = (TO_PScaling*diff) + (ue->TO_I_Ctrl*TO_IScaling); //PI controller
ue->rx_offset_slot = 1;
ue->rx_offset_comp = 0;
......
......@@ -566,6 +566,7 @@ typedef struct {
int rx_offset_TO; /// Timing offset used for compensating the time drift due to high speed
int rx_offset_slot; /// Indicating time (in slots) after rx_offset calculation
int rx_offset_comp; /// Already compensated rx_offset
int TO_I_Ctrl; /// accululative part for tracking timing offset
// Estimated Doppler frequency shift from the DMRS
int32_t DopplerEst;
......
......@@ -959,7 +959,7 @@ static int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimest
int nbAnt_tx = ptr->th.nbAnt;//number of Tx antennas
double timeForDoppler = (double)pathStartingTime;
if (counter > 6000)
if ( ((t-> typeStamp != ENB_MAGICDL) && (TO_UE_flag == 1)) || ((TO_gNB_flag == 1) && (t->typeStamp == ENB_MAGICDL)) )
timeForDoppler = (double)pathStartingTime + (double)SampIdxDoppler/fsamp;
if (timeForDoppler > (double)pathEndingTime)
......@@ -998,7 +998,7 @@ static int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimest
out[i].i += (short)(ptr->circularBuf[((t->nextRxTstamp-RFsim_PropDelay+i)*nbAnt_tx+a_tx)%CirSize].i*H_awgn_mimo[a][a_tx]);
} // end for a_tx
if ((counter > 6000))
if ( ((t-> typeStamp != ENB_MAGICDL) && (TO_UE_flag == 1)) || ((TO_gNB_flag == 1) && (t->typeStamp == ENB_MAGICDL)) )
{
int16_t outRealTmp = out[i].r;
int16_t outImagTmp = out[i].i;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment