Kiri g-code output for shapeoko xxl

super pleased to find kiri moto. i’m an onshape fan and this is what i’ve been looking for to mill models on my xxl. so first, thanks.

i’ve got an xxl with bitsetter. when i slice a job and produce the code, the first tool change is works well. i’ve added commands to raise and prompt to start the spindle to the tool change header in kiri:

M6 T{tool} ; change tool to ‘{tool_name}’
(Move to safe Z to avoid workholding)
G53G0Z-0.197
M03S18000

the first tool change works great. when the second change occurs, kiri first plunges to the Z start height, then runs to the path start. this crashed my set up.

can this be changed so that it first raises to avoid crash, then moves to XY start, THEN plunge to Z? thanks

after a tool change, the KM gcode will continue to move as though it never left the spot before the tool change. if your macro changes anything that might violate this expectation (coordinate system changes, resetting axes, etc) then it might behave poorly. you can use your tool change macro to return to the last spot before the tool change. see this page for gcode macro details. look for “CAM variable substitutions” and {pos_x} {pos_y} and {pos_z}. you can use those to synthesize a move to a position above the last cut position then lower to the last cut position, for example.

thanks for the quick reply. the code runs perfectly if i just switch the position of the XY and Z commands (Z comes first in the KM generate code). is it possible to have KM generate the code so that Z is first?

KM generated:
M6 T4 ; change tool to ‘1/8 ball’
(Move to safe Z to avoid workholding)
G53G0Z-0.197
M03S18000
G0 Z0.9806
G0 X3.9730 Y1.5689 F5999.9880

switching the last 2 lines makes it work perfectly.

is this what the command would look like:

G0 {pos_x}, {pos_y}

and if so, isn’t the last pos the location of the bitsetter?

the macro variables do not see moves that happen in the macro. the command is correct without the , (comma)

the order of XYZ moves that involve all three axis changes should always be:

up then over (Z then XY)
over then down (XY then Z)

yes, but it plunges down to Z (not up) first. i added G53G0Z-0.197 to the tool change header.

does the plunge occur if you do nothing on a tool change? I’m missing part of the picture. if anything reset on a tool change? Z homing or other offset change? when you render the gcode, does it show an inaccurate plunge?

i’ve added nothing. this will work except for the bold after the second tool change. if i reverse those lines it goes to start position, then plunges. if i don’t it plunges Z after tool change, then goes to start position. yes, unmodified here:

; Generated by Kiri:Moto 3.9.5
; Thu Apr 04 2024 13:58:07 GMT-0400 (Eastern Daylight Time)
; Bed left:0 right:830.072 top:830.072 bottom:0
; Stock X:24.89 Y:43.82 Z:5.84
; Target: My Carbide3D Shapeoko XXL
; — process —
; processName = default
…snip…
G21 ; set units to MM (required)
G90 ; absolute position mode (required)
; starting outline op
M6 T2 ; change tool to ‘end 1/8’
G0 X2.4231 Y2.4231 F5999.9880
G0 Z0.9906 F299.9994
G1 Z-1.9540 F229
G1 X2.2346 Y2.6310 F762
…snip…
G1 X23.3011 Y25.8776
G1 X23.3012 Y24.9692
G0 Z0.9906 F299.9994
; ending outline op after 1 seconds
; starting contour op
M6 T4 ; change tool to ‘1/8 ball’
G0 Z0.9806
G0 X3.9730 Y1.5689 F5999.9880
G1 Z-5.8419 F299.9994
G1 X4.0289 F991
G1 X8.0545
G0 Z0.9806 F299.9994
G0 X17.4476 F5999.9880

if you don’t mind, please right-click export your workspace and email or DM the .kmz file to me so I can repro locally and debug. thanks

I got your workspace and analyzed the gcode output around that tool change. this is what I see:

G1 X1.5875 Y4.4058
G1 Y18.9645
G0 Z0.9906 F299.9994
; ending outline op after 1 seconds
; starting contour op
M6 T4 ; change tool to '1/8 ball'
3G0Z-0.197 ; (Move to safe Z to avoid workholding)
M03S18000 ; start spindle
G0 Z0.9806
G0 X3.9968 Y1.5699 F5999.9880
G1 Z-6.3499 F299.9994

before the tool change the Z is at 0.9906 above stock. the 3G0Z line is from your tool change macro. after the tool change, KM moves Z to 0.9806 above stock before doing an XY move to the position for the contouring plunge (to Z-6.3499). top of stock is 0.00 and you have your travel clearance set to 0.039 in, which this is well above. I’m not seeing a plunge associated with the tool change. the only way the G0 Z0.9806 line would plunge into material is if the new tool is a different length than the previous one and you didn’t re-zero Z to account for this as part of the tool change.

is the workspace i sent you static snapshot?

for the tool change, i’m using a bitsetter device: Shapeoko BitSetter - Carbide 3D

in carbide motion (the stock app for the cnc) bitsetter compensates for the change in tool length. with bitsetter you don’t have to re-zero between tool changes. i wonder if KM doesn’t know how to make this adjustment?

are the coordinates relative to the origin and is minus (-) up/away (e.g. 3GZ0-0.197 move 0.197 in up?)

thanks for your help with this.

positive numbers are up and negative down. KM is not aware of tool lengths / offsets and thus does not compensate for them. all gcode paths indicate the position of the tool tip. so when a tool changes, the Z should not for the same cutting path. if the sender / controller is not managing this properly, it would cause an unexpected plunge or lift when the cutting resumes after a tool change.