Skip to main content
CNC.wiki

Siemens R Parameter Programming: Guide to Arithmetic Variables

Master Siemens SINUMERIK R parameters. Configure MD28050, run synchronized actions with $R, and troubleshoot alarm 61696 to prevent axis crashes of tools.

Hakan Gündoğdu
Hakan Gündoğdu

CNC CARE Co-founder

Introduction

Omitting a preprocessing stop immediately after calculating arithmetic variables can cause the tool to take an unpredictable path directly into a clamp mechanism, a rigid compensating chuck, or a double turret axis. Because the SINUMERIK controller utilizes a LookAhead buffer and decodes several NC blocks in advance, an R parameter mathematically calculated in the current block might be evaluated prematurely by a subsequent motion block. When the machine attempts to traverse to a coordinate based on this un-updated or empty R variable, the resulting path deviation causes a severe collision. The operator hears a violent crash as the tooling snaps, the workpiece is ruined, and the machine halts under a critical interpreter alarm. Preventing these catastrophic outcomes requires a precise understanding of channel-specific buffers, real-time synchronized action syntax, and proper coordinate handshakes.

Technical Summary

SpecificationDetails
Command CodeR (arithmetic parameter addressing)
Modal Group / ModalityParametric / Variable Programming
Applicable BrandsSiemens (brand-filtered)
Critical ParametersMD28050 $MC_MM_NUM_R_PARAM, MD18156 $MN_MM_NUM_R_PARAM_NCK
Main ConstraintStandard notation range: ±(0.0000001 to 99999999) (max 8 decimal places); Exponential notation range: ±(1*10^-300 to 1*10^+300); Must use STOPRE blocks to prevent LookAhead preprocessing errors.

Quick Read

  • Enforce Preprocessing Stops: Insert a STOPRE command on a standalone line immediately after modifying an R parameter to block LookAhead buffer calculations and prevent motion blocks from executing with stale values.
  • Differentiate Program Contexts: Program R parameters simply as R10 in standard part programs, but prefix them with a dollar sign ($R10) when evaluating them as main run variables inside synchronized actions.
  • Implement Indirect Programming: Utilize inline coordinate assignments such as X=R1 Z=R2 to program axis travel directly, avoiding the need for separate variable assignment blocks.
  • Manage Parameter Capacities: Monitor channel limits configured via MD28050 (default 100 parameters) and global limits via MD18156 to prevent exceeding memory allocation bounds.
  • Synchronize Multi-Channel Operations: Program explicit WAIT markers and flags when reading or writing global variables (RG) to prevent cross-channel data races and read/write corruption.
  • Validate Calculated Values: Check that R parameter values remain within standard notation limits of ±(0.000 0001 ... 9999 9999) with a maximum of eight decimal places to avoid Alarm 61697.

Basic Concepts

The practical programming effect of Siemens R parameters allows operators and programmers to dynamically calculate highly flexible part programs and manufacturer cycles that adapt to different workpiece geometries without requiring hardcoded coordinate values. Programmers frequently rely on these arithmetic variables to calculate complex trigonometric tool paths, configure variable thread leads (G34/G35), or define exact approach coordinates for multi-axis configurations like a double turret processing cycle (G68/G69). However, programmers and operators must watch carefully for advance calculation errors when establishing these variables. Because the SINUMERIK controller utilizes a LookAhead buffer and reads several NC blocks in advance during preprocessing, an R parameter mathematically calculated in the current block might be evaluated prematurely by a subsequent motion block.

This parametric system operates similarly to standard subprogramming but adds real-time computational power. By establishing relationships between variables and coordinates, machine shops can automate complex part families rather than repeating static G-code lines. To learn more about standard subprogram execution, refer to our guide on Writing and Calling Subprograms. When optimization is needed for high-speed machining paths, combining parametric programming with advanced smoothing filters like G645 Tolerance-Based Smoothing ensures that axes follow the calculated coordinates smoothly and without abrupt decelerations.

Command Structure

Siemens R parameters are addressed using a specific nomenclature that determines their visibility and timing behavior. In a standard NC part program, a parameter is referenced by the letter R followed by a number, such as R10, or using bracketed indexing like R[10]. These parameters are channel-specific, meaning each channel maintains its own independent set of R variables. The default channel capacity is 100 variables, but this can be adjusted in the controller settings. To share floating-point values across multiple channels, global parameters RG are used.

When variables must be evaluated in real-time by motion-synchronized actions, the dollar sign prefix $ is mandatory (e.g., $R10). This signals the numerical control kernel to treat the variable as a main run variable rather than a preprocessing variable. Standard programs can also use indirect programming by assigning R parameters directly to axes inline, such as X=R1 Z=R2, which speeds up code execution and reduces file size.

Nomenclature and Assignment Formats:

  • Channel R-Parameter: R<number> or R[<number>] (e.g., R5=12.34)
  • Synchronized Action Variable: $R<number> or $R[<number>] (e.g., $R5=12.34)
  • Global NCK Parameter: RG[<number>] (e.g., RG[1]=2.5)
  • Indirect Axis Assignment: <Axis>=R<number> (e.g., X=R1 Z=R2)
Parameter / VariableDescriptionValue Range / Option
MD28050 $MC_MM_NUM_R_PARAMDefines the channel-specific R parameter capacity.Default: 100 R variables per channel
MD18156 $MN_MM_NUM_R_PARAM_NCKDefines the global NCK-wide R parameter capacity.Configured via machine data
R[x] or R1 to R999Channel R parameter (REAL/DOUBLE type).±(0.000 0001 ... 9999 9999) (max 8 decimal places); Exponential: ±(1*10^-300 ... 1*10^+300)
RG[x]Global NCK R parameter (REAL type).±(0.000 0001 ... 9999 9999) (max 8 decimal places); Exponential: ±(1*10^-300 ... 1*10^+300)

Brand Applications

Siemens

Siemens SINUMERIK controllers manage parametric programming using a highly flexible arithmetic parameter engine. In standard part programs, variables are written simply as R10, but inside hardware-level synchronized actions (which run in parallel with the interpolator), they must be prefixed with a dollar sign as $R10 to denote them as main run variables. Siemens allows direct inline indirect programming of geometric axes (e.g., G01 X=R1 Z=R2 or R[R0]=27.123), which makes the ISO code significantly leaner and faster to parse. To share values across channels, global parameters RG[n] are configured via machine data MD18156, avoiding complex external PLC data blocks.

A typical G-code sequence on a Siemens controller initializes R parameters, performs calculations, and executes movement blocks, utilizing a STOPRE command to synchronize the LookAhead buffer: N10 R1=10.0 R2=20.0; N20 R3=R1+R2; N30 STOPRE; N40 G01 X=R3 F500; N50 R[R1]=27.123;.

CategoryParameter / Alarm / VersionTechnical Details
ParameterMD28050 $MC_MM_NUM_R_PARAMChannel-specific R parameter capacity. Default: 100 R variables per channel.
ParameterMD18156 $MN_MM_NUM_R_PARAM_NCKGlobal NCK-wide R parameter capacity. Configured via machine data.
Alarm CodeAlarm 61696"Parameter R123 incorrectly programmed". Arithmetic syntax in the parameter calculation is invalid. Triggers channel interpreter stop, active alarm, and disables NC Start.
Alarm CodeAlarm 61697"Parameter R122 too high / too low". Calculated value exceeds the permissible bounds. Triggers channel interpreter stop and disables NC Start.
VersionsSINUMERIK 808DPredefines 300 channel R parameters out of the box (fixed base configuration).
VersionsSINUMERIK 840D sl / ONEScales local and global parameter capacities dynamically via machine data configurations.

Warning: Failing to deselect tool radius compensation (G40) or omitting STOPRE immediately after arithmetic parameters are calculated can cause the LookAhead buffer to execute motion blocks with older variable values, leading to catastrophic machine collisions.

Brand Comparison

Series / OptionR-Parameter Capacities & ConfigurationSpecial Features & Execution Behavior
SINUMERIK 808DPredefines a fixed configuration of 300 channel-specific R parameters out of the box.Basic arithmetic parameter evaluation without support for high-end multi-channel global NCK parameters.
SINUMERIK 828DConfigurable via channel-specific machine data MD28050 up to system-defined limits.Includes robust support for channel R parameters, synchronized action variables ($R), and built-in diagnostic safety loops.
SINUMERIK 840D sl / ONEScales local and global capacities dynamically via machine data MD28050 and MD18156.Supports advanced multi-channel global parameters (RG) and multi-channel WAIT markers for complex, high-speed multi-axis synchronization.

Technical Analysis

Siemens exhibits several behaviors regarding arithmetic parameter evaluation that clearly distinguish its models and series. First, the entry-level SINUMERIK 808D features a fixed, non-configurable allocation of 300 channel-specific R parameters, which is ideal for standard three-axis machines but lacks the dynamic memory scaling required for complex setups. On the other hand, high-end controllers like the 840D sl and SINUMERIK ONE utilize configurable machine data (MD28050 and MD18156) to allow engineers to scale local and global parameter capacities to match specific multi-channel configurations.

The choice between channel-specific variables and global NCK parameters dictates how data is shared across the control. Channel parameters R[n] are confined to their respective channel and are evaluated sequentially by the channel's interpreter. If a programmer attempts to pass coordinates to a secondary channel using these local variables, the second channel remains completely blind to the values. To resolve this, global parameters RG[n] must be utilized. Because the control does not enforce implicit read/write locks on global variables, programmers must actively program WAIT markers to prevent data corruption. If a secondary channel reads an RG variable before the primary channel has finished writing to it, the resulting coordinate mismatch will drive the machine off-path.

Program Examples

1. Standard Assignment and Inline Axis Movement

This program demonstrates initializing local R parameters and assigning them inline directly to geometric axes for motion.

; Standard R Parameter Movement
N10 R1=25.0 R2=-50.0      ; Initialize channel variables R1 and R2
N20 G01 X=R1 Z=R2 F300    ; Move linearly to X25.0 Z-50.0 at F300

2. LookAhead Buffer Synchronization using STOPRE

This program illustrates how to use a preprocessing stop (STOPRE) block on its own line to prevent LookAhead errors when calculating tool path coordinates.

; Preprocessing Stop Synchronization
N30 R3=R1+10.0            ; Perform arithmetic calculation (R3 = 35.0)
N40 STOPRE                ; Halt LookAhead buffer until calculation is written
N50 G01 X=R3 F200         ; Move to X35.0 using the verified R3 value

3. Indirect Array Indexing and Trigonometric Calculations

This program shows how to perform indirect addressing using nested R variables and calculate an angle using the ATAN2 function.

; Nested Indexing and Trigonometry
N60 R[R1]=27.123          ; Write value 27.123 to R25 (since R1 = 25.0)
N70 R40=ATAN2(30.5,80.1)  ; Calculate angle (R40 = 20.844 degrees)
N80 M02                   ; End of program and reset modal states

Dry Run Execution Procedure

Performing a dry run of the parametric routine ensures all calculations and LookAhead stops operate correctly before machining a physical workpiece. Follow this step-by-step procedure:

  1. Verify Mechanical Pre-requisites: Ensure the workpiece is securely mounted in the chuck or vise, and all clamps are clear of the tool path.
  2. Check Parameter Limits: Access the controller parameter page to confirm that the active channel variables are within bounds and that MD28050 is set to support the programmed variable index.
  3. Position the Axes: Jog the tool in manual mode to a safe clearance location at least 50 mm away from any physical obstructions.
  4. Select MDA Mode: Switch the controller to MDA (Manual Data Automatic) or Program execution mode, and load the test blocks.
  5. Enable Single Block: Turn on the Single Block switch on the operator panel to allow stepping through the program line-by-line.
  6. Execute N10 and N20: Press Cycle Start. The controller assigns values to R1 (25.0) and R2 (-50.0). The next block commands a linear motion to X25.0 and Z-50.0. Verify that the axis coordinates on the screen update to match these variables.
  7. Execute N30 and N40: Step through the calculation block. Press Cycle Start again to execute STOPRE. Notice that the control halts preprocessing at this line, ensuring the new value for R3 is fully calculated and registered before any axis movement occurs.
  8. Execute N50 to N80: Confirm the tool moves to the computed position X35.0, then performs the nested indexing assignment to R25 and the trigonometric calculation for R40. The program ends with M02, resetting modal states.

Error Analysis

Alarm CodeTrigger ConditionOperator SymptomRoot Cause & Practical Resolution
Alarm 61696
Parameter Incorrectly Programmed
Invalid arithmetic syntax or structural error within an R-parameter calculation (e.g., unmatched brackets or incorrect function calls).Immediate channel interpreter stop; active alarm message displayed on the HMI; NC Start is disabled.A syntax error exists in the mathematical formula. Verify equation formatting, ensure all open brackets `[` have matching close brackets `]`, and correct invalid functions.
Alarm 61697
Parameter Too High / Too Low
The calculated or assigned value of an R parameter exceeds the maximum permissible floating-point range.Immediate channel interpreter stop; execution halts mid-block; NC Start is disabled.The value exceeds range boundaries (standard `±9999 9999` with 8 decimal places, or exponential limits). Check calculation bounds and add input range checks to program.
Interpreter Alarm
Invalid $R Syntax Usage
Using the synchronized action prefix `$` on an R parameter (e.g., `$R1`) within a standard program block rather than a synchronized action.Program execution is rejected at the offending block; active syntax error alarm displayed.The `$R` prefix is strictly reserved for main run evaluations in motion-synchronized actions. Remove the `$` prefix for standard part program blocks, using standard `R1` addressing instead.

Application Note

A catastrophic axis collision that crushes the clamp mechanism or bends the rigid compensating chuck is the direct mechanical consequence of omitting a preprocessing stop (STOPRE) after critical arithmetic calculations. Because the SINUMERIK LookAhead buffer decodes NC blocks in advance, the controller may evaluate a subsequent motion command using a stale or empty parameter value before the math calculation in the current block has finished writing to memory. The resulting coordinate shift drives the tool off-path, causing severe physical damage, a ruined workpiece, and triggering Alarm 61696. Programmers must enforce a strict safety rule of placing a STOPRE command on its own line immediately following any mathematical R parameter operations. When sharing global parameters (RG) across multiple machining channels, engineers must program explicit WAIT markers to prevent data corruption from unsynchronized channel read/write data races.

Related Command Network

  • STOPRE: A preprocessing stop command that synchronizes the LookAhead buffer with active arithmetic calculations to prevent premature variable evaluation.
  • RG: Global NCK-wide R parameters used to pass floating-point values between multiple machining channels.
  • g331-g332-rigid-tapping: Rigid tapping cycles that utilize synchronized spindle and Z-axis motion, which can be dynamically controlled via R parameters.
  • writing-and-calling-subprograms: The structural method for executing repetitive routines, which can be parameterized using R variables to adjust coordinates dynamically.
  • g645-tolerance-based-smoothing: An advanced path-smoothing command used to maintain high feedrates when executing complex calculated tool paths.

Conclusion

Safely leveraging Siemens R parameters requires consistent discipline in synchronizing the controller's LookAhead buffer and auditing parameter capacities. Placing a STOPRE block after all mathematical assignments prevents motion blocks from executing with stale coordinate values and eliminates the risk of collision. Combining channel-specific variables with global parameter synchronization (using WAIT markers) ensures robust, multi-channel cycle execution that protects tooling and enhances machining efficiency.

Frequently Asked Questions

Why does my SINUMERIK control execute a movement block before the preceding R-parameter math calculation is finished?

This behavior is caused by the controller's LookAhead pre-decoding engine, which processes several blocks in advance to optimize motion blending. When a calculation block is followed immediately by a travel command, the interpreter may evaluate the axis coordinate using the stale parameter value before the write cycle completes. Practical Action: Always insert a standalone STOPRE command on the line immediately after any R-parameter calculation block to halt the preprocessing buffer until the memory updates.

What causes Alarm 61697 during a parametric G-code cycle run?

Alarm 61697 indicates that a calculated or assigned variable has exceeded the permissible limits of the REAL data type range on Siemens controls. This often happens due to a division-by-zero or an incorrect trigonometric calculation that yields an extremely high value. Practical Action: Review the mathematical calculations in your program, verify that divisors are never zero, and add conditional limits to clamp calculated R-parameters within the standard non-exponential bounds of ±9999 9999 with a maximum of eight decimal places.

How do I share coordinate data between separate machining channels on a multi-turret lathe using variables?

Standard channel R parameters cannot be seen by other channels, so attempting to read them across channels will result in empty values or interpreter halts. You must use global NCK-wide parameters, addressed as RG[n], which are configured via machine data MD18156 to share floating-point values globally. Practical Action: Program the primary channel to write coordinate data to an RG variable, and use explicit multi-channel WAIT markers to block the secondary channel from reading the variable until the primary channel has completed its write cycle.

Still not resolved?

Ask our AI assistant about this topic in natural language. Grounded in verified sources, no hallucinations.

Ask AI Assistant
Hakan Gündoğdu
Hakan Gündoğdu
  • CNC CARE Co-Founder (May 2025 - Present)
  • Mitsubishi Electric NC Sales & Service Section Manager (2008 - 2025)
  • Reis CNC Service Engineer (2003 - 2005)
  • Ören Kalıp CNC Mold Line Team Leader (1999 - 2002)

With over 25 years of experience working in all areas of the CNC machine industry, I continue my activities as a co-founder of CNC CARE, where we offer brand-independent consulting, engineering, and original spare parts services.

Related Articles

Other articles on this topic