Change in osmo-bts[master]: power_control: generalize the arguments of do_pf_ewma()

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

fixeria gerrit-no-reply at lists.osmocom.org
Wed Dec 30 17:31:43 UTC 2020


fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bts/+/21907 )


Change subject: power_control: generalize the arguments of do_pf_ewma()
......................................................................

power_control: generalize the arguments of do_pf_ewma()

This way EWMA based filtering can also be applied to RxQual.

Change-Id: I439c00b394da670e314f217b3246cc85ce8213c6
Related: SYS#4918, SYS#4917
---
M src/common/power_control.c
1 file changed, 13 insertions(+), 17 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/07/21907/1

diff --git a/src/common/power_control.c b/src/common/power_control.c
index a616f18..9e6fb45 100644
--- a/src/common/power_control.c
+++ b/src/common/power_control.c
@@ -38,29 +38,29 @@
 
 /* Base Low-Pass Single-Pole IIR Filter (EWMA) formula:
  *
- *   Avg[n] = a * Pwr[n] + (1 - a) * Avg[n - 1]
+ *   Avg[n] = a * Val[n] + (1 - a) * Avg[n - 1]
  *
  * where parameter 'a' determines how much weight of the latest UL RSSI measurement
- * result 'Pwr[n]' carries vs the weight of the average 'Avg[n - 1]'.  The value of
+ * result 'Val[n]' carries vs the weight of the average 'Avg[n - 1]'.  The value of
  * 'a' is usually a float in range 0 .. 1, so:
  *
- *  - value 0.5 gives equal weight to both 'Pwr[n]' and 'Avg[n - 1]';
+ *  - value 0.5 gives equal weight to both 'Val[n]' and 'Avg[n - 1]';
  *  - value 1.0 means no filtering at all (pass through);
  *  - value 0.0 makes no sense.
  *
  * Further optimization:
  *
- *   Avg[n] = a * Pwr[n] + Avg[n - 1] - a * Avg[n - 1]
+ *   Avg[n] = a * Val[n] + Avg[n - 1] - a * Avg[n - 1]
  *   ^^^^^^                ^^^^^^^^^^
  *
  * a) this can be implemented in C using '+=' operator:
  *
- *   Avg += a * Pwr - a * Avg
- *   Avg += a * (Pwr - Avg)
+ *   Avg += a * Val - a * Avg
+ *   Avg += a * (Val - Avg)
  *
  * b) everything is scaled up by 100 to avoid floating point stuff:
  *
- *   Avg100 += A * (Pwr - Avg)
+ *   Avg100 += A * (Val - Avg)
  *
  * where 'Avg100' is 'Avg * 100' and 'A' is 'a * 100'.
  *
@@ -70,20 +70,15 @@
  *   https://en.wikipedia.org/wiki/Low-pass_filter#Simple_infinite_impulse_response_filter
  *   https://tomroelandts.com/articles/low-pass-single-pole-iir-filter
  */
-static int8_t do_pf_ewma(const struct bts_power_ctrl_params *params,
-			 struct lchan_power_ctrl_state *state,
-			 const int8_t Pwr)
+static int do_pf_ewma(int *Avg100, const int Val, const uint8_t A)
 {
-	const uint8_t A = params->pf.ewma.alpha;
-	int *Avg100 = &state->avg100_rxlev_dbm;
-
 	/* We don't have 'Avg[n - 1]' if this is the first run */
 	if (*Avg100 == 0) {
-		*Avg100 = Pwr * EWMA_SCALE_FACTOR;
-		return Pwr;
+		*Avg100 = Val * EWMA_SCALE_FACTOR;
+		return Val;
 	}
 
-	*Avg100 += A * (Pwr - *Avg100 / EWMA_SCALE_FACTOR);
+	*Avg100 += A * (Val - *Avg100 / EWMA_SCALE_FACTOR);
 	return *Avg100 / EWMA_SCALE_FACTOR;
 }
 
@@ -99,7 +94,8 @@
 	/* Filter input value(s) to reduce unnecessary Tx power oscillations */
 	switch (params->pf_algo) {
 	case BTS_PF_ALGO_EWMA:
-		rxlev_dbm_avg = do_pf_ewma(params, state, rxlev_dbm);
+		rxlev_dbm_avg = do_pf_ewma(&state->avg100_rxlev_dbm, rxlev_dbm,
+					   params->pf.ewma.alpha);
 		break;
 	case BTS_PF_ALGO_NONE:
 	default:

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/21907
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I439c00b394da670e314f217b3246cc85ce8213c6
Gerrit-Change-Number: 21907
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201230/faf0d444/attachment.htm>


More information about the gerrit-log mailing list