Functions, Functions overview – Delta RMC151 User Manual
Page 356
RMC70/150 and RMCTools User Manual
The Expression Editor displays the Assignment Expression in black text if it is valid, and in red
text when it is invalid. Listed below are common errors in the assignment expression syntax:
Mixed Data Types:
Data types cannot be mixed in the assignment expression without explicitly converting
them. A number that does not contain a decimal point is considered to be a DINT data
type. A number that does contain a decimal point is considered to be a REAL data type.
Example1:
Assume MyVariable is defined to be a REAL type. The following expression is not valid,
because "3" is a DINT type:
MyVariable:=_Axis[0].ActPos+3
The following expression is valid because "3.0" is a REAL type:
MyVariable:=_Axis[0].ActPos+3.0
The following expression is valid because the DINT_TO_REAL() function converts "3" to a
REAL type:
MyVariable:=_Axis[0].ActPos+DINT_TO_REAL(3)
Example2:
Assume MyVariable is defined to be a DINT type. The REAL_TO DINT() function converts
the REAL type part of the expression to a DINT. The following expression is not valid
because "2" is a DINT type and _Axis[0].ActPos is a REAL type:
MyVariable:=REAL_TO_DINT(Abs(_Axis[0].ActPos/2))
The following expression is valid because "2.0" is a REAL type and _Axis[0].ActPos is
also:
MyVariable:=REAL_TO_DINT(Abs(_Axis[0].ActPos/2.0))
Similarly, the following expression is not valid because the Abs() function returns the data
type of its arguments, which in this case is REAL, while MyVariable is a DINT type:
MyVariable:=Abs(_Axis[0].ActPos/2.0)
Illegal Expression Order
An expression in the Expression (113) command must begin with "[tag]:= ", where tag
is any register in the RMC and may be given as a register address, tag name, or variable
name. See the Assignment Expression topic for details.
Inaccurate Results
If the results of some expressions are not precisely correct, it may be caused by
truncation due to the 32-bit limit of RMC data.
5.14. Functions
5.14.1. Functions Overview
Functions can be used in the RMC expressions. Functions typically perform some calculation
and return a result.
The RMC supports a number of built-in standard functions. Custom user functions can also be
created.
336
Delta Computer Systems, Inc.