Arithmetic Parameters

The arithmetic parameters (known as R-parameters for short) are interpreter variables that are named by an expression of the form "R<n>". Since 'n' is an integer in the range 0..999, a total of 1000 R-parameters are available. Of these, the first 900 values (R0..R899) are local variables for the NC channel. They can only be accessed by the channel’s interpreter. The R-parameters R900..R999 are declared globally. They exist only once for each NC, and all channels access the same storage. This makes it possible to exchange data (e.g. for part tracing, collision avoidance etc.) over the channel boundaries.

Mathematical Calculations

The R-parameters (like the axis co-ordinates, feedrates etc.) are declared as variables of type 'double'. This makes full use of the computer’s arithmetic capacity. The number of places before and after the decimal point is not restricted by a format specification. The arithmetical resolution does, nevertheless, have a limit. In practice this is only visible in particularly critical cases. Examples of this include the differences of very large numbers that are almost equal, or trigonometrical functions in particular ranges of angles.

Assignment of R-Parameters

N100 R5=17.5
N110 R6=-4
N120 R7=2.5 R8=1

As can be seen in the third line, it is quite possible to make more than one assignment in one block. This speeds interpretation slightly, but it can be more difficult to localize an error in the line.

Calculation formula

A calculation formula is an extension of assignment. It consists of a target parameter, an assignment sign and a series of values (R-parameters and constants) separated by arithmetical instructions.

N100 R1=R2+R3-17.5*R9/2.5 

Such a formula, contrary to normal mathematical practice, is processed strictly from left to right.

The illustrated formula is calculated as follows:

  1. The contents of R2 is loaded into the arithmetic unit
  2. The contents of R3 is loaded into the arithmetic unit
  3. The arithmetic unit carries out the + instruction
  4. The value 17.5 is loaded into the arithmetic unit
  5. The arithmetic unit carries out the - instruction
  6. The contents of R9 is loaded into the arithmetic unit
  7. The arithmetic unit carries out the * instruction
  8. The value 2.5 is loaded into the arithmetic unit
  9. The arithmetic unit carries out the / instruction
  10. The content of the arithmetic unit is stored in R-parameter R1

Mathematical functions

The interpreter provides standard computing functions. DIN 66025 does not specify any syntax here. The computing functions are called via @6xx (see appendix - @-command overview).

The trigonometrical functions are always calculated in degrees.

Sample:

N10 R2=0 R3=45
N20 @630 R2 R3

In this sample the sine of R3 is calculated in degrees. The result is then written into R2.

R-parameter access from the PLC

You can read the R-parameters into the PLC, or write the R-parameters from the PLC. Special PLC function blocks are provided for this purpose

During writing of the R-parameters, ensure that the interpreter is ahead of the block execution. In other words, writing of the R-parameters from the PLC should take place before the NC program starts or be linked to a decoder stop.

For debugging purposes, all R-parameters can be written to a file at any time. This process can be triggered via ADS (see ADS interface - channel functions IndexOffset 0x24 & 0x25).

Other functions

RToDwordGetBit

This function converts an R-parameter to a DWord and then checks whether a particular bit is set. The result is again stored in an R-parameter.

Command

RToDwordGetBit[<dest>; <src>; <bit> ]

Parameter <dest>

R-parameter in which the result is entered

Parameter <src>

R-parameter containing the number that is to be converted and checked

Parameter <bit>

Bit to be checked (0..31)

Sample:

N10 R1=7
N20 RToDwordGetBit[R2;R1;0]
R10=31
N30 RToDwordGetBit[R3;R1;R10]

Enter 1 in R2 and 0 in R3.

Initialization of R-parameters

'set RParam' is used to assign a value to a contiguous block of R-parameters.

Command

#set RParam(<start index>; <count>; <value> )#

Parameter <start index>

Describes the first R-parameter to be written

Parameter <count>

Number of R-parameters to be written

Parameter <value>

Assigned value

Sample:

N10 G01 X100 Y200 F6000
N15 R2=3000
N20 #set RParam( 1; 2; 0.0 )# (R2 is overwritten again here)
N30 G01 X500

Saving R-Parameters

If the content of R-parameters is required for subsequent use, while in the meantime the R-parameters are used for a different purpose, it can temporarily be stored in the values stack of the arithmetic unit.

Two possibilities exist for this:

Saving the values:

Command

@40 <number> R<n> R<m>...

@41 <1st R-parameter> <last R-parameter>

Restoring the values:

Command

@42 <number> R<n> R<m>

@43 <last R-parameter> <1st R-parameter>

When restoring the values, call the parameters in reverse order.

Sample 1:

(saving the data) 
N100 @40 K4 R800 R810 R823 R4

N110 R800=4711
N120 ...

(restoring the data)
N200 @42 K4 R4 R823 R810 R800

Sample 2:

(saving the data)
N100 @41 R800 R805

N110 R800=4711
N120 ...

(restoring the data)
N200 @43 R805 R800
Arithmetic Parameters 1:

Stack size

The value stack of the arithmetic unit has limited capacity. If it overflows, the NC program is interrupted with an error message. That can occur as the value is saved, but can also occur in the course of subsequent formula evaluation.