Formulas in the NC program
Application
The NC functions Formula or Variable allow you to define several arithmetic operations in one NC block. You can also assign a single value to a variable.
Related topics
- String formula for texts
- Defining a single calculation in an NC block
Description of function
The Formula NC function is used to define the Q, QL and QR parameters.
Use the Variable NC function to define a named parameter.
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.
The control provides the following options to enter formulas:
- Auto-complete
- Pop-up keyboard for formula input from the action bar or from within the form
- Formula input mode of the virtual keyboard
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).
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 | +, – |
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 | |
---|---|---|---|
| Addition Example: Q10 = Q1 + Q5 | Line | |
| Subtraction Example: Q25 = Q7 – Q108 | Line | |
| Multiplication Example: Q12 = 5 * Q5 | Point | |
| Division Example: Q25 = Q1 / Q2 | Point | |
|
| Parenthesize Example: Q12 = Q1 * ( Q2 + Q3 ) | Expression in parentheses |
| Square (square) Example: Q15 = SQ 5 | Function | |
| Calculate square root (square root) Example: Q22 = SQRT 25 | Function | |
| Calculate sine Example: Q44 = SIN 45 | Function | |
| Calculate cosine Example: Q45 = COS 45 | Function | |
| Calculate tangent Example: Q46 = TAN 45 | Function | |
| 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 | |
| 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 | |
| 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 | |
| Exponentiation Example: Q15 = 3 ^ 3 | Power | |
| Use the “pi” constant π = 3.14159 Example: Q15 = PI | ||
| Calculate the natural logarithm (LN) Base = e = 2.7183 Example: Q15 = LN Q11 | Function | |
| Calculate the logarithm Base = 10 Example: Q33 = LOG Q22 | Function | |
| Use the exponential function (e ^ n) Base = e = 2.7183 Example: Q1 = EXP Q12 | Function | |
| Negate Multiply by –1 Example: Q2 = NEG Q1 | Function | |
| 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 | |
| Calculate the absolute value Example: Q4 = ABS Q22 | Function | |
| Calculate a fraction Truncate the digits before the decimal point Example: Q5 = FRAC Q23 | Function | |
| 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 | |
| Calculate the modulo value (division remainder) Example: Q12 = 400 % 360 Result: Q12 = 40 | Function |
Entering a formula using the auto-complete function
To enter a formula using the auto-complete function: | ||
| ||
| ||
| ||
| ||
| ||
| ||
|
Examples
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.
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 |
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.
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 {a} = 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.
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 |
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.
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 {b} = 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.
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 |
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.
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 {c} = 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.
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 |
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.
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 {d} = SIN ( 50 - 20 ) | ; Result = 0.5 |
- 1st calculation: Perform operations in parentheses first: 50 – 20 = 30
- 2nd calculation: Calculate sine of 30 = 0.5