Configuring $MN_LUD_EXTENDED_SCOPE on SINUMERIK 840D sl

David Krause13 min read
Motion ControlSiemensTutorial / How-to
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Configuring $MN_LUD_EXTENDED_SCOPE on SINUMERIK 840D sl

Overview

Variables declared with DEF inside a SINUMERIK part program are classified as Local User Data (LUD). By default they are scoped strictly to the program level where the declaration appears, so a subprogram or a Siemens cycle such as CYCLE95 cannot see them. When a contour turning macro needs a named variable to flow from the main program into the cycle's contour subroutine, the standard solution paths are R-parameters, a User Global User Data (UGUD) definition, or toggling the machine data $MN_LUD_EXTENDED_SCOPE.

This reference documents:

  • The SINUMERIK variable scope model (LUD, GUD, R-parameter, MD settable variables)
  • Bit-level semantics of $MN_LUD_EXTENDED_SCOPE
  • The root cause and decode of the alarm "Maschinendatum wegen fehlender Zugriffsrechte 2 nicht geändert"
  • Three field-proven solution paths: permanent MD change, R-parameter substitution, and UGUD.def declaration
  • Step-by-step commissioning procedures including access-level management
  • Verification, troubleshooting matrix, and field risk analysis

Prerequisites

Item Requirement
Controller SINUMERIK 840D sl (equivalent MD on 840D, 828D, ONE)
HMI SINUMERIK Operate / HMI Advanced in commissioning or service mode
NCU / PLC Access to Setup menu and to the machine-data tree
Access rights Manufacturer password or key switch position 3 (service)
Knowledge Part-program structure, DEF / DEF NCK syntax, subroutine call mechanism
Documentation Programming Manual SINUMERIK 840D sl, Lists Manual (machine data), Programming Manual Cycles

SINUMERIK Variable Scope Model

SINUMERIK distinguishes four primary user-variable scopes. Understanding the differences prevents the typical confusion between LUDs that "don't work in subprograms" and R-parameters that always do.

Scope Declaration Lifetime Visibility
LUD (Local User Data) DEF REAL WERT inline in a part program Single program run Program level where declared (default); extended by $MN_LUD_EXTENDED_SCOPE
GUD (Global User Data) Files GUD.DEF, UGUD.DEF, MGUD.DEF, SGUD.DEF in the NCK definitions directory Across all programs, loaded at NCK startup All program levels (global)
R-parameters Implicit; numbered R0..R99 standard, R100+ optional on larger NCKs Single program run All program levels (global within run)
MD settable vars Identifiers $MN_..., $NC_..., etc. Persistent (NCK lifetime) Across all programs and levels

Program-level nesting follows the call stack. The main program is the highest level. A subroutine called from the main program is one level below. A subroutine called from that subroutine is two levels below. By default, LUDs defined at one level are invisible at any other level.

Inline Scope SVG Diagram

Main program (Level 0) DEF REAL WERT -- LUD scoped here Contour subroutine Tries to read WERT CYCLE95 cycle body Calls contour subroutine (Default $MN_LUD_EXTENDED_SCOPE=0: WERT not visible) With $MN_LUD_EXTENDED_SCOPE = 1: WERT is visible (read/write) in contour subroutine Re-declaring WERT in subroutine triggers alarm PowerOn required to activate change

The $MN_LUD_EXTENDED_SCOPE Machine Data

$MN_LUD_EXTENDED_SCOPE controls whether LUD variables defined at a higher program level can be read or written by lower program levels (subprograms, Siemens cycles, user macros).

Value Behavior Field impact
0 (default) Strict separation. LUDs are local to the program level. Same name in a different level creates a separate, independent variable. Predictable, no cross-level leaks. Subprograms cannot read main LUDs.
1 Extended scope. LUDs defined in a higher level can be read and written in lower levels. Re-defining the same name in a lower level raises an alarm. Convenient variable sharing but breaks existing cycles that rely on same-name independence.

Syntax Reference

The MD identifier follows the Siemens naming convention $MN_<NAME>. Inline assignment in a part program:

$MN_LUD_EXTENDED_SCOPE=1

Common typos that produce confusing alarms:

N10 $MN_LUD_EXTENDED_SCOPE01     ; INCORRECT - stray "01", no '='
N10 LUD_EXTENDED_SCOPE=1         ; INCORRECT - missing $MN_ prefix
N10 $MN_LUD_EXTENDED_SCOPE 1     ; INCORRECT - missing '='

The correct, minimum block is a single statement on its own line, optionally preceded by a block number:

N10 $MN_LUD_EXTENDED_SCOPE=1

Activation Behavior

Aspect Behavior
Immediate effect No
NCK PowerOn required Yes
PO reset class Configuration reset (re-initialization) or full reset, depending on controller build
Persisted in NV-RAM Yes (after activation)
Reversible from part program Yes, by re-assignment to 0 (followed by another PowerOn)

Root Cause: The "Fehlende Zugriffsrechte" Alarm

When the inline write

N10 $MN_LUD_EXTENDED_SCOPE=1

is executed and the controller responds with:

Maschinendatum (und evtl.weitere) wegen fehlender Zugriffsrechte 2 nicht geändert

the alarm text decomposes as follows:

Token Meaning
Maschinendatum A machine-data identifier was targeted
wegen fehlender Zugriffsrechte Current access level is below the MD's required level
2 Required access level (Service in Siemens convention)
nicht geändert The write was rejected; existing value retained

Siemens Access Level Convention

Numeric level Role Typical unlock mechanism
0 System Siemens manufacturer only
1 Manufacturer (OEM) Manufacturer password
2 Service Key switch position 3, or service password
3 User Key switch position 1, or user password
4 Key switch pos 0 Reserved (lowest privilege)
5 Key switch pos 1 Standard operator
6 Key switch pos 2 Reserved
7 Key switch pos 3 Highest operator privilege

Note: the numeric level is inverse — lower number = higher privilege. $MN_LUD_EXTENDED_SCOPE is protected at numeric level 2 for part-program write. The HMI in operator mode typically operates at numeric level 3 (User) or higher, so the write is rejected unless service access is unlocked.

Solution Path A: Permanent MD Change via HMI Commissioning

This is the most maintainable solution when the behavior is desired across multiple part programs.

When to Use

  • Multiple programs need LUD sharing
  • Machine builder has been informed and existing cycles audited
  • A controlled NCK restart window is available

Procedure

  1. Switch the HMI to commissioning / setup mode (Setup menu in SINUMERIK Operate).
  2. Open the machine data list: Setup → Machine Data → Display MD (or General MD, depending on controller generation).
  3. Filter for LUD_EXTENDED_SCOPE or navigate the tree manually.
  4. Change the value from 0 to 1.
  5. Confirm and save. The HMI prompts for an NCK reset; choose the reset class appropriate to your environment (configuration reset is usually sufficient).
  6. Wait for the NCK to come back up. Verify the new value by reading the MD back in the list.
Access level required. Even via HMI, the write requires Service access (level 2) unless the MD's access class field has been lowered by the manufacturer. Confirm the current key-switch position before the edit; otherwise the field will appear read-only.

Solution Path B: R-Parameter Substitution

This is the most common workaround when the machine builder does not want $MN_LUD_EXTENDED_SCOPE changed.

Why R-Parameters Work

R-parameters (R0..R99 standard, R100+ on larger NCKs) are arithmetic variables visible across all program levels for the duration of the program run. They are not subject to LUD scope rules, and they do not require any access level to assign or read.

CYCLE95 R-Parameter Example

; Main program - Huelse length passed as R1
R1 = -25.0
N900 CYCLE95 ("START1:END1", 1.5, 0.1, 0.05,, 0.1, 0.1,, 3)
N910 GOTOF END1
N920 START1:
N930 G1 X41 Z0.1
N940 Z0
N950 G2 X39.42 Z-0.593 CR=0.8
N960 G1 X38.13 Z-3
N970 Z= R1                ; contour block consumes R1 directly
N980 X34
N990 END1:
M30

The cycle CYCLE95 calls the contour subroutine START1:END1; the contour reads R1 directly, bypassing any LUD scoping issue.

Reserved Parameter Strategy

Some legacy Siemens cycles overwrite R-parameters internally. Adopt a reservation policy:

Range Use
R0..R9 Reserved for Siemens cycle internal use — do not assign manually
R10..R49 User-callable parameters passed to subprograms / cycles
R50..R99 Free for general arithmetic, expression results
Always verify cycle-internal R-parameter usage for your specific software version. The ranges above are typical but not contractually defined.

Solution Path C: UGUD.def Named Global Variables

This path is preferred when the variable must be a named global (e.g., Huelsenlaenge) and the integrator does not want to enable $MN_LUD_EXTENDED_SCOPE.

UGUD.def Structure

The file UGUD.DEF (User Global User Data) lives in the NCK definitions directory and is loaded at NCK startup. Add a declaration line:

; UGUD.DEF
DEF NCK REAL Huelsenlaenge

After the next NCK startup, Huelsenlaenge is available in any program at any level. Its lifetime is the NCK session — it survives program end, lost at NCK reset unless backed by a persistent declaration.

Persistent Variation

For values that should survive NCK reset, use the SAVE attribute (software-version dependent):

DEF NCK REAL SAVE Huelsenlaenge

Confirm SAVE availability for your NCU software version before relying on it.

Editing and Activation

  1. Access the system def files (typically /NCK/Definitions/UGUD.DEF) via the Setup → Define Data menu, or via file transfer.
  2. Edit the file and save.
  3. Trigger an NCK PowerOn. The new symbol table becomes active on next NCK startup.
  4. Some controllers require explicit re-initialization via Setup → Define Data → Activate.

Writing $MN_LUD_EXTENDED_SCOPE from a Part Program

For runtime adjustment (e.g., in a startup macro or conditional program), use the inline assignment. The syntax is straightforward, but several preconditions must be met.

Inline Write Block

; Place as the first executable block of the program
N10 $MN_LUD_EXTENDED_SCOPE=1

Preconditions

  • Current access level must be ≤ 2 (Service). Confirm in the HMI status bar.
  • Key switch set to position 3, or service password entered.
  • The MD must be classified as settable from the part program (the LUD-related MDs are settable inline in current SINUMERIK versions).

Full Procedure

  1. Set the access key switch to position 3 (or input the service password via Setup → Password).
  2. Confirm the access level indicator shows "Service" or numerically ≤ 2.
  3. Insert the assignment as the first executable block.
  4. Run or dry-run the program.
  5. If accepted without alarm, expect a subsequent alarm or message indicating PowerOn required.
  6. PowerOn the NCK.
  7. Re-read the MD to confirm the new persistent value.

Limitations of the Inline Write

Aspect Behavior
Immediate effect No
PowerOn required Yes
Reversible from part program Yes (assign back to 0, then PowerOn again)
Audit trail in NCK log None by default
Protection against typo None — typos produce a different alarm family

Risk Analysis and Field Notes

Enabling $MN_LUD_EXTENDED_SCOPE = 1 changes the meaning of identically named variables that were previously considered distinct. If shop-standardized names (e.g., WERT, Huelsenlaenge, MESS_AUF) appear at multiple levels of legacy cycles, the change can produce name collisions that surface only at first invocation.

Risk Severity Mitigation
Name collision after enabling High Audit every cycle and shop-written subroutine for duplicate DEF names across levels
PowerOn disrupts production Medium Schedule change during planned maintenance
Inline write leaves no audit trail Medium Log the change in the machine logbook manually
MD write silently fails (no alarm visible) Low to Medium Always re-read the MD after a write attempt
Same-name ambiguity in legacy cycles High Contact machine builder; do not enable on machines with undocumented cycles
Cycle fails to find LUD in subroutine High (production) Use R-parameter or UGUD substitution path instead
Best practice. Before enabling extended scope, generate a cross-reference list of all DEF statements in shop programs and in the OEM cycle library (typically /NCK/CMA.DIR, /NCK/CUS.DIR). Any duplicate identifier at different levels is a candidate for collision after the MD change.

Verification

After enabling extended scope, run a controlled verification sequence before relying on the behavior in production.

Test 1: Read-Through

; Main program
DEF REAL TEST_VAL = 42.0
N100 L_TEST_UP
N110 M30

; Subroutine (L_TEST_UP.SPF)
N10 R10 = TEST_VAL      ; reads LUD from main program
N20 M17

Expected: no alarm; R10 equals 42.0 after the subroutine returns.

Test 2: Collision Alarm

; Subroutine (L_TEST_UP.SPF)
N10 DEF REAL TEST_VAL = 99.0   ; expected to alarm
N20 M17

Expected: alarm indicating name redefinition under extended scope.

Test 3: CYCLE95 Variant

Mirror the structure of the failing production program: define a named LUD, assign it, call CYCLE95, verify the contour subroutine can read it (with the contour subroutine either reading the LUD directly or reading an R-parameter the main program assigns from the LUD).

Troubleshooting Matrix

Symptom Likely cause Fix
Alarm: "Maschinendatum wegen fehlender Zugriffsrechte 2 nicht geändert" Access level too low Set key switch to 3 or input service password
MD accepts write but behavior unchanged PowerOn not performed Trigger NCK reset / PowerOn
Cycle runs but uses default / zero value MD write silently failed; or LUD redefinition collided Re-read MD value; audit DEF names
Alarm after enabling extended scope Name collision in existing cycles Audit cycles; revert MD or rename conflicting variables
LUD undefined alarm in subroutine $MN_LUD_EXTENDED_SCOPE=0 Set MD to 1 (with audit), or use R-parameter, or use UGUD
MD write accepted but disappears after NCK reset MD write was not saved persistently Save via HMI commissioning menu, not inline
CYCLE95 ignores passed dimension value Variable scope blocks the read; or R-parameter range was overwritten by the cycle internally Switch to a parameter outside the cycle's internal range, or use UGUD
Typo "SCOPE01" or similar garbage in MD identifier Operator typo in inline write Replace with exact identifier $MN_LUD_EXTENDED_SCOPE and verify the assignment operator

Related Machine Data

MD identifier Effect
$MN_LUD_EXTENDED_SCOPE Extends LUD scope to lower program levels (this article)
$MN_MM_NUM_LUD_NAMES_TOTAL Maximum number of LUD names per NCK
$MN_MM_NUM_LUD_NAMES_PER_PROG Maximum number of LUD names per program
$MN_MM_TYPE_LUD_REAL Storage type and size for LUD REAL variables
$MN_MM_TYPE_LUD_INT Storage type and size for LUD INT variables
$MN_MM_TYPE_LUD_BOOL Storage type and size for LUD BOOL variables
$MN_MM_TYPE_LUD_CHAR Storage type and size for LUD CHAR variables
$MN_MM_TYPE_LUD_STRING Storage type and size for LUD STRING variables
$MN_MM_LUD_HASH_TABLE_SIZE Internal hash table size for LUD name lookup (affects performance)

These are typically set during initial commissioning and rarely changed in the field. Review them before enabling extended scope, because the LUD name space usage grows if many programs adopt shared LUD names.

Field Commissioning Checklist

  1. Export the current machine data via Setup → Series Comm. → Backup for restore.
  2. Generate the cross-reference of DEF statements in shop programs and OEM cycle directory.
  3. Identify duplicate identifiers at different program levels; flag collisions.
  4. Schedule a maintenance window for NCK PowerOn.
  5. Set key switch to position 3; confirm "Service" indicator.
  6. Modify the MD via Setup menu; save.
  7. Trigger NCK reset / PowerOn.
  8. Re-read the MD to confirm persistence.
  9. Run the verification test sequence above on a non-production program.
  10. Run a controlled production dry run before resuming normal production.
  11. Document the change in the machine logbook with date, software version, and operator.

Cross-Reference: Variable Concept Background

The concept of a named, scoped storage location that programs read and write is fundamental to all high-level programming languages, including the part-programming language used on SINUMERIK controllers. The mechanics of declaration, scope, lifetime, and visibility apply identically to LUD, GUD, and R-parameter semantics on the NCK side. A general treatment of variables in high-level programming languages is available at the Wikipedia variable article.

FAQ

What is $MN_LUD_EXTENDED_SCOPE on a SINUMERIK 840D sl?

It is the machine data that determines whether Local User Data (LUD) variables declared with DEF in a higher-level program are visible in subprograms, cycles, and contour subroutines. Value 0 keeps LUDs strictly local; value 1 extends their scope to lower program levels and allows read/write access there.

Why does the controller raise "Maschinendatum wegen fehlender Zugriffsrechte 2 nicht geändert" when I write $MN_LUD_EXTENDED_SCOPE=1?

The MD requires Service access (numeric level 2). The HMI is running at User access (level 3 or higher numeric), so the write is rejected. Set the key switch to position 3 or input the service password via Setup → Password, then retry.

Does $MN_LUD_EXTENDED_SCOPE take effect immediately after a part-program write?

No. The change is stored but requires an NCK PowerOn (or a configuration reset, depending on the controller build) to activate. Always re-read the MD after the PowerOn to confirm the persistent value.

Can I pass a variable from the main program into CYCLE95 without changing $MN_LUD_EXTENDED_SCOPE?

Yes. Assign the value to an R-parameter (e.g., R1 = -25.0) before the CYCLE95 call and read R1 in the contour subroutine, or declare a named variable in UGUD.DEF as a User Global User Data. Both paths avoid the extended-scope MD entirely.

What risks come with enabling $MN_LUD_EXTENDED_SCOPE = 1?

The primary risk is name collision: previously independent LUDs that happened to share a name across program levels become a single shared variable, and any lower-level redefinition raises an alarm. Audit every cycle and shop subroutine for duplicate DEF names before enabling. Coordinate with the machine builder if undocumented cycles are present.

What R-parameter range should I avoid for user assignments?

Avoid R0..R9 as a convention, since some legacy Siemens cycles overwrite them internally. Use R10..R49 for user-callable parameters passed to subprograms or cycles. Always verify cycle-internal R-parameter usage for your specific software version.

What is the difference between UGUD.def and SGUD.def / MGUD.def / GUD.def?

UGUD (User Global User Data) is the integrator's own global definition file, editable by the end user. SGUD is the Siemens system GUD file. MGUD is the machine builder's GUD file. GUD is a generic term covering all of them. Edit UGUD for shop-specific global variables; do not edit SGUD.

Back to blog