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

Easier way to test if homed?

Scheduled Pinned Locked Moved
Gcode meta commands
8
29
1.6k
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
    theolodian
    last edited by theolodian 20 Feb 2022, 08:48

    Is there a single test to see if the machine is homed? The following seems to work, but it is a bit clumsy to split it into two test due the the character limit in a single line of gcode. Just curious, not a big deal if not.

    ; If the bed hasn't been homed, home it
    if !move.axes[0].homed || !move.axes[1].homed || !move.axes[2].homed || !move.axes[3].homed || !move.axes[4].homed || !move.axes[5].homed
    G28
    if !move.axes[6].homed || !move.axes[7].homed || !move.axes[8].homed || !move.axes[9].homed || !move.axes[10].homed || !move.axes[11].homed
    G28
    undefined undefined undefined 3 Replies Last reply 20 Feb 2022, 08:58 Reply Quote 0
    • undefined
      jay_s_uk @theolodian
      last edited by 20 Feb 2022, 08:58

      @theolodian you could always create a load of global variables and keep them updated using daemon.g to match the status of each axis. That could reduce the characters required per axis.
      I don't know of any other way.

      Owns various duet boards and is the main wiki maintainer for the Teamgloomy LPC/STM32 port of RRF. Assume I'm running whatever the latest beta/stable build is

      undefined 1 Reply Last reply 20 Feb 2022, 09:41 Reply Quote 0
      • undefined
        theolodian @jay_s_uk
        last edited by 20 Feb 2022, 09:41

        @jay_s_uk Thanks. Or would it be possible to do it as an iterative loop?

        Separately, it really should cancel out if the G28 fails. How could I enforce that? Cheers

        1 Reply Last reply Reply Quote 0
        • undefined
          infiniteloop @theolodian
          last edited by 20 Feb 2022, 10:14

          @theolodian You can use a macro like this:

          var nDriver = 3 ; <<< tell number of axes
          ; iterate through the axes:
          while {var.nDriver > 0}
          set var.nDriver = var.nDriver - 1
          if {! move.axes[var.nDriver].homed} ; if an axis is not homed ...
          M99 ; ... we abort this macro
          ; if all axes are homed, we arrive here:
          M300 S1000 P2000 ; beep (do whatever you want)

          Insert the axes count in line 1 and replace the beep in line 10 with any command you want.

          1 Reply Last reply Reply Quote 2
          • undefined
            OwenD @theolodian
            last edited by OwenD 20 Feb 2022, 11:28

            @theolodian

            Lots of ways to skin a cat.

            while iterations < #move.axes
            if !move.axes[iterations].homed
            G28
            if result != 0
            abort "Homing failed"
            break
            undefined undefined 3 Replies Last reply 20 Feb 2022, 11:36 Reply Quote 2
            • undefined
              theolodian @OwenD
              last edited by 20 Feb 2022, 11:36

              @owend Great, thanks! That’s exactly what I was looking for. 👍

              undefined 1 Reply Last reply 20 Feb 2022, 11:43 Reply Quote 0
              • undefined
                OwenD @theolodian
                last edited by 20 Feb 2022, 11:43

                @theolodian
                Just note, that using if result !=0 will also abort if there's just a warning, rather than an error.
                use if result >1 if you only want to abort on an error, but not a warning.
                I usually take the view that if it wasn't 100% successful then I need to stop the print.

                1 Reply Last reply Reply Quote 1
                • undefined
                  Stephen6309 @OwenD
                  last edited by 20 Feb 2022, 15:20

                  @owend You'll want to add move.axes[iterations].letter to G28, otherwise you'll be homing everything iterations times.

                  undefined 1 Reply Last reply 20 Feb 2022, 15:29 Reply Quote 0
                  • undefined
                    theolodian @Stephen6309
                    last edited by theolodian 20 Feb 2022, 15:29

                    @stephen6309 I was hoping that after the first G28 everything else would pass the test?

                    undefined undefined 2 Replies Last reply 20 Feb 2022, 15:44 Reply Quote 0
                    • undefined
                      dc42 administrators @theolodian
                      last edited by dc42 20 Feb 2022, 15:44

                      @theolodian said in Easier way to test if homed?:

                      @stephen6309 I was hoping that after the first G28 everything else would pass the test?

                      Yes, that should be the case.

                      Here's another way (not tested!):

                      var allHomed=true
                      while iterations < #move.axes & move.axes[iterations].visible
                      if !move.axes[iterations].homed
                      set var.allHomed=false
                      break
                      if !var.allHomed
                      G28

                      Duet WiFi hardware designer and firmware engineer
                      Please do not ask me for Duet support via PM or email, use the forum
                      http://www.escher3d.com, https://miscsolutions.wordpress.com

                      undefined undefined 2 Replies Last reply 20 Feb 2022, 16:45 Reply Quote 1
                      • undefined
                        Stephen6309 @theolodian
                        last edited by 20 Feb 2022, 16:06

                        @theolodian You're right, I didn't think it all the way through. My addition would make it home each one at a time.

                        1 Reply Last reply Reply Quote 1
                        • undefined
                          Stephen6309 @dc42
                          last edited by Stephen6309 20 Feb 2022, 16:45

                          @dc42 Doesn't work. Printer not homed, run macro, allHome is set to false, but it's true after exiting the loop. 3.4.0.rc1

                          The allHomed needs to be changed to var.allHomed in line 4 and 6, or you get an error.

                          Change line 4 to G28, remove 1, 6 and 7, and it works.

                          undefined undefined 2 Replies Last reply 20 Feb 2022, 18:07 Reply Quote 0
                          • undefined
                            zapta @Stephen6309
                            last edited by zapta 20 Feb 2022, 18:07

                            @stephen6309 said in Easier way to test if homed?:

                            The allHomed needs to be changed to var.allHomed in line 4 and 6, or you get an error.

                            Or just drop allHome all together?

                            while iterations < #move.axes & move.axes[iterations].visible
                            if !move.axes[iterations].homed
                            G28
                            break
                            1 Reply Last reply Reply Quote 0
                            • undefined
                              dc42 administrators @Stephen6309
                              last edited by 20 Feb 2022, 20:41

                              @stephen6309 said in Easier way to test if homed?:

                              @dc42 Doesn't work. Printer not homed, run macro, allHome is set to false, but it's true after exiting the loop. 3.4.0.rc1

                              The allHomed needs to be changed to var.allHomed in line 4 and 6, or you get an error.

                              Change line 4 to G28, remove 1, 6 and 7, and it works.

                              Thanks, I have made some corrections to that post.

                              Duet WiFi hardware designer and firmware engineer
                              Please do not ask me for Duet support via PM or email, use the forum
                              http://www.escher3d.com, https://miscsolutions.wordpress.com

                              1 Reply Last reply Reply Quote 0
                              • undefined
                                OwenD @dc42
                                last edited by OwenD 21 Feb 2022, 03:09

                                @dc42
                                Out of curiosity, what are the rules with regards to hiding axes?
                                Your macro would break out of the loop upon the first hidden axis (without necessarily having homed)
                                So presumably if you had axes 0..12, you can't hide say 6 & 7 and leave 8 through 12 visible?
                                Or should the macro loop contain something like

                                if !move.axes[iterations].visible
                                continue

                                prior to G28?

                                undefined 1 Reply Last reply 21 Feb 2022, 08:26 Reply Quote 1
                                • undefined
                                  dc42 administrators @OwenD
                                  last edited by 21 Feb 2022, 08:26

                                  @owend the M584 command allows you to make the first P axes visible and hide all higher numbered axes.

                                  Duet WiFi hardware designer and firmware engineer
                                  Please do not ask me for Duet support via PM or email, use the forum
                                  http://www.escher3d.com, https://miscsolutions.wordpress.com

                                  undefined 1 Reply Last reply 21 Feb 2022, 10:00 Reply Quote 0
                                  • undefined
                                    theolodian @dc42
                                    last edited by 21 Feb 2022, 10:00

                                    @dc42 said in Easier way to test if homed?:

                                    @owend the M584 command allows you to make the first P axes visible and hide all higher numbered axes.

                                    The inference being that if you have hidden axes then you probably don't care to home them, say extruders, etc.? Thanks.

                                    undefined undefined 2 Replies Last reply 21 Feb 2022, 16:02 Reply Quote 0
                                    • undefined
                                      zapta @theolodian
                                      last edited by zapta 21 Feb 2022, 16:02

                                      @theolodian said in Easier way to test if homed?:

                                      The inference being that if you have hidden axes then you probably don't care to home them, say extruders, etc.? Thanks.

                                      When I open the object model in DWC, it shows in the move section only x,y,z. Is E is also there in the move section of the object model but is hidden by DWC?

                                      undefined 1 Reply Last reply 21 Feb 2022, 16:23 Reply Quote 0
                                      • undefined
                                        dc42 administrators @zapta
                                        last edited by 21 Feb 2022, 16:23

                                        @zapta the axes are described in move.axes and the extruders in move.extruders.

                                        Duet WiFi hardware designer and firmware engineer
                                        Please do not ask me for Duet support via PM or email, use the forum
                                        http://www.escher3d.com, https://miscsolutions.wordpress.com

                                        1 Reply Last reply Reply Quote 0
                                        • undefined
                                          OwenD @theolodian
                                          last edited by OwenD 21 Feb 2022, 18:51

                                          @theolodian said in Easier way to test if homed?:

                                          @dc42 said in Easier way to test if homed?:

                                          @owend the M584 command allows you to make the first P axes visible and hide all higher numbered axes.

                                          The inference being that if you have hidden axes then you probably don't care to home them, say extruders, etc.? Thanks.

                                          Well not extruders, but you may have defined axes to allow you to perform certain tasks at startup which are then hidden during normal running.
                                          My question was just whether those hidden axes numbers could fall in the middle of a range.
                                          Since it doesn't appear that this is possible, it is safe to cease testing axes for their homed state once a hidden axes is found in the array.

                                          1 Reply Last reply Reply Quote 1
                                          3 out of 29
                                          • First post
                                            3/29
                                            Last post
                                          Unless otherwise noted, all forum content is licensed under CC-BY-SA