Mesh Bed Compensation - Homing to Probe Bed

  • I recently upgraded to a Duet Wifi and setup dual independent z motors and corresponding endstops as in this guide here: I was wondering whether I could use the homing gcode "script" to also probe the bed for the mesh bed compensation sequence. For hardware reference, my printer is a Robo 3d R1+.

  • for mesh bed leveling you need a probe of some sorts.

    if you have a probe then you can refer to this

  • Moderator

    I tend to do it the other way around, and have the homing sequence at the beginning of bed probing, because you need to have homed the printer before bed probing, and it also means that you can home without probing (which can take a while). Or make a new macro that does both things.


  • @veti I took a look at that article, but my bed can't be adjusted through any screw, it only uses bed compensation to make sure the nozzle is in the right place.

  • @droftarts Could you please specify how you would create a macro to do both things?

  • @shad0wv1rus

    that article does not mention any screws. its for multiple z motors. your article that you linked suggested that that is what you have.

  • Moderator

    Looking at the Robo 3d R1+ website (this shows it best:, it looks like you have a Z endstop microswitch on each Z carriage, under each end of the X axis. The X axis floats on this, and when the hot end touches the bed, the axis lifts up and triggers one of the Z endstops. You said the bed is fixed and cannot be adjusted. Print size from Robo website is reported as 254 x 228.6 x 203.2 mm (I assume X x Y x Z).

    This should be able to do mesh compensation, but it may be a bit inaccurate, as the height at which the Z endstops trigger changes as the extruder/hot end moves along the X axis. This may give you a U-shaped heightmap. You'll just have to try it and see.

    If you want to give it a try, you'll need to add something like this to your config.g, after the '; Endstops' section:

    ; Z-Probe
    M558 P5 H5 F120 T6000        ; Set Z probe type to switch and the dive height + speeds
    G31 P500 X0 Y0 Z2.5          ; Set Z probe trigger value, offset and trigger height
    M557 X15:239 Y15:213.6 S20   ; Define mesh grid

    Have a look at the gcode dictionary so you understand what M558, G31 and M557 are doing, and tune them to your needs.

    You can then invoke bed probing with G32. This runs the bed.g macro, which usually just has:

    M561 ; clear any bed transform
    G29  ; probe the bed and enable compensation

    If you haven't homed the axes before running bed compensation, it will fail, so I usually add G28 to home all axes in bed.g (which is what I was talking about in my first post):

    G28  ; Home all axes
    M561 ; clear any bed transform
    G29  ; probe the bed and enable compensation

    Hopefully that helps, let me know how you get on.


  • @droftarts @Veti I don't have a z-probe and I can't figure out the M558 command because I have two endstops that tell me where the bed is in relation to the nozzle. I can't just use one because for whatever reason, the endstops trigger differently depending on where the head is on the x-axis, probably due to the center of gravity.

  • @shad0wv1rus said in Mesh Bed Compensation - Homing to Probe Bed:

    I can't figure out the M558 command because I have two endstops that tell me where the

    if you dont have a z probe then the M558 command is.
    M558 P0

    you can not emulate a probe with z endstop switches

    here is an idea how to upgrade your printer with a probe.

  • sorry i just realized how the setup is one.

    are the switches NO or NC?

    i would try to wire them in parallel and use M558 P5

    they will need to be connected to the z probe port.

    but a construct would allow the printhead to move. this would not be beneficial for the print quality.