Hysteresis_DINT (FB) ¶ FUNCTION_BLOCK Hysteresis_DINT This function block will set the output variable to TRUE , if the integral value \(x \in \mathbb{Z}\) is smaller than an integral lower bound \(x_{u} \in \mathbb{Z}\) It will set the Boolean output variable to FALSE , if the input value \(x\) exceeds the integral upper bound \(x_{o} \in \mathbb{Z}\) . If \(x\) lies between the lower and upper bound, the value of the output will rest unchanged by the module. InOut: Scope Name Type Comment Input diValue DINT input value \(x \in \mathbb{Z}\) diLimitPos DINT upper bound \(x_{o} \in \mathbb{Z}\) diLimitNeg DINT lower bound \(x_{u} \in \mathbb{Z}\) Output xOut BOOL FALSE : If \(x > x_{o} \land x_{u} < x_{o}\) TRUE : If \(x < x_{u} \land x_{u} < x_{o}\) “ xOut ” else
Hysteresis_LREAL (FB) ¶ FUNCTION_BLOCK Hysteresis_LREAL This function block will set the output variable to TRUE , if the input value \(x \in \mathbb{R}\) is smaller than a lower bound \(x_{u} \in \mathbb{R}\) . It will set the output variable to FALSE , if the input value \(x\) exceeds the upper bound \(x_{o} \in \mathbb{R}\) . If \(x\) lies between the lower and the upper bound, the value of the output variable will rest unchanged by the module. InOut: Scope Name Type Comment Input lrValue LREAL input value \(x \in \mathbb{R}\) lrLimitPos LREAL upper bound \(x_{o} \in \mathbb{R}\) lrLimitNeg LREAL lower bound \(x_{u} \in \mathbb{R}\) Output xOut BOOL FALSE : If \(x > x_{o} \land x_{u} < x_{o}\) TRUE : If \(x < x_{u} \land x_{u} < x_{o}\) “ xOut ” else
LimitAlarm_DINT (FB) ¶ FUNCTION_BLOCK LimitAlarm_DINT This function block checks whether an integral value \(x \in \mathbb{Z}\) lies between an integral lower bound \(x_{u} \in \mathbb{Z}\) and an integral upper bound \(x_{o} \in \mathbb{Z}\) . The output value will be set according to the result. InOut: Scope Name Type Comment Input diValue DINT value \(x \in \mathbb{Z}\) to be tested diLimitPos DINT upper bound \(x_{o} \in \mathbb{Z}\) diLimitNeg DINT lower bound \(x_{u} \in \mathbb{Z}\) Output xExceedsPos BOOL TRUE : If \(x > x_{o}\) FALSE : Else xExceedsNeg BOOL TRUE : If \(x < x_{u}\) FALSE : Else xInLimits BOOL TRUE : If \(x_{u} \leq x \leq x_{u}\) FALSE : Else, also in the atypical case \(x_{o} < x_{u}\)
LimitAlarm_LREAL (FB) ¶ FUNCTION_BLOCK LimitAlarm_LREAL This function block checks whether the value \(x \in \mathbb{R}\) lies between an lower bound \(x_{u} \in \mathbb{R}\) and an upper bound \(x_{o} \in \mathbb{R}\) . The output value will be set according to the result. InOut: Scope Name Type Comment Input lrValue LREAL value \(x \in \mathbb{R}\) to be tested lrLimitPos LREAL upper bound \(x_{o} \in \mathbb{R}\) lrLimitNeg LREAL lower bound \(x_{u} \in \mathbb{R}\) Output xExceedsPos BOOL TRUE : If \(x > x_{o}\) FALSE : Else xExceedsNeg BOOL TRUE : If \(x < x_{u}\) FALSE : Else xInLimits BOOL TRUE : If \(x_{u} \leq x \leq x_{u}\) FALSE : Else, also in the atypical case \(x_{o} < x_{u}\)
sgn (FUN) ¶ FUNCTION sgn : INT This function will return the result of the signum function applied to input value \(x\) : \[\begin{split}\text{sgn}(x) = \begin{cases} -1 &\mbox{if } x < 0 \\0 &\mbox{if } x = 0 \\1 &\mbox{if } x > 0 \end{cases}\end{split}\] InOut: Scope Name Type Comment Return sgn INT Input lr LREAL input value \(x\)
analytical functions ¶ CalcRootLin (FunctionBlock) CalcRootParable (FunctionBlock) Derivative (FunctionBlock) Integral (FunctionBlock) PolynomialValue (Function)
CalcRootLin (FB) ¶ FUNCTION_BLOCK CalcRootLin By use of this function block the root of a linear function \(y = a \cdot x + b\) with \(a\mbox{, }b\mbox{, }x \in \mathbb{R}\) , if there is one, will be calculated. InOut: Scope Name Type Comment Input lrParam1 LREAL gradient of straight line (corresponds to \(a\) ) lrParam0 LREAL height at which line cuts the vertical y-axis (corresponds to \(b\) ) Output byRoots BYTE number of roots 0: If line is parallel, but not identical to horizontal x-axis | 255: If line is identical to x-axis 1: Else lrRoot LREAL root
CalcRootParable (FB) ¶ FUNCTION_BLOCK CalcRootParable By use of this function block the root of a linear function \(y = a \cdot x^{2} + b \cdot x + c\) with \(a\mbox{, }b\mbox{, }c\mbox{, }x \in \mathbb{R}\) , if there are some, are calculated. InOut: Scope Name Type Comment Input lrParam2 LREAL multiplier of \(x^{2}\) (corresponds to \(a\) ) lrParam1 LREAL multiplier of \(x\) (corresponds to \(b\) ) lrParam0 LREAL multiplier of \(1\) (corresponds to \(c\) ) Output byRoots BYTE number of roots (0, 1, 2 or 255 in case of infinite roots) lrRoot0 LREAL first root lrRoot1 LREAL second root
Derivative (FB) ¶ FUNCTION_BLOCK Derivative This function block will approximate the first derivative \(f\prime\) of a function \(f = f(t)\) at the actual time \(t_{n}\) with the respect to the values of the last three function calls according to the BDF method: \[f\prime (t_{n}) \doteq \frac{3 (f(t_{n}) - f(t_{n-3})) + f(t_{n-1}) - f(t_{n-2})}{3(t_{n-2}-t_{n-3})+4(t_{n-1}-t_{n-2})+3(t_{n}-t_{n-1})}\] InOut: Scope Name Type Comment Input xEnable BOOL reset lrInputValue LREAL actual function value udiTM UDINT length of time interval \([t_{n-1}, t_{n}]\) (equals time passed since last call to function) Output lrDerivative LREAL approxmated value of first derivative xValid BOOL Validity of result FALSE : If the number of calls neccessary for approximating has not been executed yet.
Integral (FB) ¶ FUNCTION_BLOCK Integral This function block will approximate the integral function of the fuction \(f = f(t)\) over the time interval between the first function call \(t_{0}\) and the actual time \(t_{n}\) : \(\int_{t_{0}}^{t_{n}}f(t)\mbox{d}t\) . The size of the time intervals \([t_{i+1}, t_{i}]\) are integers and measured in micro seconds. The approximation is carried out by use of the explicit ( \(x = f(t_{n-1})\) ) resp. implicit ( \(x = f(t_{n})\) ) Euler method: \[\int_{t_{0}}^{t_{n}}f(t)\mbox{d}t \doteq \int_{t_{0}}^{t_{n-1}}f(t)\mbox{d}t + (t_{n} - t_{n-1}) \cdot x\] InOut: Scope Name Type Initial Comment Input xEnable BOOL reset lrInputValue LREAL function value (corresponds to :math`x`) udiTM UDINT size of time interval \([t_{n-1}, t_{n}]\) (equals time passed since last call to function) Output lrIntegral LREAL approximated value of integral xOverflow BOOL FALSE error flag TRUE : If an overflow has occured