Fine tune bed height in Marlin while you are printing


While I enjoy using my 3d printer there’s one chore that I hate doing over and over again. Leveling my print bed and adjusting the print height!
I even have an auto bed leveling setup with an inductive probe, but I still find it necessary to tweak the height of the bed to get the perfect first layer on my prints. I’m often switching nozzles or changing filament types and tweaking my bed height is such a pain.

Well, I’ve found the solution! I’ve created a new command in Marlin that allows me to tweak the bed height and I can even save the setting for future prints.

The new command is M116.


To add this command to Marlin, you must add the code snippet below to the file Marlin_main.cpp and upload to your 3d printer( I added it after the command gcode_M115() )

M116 Tweak Z setting (positive values raise the bed)
inline void gcode_M116() {
float origPosition;
origPosition = current_position[Z_AXIS];
float tweak_step=0;
if (code_seen('Z')) tweak_step = code_value();
destination[Z_AXIS] = origPosition+tweak_step;
prepare_move(); // this will also set_current_to_destination

st_synchronize(); // This will reset Z readout to original value after moving Z the tweak distance
float v = current_position[2] = origPosition;

This command will raise the bed by 0.1mm when you send the command “M116 Z-0.1″ and to lower the bed 0.1mm by sending “M116 Z0.1″. It will adjust the bed height, but it will then set the Z height value to whatever it was before you adjusted the bed, so it is fine to run this command in the middle of a print.

To add these commands to your control panel in Simplify3d go to Tools>Firmware>Macros tab and copy from the image below. (Add M500 to the end of each macro if you want these tweaks saved after resetting your printer)


For convenience I added these commands to my Simplify3d machine control panel, and now my first layer headaches are gone!