Buildings.Obsolete.Controls.OBC.CDL.Discrete

Package with obsolete discrete blocks

Information

Package that contains obsolete models for discrete controls.

Package Content

Name Description
Buildings.Obsolete.Controls.OBC.CDL.Discrete.MovingMean MovingMean Discrete moving mean of a sampled input signal
Buildings.Obsolete.Controls.OBC.CDL.Discrete.Examples Examples Collection of models that illustrate model use and test models

Buildings.Obsolete.Controls.OBC.CDL.Discrete.MovingMean Buildings.Obsolete.Controls.OBC.CDL.Discrete.MovingMean

Discrete moving mean of a sampled input signal

Buildings.Obsolete.Controls.OBC.CDL.Discrete.MovingMean

Information

Block that outputs the sampled moving mean value of an input signal. At each sampling instant, the block outputs the average value of the past n samples including the current sample.

At the first sample, the block outputs the first sampled input. At the next sample, it outputs the average of the past two samples, then the past three samples and so on up to n samples.

Extends from Modelica.Icons.ObsoleteModel (Icon for classes that are obsolete and will be removed in later versions).

Parameters

TypeNameDefaultDescription
Integernn(min=2)Number of samples over which the input is averaged
TimesamplePeriodsamplePeriod(min=1E-3)Sampling period of component [s]

Connectors

TypeNameDescription
input RealInputuContinuous input signal
output RealOutputyDiscrete averaged signal

Modelica definition

block MovingMean "Discrete moving mean of a sampled input signal" extends Modelica.Icons.ObsoleteModel; parameter Integer n(min=2) "Number of samples over which the input is averaged"; parameter Modelica.SIunits.Time samplePeriod(min=1E-3) "Sampling period of component"; Buildings.Controls.OBC.CDL.Interfaces.RealInput u "Continuous input signal"; Buildings.Controls.OBC.CDL.Interfaces.RealOutput y "Discrete averaged signal"; protected parameter Modelica.SIunits.Time t0(fixed=false) "First sample time instant"; Boolean sampleTrigger "Trigger samples at each sampling instant"; Integer iSample(start=0, fixed=true) "Sample numbering in the simulation"; Integer counter(start=0, fixed=true) "Number of samples used for averaging calculation"; Integer index(start=0, fixed=true) "Index of the vector ySample"; discrete Real ySample[n]( start=vector(zeros(n,1)), each fixed=true) "Vector of samples to be averaged"; initial equation t0 = time; y = u; equation sampleTrigger = sample(t0, samplePeriod); algorithm when sampleTrigger then index := mod(iSample, n) + 1; ySample[index] := u; counter := if counter == n then n else counter + 1; y := sum(ySample)/counter; iSample := iSample + 1; end when; end MovingMean;