NaN values

In some cases error handling by error codes is not the best choice, in particular if operations return undefined values on account of unusual, but in principle possible input data, or if values are to be excluded from the processing.

The IEEE 754 standard defines symbolic values of the category NaN (Not a Number) for these purposes. In the following situations these are generated or taken into account in the TwinCAT 3 Condition Monitoring library:

The ability of a function block to create NaN values is noted in its description.

The following points rank among the main features of NaN values:

The fact that NaN values reproduce themselves when used in further calculations is advantageous in that invalid values cannot be overlooked.

CAUTION

Software malfunctions

NaN values may only be used in PLC libraries, in particular as control values in functions for Motion Control and for drive control, if they are expressly approved! Otherwise NaN values can lead to potentially dangerous malfunctions of the software concerned!

CAUTION

Floating point exceptions

If NaNs are to be used and processed in the application, the FP exceptions must be switched off. Otherwise, comparisons with NaN can lead to an exception, which will cause a stop of the runtime and possible machine damage.

Further explanations on the option to switch the FP exceptions off and on can be found in chapter Task settings.