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

    Abort if a switch is not activated within a certain time ?

    Scheduled Pinned Locked Moved
    Gcode meta commands
    4
    9
    271
    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.
    • Bertie-Bassetundefined
      Bertie-Basset
      last edited by Bertie-Basset

      Hello.

      First post so please be gentle as I'm not that technically minded.

      would anyone be able to help me with either writing the required conditional gcode.

      Or be able to point me in the direction of any useful easy(ish) to follow reading that explains in detail what every action being taken means/does?

      I look and look trying to understand and it just seems like a foreign language.

      What I would like to do if possible (as the title says) is prevent an axis from moving further than is required by having a macro which aborts that axis's movement if a switch is not triggered within a certain time frame (sec or m/sec)

      would such a thing even be possible ?

      thank you in advance if anyone has helpful input.

      (edited to make it clear, that it is not relevant in the context of homing) only that a movement abort is required after a certain time period if a switch has not been activated.

      This is for a work project and i am not allowed to elaborate further than what is being asked.

      Stephen6309undefined 1 Reply Last reply Reply Quote 0
      • infiniteloopundefined
        infiniteloop
        last edited by

        Sure you can write a macro which contains a timeout, but in your case, it is not useful: before homing, an axis doesn’t „know“ where it is, so you can’t calculate the travel time up to the endstop. Better you have reliable endstops in the first place.

        Bertie-Bassetundefined 1 Reply Last reply Reply Quote 0
        • Bertie-Bassetundefined
          Bertie-Basset @infiniteloop
          last edited by

          @infiniteloop said in Abort if a switch is not activated within a certain time ?:

          Sure you can write a macro which contains a timeout, but in your case, it is not useful: before homing, an axis doesn’t „know“ where it is, so you can’t calculate the travel time up to the endstop. Better you have reliable endstops in the first place.

          Please accept my apologies maybe i was not clear enough in my original post, I didnt say i wanted (or needed ) to know where the axis was, only that the goal is to abort a movement within a certain time frame if a switch is not activated.

          So Can you assist with the original question ?

          1 Reply Last reply Reply Quote 0
          • infiniteloopundefined
            infiniteloop
            last edited by

            @Bertie-Basset After you've edited your post, you no longer mention endstops. Thanks for the clarification. Further, you added:

            i am not allowed to elaborate further than what is being asked

            On my turn, I want to clarify that I deeply dislike to code "into the blue".

            Bertie-Bassetundefined 1 Reply Last reply Reply Quote 0
            • Bertie-Bassetundefined
              Bertie-Basset @infiniteloop
              last edited by Bertie-Basset

              @infiniteloop said in Abort if a switch is not activated within a certain time ?:

              @Bertie-Basset After you've edited your post, you no longer mention endstops. Thanks for the clarification. Further, you added:

              i am not allowed to elaborate further than what is being asked

              On my turn, I want to clarify that I deeply dislike to code "into the blue".

              No one is asking you to, the parameters of the the request are clear to understand.

              1 Reply Last reply Reply Quote 0
              • oliofundefined
                oliof
                last edited by oliof

                Normal homing aborts if the distance traveled is larger than defined axis length x 1.5 or so. If you worry about breaking something during such a move, temporarily reducing the motor current during homing so your axis head moves but stalls rather than breaking stuff could be sufficient for your use case without any additional change in code.

                <>RatRig V-Minion Fly Super5Pro RRF<> V-Core 3.1 IDEX k*****r <> RatRig V-Minion SKR 2 Marlin<>

                Bertie-Bassetundefined 1 Reply Last reply Reply Quote 0
                • Bertie-Bassetundefined
                  Bertie-Basset @oliof
                  last edited by

                  @oliof said in Abort if a switch is not activated within a certain time ?:

                  Normal homing aborts if the distance traveled is larger than defined axis length x 1.5 or so. If you worry about breaking something during such a move, temporarily reducing the motor current during homing so your axis head moves but stalls rather than breaking stuff could be sufficient for your use case without any additional change in code.

                  Thank you but that is not sufficient, the requirement is to have the axis STOP movement after a defined amount of time NOT Distance unless a switch has been activated.

                  1 Reply Last reply Reply Quote 0
                  • Stephen6309undefined
                    Stephen6309 @Bertie-Basset
                    last edited by Stephen6309

                    @bertie-basset Use the object model.

                    gpOut.upTime returns the uptime of the printer

                    One way (NOT tested):

                    var StartTime = gpOut.upTime
                    var TimeToWait=50 ; in seconds
                    var TooLong=false
                    
                    while !axes[0].homed  ; for x axis
                      if(gpOut.upTime > StartTime+TimeToWait)
                          TooLong=true
                          break
                      ; Do what's needed here
                    if(TooLong)
                      ; do your error code here
                    
                    

                    Ignore the {1} the forum puts in there

                    Bertie-Bassetundefined 1 Reply Last reply Reply Quote 0
                    • Bertie-Bassetundefined
                      Bertie-Basset @Stephen6309
                      last edited by

                      @stephen6309

                      Thank you very much, i will test tomorrow and report back, thank you again.

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post
                      Unless otherwise noted, all forum content is licensed under CC-BY-SA