Gcode to force Z-axis sync on Prusa i3 MK3/S

I’m running into issues with z-axis sync issues with my Prusa i3 MK3/S. I’d like to force both z-axis steppers to the top, ensuring that the x-axis is level, before each print. Specifically, I’m looking for the proper gcode to force the z-axis past the boundary that works with Prusia’s firmware.

I remember hearing Tom mention in one of his videos that he uses some gcode to force the Z-axis all the way to the physical top of the frame to force both z-axis steppers back into sync. That sounds like exactly what I want. Unfortunately, I can’t remember which video this was in, since I’ve binge-watched dozens of them in the last month. I think it may have been a live stream; during one of those impromptu discussions triggered by chat. (Next to impossible to search for.)


I’ve been periodically noticing that the z-axis stepper motors are getting out of sync just a little. Typically it’s not bad enough to trigger a z-axis alignment warning during the 3x3 bed leveling, but enough that it’s causing prints to fail from time to time. I don’t know if there’s multiple cause for this, but I know for sure that I’ve caught my kids walking by the printer and manually turning the z-axis threaded rods. I’ve been burnt by this a few times now, trying all kinds of things before realizing the real source of the issue. Fixing this by hand requires (1) remembering, and (2) manually running the Z-axis half-way up, resetting (to clear the z-axis location info), and then finally running it all the way to the top, but not too quickly so that it doesn’t grind against the for any longer than necessary. (And, if I get too aggressive, holding down the turn knob too soon during the restart, then the printer wants to factory reset, instead of move the z-axis, which is NOT what I want!)

It seems like if I knew the right gcode, I could just drop it in the “Start G-code” section in Prusa Slicer (right before the G28/G80 home/mesh-level sequence) and then never worry about this again.

Does anyone know the proper gcode to tell the printer to run the Z-axis all the way to the top to hit the physical limits?

What I’ve tried so far

G1 Z210;  Stops short of hitting the physical top
G1 S1;   Disables boundy checking?  Nope, does not work
M45 Z;   This "works" but runs the full calibration \w user prompt
G34 - Z Steppers Auto-Alignment; Sounds promising.  Response:  Unknown G code
M120 - Disable Endstops - Listed on Prusa Wiki page of gcodes.   No luck.


This is a list of all prusa used gcodes I guess you might be looking for M120? If that does not work you can get a block and put it on one side under the gantry and microstep until it touches and then put it on the other side, turn the steppers off or even turn the printers off and turn the lead screws until both sides touch the same - works on my prusa clone. Or you can see how much the bed leveling is off from one side to the other and turn the lead screw appropriately with the printer off

Oops. I realized I incorrectly switched M120 and M121 in my original post (fixed).

So I’ve tried M120 with no luck. (And I just tried it again.) I wasn’t sure if “endstops” referring to endstop sensors rather than the software boundaries? Or maybe it means something else completely? Doesn’t seem to have the effect I’m going for. Which is simply, move past the 120mm known boundary.

G1 Z120   # The logical boundary
M120        # Disable end stop
G1 Z121   #  Go 1mm beyond the software bounard.  Result:  No movement.

Btw, I’m issuing these commands via the OctoPrint “Terminal” interface. Is there any chance that it’s filtering and preventing such movements? (That just occurred to me.) It does know the size of my print area. I get a Recv: ok so I’m assuming not, but I guess it’s worth considering.

On my PULSE (I3 Clone) I have to do the blocks under carriage method as the others don’t work either. That is what I like on my CHIRON it got 2 endstop switches one on each Z axis and auto adjusts them every time you home the Z axis

i can set the z height manually / just go (if the max height is 210) to 210 then set to 0 and then go 10 up.

G0 Z210
G92 Z0 
G0 Z10