LinearTrafo (FB)ΒΆ
FUNCTION_BLOCK LinearTrafo
This function will calculate the linear transformation \(y \in \mathbb{R}\) of \(x \in \mathbb{R}\) according to
\[ \begin{align}\begin{aligned}\frac{y - y_{1}}{y_{2}-y_{1}} = \frac{x-x_{1}}{x_{2}-x_{1}}\\\mathrm{with}\ x_{1}, x_{2}, y_{1}, y_{2} \in \mathbb{R}\ \mathrm{and}\ x_{1} \neq x_{2} \land x_{1} \leq x \leq x_{2}\end{aligned}\end{align} \]
- InOut:
Scope
Name
Type
Comment
Input
lrInputValue
LREAL
Value \(x\) to be transformated
lrInput1
LREAL
Coefficient \(x_{1} \in \mathbb{R}\)
lrInput2
LREAL
Coefficient \(x_{2} \in \mathbb{R}\)
lrOutput1
LREAL
Coefficient \(y_{1} \in \mathbb{R}\)
lrOutput2
LREAL
Coefficient \(y_{2} \in \mathbb{R}\)
Output
lrOutputValue
LREAL
Linear transformation \(y \in \mathbb{R}\) of \(x \in \mathbb{R}\)
xOutOfLimits
BOOL
Error flagTRUE
: If \(x_{1} = x_{2} \lor x < x_{1} \lor x > x_2\)