Reading Tool Length on SINUMERIK 880M: @-Codes, D Offsets, and GETTCOR
Tool length readout on Siemens CNC controllers is one of the most frequently misunderstood operations because three independent concepts — physical tool selection (T), wear/geometry offset selection (D), and runtime tool data access (@320 or GETTCOR) — are often conflated. This reference consolidates the @-code tool read mechanism used on SINUMERIK 880M, the modern GETTCOR function documented for the SINUMERIK 840D sl, and the safety procedures required to handle manual tools when the automatic changer must be bypassed.
GETTCOR, documented in Siemens support article ID 109777937 — SINUMERIK 840D sl NC Programming Manual. The behavior described below for @-code 320 is taken from operator field experience on 880M; cross-check against your controller-specific manual revision before commissioning production code.1. System Overview
The SINUMERIK 880M separates tool identity from tool compensation. Three logical data sets participate in every cutting operation:
-
Tool magazine slot (T number) — physical tool location.
T1is the first magazine pocket,T0denotes an empty spindle. -
Tool offset (D number) — geometric and wear values entered in the offset screen.
D1–Dnare available independent of magazine state. - Active compensation (G43/G44/G49 state) — the modal group that selects which D offset is currently applied to the programmed axis positions.
An @320 read against a missing or inactive offset returns 0 regardless of how the offset screen is populated, because the runtime has no active record to report.
2. Tool Number (T) vs. Tool Offset (D)
The T/D split is the first concept every 880M programmer must internalize.
| Code | Function | Example | Side Effects |
|---|---|---|---|
T<n> |
Selects the physical tool at magazine pocket n. | T3 |
Triggers tool change sequence when M6 is issued. |
T0 |
Empty spindle marker. | T0 M6 |
Clears spindle of current tool; no offset selected automatically. |
D<n> |
Selects tool offset n from the offset table. | D17 |
Activates compensation values; no tool change occurs. |
G43 / G44 |
Length compensation sign/direction. | G43 H17 |
Applies offset 17 in positive direction. |
G49 |
Cancel length compensation. | G49 |
Disables active offset. |
Key principle: any D number can be paired with any T number. T selects the magazine slot; D selects the compensation record. The two are not coupled by index.
T0 M6 to evacuate the spindle before mounting a manual tool, and verify the changer arm position via the machine manufacturer's HMI screen.3. @-Code 320 — Tool Data Read Syntax
The @320 function reads tool compensation data into a user-defined R-variable. The full syntax observed on 880M is:
@320 R<target> K<area> K<tool_no> K<component>
Where:
-
R<target>— destination R-variable (e.g.,R500). -
K<area>— tool area selector.1typically selects the active tool area. -
K<tool_no>— T number of the tool whose offset is being queried. -
K<component>— offset sub-index: typically1= length 1 (Z),2= length 2 (Y or secondary),3= radius.
Example from the source case:
@320 R500 K1 K1 K2 ; TO AREA 1-D1-P2 — read Z-secondary length of tool 1, offset 1
This call should deposit the secondary length of tool 1, offset 1, into R500. When R500 remains zero, one of the conditions listed in Section 5 has not been satisfied.
4. Parameter Mapping Reference
The K-parameter mapping used by @320 is consistent across 880M revisions but the offset sub-index numbering is OEM-customizable. The following mapping applies to standard Siemens tool offset screens:
| K-component | Standard Meaning | Units | Typical Use |
|---|---|---|---|
| K1 (component) | Length 1 — primary axis (Z) | mm or inch (per G70/G71) | Standard end-mill, drill length |
| K2 (component) | Length 2 — secondary axis (Y or X) | mm or inch | Right-angle head, 5-axis offset |
| K3 (component) | Length 3 — tertiary axis | mm or inch | Rotary table tool vector |
| K4 (component) | Radius | mm or inch | Cutter compensation (G41/G42) |
| K5+ (component) | Wear, additional geometry | mm or inch | OEM-defined |
If the machine builder has implemented a non-standard offset screen (very common on production-turnkey machines), the K-component meaning can shift by ±1. Always verify against the machine-specific programming manual.
5. Root Cause Analysis: Why @320 Returns Zero
A zero return from @320 is not a programming error — it is a runtime condition report. The following five conditions each produce a zero result:
- Tool not loaded. The spindle contains no tool (T0 active). @320 has no compensation record to read.
- Offset record empty. The D number exists but the length field has not been measured or entered. The default value is 0.
- Wrong tool area. K<area> selects a tool data area that is not active for the current setup (e.g., area 2 selected but only area 1 is configured).
- T/D mismatch. The queried T number has no offset pairing configured. Reading component 2 of an offset that does not have a secondary length entry returns 0.
- Compensation not active. G49 has cancelled compensation. The offset data still exists, but G49 prevents it from being applied — and some 880M builds gate @320 behind the active compensation state.
Diagnostic flow:
- Verify the active tool with the machine HMI: confirm a T number other than T0 is loaded.
- Open the tool offset screen and confirm the D number contains a non-zero length value.
- Issue a
G43 H<D>to activate the offset and re-run the read. - If still zero, change the area parameter K1 to K2 and re-test.
6. GETTCOR — Modern Equivalent on SINUMERIK 840D sl
On SINUMERIK 840D sl and successors, the runtime tool data read is performed by GETTCOR. The function returns tool lengths or tool length components of the active tool or any indexed tool/edge. The 840D sl programming manual (Siemens support ID 109777937) defines the read parameters as:
GETTCOR(<tNo>, <dNo>, <comp>)
-
<tNo>— tool number -
<dNo>— offset number -
<comp>— component selector (length 1, length 2, length 3, radius)
Compared to @320, GETTCOR provides several advantages: it supports structured error handling via state queries, it operates on tool-management-active configurations without re-numbering, and it returns a meaningful status when no valid record exists rather than silently zeroing the destination.
| Function | Controller | Returns on Empty Record | Supports Tool Management |
|---|---|---|---|
@320 |
SINUMERIK 880M | 0 (silent) | Limited |
GETTCOR |
SINUMERIK 840D sl | State-driven, configurable | Full |
When migrating 880M programs to 840D sl, replace @320 R<var> K1 K<t> K<comp> with R<var> = GETTCOR(<t>, <d>, <comp>) after verifying the tool-management configuration on the target controller.
7. Manual Tool Loading Without Triggering the Changer
Operators occasionally need to run a manual tool (e.g., a long boring bar or an edge finder) that the automatic magazine cannot accommodate. The 880M supports this through the T0 mechanism:
T0 M6 ; evacuate current tool from spindle
M0 ; optional: program stop for operator mounting
; --- operator mounts manual tool manually ---
G43 H<D_no> ; activate the manual tool's offset
; ... machining moves ...
G49 ; cancel offset before returning to auto mode
T<next> M6 ; reload an auto-magazine tool
The D number for the manual tool is selected freely from the offset table; it is not linked to T0. The T0 state only affects magazine behavior, not offset lookup.
T<n> M6 without first verifying the spindle is empty, the changer arm may attempt to load into an occupied pocket or collide with the manual tool. Always run a T0 M6 cycle at end-of-program before resuming automatic operation, and post operator messages on both the entry and exit of the manual-tool block.8. Operator Messaging for Manual Tool Blocks
Siemens 880M supports inline operator messages via MSG(). Two messages are required for safe manual-tool handling:
MSG("MOUNT MANUAL TOOL <NAME> — CONFIRM SPINDLE EMPTY")
M0
T0 M6 ; or skip if spindle is already empty
G43 H<D_manual>
; ... manual tool work ...
G49
MSG("REMOVE MANUAL TOOL <NAME> — RESUME AUTO CHANGER")
M0
This pattern satisfies the machine-builder best practice of bracketing every manual-tool block with a confirmation stop. Production programs that omit the second message risk an unattended tool collision on next job start.
9. Tool Management Configuration
The 880M supports two operating modes for tool data:
| Mode | Configuration Path | T-Semantics | D-Semantics | Typical Use |
|---|---|---|---|---|
| Conventional (no tool management) | Machine data MD flags for tool management disabled |
Selects magazine slot directly | Selects any offset, not coupled to T | Manual machines, light-duty changers |
| Tool management active | Tool management tables populated, magazine configuration loaded | Resolved via tool-management lookup (aliasing, sister tools, life monitoring) | Selected offset after T-resolution | Production cells, lights-out operation |
If tool management is active, @320 must query the resolved T number, not the programmed T alias. Failure to do so is a common cause of unexpected zero returns in managed configurations.
10. Verification and Commissioning Procedure
- Load a known tool. Mount tool 1, enter a non-zero value for length 1 in offset D1 (e.g., 100.000 mm).
-
Activate offset. Issue
T1 M6followed byG43 H1. -
Read length. Execute
@320 R500 K1 K1 K1and verifyR500reports 100.000. -
Test secondary component. Enter 25.000 mm in length 2 of D1, then execute
@320 R501 K1 K1 K2. VerifyR501reports 25.000. -
Test radius. Enter 10.000 mm in radius of D1, execute
@320 R502 K1 K1 K4. VerifyR502reports 10.000. -
Test empty case. Issue
G49then re-run the read. Observe whether the controller reports 0 (some builds) or holds the last value (others). - Test manual block. Run the T0 / manual-tool / MSG sequence from Section 7 with no spindle collision and confirm the second MSG fires on completion.
11. Troubleshooting Matrix
| Symptom | Likely Cause | Verification | Remedy |
|---|---|---|---|
| @320 returns 0 with T active and D populated | Wrong area parameter | Change K1 to K2 and re-test | Use area matching active tool data set |
| @320 returns 0 with all parameters correct | Compensation cancelled by G49 | Read modal state | Issue G43 H<D> before read |
| @320 returns 0 in tool-management mode | Reading alias T instead of resolved T | Inspect tool-management tables | Use resolved T number for the read |
| @320 returns non-zero only after M6 | Read placed before tool change | Re-order blocks | Move @320 after T<n> M6
|
| GETTCOR errors on 840D sl after porting @320 code | Component index shift (840D sl starts at L1 not L0) | Inspect function return value | Decrement component index by 1 |
| Manual tool causes changer alarm on next job | Spindle not cleared via T0 M6 | Check spindle pocket at end of program | Add T0 M6 before end-of-program |
| D offset returns length but radius is zero | Component index K4 not configured for this offset | Inspect offset screen columns | Enter radius value in offset record |
12. Frequently Asked Questions
What does the D-code do on a SINUMERIK 880M?
The D-code selects the tool offset number from the offset table. It does not trigger a tool change — it only activates the geometric and wear values stored under that D number. Any D number can be paired with any T number, so D1 may be used with T3 or T17 as needed.
How do I activate a manual tool without triggering the automatic tool changer?
Issue T0 M6 to clear the spindle, mount the manual tool, and activate its offset with G43 H<D_no>. Bracket the block with MSG() operator messages and end the manual block with a second T0 M6 before returning to automatic tool changes.
Why does @320 return zero to my destination R-variable?
Five conditions cause a zero return: no tool loaded, offset record empty, wrong area parameter, T/D mismatch, or compensation cancelled by G49. Verify each condition in turn — start by confirming a non-zero value is present in the offset screen and that G43 is active before the read.
What is the difference between @320 and GETTCOR?
@320 is the 880M runtime tool-data read; GETTCOR is the equivalent function on SINUMERIK 840D sl. GETTCOR returns a configurable state when the record is invalid rather than silently zeroing the destination, and it integrates with the 840D sl tool-management framework without alias resolution workarounds.
Can I read an offset for a tool that is not currently in the spindle?
Yes, as long as the tool data record exists in the offset table and the tool-management lookup (if active) resolves the T number to a valid D number. The @320 / GETTCOR functions query the data table directly and do not require the tool to be physically loaded.
Is typing T=1 sufficient to activate a tool on the 880M?
No. On Siemens controllers the canonical activation sequence is T1 M6. The T word stages the tool; M6 executes the change. Using only T1 without M6 will not complete the tool change on a magazine-equipped machine.