G28 and M30 (program end) issues on Shapeoko 3

Discussion about the arduino based g-code interpreter, grbl
Post Reply
Posts: 3
Joined: Sat Sep 19, 2015 6:14 am

G28 and M30 (program end) issues on Shapeoko 3

Post by adamsd5 » Sun Jan 27, 2019 4:06 am

I've recently returned to my Shapeoko 3, upgrading Fusion 360 and building a simple model. I don't know if the Fusion 360 post-processing has changed, but I got some bad behavior. First, it's adding commands like this:

G28 G91 Z0

I don't know what this is supposed to do, but it causes my retraction to slam up into the Z limit switch. If I manually comment this out, things work fine.

Second, at the end of the program, my bit suddenly dropped about 0.5". I'm 100% certain this is not in the Gcode. It seemed more like the motors de-energized for 0.1 second and the router dropped due to gravity before the bit stopped spinning. This dug a hole in my test piece, right at the end. I noticed that the current post-process end commands are:

G28 G91 Z0
G28 G91 X0 Y0

Where in a gcode file from a year ago, that I know worked properly, ends like this:


Does anyone understand the gcode well enough to give me some insight on these two issues?

I'd prefer not manually modify each gcode file that comes out of Fusion 360, or to provide my own post-process script, so hopefully someone can give me some pointers about why my machine is not happy with the Fusion 360 gcode. (Note that I'm using the "Carbide 3D (grbl) / carbide3d" post-processor in Fusion 360.

Posts: 1348
Joined: Tue Jan 29, 2013 4:51 pm
Location: Minneapolis, MN

Re: G28 and M30 (program end) issues on Shapeoko 3

Post by twforeman » Fri Feb 01, 2019 7:38 pm

G28 is "go to pre-defined position" If you don't have that position set, then it could cause issues.

The predefined position is set by sending G28.1 followed by the X Y Z coordinates. I never use G28.

G91 sets incremental mode

G28 G91 Z0 doesn't really make any sense to me, since it's telling it to go to the predefined position and then set incremental mode and the go to Z0 (which shouldn't move in incremental mode.)

I always hand edit my G code after creating it with Fusion 360. The post-processor is not quite correct for the Shapeoko. I should figure out what it takes to fix it and publish a correct version...

At the end of the program I never use an M30. M30 means end of program and I think that tells Grbl to turn off the steppers.

M9 turns off coolant, M5 turns off the spindle.

G code definitions are here: https://wiki.shapeoko.com/index.php/G-Code
Ender 3 3D Printer
ShapeOko v3 serial #0004 - upgrade thread
All of my ShapeOko related blog posts

Posts: 57
Joined: Thu Jul 02, 2015 10:40 pm

Re: G28 and M30 (program end) issues on Shapeoko 3

Post by sjj47 » Wed Nov 20, 2019 12:39 am

I'm having a similar issue. I normally set up my work so that the bit is positioned at the WCS origin. If I use gcode created by other tools (e.g. MakerCAM) the bit moves to the (X,Y) start of the cut path, then descend on the Z-axis to the material surface and starts cutting.

In contrast, the gcode generated by the Fusion 360 Carbide post-processor moves the router from the WCS origin to the MCS origin, then to the cutting path starting position, performs the cut, then back to the MCS origin. This is a lot of unnecessary movement, and I think it is unsafe. You've got a spinning bit moving over the workholding clamps.

I could hand-edit the gcode, but that seems inelegant. Are there any other solutions? Or am I just misunderstanding the issue?

Here is the generated gcode with my comments:

(T1 D=12.7 CR=0 - ZMIN=-1 - flat end mill)
G90 absolute distance mode
G17 select the X_Y plane
G21 unit selection - mm
G28 G91 Z0 return to home; :?:
relative distance mode;
raise z axis 0 mm?
G90 absolute distance mode

T1 M6
S17000 M3
G54 work offset (sets WCS origin?)
G0 X30.255 Y-17.21 rapid move to WCS origin offset
(start of cutting path)
G1 Z0.27 F1000
G18 G3 X28.985 Z-1 I-1.27 K0
G1 X22
G17 G2 Y-6.192 I0 J5.509
G1 X22 Y-6.191
G3 Y4.827 I0 J5.509
G1 X-22 Y4.828
G2 Y15.846 I0 J5.509
G1 X22 Y15.847
G18 G2 X23.27 Z0.27 I0 K1.27

G0 Z15 move to Z-axis WCS origin + 15mm
G17 select the X_Y plane
G28 G91 Z0 return to home; :?:
relative distance mode;
raise z axis 0mm Unnecessary command? :?:

G90 absolute distance mode
G28 G91 X0 Y0 return to home; :?:
relative distance mode;
X axis + 0mm, Y axis + 0mm - unnecessary? :?:
G90 absolute distance mode
Shapeoko 3 # 0761 - DW611 - Limit switches - probe
Current tool chains: Inkscape > MakerCAM > UGS | bCNC & F-Engrave > UGS | bCNC

Post Reply