Skip to content

Functions

F_ApplyScaling

Generic analog scaling function

Note

See ST_ScalingParameters for more information.

1
2
3
4
5
FUNCTION F_ApplyScaling : LREAL
VAR_INPUT
    X : LREAL;
    Parameters : ST_ScalingParameters;
END_VAR

F_CompareLREAL

Returns true if Val1 and Val2 are within +/- Tolerance of each other.

Why would I want this?

Floating-point values should not be compared directly for equality. See here for more information.

1
2
3
4
5
6
FUNCTION F_CompareLREAL : BOOL
VAR_INPUT
    Val1      : LREAL;
    Val2      : LREAL;
    Tolerance : LREAL;
END_VAR

F_CompareREAL

Returns true if Val1 and Val2 are within +/- Tolerance of each other.

Why would I want this?

Floating-point values should not be compared directly for equality. See here for more information.

1
2
3
4
5
6
FUNCTION F_CompareREAL : BOOL
VAR_INPUT
    Val1      : REAL;
    Val2      : REAL;
    Tolerance : REAL;
END_VAR

F_LREAL_RoundToPlace

Returns In rounded to DecimalPlaces.

1
2
3
4
5
FUNCTION F_LREAL_RoundToPlace : LREAL //! Rounded number
VAR_INPUT
    In            : LREAL; //! Number to be rounded
    DecimalPlaces : DINT;  //! Number of decimal places
END_VAR