Formulas in the NC program

Application

You can use the Formula Q/QL/QR function to define multiple arithmetic operations in one NC block.

Description of function

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

To the right of the = sign, you define the arithmetic operations.

If you define the functions Formula Q/QL/QR or String Formula QS, you can open a keyboard for formula input with all available calculation steps in the action bar or form. The virtual keyboard also contains a formula input mode.

Virtual keyboard of the control bar

Rules for formulas

Sequence for the evaluation of arithmetic operations

If you enter a mathematical formula that contains more than one mathematical operation, the control always evaluates the individual operations in a defined sequence. A familiar example of this is the rule that multiplication/division takes place before addition/subtraction (higher-level operations are performed first).

The control adheres to the following rules of priority for the evaluation of mathematical formulas:

Priority

Designation

Arithmetic operator

1

Resolve parentheses

( )

2

Note the sign,

calculate the function

Minus sign, SIN, COS, LN etc.

3

Powers

^

4

Multiplication and division

* , /

5

Addition and subtraction

+, -

Sequence of operations with the same priority

The control generally calculates operations with the same priority from the left to the right.

2 + 3 - 2 = ( 2 + 3 ) - 2 = 3

Exception: Concatenated powers are evaluated from right to left.

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

Arithmetic operations

The formula input keyboard includes the following shortcut functions:

Syntax

Linking function

Priority

+

Addition

e.g. Q10 = Q1 + Q5

Addition/subtraction calculation

Subtraction

e.g. Q25 = Q7 – Q108

Addition/subtraction calculation

*

Multiplication

e.g. Q12 = 5 * Q5

Multiplication/division calculation

/

Division

e.g. Q25 = Q1 / Q2

Multiplication/division calculation

(

Opening parenthesis

e.g. Q12 = Q1 * ( Q2 + Q3 )

Expression in parentheses

)

Closing parenthesis

e.g. Q12 = Q1 * ( Q2 + Q3 )

Expression in parentheses

SQ

Square of a value

e.g. Q15 = SQ 5

Function

SQRT

Square root

e.g. Q22 = SQRT 25

Function

SIN

Sine of an angle

e.g. Q44 = SIN 45

Function

COS

Cosine of an angle

e.g. Q45 = COS 45

Function

TAN

Tangent of an angle

e.g. Q46 = TAN 45

Function

ASIN

Arc sine

Inverse of the sine. Determines the angle from the ratio of the side opposite the angle and the hypotenuse

e.g. Q10 = ASIN ( Q40 / Q20 )

Function

ACOS

Arc cosine

Inverse of the cosine. Determines the angle from the ratio of the side adjacent to the angle and the hypotenuse

e.g. Q11 = ACOS Q40

Function

ATAN

Arc tangent

Inverse of the tangent. Determines the angle from the ratio of the opposite side to the adjacent side

e.g. Q12 = ATAN Q50

Function

^

Raising values to a power

e.g. Q15 = 3 ^ 3

Power

PI

Pi constant

π = 3.14159

e.g. Q15 = PI

LN

Natural logarithm (LN) of a number

Base = e = 2.7183

e.g. Q15 = LN Q11

Function

LOG

Logarithm of a number

Base = 10

e.g. Q33 = LOG Q22

Function

EXP

Exponential function (e ^ n)

Base = e = 2.7183

e.g. Q1 = EXP Q12

Function

NEG

Negate values

Multiply by -1

e.g. Q2 = NEG Q1

Function

INT

Truncate decimal places

Form an integer

e.g. Q3 = INT Q42

 
Tip

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

Function

ABS

Absolute value of a number

e.g. Q4 = ABS Q22

Function

FRAC

Truncate places before the decimal point

Form a fraction

e.g. Q5 = FRAC Q23

Function

SGN

Check algebraic sign of a number

e.g. 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

%

Calculate the modulo value (division remainder)
e. g., Q12 = 400 % 360 Result: Q12 = 40

Function

You can also define shortcut functions for strings.

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 )

; = 0.5

  • 1st calculation: Resolve parentheses: 50 - 20 = 30
  • 2nd calculation: Calculate sine of 30 = 0.5