Standard Functions

The RMC expressions support many built-in standard functions, as listed below. You can also create custom User Functions.

 

General Math Functions

Description

ABS(a)

Returns the absolute value of a.

EXP(a)

Returns natural (e) raised to the ath power.

LN(a)

Returns the natural logarithm (base e) of a.

LOG(a)

Returns the logarithm (base 10) of a.

SQRT(a)

Returns the square root of a.

POLY(t, a, b, c, d,...)

Returns the polynomial calculation up to 8 coefficients

a + bt + ct2 + dt3...

SIGNUM(a)

Returns -1 if a is negative, +1 if a is positive, and 0 if a is zero.

 

Rounding Functions

Description

ROUND(a)

ROUND(a, n)

Rounds a to n decimal places.

MROUND(a, multiple)

Rounds a to the desired multiple.

TRUNC(a)

Rounds a to an integer towards zero. Return type is DINT.

TRUNC_REAL(a)

Rounds a to an integer towards zero. Return type is REAL.

CEIL(a)

Rounds a to the next greater (most positive) integer.

FLOOR(a)

Rounds a to the next lesser (most negative) integer.

 

Selection Functions

Description

MIN(a, b, ...)

Returns the smallest value of the parameters (up to 10 operands).

MAX(a, b, ...)

Returns the largest value of the parameters (up to 10 operands).

LIMIT(Min, InVal, Max)

Limits InVal to the lower limit Min and the upper limit Max.

SEL(cond, a, b)

In-line IF statement. If cond is true, returns a, otherwise returns b.

 

Trigonometric and Hyperbolic Functions

Description

SIN(a)

Returns the sine of a.

COS(a)

Returns the cosine of a.

TAN(a)

Returns the tangent of a.

ASIN(a)

Returns the arcsine of a.

ACOS(a)

Returns the arccosine of a.

ATAN(a)

Returns the arctangent of a.

SINH(a)

Returns the hyperbolic sine of a.

COSH(a)

Returns the hyperbolic cosine of a.

TANH(a)

Returns the hyperbolic tangent of a.

 

Bit String Functions

Description

SHR(a, n)

Shifts the bits in a to the right n times. Zeros are shifted in.

SHL(a, n)

Shifts the bits in a to the left n times. Zeros are shifted in.

ASHR(a, n)

Shifts the bits in a to the right n times. The sign bit is shifted in on the left.

ROR(a, n)

Rolls the bits in a to the right n times.

ROL(a, n)

Rolls the bits in a to the left n times.

 

Curve Functions

Description

CRV_FIRST_X(id)

Returns the x value for the first point in the curve with the specified id.

CRV_LAST_X(id)

Returns the x value for the last point in the curve with the specified id.

CRV_INTERP_Y(id, x, [options])

Interpolates the curve with the specified id at the given value of x, and returns the Y value of the curve at that point.

CRV_INTERP_V(id, x, [options])

Interpolates the curve with the specified id at the given value of x, and returns the V (velocity) value of the curve at that point.

CRV_INTERP_A(id, x, [options])

Interpolates the curve with the specified id at the given value of x, and returns the A (acceleration) value of the curve at that point.

CRV_EXISTS(id)

Returns TRUE if the curve with the specified id exists, otherwise returns FALSE.

 

Array Functions

Description

LENGTH(array)

Returns the number of elements in the array.

FILL(to, val, len)

Fill len values with val starting at to.

 

Type Conversion Functions

Description

REAL_TO_DINT(a)

Rounds a to the nearest integer.

CAST_TO_DINT(a)

Converts the type of a to a DINT type without changing the underlying bit pattern.

CAST_TO_DWORD(a)

Converts the type of a to a DWORD type without changing the underlying bit pattern.

CAST_TO_REAL(a)

Converts the type of a to a REAL type without changing the underlying bit pattern.

DINT_TO_REAL(a)

Returns a in REAL type.

DWORD_TO_DINT(a)

a and its bit order remains the same, but type is changed to DINT.

DINT_TO_DWORD(a)

a and its bit order remains same, but type is changed to DWORD.

TRUNC(a)

Rounds a to an integer towards zero.

 

Other Functions

Description

ADDR_OFS(loc, i)

Returns the address of the ith register after the register loc.

COPY(src, dst, len)

Copies up to 32 variables from src to dst.

LOG_EVENT(a, ...)

Logs the values of the operands a, ... in the Event Log. From 1 to 3 operands.

REG_REAL(f, e)

Represents the register at the specified address %MDf.e.

REG_DINT(f, e)

REG_DWORD(f, e)

 

See Also

Expressions Overview | User Functions | Operators | Data Types


Send comments on this topic.

Copyright © 2024 Delta Computer Systems, Inc. dba Delta Motion