At the beginning of the fitting to mention how to define variables Fanuc controllers in our macro. For Sinumerik been done to this by assigning specific values of R parameters, eg

`R10=25`

. For Fanucach proceed similarly, except that the letter R, using, # ', ie, `#10=25`

. More as a curiosity must be given to the fact that the number of our variable, we also present in the form of an arithmetic expression, recognized in square brackets, for example: N10 # 1 = 10 N15 # 2 = 1 N20 # [# 1 + # 2-8] = 5 // which in our case is equivalent to # 3 = 5

Variables can be set to zero, and the values in the range (-10 ^{47} -10 ^{-29)} ∪ (10 ^{-29,} 10 ^{47).} Values outside this range will trigger the alarm No. 111.

In the program, to specify the variables referenced in the following manner:

N10 # 2 = 10 # 5 = 100 N15 G90 G1 X # 2 F # 5 // equivalent to G1 G90 X10 F100 N20 G90 G1 X # 2 // equivalent to G1 G90 X-10 N25 G90 G1 Y [# 1 + # 5] // mandatory in square brackets. equivalent to G90 G1 Y110

When defining the values of the variables do not need to use commas as decimal values, so important when programming for Fanuc controllers, ie .:

N10 # 1 = 5 // definition of a variable without a point / comma decimal N15 G90 G1 X5. // Here the lack of dots for the X5. will cause an error N20 G90 G2 X # 1 // even though the value was not dot, it will not cause a program error

Arithmetic and logical operations on variables make very straight

- the sum of
`#1+#2`

- difference
`#1-#2`

- product
`#1*#2`

- quotient
`#1/#2`

The angle defined by the degrees, for example to an angle

90 degrees 30 minutes: # 1 = 90.5

- Sine
`SIN[#1]`

- cosine
`COS[#1]`

- Tangent
`TAN[#1]`

- arc tangent
`ATAN[#1]`

- square root
`SQRT[#1]`

- the absolute value
`ABS[#1]`

- rounding the
`ROUND[#1]`

- rounding down
`FIX[#!]`

- rounding up
`FUP[#1]`

- boolean value OR
`#1 OR #2`

- Boolean value XOR
`#1 XOR #2`

- Boolean value AND
`#1 AND #2`

We can make nesting operations and the order of execution is defined by using square brackets. We can nest up to 5 arithmetic functions, such as:

```
N10 # 1 = SIN [[[# 2 + # 3] * # 4 & # 5] * # 6]
```

## 1 comment

Widget says:

Sep 28, 2012

Regarding the decimal commas, where the subject poruszyłeś, it is to your advantage to change the parameters that the machine read the number without a decimal point as mm, and not as micrometers. Unfortunately I can not remember at the moment who is responsible for this parameter. But much more convenient to write programs without those unnecessary commas.