Tool Change gcode for Manual Tool Change

Is there a way to turn off the first tool change output on the gcode? I do not have an ATC on my CNC, so any job where I am going to use more than one tool I have gcode set for the tool change. But any time I have “output tool change” turned on it puts the tool change Gcode right after my start gcode. That makes me have to go through the probe sequence twice in a row at the start of a job, or go in an manually edit the gcode before sending it to the CNC.

Is there a setting somewhere that I am missing to turn this first tool change off? Also it puts that tool change info in when I am only using one tool as well. Coming from Estlcam I am not used to having to go in and edit this out every time as it does not put that first tool change in, it assumes I am starting the job with the first tool already.

Also while I am asking. My machine needs gcode in mm/min but I prefer to work in mm/sec for my CAM settings. This is possible in Lightburn but I am not seeing where I can make this happen in MM.

Any help would be appreciated. Thanks!

1 Like

I’m trying to do the same thing as Jonathan who I know is also using FluidNC. I attempted to do a workaround using the gcode parameter and expression functionality of FluidNC and stumbled on a bug.

My attempt at making this work was to define a User Start Script of:
#<IsInitialTool>=1

The idea here is that I set a variable saying it is the initial tool. So, then the tool change code looks like this:

o100 if [#<IsInitialTool> EQ 1]

  M0 (MSG Attach probe)
  G38.2 Z-110 F200 P0.5 (probe down set thickness )
  G1 Z10 F900
  M0 (MSG Remove probe)
  M62 P1 (If used start spindle pin27 )

#<IsInitialTool> = 0

o100 else
  M63 P1 (turn off pin 27)
  $HZ (Home Z)
  G0 X0 Y10 F2520 
  M0 (MSG change tool, probe)
  G38.2 Z-110 F200 P0.5 (Probe set thickness)
  G00 Z10.0000 F500 (Clearance)
o100 endif

So, the first time through, the variable says it’s the first tool so it just probes. It then updates the variable so on the next pass through, the same tool change gcode will process a full manual tool change.

The bug is that the custom gcode does not like the <> characters (neither does this forum).

In the user start script, the example strips away those characters and what it contains:

However, what happened with that tool change gcode is more interesting. When I entered it, it did give me a warning about it being invalid gcode.

However, I saved anyway and generated my gcode but it didn’t include the tool change gcode at all (despite it doing it correctly before updating to this fancy gcode).

When I went back into check it, the tool change section doesn’t show at all now. The section just doesn’t exist anymore.

So anyway, you can ignore most of that, but the part specific to Millmage is that it should allow for custom gcode using gcode parameters and expressions. LinuxCNC also supports this kind of gcode.

Further investigation shows that it’s the left square bracket (“[”) that results in the “Invalid command character” issue. It allows you to save this configuration which then results in no longer being able to see that section on the Custom GCode tab.

So, it’s this line that I can’t put in custom gcode:
o100 if [#<IsInitialTool> EQ 1]

It looks like square brackets already have special meaning which is interfering with this:

Surrounding the letter before a variable with [] will tell MillMage that this portion of the command has not changed since the last emit.

Is there an escape character that can be used so it doesn’t try to treat it like a command?

Or since commands can only be a single character, can it just not treat it as a command if there is more than 1 character?
image

It looks like the <> issues are strictly with the Example preview. It will still output it to the exported gcode correctly.

My next workaround attempt will be to move the tool change gcode to a separate file and set the custom Tool Change gcode to run that file, something like:
$SD/Run=toolchange.gcode

I’m still interested in a non-workaround method of trying to have the first tool change be different gcode since normally the first tool is already installed.