• 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
    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
                • undefined
                  Kolbi
                  last edited by 30 Jul 2020, 17:41

                  @bearer Ah ok - thanks! Besides rel/nonrel state changes - what would be an additional use case?

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

                    @Kolbi ref M120 docs; i only used for absolute/relative and feedrate

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

                      @bearer Thanks! I'll read the docs again and go for a run to let it soak in.

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

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

                        already were in relative mode you would not return to absolute in error

                        If I'm understanding correctly; If you are in currently in relative positioning and then you issue a G91 again - it would toggle, putting you in absolute positioning?

                        undefined 1 Reply Last reply 30 Jul 2020, 19:34 Reply Quote 0
                        • undefined
                          fcwilt @Kolbi
                          last edited by 30 Jul 2020, 19:34

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

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

                          already were in relative mode you would not return to absolute in error

                          If I'm understanding correctly; If you are in currently in relative positioning and then you issue a G91 again - it would toggle, putting you in absolute positioning?

                          G90 sets the mode to absolute. Sending it again changes nothing.

                          G91 sets the mode to relative. Sending it again changes nothing.

                          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, 19:45 Reply Quote 0
                          • undefined
                            Kolbi @fcwilt
                            last edited by Kolbi 30 Jul 2020, 19:45

                            Ok, rgr that. So given the following:

                            M120: Push
                            Example
                            M120
                            Push the state of the machine onto a stack. Called automatically when a macro file is run. It pushes the following values on the stack:
                            Current feedrate
                            Extruder positions
                            Whether moves (and separately extrusion) are relative or absolute
                            M121: Pop
                            Example
                            M121
                            Recover the last state pushed onto the stack.

                            Could use M120 before issuing any homing related current/sensing changes and then instead of changing them all back via individual commands - just use M121? I'm thinking no, but figure it doesn't hurt to ask.

                            I guess what I'm trying to figure out and ask is, what exactly is saved in the 'stack'? Also, the documentation states that M120 is called automatically when a macro file is run - I assume this means any gcode file that resides in the macros directory and that this would not apply to files in the sys directory?

                            BTW, @fcwilt & @bearer Thanks for helping me understand this.

                            undefined 1 Reply Last reply 30 Jul 2020, 21:49 Reply Quote 0
                            • undefined
                              Kolbi
                              last edited by 30 Jul 2020, 20:33

                              pushpop.jpg
                              ...Maybe if I get one of these, all will be clear 😂

                              1 Reply Last reply Reply Quote 0
                              • undefined
                                fcwilt @Kolbi
                                last edited by 30 Jul 2020, 21:49

                                @Kolbi

                                Hi,

                                I've never used Push & Pop.

                                Yes there are places where I switch to relative (G91) and shortly thereafter switch back to absolute (G90) but not that many places, primarily in the homing macros.

                                If you were to look at all of the .g files in my sys directory the numbers of G90s or G91s would be small in comparison with all the other code.

                                I've simply never worried about it - I use them as needed.

                                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, 22:01 Reply Quote 0
                                • undefined
                                  Kolbi @fcwilt
                                  last edited by 30 Jul 2020, 22:01

                                  Thanks @fcwilt, much like what you have stated - I have never used M120/1 and haven't had any issues.

                                  But on the other side of the coin, it makes me wonder if I could/should be doing things better by employing it's use? It seems to me, with my limited duet experience, that such command would be most usefully employed by a macro being called while performing an actual print, so that the desired settings set by the slicer would 'pick up where the macro leaves off' & not so important while performing homing evolutions before a print is started.

                                  undefined 1 Reply Last reply 30 Jul 2020, 22:14 Reply Quote 0
                                  • undefined
                                    fcwilt @Kolbi
                                    last edited by fcwilt 30 Jul 2020, 22:14

                                    @Kolbi

                                    I don't rely on the commands my slicer sets at the beginning of a print.

                                    Here is my "print begin" macro called by the slicer at the beginning of a print.

                                    None of those slicer commands matter because my code overrides them all.

                                    ; S3D inserts the following 5 lines of code just before calling this file
                                    ;G90 ; absolute XYZ moves
                                    ;M83 ; relative E moves
                                    ;M106 S0 ; fan off
                                    ;M140 S60 ; bed temp to 60
                                    ;M104 S190 T0 ; extruder temp to 190
                                    M98 P"test_if_homed.g" ; aborts print if not homed
                                    T0 ; select tool 0 so extruder commands below will work
                                    M703 ; configure selected filament (sets bed/extruder temps)
                                    M106 P2 S255 ; lights on
                                    M106 P3 S255 ; lights on
                                    M106 P4 S255 ; lights on
                                    G90 ; absolute moves
                                    G1 Z75 F1200 ; position for cleaning
                                    G1 X0 Y-145 F6000 ; position for cleaning
                                    M291 R"Heating Extruder/Bed" P"Please wait..." T0
                                    M116 ; wait for temps to reach set points
                                    M291 R"Priming Extruder" P"Please wait..." T0
                                    G92 E0 ; reset the extruder logical position
                                    M83 ; extruder relative mode
                                    G1 E10 F120 ; prime the extruder
                                    M400 ; wait for extruding to finish
                                    G92 E0 ; reset the extruder logical position
                                    M291 R"Clean Nozzle and Bed" P"Click OK to begin printing" S3
                                    M98 P"mesh_comp_map_load.g" ; load height map based on height map mode

                                    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, 22:29 Reply Quote 0
                                    • undefined
                                      Kolbi @fcwilt
                                      last edited by 30 Jul 2020, 22:29

                                      @fcwilt Thanks for that info. Could you achieve the same thing by use of start.g? If not the same because timing with regards of being called by the slicer, what does your start.g contain?

                                      Many thanks,
                                      Kolbi

                                      undefined 1 Reply Last reply 30 Jul 2020, 23:22 Reply Quote 0
                                      • undefined
                                        fcwilt @Kolbi
                                        last edited by 30 Jul 2020, 23:22

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

                                        @fcwilt Thanks for that info. Could you achieve the same thing by use of start.g? If not the same because timing with regards of being called by the slicer, what does your start.g contain?

                                        Many thanks,
                                        Kolbi

                                        I haven't gotten around to determining exactly when start.g executes, just too many things on my plate.

                                        My current system works but I imagine converting it to rely on start.g would not be a problem.

                                        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, 23:40 Reply Quote 0
                                        • undefined
                                          Kolbi @fcwilt
                                          last edited by 30 Jul 2020, 23:40

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

                                          too many things on my plate

                                          I totally understand that. Thanks again for sharing all the info.

                                          Cheers,
                                          Kolbi

                                          undefined 1 Reply Last reply 31 Jul 2020, 01:40 Reply Quote 0
                                          40 out of 79
                                          • First post
                                            40/79
                                            Last post
                                          Unless otherwise noted, all forum content is licensed under CC-BY-SA