From 0ab2b2b26190c81350634d8418ed34386e1738fe Mon Sep 17 00:00:00 2001
From: Raymond Knopp <raymond.knopp@eurecom.fr>
Date: Fri, 6 Apr 2018 10:27:23 -0700
Subject: [PATCH] modifications for simulator : power normalizations for UE TX,
 small changes to SNR targets for power control, default UE power (23 dBm now)

---
 openair1/SIMULATION/RF/dac.c                           | 10 ++++------
 openair2/LAYER2/MAC/eNB_scheduler.c                    |  2 +-
 openair2/LAYER2/MAC/eNB_scheduler_ulsch.c              |  2 +-
 .../CONF/rcc.band7.tm1.if4p5.50PRB.lo.conf             |  5 ++---
 targets/SIMU/USER/oaisim.c                             |  1 +
 5 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/openair1/SIMULATION/RF/dac.c b/openair1/SIMULATION/RF/dac.c
index 8cf6b49623..08f1ed7ab4 100644
--- a/openair1/SIMULATION/RF/dac.c
+++ b/openair1/SIMULATION/RF/dac.c
@@ -91,10 +91,8 @@ double dac_fixed_gain(double *s_re[2],
 
   int i;
   int aa;
-  double amp,amp1_local,*amp1p;
-
-  amp = //sqrt(NB_RE)*pow(10.0,.05*txpwr_dBm)/sqrt(nb_tx_antennas); //this is amp per tx antenna
-    pow(10.0,.05*txpwr_dBm)/sqrt(nb_tx_antennas); //this is amp per tx antenna
+  double amp1_local,*amp1p;
+  double amp = pow(10.0,.05*txpwr_dBm)/sqrt(nb_tx_antennas); //this is amp per tx antenna
 
   if (amp1==NULL) amp1p = &amp1_local;
   else            amp1p = amp1;
@@ -123,7 +121,7 @@ double dac_fixed_gain(double *s_re[2],
     //printf("DL: amp1 %f dB (%d,%d), tx_power %f\n",20*log10(amp1),input_offset,input_offset_meas,txpwr_dBm);
   */
 
-
+  //  printf("DAC: amp/amp1p %f amp1 %f dB (%d,%d), tx_power %f\n",amp/(*amp1p),20*log10(*amp1p),input_offset,input_offset_meas,txpwr_dBm);
   for (i=0; i<length; i++) {
     for (aa=0; aa<nb_tx_antennas; aa++) {
       s_re[aa][i] = amp*((double)(((short *)input[aa]))[((i+input_offset)<<1)])/(*amp1p); 
@@ -131,7 +129,7 @@ double dac_fixed_gain(double *s_re[2],
     }
   }
 
-  //  printf("ener %e\n",signal_energy_fp(s_re,s_im,nb_tx_antennas,length,0));
+  //  printf("ener %e\n",signal_energy_fp(s_re,s_im,nb_tx_antennas,length<length_meas?length:length_meas,0));
 
   return(signal_energy_fp(s_re,s_im,nb_tx_antennas,length<length_meas?length:length_meas,0)/NB_RE);
 }
diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c
index 8dab2a9b71..58b11b2b6f 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler.c
@@ -541,7 +541,7 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP,
     rnti = UE_RNTI(module_idP, i);
     CC_id = UE_PCCID(module_idP, i);
 
-    if ((frameP == 0) && (subframeP == 0)) {
+    if (((frameP&127) == 0) && (subframeP == 0)) {
       LOG_I(MAC,
             "UE  rnti %x : %s, PHR %d dB DL CQI %d PUSCH SNR %d PUCCH SNR %d\n",
             rnti,
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
index 9ccb0e66ab..b070167501 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
@@ -1281,7 +1281,7 @@ schedule_ulsch_rnti(module_id_t module_idP,
 
 	  // this is the normalized RX power and this should be constant (regardless of mcs
 	  normalized_rx_power = UE_sched_ctrl->pusch_snr[CC_id];
-	  target_rx_power = 178;
+	  target_rx_power = 158;
 
 	  // this assumes accumulated tpc
 	  // make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out
diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.lo.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.lo.conf
index 72ee47b9d6..771bf09499 100644
--- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.lo.conf
+++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.lo.conf
@@ -73,10 +73,9 @@ eNBs =
       srs_SubframeConfig                                 =;
       srs_ackNackST                                      =;
       srs_MaxUpPts                                       =;*/
-
-      pusch_p0_Nominal                                   = -96;
+      pusch_p0_Nominal                                   = -104;
       pusch_alpha                                        = "AL1";
-      pucch_p0_Nominal                                   = -100;
+      pucch_p0_Nominal                                   = -104;
       msg3_delta_Preamble                                = 6;
       pucch_deltaF_Format1                               = "deltaF2";
       pucch_deltaF_Format1b                              = "deltaF3";
diff --git a/targets/SIMU/USER/oaisim.c b/targets/SIMU/USER/oaisim.c
index 65b0b8a3e4..898c695da4 100644
--- a/targets/SIMU/USER/oaisim.c
+++ b/targets/SIMU/USER/oaisim.c
@@ -1065,6 +1065,7 @@ void set_UE_defaults(int nb_ue) {
 	PHY_vars_UE_g[UE_id][CC_id]->pdcch_vars[i][0]->agregationLevel      = 0xFF;
       }
       PHY_vars_UE_g[UE_id][CC_id]->current_dlsch_cqi[0] = 10;
+      PHY_vars_UE_g[UE_id][CC_id]->tx_power_max_dBm = 23;
     }
   }
 }
-- 
GitLab