Siemens 840D Tool Compensation: Configuring OFFN, TOFFL, and L_39

David Krause10 min read
Motion ControlSiemensTechnical Reference
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

Siemens 840D Tool Compensation: Configuring OFFN, TOFFL, and the L_39 Manufacturer Cycle

This technical reference consolidates field-proven practices for runtime tool compensation on Siemens 840D / 840D sl controllers, with emphasis on the DIN/ISO programming environment used on Deckel Maho DMC machining centers. It covers the OFFN, TOFFL, and TOFFR system variables introduced in SW 7.x, the manufacturer-specific L_39 subprogram, the PROG_EVENT.SPF reset hook, and the additive DL correction mechanism.

Scope: SINUMERIK 840D and 840D sl with software version 7.x or higher. Some system variables (TOFFL, TOFFR) are not available prior to SW 7.0 and will trigger an NC alarm if programmed on legacy controllers.

1. Compensation Strategies Overview

Tool compensation on a Siemens 840D can be performed at three distinct layers, and selecting the correct layer is the most common source of programming and operational issues:

Layer Mechanism Persists after RESET / M30? Modifies tool list?
Tool list (wear) $TC_DP12 (length), $TC_DP15 (radius) Yes (NV-RAM) Yes
System variables OFFN, TOFFL, TOFFR Only if explicitly preserved No
Additive corrections DL numbers Until deselected No (separate edge data)

For any correction that must be reversible on RESET or program interruption, system variables or additive DL corrections are strongly preferred. Direct writes to $TC_DP12 / $TC_DP15 persist in non-volatile tool memory and will survive power-cycle — a frequent cause of part scrap after weekend shutdown.

2. OFFN — Normal Offset (Contour Offset)

OFFN shifts the programmed contour normal to the path. It is active only while G41 or G42 cutter-radius compensation (CRC) is selected, and it works in the active machining plane.

Typical use cases:

  • Radial stock allowance for finish-pass machining.
  • Groove wall correction with TRACYL (where it differs from TOFFR).
  • Compensating measured dimensional drift without touching tool wear.

Programmatic behavior:

; Apply 0.03 mm radial allowance
G0 X0 Y0 Z50
G41 G1 X10 Y0 F500 OFFN=0.03
; ... machining ...
OFFN=0            ; MUST be reset at end of operation
G40 X0 Y0         ; deselect CRC

OFFN is modal and additive to the active CRC. Forgetting OFFN=0 at program end is a documented cause of incorrect contour on the next workpiece, especially in mixed roughing/finishing programs.

3. TOFFL and TOFFR — Programmed Tool Offsets (SW 7.x)

TOFFL applies an additional length offset in the tool axis; TOFFR applies an additional radius offset. Both are write-only from the part program and are reset to zero on RESET / M30 / M6 by default. They were introduced with SW 7.0 and represent the recommended replacement for direct manipulation of $TC_DP12 / $TC_DP15.

3.1 Syntax Variants

Command Effect
TOFFL = 0.02 Corrects length component L1 by 0.02 mm
TOFFL[2] = 0.01 Corrects length component L2 (n ∈ {1,2,3})
TOFFL[GEOAX] = 0.05 Corrects length in direction of the named geometry axis (X / Y / Z)
TOFFR = 0.03 Adds 0.03 mm to the active radius

Behavior comparison:

  • Under normal conditions, TOFFR and OFFN produce identical results in the machining plane.
  • For groove wall correction with TRACYL, TOFFR and OFFN diverge — use OFFN for cylinder-related groove compensation.
  • All three (OFFN, TOFFL, TOFFR) are independent of tool-list wear data.

3.2 Ball-End Mill Reference Example

When a ball-end mill is automatically measured at the tip, but the CAM post-processor assumes the radius center, an axial offset equal to the negative radius is required:

; Ball mill D6, measured at tip, CAM assumes radius center
TOFFL = -3.0      ; D=6 → radius=3, so offset = -3 mm
; ... machining ...
TOFFL = 0          ; reset before tool change

4. The L_39 Manufacturer Cycle (Deckel Maho)

L_39 is a manufacturer cycle supplied by Deckel Maho (DMG MORI) on selected DMC machining centers. Its semantics mirror the Heidenhain DL/DR function:

L_39(REAL D_L, REAL D_R)

Where D_L is the length correction and D_R is the radius correction. Both may be positive or negative. The values are written into the wear fields of the active tool — not into a separate runtime variable. Calling L_39(0,0) zeroes both wear values for the active cutting edge.

4.1 Availability Matrix

Plant / Series L_39 Available Notes
Pfronten plant (most DMC series) Yes Standard manufacturer cycle
Seebach plant (some legacy series) Partial / No Compatibility varies by machine series
Non-DMG Siemens 840D systems No Use OFFN / TOFFL / DL
Risk warning: Because L_39 writes into the wear data ($TC_DP12 / $DP15), the values persist after RESET and M30. Any program interruption leaves the wear modified unless L_39(0,0) was issued. This is the most common scrap mechanism reported on DMG cells running third-party CAM post-processors.

4.2 Worked Program Excerpt

N18  MSG("SPHERE MILLING CUTTER D3")
N19  M6
N20  L_FREE
N21  G0 SUPA Z-1 D0
N22  G0 SUPA Y-1
N23  D1
N24  L_39(0.2,0)     ; OFFSET: L=0.2, R=0
N25  M0              ; operator confirms offset applied
...
N6750 D1
N6751 CYCLE800
N6752 L_39(0,0)      ; clear offsets before tool change
N6753 ;M91
N6756 M17

5. L_39 Source with Save/Restore Logic

The most robust pattern combines L_39 with GUD/U-GUD persistence and a PROG_EVENT.SPF hook. The example below reads the active tool's wear before the write and stores the deltas in user globals so the original wear can be reconstructed after a RESET.

5.1 GUD Definitions (UGUD.DEF or similar)

DEF CHAN INT  L_39_AKTIV      ; flag: correction active
DEF CHAN REAL KORR_D_L        ; original wear length at save time
DEF CHAN REAL KORR_D_R        ; original wear radius at save time

5.2 Modified L_39 Cycle

PROC L_39(REAL D_L, REAL D_R) SAVE DISPLOF
; VERSION: 1.0.0  Aug 28 2008
; Function: Fine adjustments to tool wear
; L_39(Length, Radius)
; L_39(0,0) restores the previously saved wear values

DEF REAL _DD

STOPRE
IF ($TC_MPP6[9998,1]==0) OR ($P_TOOL==0)
   ;msg("No tool or inactive tool in spindle")
ELSE
   IF L_39_AKTIV == 0
      ; first call: snapshot current wear
      KORR_D_L = $TC_DP12[$P_TOOLNO,$P_TOOL]
      KORR_D_R = $TC_DP15[$P_TOOLNO,$P_TOOL]
      _DD       = $P_TOOL
      L_39_AKTIV = 1
   ELSE
      ; second call with (0,0): restore
      D_L = KORR_D_L
      D_R = KORR_D_R
      L_39_AKTIV = 0
   ENDIF

   $TC_DP12[$P_TOOLNO,_DD] = D_L
   $TC_DP15[$P_TOOLNO,_DD] = D_R
   D = _DD
   STOPRE
ENDIF
M17

This pattern guarantees that wear is preserved even when the operator hits RESET mid-program. Three pre-allocated R-parameters can substitute for the GUD variables if GUD definitions are not permitted.

6. PROG_EVENT.SPF Reset Hook

The SINUMERIK program-event file PROG_EVENT.SPF (or the older CYCPE_MA.SPF) is invoked automatically by the NCK on specific lifecycle events. Two event codes are most relevant for tool compensation cleanup:

$P_PROG_EVENT Trigger Recommended Action
1 Program start Initialize GUD flags, set OFFN=0, TOFFL=0, TOFFR=0
2 Program end (M30 / M17) Restore wear from GUD, clear TOFFL, TOFFR
3 RESET Same as event 2 — clear all runtime corrections
4 / 5 Tool change pre / post Clear corrections before tool change

Minimum reset block:

IF (($P_PROG_EVENT==2) OR ($P_PROG_EVENT==3)) ; end or RESET
   ; delete fine corrections on active tool
   IF L_39_AKTIV == 1
      L_39(0,0)
   ENDIF
   TOFFL = 0
   TOFFR = 0
   OFFN  = 0
ENDIF
Caution: CYCPE_MA.SPF is reserved for Siemens and the machine manufacturer. Do not modify CYCPE_MA.SPF directly — place custom logic in PROG_EVENT.SPF, which is the user-accessible counterpart. See the SINUMERIK 840D sl Programming Manual, Work Planning, section 9.2 for additive corrections and the SINUMERIK 840D sl Programming Documentation for PROG_EVENT details.

7. Alternative Correction Paths Without L_39

On Siemens controllers without L_39, three alternatives are field-standard:

7.1 OFFN for Radial Allowance

R99 = 0.03                     ; radial allowance
G41 G1 X10 Y0 F500 OFFN=R99
; ...
OFFN = 0
G40

7.2 $P_TOOLR for Single-Position Radial Approach

$P_TOOLR returns the active tool radius. For a single axis approach with compensation:

R99 = 0.03
G1 X=(10 - $P_TOOLR - R99) F500

7.3 TRANS Z= for Axial Offset

TRANS Z=0.05                  ; +0.05 mm in Z
; ...
TRANS                          ; clear all frames

TRANS is cleared by any subsequently programmed frame function, which is the main reason it is preferred only for short, isolated offset operations.

8. Additive Corrections (DL)

Additive corrections are tool-edge-specific offsets that are separate from the standard wear data. They are the cleanest method for in-process corrections because they are addressable by DL number and can be activated / deactivated without modifying the geometric tool data.

Term Meaning
DL Location-dependent correction; a numbered additive offset set
DP21 Optional edge parameter; when activated, extends DL to the length component
Selection DL=1 selects additive set 1 alongside the active D
Deselection DL=0

Typical flow:

D1 DL=1             ; activate D1 with additive correction 1
; ...
DL=0                ; deactivate additive offset

Additive DL data is entered through the HMI; the NC program only references the DL number. This separation makes DL corrections auditable and recoverable.

9. Recommended Pattern Selection

Requirement Recommended mechanism
Single radial allowance, must clear on RESET OFFN
Single axial allowance, must clear on RESET TOFFL
Repeatable, auditable in-process corrections Additive DL
Ball-end mill tip-to-center correction TOFFL = -radius
DMG machine with L_39 available and wear edit desired L_39 + PROG_EVENT.SPF + GUD snapshot
Groove wall correction with TRACYL OFFN (do not use TOFFR)
Single-position radial approach without CRC $P_TOOLR in geometry expression

10. Troubleshooting Matrix

Symptom Likely Cause Corrective Action
Alarm 140xx on TOFFL use SW < 7.0 Upgrade NCK software or use OFFN / TRANS
First part after weekend is oversize L_39 wear write not cleared Add L_39(0,0) in PROG_EVENT.SPF for events 2 and 3
Different tool inherits previous tool's offset Tool-change event not handled Add event-4/5 hook to clear TOFFL/TOFFR
Groove wall incorrect on TRACYL contour TOFFR used instead of OFFN Replace TOFFR with OFFN
L_39 does not exist on this controller Non-DMG / Seebach plant Switch to OFFN + TOFFL pattern
Compensation lost after frame change TRANS overwritten by subsequent frame Use TOFFL / TOFFR (frame-independent)
Operator cannot modify tool data on shop floor Access level lock on tool list Use DL additive corrections (operator-editable via HMI)

11. Field-Commissioning Checklist

  1. Confirm NCK software version: >SWE> in the HMI — must be ≥ 7.x if TOFFL/TOFFR will be used.
  2. Verify L_39 exists: open the cycles directory and search for L_39.SPF. If absent, fall back to OFFN/TOFFL.
  3. Confirm PROG_EVENT.SPF is active: simulate RESET and observe whether the file is called ($P_PROG_EVENT reports 3).
  4. Snapshot baseline wear for the test tool before the first L_39 run.
  5. Run a single-part dry cycle; verify wear returns to baseline after M30.
  6. Force a RESET mid-cycle; verify that all OFFN, TOFFL, TOFFR are zero and that wear is either restored or explicitly zeroed.
  7. Document the chosen pattern in the cell setup sheet (operator-facing).

12. Related Siemens Documentation

What is the difference between OFFN and TOFFR on a Siemens 840D?

Under normal conditions, OFFN and TOFFR behave identically in the machining plane. They diverge only for groove wall correction with TRACYL, where OFFN must be used. Both are modal and reset to zero on RESET / M30 by default, and neither modifies the tool-list wear data.

From which Siemens software version are TOFFL and TOFFR available?

TOFFL and TOFFR are available from SINUMERIK SW 7.0 onwards. On older controllers they raise an NC alarm; use OFFN, TRANS, or an additive DL correction as a fallback.

How can I clear L_39 wear values on M6 (tool change) without inserting a subroutine call?

Add the L_39(0,0) call to PROG_EVENT.SPF under event codes 4 and 5 (tool-change pre/post), in addition to events 2 and 3 (program end / RESET). This guarantees that any pending wear write is committed or reverted at every tool change without touching the calling part program.

Why does L_39 not exist on my Siemens 840D controller?

L_39 is a Deckel Maho (DMG MORI) manufacturer cycle and is only present on selected DMC series — typically machines built at the Pfronten plant. Seebach-built machines and non-DMG Siemens controllers do not ship L_39. Use OFFN / TOFFL / additive DL as portable alternatives.

What is the safest pattern for an in-process correction that must not persist past RESET?

Use OFFN for radial and TOFFL/TOFFR for axial. Both are cleared on RESET/M30 without touching the tool-list wear data, and they survive frame changes. For auditable, per-edge corrections use additive DL with DP21 enabled for length.

Back to blog