I have a Monoprice Maker Select Plus, currently using Ultimaker Cura 3.6.0 with the default settings for a Wanhao Duplicator i3 Plus. Right now when a print finishes, the bed retreats towards the back of the machine. I'd rather present the bed forward for easier part removal.

Here is my ending G-Code:

M104 S0      ;extruder heater off 
G91          ;relative positioning
G1 E-1 F300  ;retract the filament a bit before lifting the nozzle, to release some of the pressure
G1 Z+0.5 E-5 X-20 Y-20 F{travel_speed} ;move Z up a bit and retract filament even more
G28 X0 Y0    ;move X/Y to min endstops, so the head is out of the way
M84          ;steppers off
G90          ;absolute positioning

It looks like I need to change that G28 line third from the bottom, but I'm not sure what to change it to. I've not yet done any g-code manipulation of my own. I don't know what units it's using, and it looks like it still has relative positioning, so even then I don't know it's a good idea to just set it for the max size of the bed.

So how can I change this code to move the bed as I want?


Note that this reference states that:

Because the behavior of G28 is unspecified, it is recommended not to automatically include G28 in your ending GCode. On a Cartesian this will result in damaging the printed object. If you need to move the carriage at the completion of a print, use G0 or G1.

So you need to use a G0 or G1 move.

When using Ultimaker Cura (like many other slicers), there is built in functionality known as keywords with a complete list found here.

The keyword machine_depth is the one that is of use to you, embed this in your end G-code in between curly brackets and it will expand to the bed size of your machine (replacing G28 X0 Y0):

G1 X0 Y{machine_depth}

For me this compiles to (e.g. for my coreXY printer):

G1 X0 Y300

To set the speed, just add the following command prior to the one above:

G1 F2500

Adding this line before the actual move ensures that the speed is constant, if F2500 would have been included in the move command (like G1 X0 Y{machine_depth} F2500), this defines the end speed, it would start moving at the last speed value prior to the move.

This results in adding the following lines in your endscript:

G1 F2500
G1 X0 Y{machine_depth}
  • $\begingroup$ I just saw a video that used keywords (didn't know what they were so I was confused) and it looks like keywords might change in the near future as 4.0.0 had different key words than 3.6.0. The focus was on the beta 4.0.0 as a whole and not so much on the keyword changes though so I'm not sure what all will be changing. $\endgroup$ – Lux Claridge Feb 6 at 19:26
  • $\begingroup$ Hmm... I plan to upgrade to the first release after 4.0.0 goes stable (they always miss things in QA), so I may wait for that before making the actual change. $\endgroup$ – Joel Coehoorn Feb 6 at 21:29
  • $\begingroup$ @JoelCoehoorn Don't worry, keywords will be there, if not, the competitors would have a huge advantage. They don't want to loose their market share. $\endgroup$ – 0scar Feb 6 at 22:14

You're correct that the G28 line should be changed. What I would do is the following:

M104 S0 ;extruder heater off 
G91 ;relative positioning
G1 E-1 F300  ;retract the filament a bit before lifting the nozzle, to release some of the pressure
G1 Z+0.5 E-5 X-20 Y-20 F{travel_speed} ;move Z up a bit and retract filament even more
G28 X0 ;move X to min endstop, so the head is out of the way
G90 ;absolute positioning
G1 Y200 ;Move bed forward
M84 ;steppers off

This way your X axis still gets homed after the Z bumps up and before Y moves to present the print.

G28 is the command to home the print head. Your current settings homes the X and Y axes. G1 is a linear movement. One caveat to this change in G-Code is that there needs to be a home command at the start of your prints since you're not homing afterwards anymore. (I believe most slicers default to a G28 at the start AND end of prints so it's not a major concern, but one to be wary of now just in case.)

  • 1
    $\begingroup$ Cool. What do I use for the max Y value, given a 200mm bed? Is it just 200? And why G1 instead of G28? $\endgroup$ – Joel Coehoorn Feb 6 at 18:55
  • $\begingroup$ @JoelCoehoorn Sorry, having a caffeine crash and brain farted those particulars. Edited answer to clarify. $\endgroup$ – Lux Claridge Feb 6 at 18:59
  • 1
    $\begingroup$ @JoelCoehoorn You can do even better and use the actual bed size, I'll show you in an answer. $\endgroup$ – 0scar Feb 6 at 19:14
  • $\begingroup$ fwiw, I have verified a G28 for all three axes (axixes?) over two commands as part of my start code. $\endgroup$ – Joel Coehoorn Feb 6 at 19:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.