Manual Toolchange + Abs Z Probe (QtDragon)

More
1 year 5 months ago #327594 by SanzuiWorks
I'd like to share a structured and slightly modified version of `qt_auto_probe_tool.ngc` I'm using on my self-built 3-axis CNC with LinuxCNC 2.9.3 and the QtDragon GUI.  

---

### ? My Goals:
- Separate tool length offset from work coordinate systems (WCS)
- Make the tool table intuitive and readable
- Ensure safe and efficient probing using machine coordinates

---

#### 1. Set the Probe Top:
I defined the probe top using the tip of the spindle body (with no tool/collet) as a consistent mechanical reference.

- For example, if the empty spindle is lowered to Z = -120 (machine coordinates), I input `-120` as PROBE HT in the QtDragon Probe tab.(I know this is not the intended use.)
- I do not use BLOCK HT at all.

#### 2. Define Work Coordinates:
Once a tool is mounted (e.g., Tool #1 with 30mm protrusion), I:
- Add `T1 Z30` into the tool table
- Set up the G54 (or other WCS) normally

This way, the tool length stored in the table is actual physical protrusion and independent from any WCS — much more intuitive for manual tool changers.

Use G43 to apply the offset.

---

- Tool table values are stable and logical (they represent actual tool lengths).
- Easy to estimate and input values for new tools before probing.
- Tool probing uses machine coordinates, so:
  - Probe start position can be calculated from tool length
  - No dependency on current WCS
  - Safer: if tool table Z is negative by mistake, start offset is clamped to zero
- Multi-WCS workflows (G54, G55...) work seamlessly — no need to re-probe per WCS
- Tool probing is simpler and can be single-pass since start is close

---

Thanks,  

SanzuiWorks

Please Log in to join the conversation.

More
1 year 5 months ago #327597 by SanzuiWorks
I created a diagram so that the offset value can be visually confirmed.

Please Log in to join the conversation.

More
1 year 5 months ago #328088 by SanzuiWorks
In the conventional method, if the table bottom is always set to G54_Z0, there is no problem with setting [BLOCK HT], but if the work top is set to WCS, [BLOCK HT] must be changed frequently.
Changing is troublesome, and checking the current setting value is also cumbersome.
If the WCS or [BLOCK HT] changes, the tool table value also changes.
Also, I cannot read what the offset value in the tool table indicates.

After the change,
Z height can be set in WCS as well as XY,
so the situation can be checked from the main screen.
In particular, the Z height is consistent, and is reflected when the WCS is switched.

The tool is always consistent with positive compensation.
The Z_offset in the tool table is easy to read because it lists the tool length.

Since the tool offset is consistent, it can be approached at high speed in advance when probing. This is expected to reduce probe time, especially on slow-moving machines.
If the previous tool length could be displayed in the tool change dialog, human error would also be reduced.

So far we haven't had any major issues,
but we'd like other people to take an interest and find ways to improve it.

Please Log in to join the conversation.

More
1 year 5 months ago #328349 by SanzuiWorks
Code:
[RS274NGC] RS274NGC_STARTUP_CODE = G17 G21 G40 [color=#f1c40f]G43H0 G54[/color] G64P0.0005 G80 G90 G94 G97 M5 M9

I had been using it without much thought, but it seems better to remove G43H0 G54.
The tool length offset is unintentionally canceled, and the work coordinate system switches."

Please Log in to join the conversation.

More
1 year 5 months ago #328350 by SanzuiWorks
Reading Work Coordinates When Loading a New NGC File  

When loading a new `.ngc` file in LinuxCNC, is it possible to read the work coordinates at that stage? Since the G-code has not been executed yet, the work coordinates might not be applied.  

Would it be possible to create a custom button, similar to "WCS Sync," that reads the `.ngc` file and sends commands like `G55` to MDI?  

Has anyone implemented something similar, or does LinuxCNC provide a built-in way to achieve this? Any insights or suggestions would be greatly appreciated.

Thanks!

Please Log in to join the conversation.

More
1 year 5 months ago #328507 by cmorley
Can you post the changes you made?

Please Log in to join the conversation.

More
1 year 5 months ago #328543 by SanzuiWorks
Thanks for your interest! I made several modifications to qt_auto_probe_tool.ngc to improve tool length offset management and work coordinate independence.

Changes Made:
Separated tool length offset (G43) from work coordinate systems (G54/G55), making the tool table more intuitive.

The probe height was defined in machine coordinates and probed at the tip of the spindle.

Ensured tool length offset remains consistent regardless of WCS changes.

Thanks!

Please Log in to join the conversation.

More
1 year 5 months ago #328612 by cmorley

Please Log in to join the conversation.

More
1 year 5 months ago #328615 by SanzuiWorks
This is the first time I've seen the filter function. I need to learn about this first.

Please Log in to join the conversation.

More
1 year 5 months ago #328617 by SanzuiWorks
This requires QtDragon to support parsing (MDI_COMMAND, Gxx) output from FILTERs and executing it as an MDI command.  


load_wsc_from_ngc.py
Code:
import re import linuxcnc import os def on_button_detect_wcs(self):     filename = STATUS.file       if not os.path.exists(filename):         print("G-code file not found.")         return     try:         with open(filename, 'r') as f:             for line in f:                 m = re.search(r'\bG5(4|5|6|7|8|9)(\.\d)?\b', line.upper())                 if m:                     g_code = m.group(0)                     print(f"Detected WCS: {g_code}")                     c = linuxcnc.command()                     s = linuxcnc.stat()                     s.poll()                     if s.task_state == linuxcnc.STATE_ON and s.interp_state == linuxcnc.INTERP_IDLE:                         c.mode(linuxcnc.MODE_MDI)                         c.wait_complete()                         c.mdi(g_code)                     else:                         print("Interpreter not idle. Cannot send MDI.")                     return         print("No WCS (G54~G59.3) found.")     except Exception as e:         print(f"Error: {e}")

.ini
Code:
[FILTER] PROGRAM_EXTENSION = .ngc G-Code File FILTER = load_wsc_from_ngc.py .ngc


When you run the program directly, you can obtain the WSC, but it does not run automatically during the NGC loading.

Please Log in to join the conversation.

Time to create page: 0.105 seconds
Powered by Kunena Forum