I am building a 3D printer from scratch, the bed will only move on Z and the head will stay at the top of the printer and move X and Y.

How do I modify the Marlin firmware to have the bed lower as it prints instead of lift like most printers.


2 Answers 2


You can control in Marlin what the direction of the stepper motor is, e.g. my Hypercube CoreXY printer (which has a similar setup like you described) has the following set (in the Marlin Configuration.h file) to ensure the platform raises when it has to decrease height:

// Invert the stepper direction. Change (or reverse the motor connector) 
// if an axis goes the wrong way.
#define INVERT_Z_DIR true

Furthermore, it matters where the Z endstop is located, e.g. using a bed probe sensor or a min Z endstop, you need to home towards a decreasing height (in the direction of your probe/endstop):

// Direction of endstops when homing; 1=MAX, -1=MIN
#define Z_HOME_DIR -1

Don't forget to set a max Z height that falls within the printer volume, e.g.:

#define Z_MAX_POS 345

If the bed is heavy, you should also prevent the steppers to lose power when not being used, so at least set Z to false:

// Disables axis stepper immediately when it's not being used.
// WARNING: When motors turn off there is a chance of losing position accuracy!
#define DISABLE_Z false
  • $\begingroup$ This is very helpful, when I get things build this will really help me get my firmware set up correctly. $\endgroup$ Mar 8, 2021 at 20:19

To understand normal commands from a basic printer slicer, all movement commands in g-code are written to be away from the base layer as positive. Note that technically a "lower the bed" printer does violate Orthonormal coordinates unless you either swap X and Y while retaining 0 in the front-left corner or put 0 in the front-right corner, going left for +X (e.g. inverting that motor axis too) and back for -Y.


To invert the movement direction of an axis without rewriting the firmware there are two main ways, from mos invasive to easiest:

  • Mount the actuator "upside-down" as that flips the rotational normal vector.
  • use a left-hand-threaded rod and nut. This does not flip rotation but how rotation affects the bed.
  • alter the stepper cables by "crossing" one of the phases leads. The motor rotates reversed to its commands now.

enter image description here


In Marlin, you can also just flip the direction of the motor via configuration.h by altering the line from false to true:

#define INVERT_Z_DIR true

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .