Level bed only once



  • Right now in my startup gcode in the slicer, I am calling "M98 Pbed.g", but if I print small parts, and many times without restarting the printer; the subsequent levelling is unnecessary, and takes a long time.

    This is the gcode in bed.g

    M561                ; clear any bed transform
    M98 Pdeployprobe.g  ; deploy mechanical Z probe
    
    G30 P0 X0   Y20   Z-99999 ; probe near a leadscrew
    G30 P1 X400 Y20   Z-99999 ; probe near a leadscrew
    G30 P2 X0   Y380  Z-99999 ; probe near a leadscrew
    G30 P3 X400 Y380  Z-99999 S4 ; probe near a leadscrew and calibrate 4 motors
    
    M98 Pretractprobe.g ; retract mechanical Z probe
    
    M98 Phomez.g
    
    M561                ; clear any bed transform
    M98 Pdeployprobe.g  ; deploy mechanical Z probe
    G29                 ; probe the bed and enable compensation
    M98 Pretractprobe.g ; retract mechanical Z probe
    

    Is there a way to tell it: if this is already done, don't do it again ?



  • Conditional gcode in rrf can do this.



  • Thanks for your reply!

    But what is rrf ?



  • rrf = RepRap Firmware, which is what runs on the Duet.

    rrf2 = the mainstream release, V2, until a couple of months ago, when:

    rrf3 = newer release, V3, that just came out of beta. RRF3 is the one with conditional gcode.





  • @CVMichael

    You could do this:

    I put the bed levelling code in a macro called LevelLeadscrews and placed it in the /sys folder then added this at the bottom of my config.g:

    M98 P"LevelLeadscrews.g"

    The bed levelling will auto start when printer is first switched on but will not be performed again until the next switch on.


  • administrators

    In RRF 3.01RC1 I think the following in the start.g file should work:

    if move.compensation.deviation == 0  ; if bed probing hasn't been done yet
      G32   ; run bed.g
      if move.compensation.deviation > 0.2  ; if bed probing indicates the bed is far from level
        abort "Too much bed compensation needed"
    

    You may need to adjust the 0.2 value depending on how flat your bed and gantry are.

    BTW your bed.g file could be improved:

    • Don't use M98 commands to deploy/retract the Z probe. For most types of Z probe, deployment and retraction are not needed. For BLTouch it is automatic. For other types of probe that need to be deployed, use M401 before the group of G30 commands and M402 after; and you do not need any deploy/retract commands around G29 because it is automatic.

  • Moderator

    @chas2706 putting movement gcodes into config is a bit risky. What happens if the power goes out and comes back on? Do you really want the printer to start moving and homing and probing with something still on the bed?



  • @Phaedrux

    I understand that but I forgot to mention that a message auto appears using M291 S3 asking for confirmation rather than auto levelling so you have the chice to either go ahead or cancel.



  • This is the content of LevelLeadscrews.g:

    M291 P"Leadscrew levelling will be performed, Ok or Cancel?" R"Bed Levelling" S3 ; User must click OK or cancel.
    G32 ; Home all axis then do true bed levelling (Leadscrew Levelling Check)


Log in to reply