signals ¶ MeasureFrequence (FunctionBlock)
MeasureFrequence (FB) ¶ FUNCTION_BLOCK MeasureFrequence This function block will measure the average frequency of an input signal over a defined number of periods. Note The function block has to be called with a frequency higher than the maximum frequency of the input signal to be able to calculate the correct result. InOut: Scope Name Type Initial Comment Input xEnable BOOL Reset xInput BOOL Input signal usiPeriods USINT (1..10) 1 Number of time periods the frequency shall be averaged in ( \(1 \leq \mbox{number} \leq 10\) ) Output lrFrequency LREAL Avareged frequency (in Hz) xValid BOOL Validity of result FALSE : If the required number of time periods has not yet been passed or if the distance in time of two raising edges exceeds \(3 \cdot \mbox{lrFrequency}\)
statistical functions ¶ Statistics_DINT (FunctionBlock) Statistics_LREAL (FunctionBlock) Variance (FunctionBlock)
Statistics_DINT (FB) ¶ FUNCTION_BLOCK Statistics_DINT This function block will update the values of minimum, maximum and average with respect to the integral input parameter \(x_{n}\) , which will be added to a set of integral data \(x_{n-1},\dots,x_{1}\) (stemming from previous calls). \[\left \lfloor \frac{\sum_{i=1}^{n}x_{i}+\left \lfloor \frac{n}{2} \right \rfloor}{n} \right \rfloor\] Note Pay attention, that the returned average is of type DINT . In contrast to the arithmetic mean the result will be rounded. InOut: Scope Name Type Initial Comment Input xEnable BOOL Reset diInput DINT New data \(x_{n}\) Output diMin DINT 16#7FFFFFFF Minimum of set \(x_{n},\dots,x_{1}\) diMax DINT DWORD_TO_DINT(16#80000000) Maximum of set \(x_{n},\dots,x_{1}\) diAverage DINT Rounded avarage of data \(x_{n},\dots,x_{1}\) xOverrun BOOL TRUE : In case of overflow The module will compensate this by a minor weighting of the old data leading to inaccuracy of the result
Statistics_LREAL (FB) ¶ FUNCTION_BLOCK Statistics_LREAL This function block will update the values of minimum, maximum and average with respect to the integral input parameter \(x_{n}\) , which will be added to a set of integral data \(x_{n-1},\dots,n_{1}\) (stemming from previous calls). The arithmetic mean \(\bar{x}\) of the values \(x_{n},\dots,x_{1}\) is calculated by: \[\bar{x} = \frac{1}{n}\sum_{i=1}^{n}x_{i}\] InOut: Scope Name Type Initial Comment Input xEnable BOOL Reset lrInput LREAL New data \(x_{n}\) Output lrMin LREAL LREAL#1E+80 Minimum of set \(x_{n},\dots,x_{1}\) lrMax LREAL LREAL#-1E+80 Maximum of set \(x_{n},\dots,x_{1}\) lrAverage LREAL Arithmetic mean of data \(x_{n},\dots,x_{1}\) xOverrun BOOL TRUE : In case of overflow The module will compensate this by a minor weighting of the old data leading to inaccuracy of the result
Variance (FB) ¶ FUNCTION_BLOCK Variance This function will update the experimental variance of the mean with respect to the new input parameter \(x_{n}\) , which will be added to a series of data \(x_{n-1},\dots,n_{1}\) (stemming from previous calls). The variance \(s\) of the data \(x_{n},\dots,x_{1}\) is calculated according to: \(s = \frac{1}{n}\sum_{i=1}^{n}\left(x_{i} - \bar{x}\right)\) , where \(\bar{x}\) is the arithmetic mean of the data. InOut: Scope Name Type Comment Input xEnable BOOL Reset lrInputValue LREAL New data \(x_{n}\) Output lrVariance LREAL Experimental variance of the mean of \(x_{n},\dots,x_{1}\)
trigonometrical functions ¶ atan2 (Function)
atan2 (FUN) ¶ FUNCTION atan2 : LREAL This function will return the angle \(\varphi\) (azimuth) necessary for changing Cartesian to polar coordinates. InOut: Scope Name Type Comment Return atan2 LREAL The angle \(\varphi \in \left(-\pi, \pi \right]\) , whose sine and cosine correspond to the input values. Input lrSinus LREAL Sine of angle \(\varphi\) lrCosinus LREAL Cosine of angle \(\varphi\)
Global Variables ¶ GlobalConstants (GVL)
GlobalConstants (GVL) ¶ InOut: Scope Name Type Initial Comment Constant PI LREAL 3.1415926535897931 The mathematical constant \(\pi\)