CNCSimulator Pro

user guide
×
Menu
Index

11.4. Arithmetic Expressions

Arithmetic Expressions are formulas used in parameterized programming to calculate values.
 
You use square brackets instead of parenthesis in expressions. An expression may look like this:
 
#100 = #102*#101+[#10+23]
 
In plain English this expression says: Multiply the value of variable 102 and 101 and then add the sum of variable 10 and 23 and put the result in variable 100.
 
There are a number of functions that you can use in expressions. They are listed here. For an in-depth explanation of these, please refer to the Fanuc programming manual or the book mentioned in the introduction.
 
Name
Function
SIN
Sine (in degrees)
COS
Cosine (in degrees)
TAN
Tangent (in degrees)
ASIN
Arc sine
ACOS
Arc cosine
ATAN or ATN
Arc tangent with one or two arguments
SQRT or SQR
Square root   
ABS
Absolute value
ROUND or RND
Rounding off
BIN and BCD
Currently not in use in the simulator
FIX
Rounding down to the closest integer
FUP
Rounding up to the closest integer
LN
Natural logarithm
EXP
Exponent using base e
POW
First argument to the power of the second one
ADP
Currently not in use in the simulator
OR
Logical OR performed on integers, bit by bit
XOR
Logical XOR performed on integers, bit by bit
AND
Logical AND performed on integers, bit by bit
MOD
Modulus
 
Example calculating the sine value of the value of variable 101:
 
#100 = SIN[#101]
 
Note that in the simulator, the logical bitwise operators will only work on integers.
 
Example:
 
#10 = 2
#11 = 4
#12 = #10 AND #11 (This is OK)
 
Incorrect use:
 
#10 = 2.1
#11 = 4
#12 = #10 AND #11 (Will show an alarm)