summaryrefslogtreecommitdiff
path: root/exp/FB_EWMA.EXP
diff options
context:
space:
mode:
authorpux <pux@pux.dom>2021-01-07 19:39:17 +0100
committerpux <pux@pux.dom>2021-01-07 19:39:17 +0100
commit39765e002e71a2dd54e932469877acfc1b6fcb67 (patch)
tree83456425ad35e8c47894dee6660bd9ed574ebfdd /exp/FB_EWMA.EXP
parentbbbba6c698a73fc1a6bd00f7a07c89ba19ce38c5 (diff)
downloadlib61131aux-master.tar.gz
lib61131aux-master.tar.bz2
lib61131aux-master.zip
add *.exp; (this is redundant information, just to be able to diff later on)HEADmaster
Diffstat (limited to 'exp/FB_EWMA.EXP')
-rw-r--r--exp/FB_EWMA.EXP35
1 files changed, 35 insertions, 0 deletions
diff --git a/exp/FB_EWMA.EXP b/exp/FB_EWMA.EXP
new file mode 100644
index 0000000..6496df9
--- /dev/null
+++ b/exp/FB_EWMA.EXP
@@ -0,0 +1,35 @@
+
+(* @NESTEDCOMMENTS := 'Yes' *)
+(* @PATH := '' *)
+(* @OBJECTFLAGS := '0, 8' *)
+(* @SYMFILEFLAGS := '2048' *)
+FUNCTION_BLOCK FB_EWMA
+VAR_INPUT
+ IN_rN : REAL := 15; (* Filter constant alpha := rN/(rN+1) *)
+ IN_rXk : REAL; (* Input value to smooth *)
+END_VAR
+VAR_OUTPUT
+ OUT_rXk_avg : REAL; (* smoothed output *)
+END_VAR
+VAR
+ rAlpha : REAL;
+ rXk_avg_old : REAL;
+END_VAR
+
+(* Exponentially Weighted Moving Average Filter
+Author: mo
+Date: 2019-02
+
+Filter constant: alpha := n / (n+1)
+EWMA Filter: Xk_avg := alpha*Xk_prev + (1-alpha)*Xk
+
+*)
+(* @END_DECLARATION := '0' *)
+rAlpha := IN_rN/(IN_rN+1);
+
+OUT_rXk_avg := rAlpha * rXk_avg_old
+ + ( (1 - rAlpha) * IN_rXk);
+
+rXk_avg_old := OUT_rXk_avg;
+
+END_FUNCTION_BLOCK
in each repos: see "about"-tab (if existing) for more details / README.
mailto contact at omeckman dot net
all timestamps in UTC (German winter time: UTC+01:00, summer time: UTC+02:00)
dark theme is a modded version of: https://gist.github.com/Yoplitein/f4b671a2ec70c9e743fa