ℹ️ Select 'Choose Exercise', or randomize 'Next Random Exercise' in selected language.

Choose Exercise:
Timer 00:00
WPM --
Score --
Acc --
Correct chars --

Tool Length Offset Measurement Macro

CNC Sinumerik

Goal -- WPM

Ready
Exercise Algorithm Area
1PROGRAM MEASURE_TOOL_LENGTH(TOOL_NUMBER)
2
3// Macro to measure and store the length offset for a specified tool.
4// TOOL_NUMBER: The number of the tool for which to measure the length.
5
6VAR tool_length_offset_register = 100 + TOOL_NUMBER // Example: Tool 1 uses H101, Tool 2 uses H102
7
8// Move tool to probe position (e.g., over a known height gauge or probe)
9G0 X0 Y0 Z50.0 // Rapid to a safe position
10
11// Use G37 to automatically measure tool length offset
12// The machine will move down until it contacts the probe/gauge
13// and store the measured length in the specified offset register.
14G37 H[tool_length_offset_register]
15
16PRINT "Tool " + TOOL_NUMBER + " length offset measured and stored in H" + tool_length_offset_register
17
18END_PROGRAM:
19END_PROGRAM
Algorithm description viewbox

Tool Length Offset Measurement Macro

Algorithm description:

This CNC macro automates the process of measuring and storing the length offset for a specific cutting tool. It uses the machine's built-in probing functionality (G37) to contact a reference surface and automatically calculate the tool's length. This is essential for accurate depth control in machining operations, ensuring consistent results and preventing collisions.

Algorithm explanation:

The `MEASURE_TOOL_LENGTH` macro takes a `TOOL_NUMBER` as input. It calculates the corresponding tool length offset register number (e.g., H101 for tool 1) by adding 100 to the tool number. It then moves the tool to a safe starting position. The core of the macro is the `G37 H[tool_length_offset_register]` command, which instructs the CNC machine to move downwards until it contacts a pre-defined reference surface (like a probe or a height gauge). Upon contact, the machine automatically measures the distance from the machine's reference plane to the tool tip and stores this value in the specified offset register. Finally, it prints a confirmation message. This simplifies tool setup and ensures accurate depth control for subsequent machining operations.

Pseudocode:

DEFINE SUBPROGRAM MEASURE_TOOL_LENGTH(TOOL_NUMBER)

    CALCULATE tool_length_offset_register = 100 + TOOL_NUMBER

    MOVE RAPID to safe XY position and Z=50
    EXECUTE G37 command to measure length into H[tool_length_offset_register]
    PRINT confirmation message

END SUBPROGRAM