• Tags
  • Documentation
  • Order
  • Register
  • Login
Duet3D Logo Duet3D
  • Tags
  • Documentation
  • Order
  • Register
  • Login

Automatic Bed Leveling with Conditional Gcode Iterations

Scheduled Pinned Locked Moved
Gcode meta commands
5
79
6.4k
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • undefined
    Kolbi
    last edited by Kolbi 30 Jul 2020, 00:38

    Thanks @mwolter!

    For brevity, here is my final working version:

    ; bed.g
    ; Called to perform automatic bed compensation via G32
    M561 ; Clear any bed transform
    G28 ; Home
    while iterations <=1 ; Do minimum of 2 passes
    G30 P0 X25 Y100 Z-99999 ; Probe near a leadscrew, half way along Y axis
    G30 P1 X235 Y100 Z-99999 S2 ; Probe near a leadscrew and calibrate 2 motors
    G90
    while move.calibration.initial.deviation >= 0.002 ; perform additional tramming if previous deviation was over 0.002mm
    if iterations = 5 ; Perform 5 checks
    M300 S3000 P500 ; Sound alert, required deviation could not be achieved
    abort "!!! ABORTED !!! Failed to achieve < 0.002 deviation within 5 movements. Current deviation is " ^ move.calibration.initial.deviation ^ "mm."
    G30 P0 X25 Y100 Z-99999 ; Probe near a leadscrew, half way along Y axis
    G30 P1 X235 Y100 Z-99999 S2 ; Probe near a leadscrew and calibrate 2 motors
    G90 ; Back to absolute mode
    echo "Gantry deviation of " ^ move.calibration.initial.deviation ^ "mm obtained."
    G1 H2 Z8 F2600 ; Raise head 8mm to ensure it is above the Z probe trigger height
    G1 X104 Y100 F6000 ; Put head over the centre of the bed, or wherever you want to probe
    G30
    1 Reply Last reply Reply Quote 1
    • undefined
      fcwilt @mwolter
      last edited by 30 Jul 2020, 01:40

      @mwolter said in Automatic Bed Leveling with Conditional Gcode Iterations:

      @fcwilt Using that command I can be sure it raised 20mm from the previous height.

      Hi,

      Thanks for the reply.

      Why do you think G91 G1 Z20 doesn't do that same thing?

      Frederick

      Printers: a small Utilmaker style, a small CoreXY and a E3D MS/TC setup. Various hotends. Using Duet 3 hardware running 3.4.6

      undefined 1 Reply Last reply 30 Jul 2020, 03:29 Reply Quote 0
      • undefined
        mwolter @fcwilt
        last edited by 30 Jul 2020, 03:29

        @fcwilt
        It’s just a different way of doing it and like I mentioned, this way I can be sure it’s raised 20mm from its current position. The G30 command actually sets Z to about 3m. So G1 Z20 will only raise Z by 17mm.

        undefined 1 Reply Last reply 30 Jul 2020, 03:40 Reply Quote 0
        • undefined
          Kolbi @Phaedrux
          last edited by 30 Jul 2020, 03:37

          @Phaedrux said in Automatic Bed Leveling with Conditional Gcode Iterations:

          Now you're cooking with gas!

          Definitely cooking with gas now!

          1 Reply Last reply Reply Quote 0
          • undefined
            fcwilt @mwolter
            last edited by fcwilt 30 Jul 2020, 03:40

            @mwolter said in Automatic Bed Leveling with Conditional Gcode Iterations:
            The G30 command actually sets Z to about 3m. So G1 Z20 will only raise Z by 17mm.

            I think you will find that a G91 G1 Z20 will raise Z by 20 unless it doesn't have that much room left on the axis.

            If a G30 sets Z to 3 then a G91 G1 Z20 will take Z to 23.

            At least that is my experience.

            Good luck.

            Frederick

            Printers: a small Utilmaker style, a small CoreXY and a E3D MS/TC setup. Various hotends. Using Duet 3 hardware running 3.4.6

            undefined undefined 2 Replies Last reply 30 Jul 2020, 03:42 Reply Quote 1
            • undefined
              mwolter @fcwilt
              last edited by 30 Jul 2020, 03:42

              This post is deleted!
              1 Reply Last reply Reply Quote 0
              • undefined
                Phaedrux Moderator @fcwilt
                last edited by 30 Jul 2020, 03:42

                @fcwilt said in Automatic Bed Leveling with Conditional Gcode Iterations:

                I think you will find that a G91 G1 Z20 will raise Z by 20 unless it doesn't have that much room left of the axis.

                Correct. G90 moves to an absolute point, G91 is relative to the current position.

                https://duet3d.dozuki.com/Wiki/Gcode#Section_G90_Set_to_Absolute_Positioning

                Z-Bot CoreXY Build | Thingiverse Profile

                undefined 1 Reply Last reply 30 Jul 2020, 03:47 Reply Quote 1
                • undefined
                  mwolter @Phaedrux
                  last edited by 30 Jul 2020, 03:47

                  @Phaedrux If the command G90 G1 Z20 is used in one line, does G91 have to be used to return to absolute mode?

                  undefined ? undefined 3 Replies Last reply 30 Jul 2020, 03:51 Reply Quote 1
                  • undefined
                    Phaedrux Moderator @mwolter
                    last edited by 30 Jul 2020, 03:51

                    @mwolter That's a good question, and I'm not sure off the top of my head. Would have to test to see if it sticks in that format or not.

                    Z-Bot CoreXY Build | Thingiverse Profile

                    1 Reply Last reply Reply Quote 0
                    • undefined
                      Kolbi
                      last edited by 30 Jul 2020, 04:26

                      Another thing I noticed is repeatability with PindaV2 probe is not as consistent as BLTouchV3.1... So being that I use a bondtech bmg mosquito, I've made this modified version to scrap the Pinda and welcome the BLTouch. Will get it sorted on the printer and test it fully this weekend.
                      BMGm-BLTouch.JPG BMGm-BLTouch-Actual.jpg

                      undefined 1 Reply Last reply 30 Jul 2020, 04:29 Reply Quote 0
                      • undefined
                        mwolter @Kolbi
                        last edited by 30 Jul 2020, 04:29

                        @Kolbi looks good! Is that SLS or MJF printed?

                        undefined 1 Reply Last reply 30 Jul 2020, 04:32 Reply Quote 0
                        • undefined
                          Kolbi @mwolter
                          last edited by Kolbi 30 Jul 2020, 04:32

                          @mwolter It was done on an HP Multijet Fusion (MJF), using Nylon PA12.

                          1 Reply Last reply Reply Quote 0
                          • ?
                            A Former User @mwolter
                            last edited by 30 Jul 2020, 04:45

                            @mwolter said in Automatic Bed Leveling with Conditional Gcode Iterations:

                            If the command G90 G1 Z20 is used in one line, does G91 have to be used to return to absolute mode?

                            yes, g-code knows nothing about white space or line breaks

                            (optionally you can use push and pop, M120, M121)

                            undefined 1 Reply Last reply 30 Jul 2020, 17:28 Reply Quote 1
                            • undefined
                              fcwilt @mwolter
                              last edited by 30 Jul 2020, 06:14

                              @mwolter said in Automatic Bed Leveling with Conditional Gcode Iterations:

                              @Phaedrux If the command G90 G1 Z20 is used in one line, does G91 have to be used to return to absolute mode?

                              G90 is absolute, G91 is relative.

                              Frederick

                              Printers: a small Utilmaker style, a small CoreXY and a E3D MS/TC setup. Various hotends. Using Duet 3 hardware running 3.4.6

                              undefined 1 Reply Last reply 30 Jul 2020, 12:17 Reply Quote 0
                              • undefined
                                mwolter @fcwilt
                                last edited by 30 Jul 2020, 12:17

                                @fcwilt
                                That’s why I used that command. Pulled that command from another macro and couldn’t remember why it was created. It’s used to move some amount from the current position without needing to bounce back and forth from absolute to relative and back to absolute positioning.

                                undefined 1 Reply Last reply 30 Jul 2020, 12:32 Reply Quote 0
                                • undefined
                                  fcwilt @mwolter
                                  last edited by 30 Jul 2020, 12:32

                                  @mwolter said in Automatic Bed Leveling with Conditional Gcode Iterations:

                                  @fcwilt
                                  That’s why I used that command. Pulled that command from another macro and couldn’t remember why it was created. It’s used to move some amount from the current position without needing to bounce back and forth from absolute to relative and back to absolute positioning.

                                  But there is no reason not to make use of the two positioning modes, there is no downside to using them.

                                  There is nothing to be gained by emulating relative mode using the object model as you are doing.

                                  Frederick

                                  Printers: a small Utilmaker style, a small CoreXY and a E3D MS/TC setup. Various hotends. Using Duet 3 hardware running 3.4.6

                                  1 Reply Last reply Reply Quote 0
                                  • undefined
                                    Kolbi @A Former User
                                    last edited by 30 Jul 2020, 17:28

                                    @bearer said in Automatic Bed Leveling with Conditional Gcode Iterations:

                                    optionally you can use push and pop, M120, M121

                                    @bearer I read the gcode manual but these two functions still made little sense to me - best I can derive is a save state / restore state? Could you expand a little on these and give me some use examples?

                                    Many thanks,
                                    Kolbi

                                    ? 1 Reply Last reply 30 Jul 2020, 17:30 Reply Quote 0
                                    • ?
                                      A Former User @Kolbi
                                      last edited by 30 Jul 2020, 17:30

                                      @Kolbi does https://forum.duet3d.com/topic/17854/retrieve-the-position-of-an-axis/5?_=1596130135808 help?

                                      undefined 1 Reply Last reply 30 Jul 2020, 17:37 Reply Quote 0
                                      • undefined
                                        Kolbi @A Former User
                                        last edited by 30 Jul 2020, 17:37

                                        @bearer Maybe because I just woke or hadn't gone on my run yet - but it is not completely crystal clear to me. Given the example below:

                                        M120 ;push
                                        G91 ; relative positioning
                                        G0Z30 ; move Z 30mm
                                        M121 ;pop

                                        I gather that 'M120; push' saves the current kinematic control state, then the user issues G91 & G0Z30 to relatively move the Z axis, and then returns to the previous control state by issuing an M121 - meaning that no M90 command was needed as M121 sorted that out?

                                        ? 1 Reply Last reply 30 Jul 2020, 17:39 Reply Quote 0
                                        • ?
                                          A Former User @Kolbi
                                          last edited by 30 Jul 2020, 17:39

                                          @Kolbi said in Automatic Bed Leveling with Conditional Gcode Iterations:

                                          meaning that no M90 command was needed as M121 sorted that out?

                                          yes - but more importantly if you for reasons unknown already were in relative mode you would not return to absolute in error.

                                          undefined 1 Reply Last reply 30 Jul 2020, 19:33 Reply Quote 1
                                          27 out of 79
                                          • First post
                                            27/79
                                            Last post
                                          Unless otherwise noted, all forum content is licensed under CC-BY-SA