### DER – Derivation, filtering and prediction from the last n+1 samples

Block SymbolLicensing group: STANDARD Function Description
The DER block interpolates the last $\mathtt{\text{n}}+1$ samples ($\mathtt{\text{n}}\le N-1$, $N$ is implementation dependent) of the input signal u by a line $\mathtt{\text{y}}=at+b$ using the least squares method. The starting point of the time axis is set to the current sampling instant.

In case of $\mathtt{\text{RUN}}=\mathtt{\text{on}}$ the outputs y and z are computed from the obtained parameters $a$ and $b$ of the linear interpolation as follows:

$\begin{array}{cccc}\mathrm{\text{Derivation:}}\hfill & \hfill \mathtt{\text{y}}\hfill & \hfill =\hfill & a\hfill \\ \mathrm{\text{Filtering:}}\hfill & \hfill \mathtt{\text{z}}\hfill & \hfill =\hfill & b,\phantom{\rule{1em}{0ex}}\mathrm{\text{for}}\phantom{\rule{1em}{0ex}}{t}_{p}=0\hfill \\ \mathrm{\text{Prediction:}}\hfill & \hfill \mathtt{\text{z}}\hfill & \hfill =\hfill & a{t}_{p}+b,\phantom{\rule{1em}{0ex}}\mathrm{\text{for}}\phantom{\rule{1em}{0ex}}{t}_{p}>0\hfill \\ \mathrm{\text{Retrodiction:}}\hfill & \hfill \mathtt{\text{z}}\hfill & \hfill =\hfill & a{t}_{p}+b,\phantom{\rule{1em}{0ex}}\mathrm{\text{for}}\phantom{\rule{1em}{0ex}}{t}_{p}<0\hfill \end{array}$

In case of $\mathtt{\text{RUN}}=\mathtt{\text{off}}$ or $\mathtt{\text{n}}+1$ samples of the input signal are not yet available ($\mathtt{\text{RDY}}=\mathtt{\text{off}}$), the outputs are set to $\mathtt{\text{y}}=0$, $\mathtt{\text{z}}=\mathtt{\text{u}}$.

Inputs

 u Analog output of the block Double (F64) RUN Enable execution Bool off .. tracking ($\mathtt{\text{z}}=\mathtt{\text{u}}$) on ... filtering (y – estimate of the derivative, z – estimate of u at time ${t}_{p}$) tp Time instant for prediction/filtering ($\mathtt{\text{tp}}=0$ corresponds with the current sampling instant) Double (F64)

Outputs

 y Estimate of input signal derivative Double (F64) z Predicted/filtered input signal Double (F64) RDY Ready flag (all $\mathtt{\text{n}}+1$ samples are available) Bool

Parameters

 n Number of samples for interpolation ($\mathtt{\text{n}}+1$ samples are used); $1\le \mathtt{\text{n}}\le nmax$  $↓$1 $↑$10000000 $\odot$10 Long (I32) nmax Limit for parameter n (used for internal memory allocation)  $↓$1 $↑$10000000 $\odot$10 Long (I32)

2020 © REX Controls s.r.o., www.rexygen.com