Z height wrong in gcode export?

Hey folks, i repeatedly have the problem that after zeroing my bit at the starting position and starting the CNC process, that the bit does not retract at all when moving to the starting position and runs through the very top of my piece.

I tried finding similar posts, but the software or process used is always different from mine. For example here

So lets start with my software and process.

  1. I use Carbide Create Pro on Mac
  1. once design is finished, i export the GCode , usually per toolpath
  2. i load the GCode into UGS (Universal GCode Sender)
  3. zero my bit to XYZ and hit start
  4. my CNC is a Genmitsu ProVerXL 4030 Pro (with extended 1010 rails) which uses a generic GRBL controller

When i look at the generated gcode it generally looks ok but between lines 5 and 6 i think im missing a retract of the defined 15mm.

01 G90     ; enable "absolute mode"
02 G21     ; set units to millimeter   
03 M05.    ; spindle stop
04 M0 ;T10  ; dont really know what this does
05 M03S10000  ; spindle on, 10000rpm
no retract here, this is where it cuts through my piece moving to starting position
06 G0X919.958Y105.876. ; rapid positioning to starting coordinates
07 Z0.250    ; retract here is +0.250 millimeter, dont know what this is supposed to achieve
08 G1Z0.000F203.2 ; go to Z0, the desired starting height
09 X919.214Y105.227Z-0.360F266.7  ; start moving and cutting
10 X918.461Y104.586Z-0.720

I attached the design file as well.
ams_sideboard.c2d (80 KB)

Is this a bug in the GCode export?
Am i missing or misunderstanding a setting here?

Thanks a lot in advance!

  • Volker

4b. Raise tool above job :wink:
4c. Hit start

The M0 ;T10 is a manual toolchange. It assumes you are at the toolchange position, or a safe position. With an automatic toolchange you get a M6T10, which retracts to the toolchange position, which is at a safe Z height.

Note line 6 is only moving XY, then it feeds down to the start point in Z. That is not a retract, it’s an engage.

2 Likes

Wait, are you saying that what i described happens because im not raising my bit AFTER zeroing and BEFORE hitting start? Oh god… I assumed the gcode and retraction would do that for me. The other question is, why didn’t i just try that? Sometimes solutions are too obvious…

Thanks! I’ll try that!

1 Like

If your machine has homing switches, it may be worth trying one of the Carbide3D post processors. I believe the GRBL post processor is coded to be VERY generic. IE It cannot assume a machine has homing switches and so it avoids big retraction moves outside of clearance heights. The C3D post processors all have a move to retract to the max height of the Z-axis minus 5mm.

1 Like

You don’t need home switches to retract to a configured clearance height. Suppose you have your clearance height set to 0.250, if line 7 in the original example works then there’s no reason it can’t be moved above line 6 instead. The G0 on line 7 can be removed, but I didn’t. From looking at the posted Gcode it looks like CC has an error in the way it generates the clearance retract before the first move and the order should be switched.

I’d be tempted to replace the feed rate move in line 8 with a G0, or perhaps split it into a G0 to some small distance above Z0 and then a short feed rate move to Z0 or the non-ramping final plunge depth. While this isn’t all that significant with a quarter mm clearance height it can make a fair difference with higher clearances, such as when you’re using clamps and tired of occasionally cutting through one. Not that I’d ever admit to doing that. For example if the clearance height is 10mm then it would be G0 Z0.25, G1 Z0 Fwhatever. I digress, but that would also be nice if you’re retracting before moving to a new cutting depth between passes, with the Z0 depth modified to slightly above whatever you cut to in the previous pass, since presumably you’re moving to a location that was previously cut.

01 G90 ; enable “absolute mode”
02 G21 ; set units to millimeter
03 M05. ; spindle stop
04 M0 ;T10 ; dont really know what this does
05 M03S10000 ; spindle on, 10000rpm
no retract here, this is where it cuts through my piece moving to starting position
06 G0 Z0.250 ; retract here is +0.250 millimeter, dont know what this is supposed to achieve
07 G0X919.958Y105.876. ; rapid positioning to starting coordinates
08 G1Z0.000F203.2 ; go to Z0, the desired starting height