Formulas in the NC program

Application

With the Formula Q/QL/QR NC function, you can define multiple arithmetic operations in a single NC block using fixed or variable values. You can also assign a single value to a variable.

Description of function

As the first entry, you define the variable to which you assign the result.

To the right of the equal sign, define the arithmetic operations or a value that the control assigns to the variable.

When defining the Formula Q/QL/QR NC function, you can open a virtual keyboard for formula input containing all available arithmetic operators in the action bar or form. The virtual keyboard also has a formula input mode.

Virtual keyboard of the control bar

Rules for formulas

Evaluation order for different operators

If a formula includes arithmetic operations involving a combination of different operators, the control evaluates the operations in a certain order. A familiar example of this is the rule that multiplication/division takes precedence over addition/subtraction (higher-level operations are performed first).

Example

The control evaluates the arithmetic operations in the following order:

Order

Arithmetic operation

Operator

Arithmetic operator

1

Perform operations in parentheses first

Parentheses

( )

2

Note the algebraic sign

Algebraic sign

3

Calculate functions

Function

SIN, COS, LN, etc.

4

Exponentiation

Power

^

5

Multiplication and division

Point

*, /

6

Addition and subtraction

Line

+,

Arithmetic operations

Order in the evaluation of equivalent operators

The control evaluates arithmetic operations with equivalent operators from left to right.

Example: 2 + 3 - 2 = ( 2 + 3 ) - 2 = 3

Exception: Concatenated powers are evaluated from right to left.

Example: 2 ^ 3 ^ 2 = 2 ^ ( 3 ^ 2 ) = 2 ^ 9 = 512

Arithmetic operations

The virtual keyboard for formula input allows you to perform the following arithmetic operations:

Button

Arithmetic operation

Operator

Plus
+

Addition

Example: Q10 = Q1 + Q5

Line

Minus

Subtraction

Example: Q25 = Q7 – Q108

Line

Stern
*

Multiplication

Example: Q12 = 5 * Q5

Point

Slash
/

Division

Example: Q25 = Q1 / Q2

Point

RoundBracketOpening
(
RoundBracketClosing
)

Parenthesize

Example: Q12 = Q1 * ( Q2 + Q3 )

Expression in parentheses

Sq
SQ

Square (square)

Example: Q15 = SQ 5

Function

Sqrt
SQRT

Calculate square root (square root)

Example: Q22 = SQRT 25

Function

Sin
SIN

Calculate sine

Example: Q44 = SIN 45

Function

Cos
COS

Calculate cosine

Example: Q45 = COS 45

Function

Tan
TAN

Calculate tangent

Example: Q46 = TAN 45

Function

Asin
ASIN

Calculate arcsine

Inverse function of sine

The control determines the angle from the ratio of the opposite side to the hypotenuse.

Example: Q10 = ASIN ( Q40 / Q20 )

Function

Acos
ACOS

Calculate arccosine

Inverse function of cosine

The control determines the angle from the ratio of the adjacent side to the hypotenuse.

Example: Q11 = ACOS Q40

Function

Atan
ATAN

Calculate arctangent

Inverse function of tangent

The control determines the angle from the ratio of the opposite side to the adjacent side.

Example: Q12 = ATAN Q50

Function

Circumflex
^

Exponentiation

Example: Q15 = 3 ^ 3

Power

Pi
PI

Use the “pi” constant

π = 3.14159

Example: Q15 = PI

Ln
LN

Calculate the natural logarithm (LN)

Base = e = 2.7183

Example: Q15 = LN Q11

Function

Log
LOG

Calculate the logarithm

Base = 10

Example: Q33 = LOG Q22

Function

Exp
EXP

Use the exponential function (e ^ n)

Base = e = 2.7183

Example: Q1 = EXP Q12

Function

Neg
NEG

Negate

Multiply by –1

Example: Q2 = NEG Q1

Function

Int
INT

Calculate an integer

Truncate decimal places

Example: Q3 = INT Q42

 
Tip

The INT function does not round off—it simply truncates the decimal places.

Input: 0...999999999

Function

Abs
ABS

Calculate the absolute value

Example: Q4 = ABS Q22

Function

Frac
FRAC

Calculate a fraction

Truncate the digits before the decimal point

Example: Q5 = FRAC Q23

Function

Sgn
SGN

Check the algebraic sign

Example: Q12 = SGN Q50

If Q50 = 0, then SGN Q50 = 0

If Q50 < 0, then SGN Q50 = -1

If Q50 > 0, then SGN Q50 = 1

Function

Percent
%

Calculate the modulo value (division remainder)

Example: Q12 = 400 % 360 Result: Q12 = 40

Function

Basic arithmetic folder

Trigonometric functions folder

You can also define arithmetic operations for strings.

String functions

Example

Multiplication and division before addition and subtraction

NC programs contained in this User's Manual are suggestions for solutions. The NC programs or individual NC blocks must be adapted before being used on a machine.

  • Change the following contents as needed:
  • Tools
  • Cutting parameters
  • Feed rates
  • Clearance height or safe position
  • Machine-specific positions, e.g. with M91
  • Paths of program calls

Some NC programs depend on the machine kinematics. Adapt these NC programs to your machine kinematics before the first test run.

In addition, test the NC programs using the simulation before the actual program run.

 
Tip

With a program test you determine whether the NC program can be used with the available software options, the active machine kinematics and the current machine configuration.

11 Q1 = 5 * 3 + 2 * 10

; Result = 35

  • 1st calculation: 5 * 3 = 15
  • 2nd calculation: 2 * 10 = 20
  • 3rd calculation: 15 + 20 = 35

Power before addition and subtraction

NC programs contained in this User's Manual are suggestions for solutions. The NC programs or individual NC blocks must be adapted before being used on a machine.

  • Change the following contents as needed:
  • Tools
  • Cutting parameters
  • Feed rates
  • Clearance height or safe position
  • Machine-specific positions, e.g. with M91
  • Paths of program calls

Some NC programs depend on the machine kinematics. Adapt these NC programs to your machine kinematics before the first test run.

In addition, test the NC programs using the simulation before the actual program run.

 
Tip

With a program test you determine whether the NC program can be used with the available software options, the active machine kinematics and the current machine configuration.

11 Q2 = SQ 10 - 3^3

; Result = 73

  • 1st calculation: 10 squared = 100
  • 2nd calculation: 3 to the power of 3 = 27
  • 3rd calculation: 100 – 27 = 73

Function before power

NC programs contained in this User's Manual are suggestions for solutions. The NC programs or individual NC blocks must be adapted before being used on a machine.

  • Change the following contents as needed:
  • Tools
  • Cutting parameters
  • Feed rates
  • Clearance height or safe position
  • Machine-specific positions, e.g. with M91
  • Paths of program calls

Some NC programs depend on the machine kinematics. Adapt these NC programs to your machine kinematics before the first test run.

In addition, test the NC programs using the simulation before the actual program run.

 
Tip

With a program test you determine whether the NC program can be used with the available software options, the active machine kinematics and the current machine configuration.

11 Q4 = SIN 30 ^ 2

; Result = 0.25

  • 1st calculation: Calculate sine of 30 = 0.5
  • 2nd calculation: 0.5 squared = 0.25

Brackets before function

NC programs contained in this User's Manual are suggestions for solutions. The NC programs or individual NC blocks must be adapted before being used on a machine.

  • Change the following contents as needed:
  • Tools
  • Cutting parameters
  • Feed rates
  • Clearance height or safe position
  • Machine-specific positions, e.g. with M91
  • Paths of program calls

Some NC programs depend on the machine kinematics. Adapt these NC programs to your machine kinematics before the first test run.

In addition, test the NC programs using the simulation before the actual program run.

 
Tip

With a program test you determine whether the NC program can be used with the available software options, the active machine kinematics and the current machine configuration.

11 Q5 = SIN ( 50 - 20 )

; Result = 0.5

  • 1st calculation: Perform operations in parentheses first: 50 – 20 = 30
  • 2nd calculation: Calculate sine of 30 = 0.5