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.