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

Stop program if no tpost.g for called tool has not been defined

Scheduled Pinned Locked Moved
Firmware wishlist
5
16
682
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
    MaxGyver
    last edited by MaxGyver 23 Jan 2023, 11:53

    I just had a nasty crash on my CNC-Lathe because I forgot to renumber my tools, correctly.
    I have defined the tool change behavior to stop the spindle and prompt the user to load the next tool before continuing with the program. This is defined in the toolchange macros from tpost1.g to tpost5.g. But in my case, the tool number was T8 and since there was no tpost.8.g macro, the program just continued and rammed the old tool into the workpiece.

    I would expect the program to stop/cancel and an error message if a tool is called and no tool change macro has been defined for that tool.

    undefined undefined 2 Replies Last reply 23 Jan 2023, 12:33 Reply Quote 0
    • undefined
      infiniteloop @MaxGyver
      last edited by 23 Jan 2023, 12:33

      @MaxGyver

      I would expect the program to stop/cancel and an error message if a tool is called and no tool change macro has been defined for that tool.

      Instead of changing the default behaviour, having consequences for many 3D users who rely on the fact that a non-existent macro does "nothing", I propose to write protective code for undefined tools (6-9?):

      ; tpost6.g
      M0 ; stop
      
      undefined 1 Reply Last reply 23 Jan 2023, 15:55 Reply Quote 0
      • undefined
        MaxGyver @infiniteloop
        last edited by 23 Jan 2023, 15:55

        @infiniteloop

        An empty tpost1.g would still do nothing. And an empty tpost1.g is already present after a fresh install if I recall correctly.

        undefined 1 Reply Last reply 23 Jan 2023, 16:42 Reply Quote 0
        • undefined
          infiniteloop @MaxGyver
          last edited by 23 Jan 2023, 16:42

          @MaxGyver

          An empty tpost1.g would still do nothing…

          … jus as a missing tpost1.g - that's consistent 😊

          1 Reply Last reply Reply Quote 0
          • undefined
            OwenD @MaxGyver
            last edited by OwenD 23 Jan 2023, 20:08

            @MaxGyver
            Although I don't use CNC, I can agree that from a safety point of view perhaps the firmware should check for the existence of these files if in CNC mode and halt if the don't exist.

            In the mean time you can get something like it by using the object model.

            In each tfree# put something like

            var nextPreFile = "0:/sys/tpre" ^ state.nextTool ^ ".g"
            var nextPostFile = "0:/sys/tpost" ^ state.nextTool ^ ".g"
            var thisPostFile = "0:/sys/tpost" ^ state.currentTool ^ ".g"
            var nextFreeFile = "0:/sys/tfree" ^ state.nextTool ^ ".g"
            
            
            
            if !fileexists(var.nextPreFile)
               abort "File not found: " ^ var.nextPreFile
            if !fileexists(var.nextPostFile)
               abort "File not found: " ^ var.nextPostFile
            if !fileexists(var.nextFreeFile)
               abort "File not found: " ^ var.nextFreeFile
            if !fileexists(var.thisPostFile)
               abort "File not found: " ^ var.thisPostFile
            

            Note this hasn't been tested.
            It would also require RRF 3.5.0b1
            It requires obviously that tfree0.g exists

            Edit
            You probably should check for the post file of the current tool
            You should also account for cases where the next tool is -1 (no tool)

            undefined 1 Reply Last reply 24 Jan 2023, 14:08 Reply Quote 0
            • undefined
              T3P3Tony administrators @OwenD
              last edited by 24 Jan 2023, 14:08

              @OwenD said in Stop program if no tpost.g for called tool has not been defined:

              perhaps the firmware should check for the existence of these files if in CNC mode

              I am personally not keen on divergence between CNC mode and FDM/General mode when its not needed. We are increasingly seeing mixed mode machines for hybrid manufacturing.

              www.duet3d.com

              undefined 1 Reply Last reply 24 Jan 2023, 20:03 Reply Quote 0
              • undefined
                OwenD @T3P3Tony
                last edited by OwenD 24 Jan 2023, 20:03

                @T3P3Tony said in Stop program if no tpost.g for called tool has not been defined:

                I am personally not keen on divergence >between CNC mode and FDM/General >mode when its not needed. We are >increasingly seeing mixed mode >machines for hybrid manufacturing.

                Totally understandable and acceptable to me.
                Just the increased debugging requirements are a major disincentive to any divergence.
                The object model gives use the ability to do lots of things, including even the use a single tool change macro, but in the current state, there must at least exist the files for T0 as they are the only "trigger" that's accessible.
                I would suggest that the configurator could perhaps initially generate CNC tool change files (for all defined tools) that paused and/or slowed movement by default, but it sounds to me that in this case the tool was likely defined manually so that doesn't help either 🤷

                I guess CNC users must assume a certain level of responsibility that they're operating dangerous equipment.
                I've personally seen a (industrial sized) router throw a 200mm square piece of 12mm aluminium about 10 metres with enough torch force to punch through the metal shed wall.

                undefined 1 Reply Last reply 25 Jan 2023, 07:47 Reply Quote 0
                • undefined
                  MaxGyver @OwenD
                  last edited by 25 Jan 2023, 07:47

                  @OwenD said in Stop program if no tpost.g for called tool has not been defined:

                  I guess CNC users must assume a certain level of responsibility that they're operating dangerous equipment.

                  On this I absolutely agree. I have been the witness and cause of more than one CNC-related mishap on industrial and hobbyist equipment. But shit happens...

                  I have never had the case where a Toolchange in the Gcode did not trigger any response on the controller side.

                  Most Cam software I have worked with automatically number the tools in the library. With other CNC-Controllers this is not a problem.
                  On our router with a industrial controller for example it is impossible to change a tool without having the according offsets defined or a toolsetting/ probing routine in place. This is absolut standard procedure for every CNC-machine I have worked with so far.

                  undefined 1 Reply Last reply 25 Jan 2023, 09:53 Reply Quote 0
                  • undefined
                    T3P3Tony administrators @MaxGyver
                    last edited by 25 Jan 2023, 09:53

                    @MaxGyver said in Stop program if no tpost.g for called tool has not been defined:

                    Most Cam software I have worked with automatically number the tools in the library. With other CNC-Controllers this is not a problem.
                    On our router with a industrial controller for example it is impossible to change a tool without having the according offsets defined or a toolsetting/ probing routine in place. This is absolut standard procedure for every CNC-machine I have worked with so far.

                    This is also a good point. the current way of defining a tool allows for significant latitude for the user to define one without completing the requisite tool change files.

                    The config tool creating files with safe defaults (basically stop and provide a message to the user that they need to configure them) would be a step forward. but does not catch the cases where they are defined after the fact which is probably common.

                    Changing the behaviour to throw an error if the tool change files do not exist could make sense for all users (CNC & FDM). It would still rely on the user to put something in those files.

                    If any one reading this has an example of where requiring the files to exist (they could be empty) would be an issue it would be interesting to have that added to the conversation. (paging @deckingman for your input where you have a lot of "tools" but one extruder).

                    www.duet3d.com

                    undefined 1 Reply Last reply 25 Jan 2023, 13:43 Reply Quote 1
                    • undefined
                      deckingman @T3P3Tony
                      last edited by 25 Jan 2023, 13:43

                      @T3P3Tony said in Stop program if no tpost.g for called tool has not been defined:

                      ..........(paging @deckingman for your input where you have a lot of "tools" but one extruder).

                      Keh? My case is one nozzle but multiple extruders but essentially two different types of configuration. The first is combining filaments of the same temperature characteristics which can have up to 6 extruders but many more tools. In this case, about the only thing that happens between tool changes might be a purge and wipe. But depending on the print, this isn't always necessary so I tend to post process the gcode file to run a purge/ wipe macro, rather than use the tool change macros. In this case, the tool change files are empty and it wouldn't matter if they were missing. The second configuration type is different filament types requiring different temperatures. In this case, there are again 6 extruders but no combinations so only 6 tools. In this case, all 3 tool change macros are required and essential for all 6 tools.

                      But given that users can do pretty much anything they like with tool change macros, I don't see much point making it a prerequisite that macros exist for every tool. If the macro contains mistakes or spurious commands, bad things are still going to happen. In fact, I could think of quite a few scenarios where doing nothing would be better than doing the wrong thing. Just my twopence worth seeing that my name was mentioned.

                      Ian
                      https://somei3deas.wordpress.com/
                      https://www.youtube.com/@deckingman

                      undefined 1 Reply Last reply 25 Jan 2023, 15:05 Reply Quote 2
                      • undefined
                        T3P3Tony administrators @deckingman
                        last edited by 25 Jan 2023, 15:05

                        @deckingman thanks for the response, just mentioned you as I knew you had a bunch of different tools that we not physical tools.

                        www.duet3d.com

                        undefined 1 Reply Last reply 6 Feb 2023, 15:42 Reply Quote 0
                        • undefined
                          MaxGyver @T3P3Tony
                          last edited by 6 Feb 2023, 15:42

                          I would like to give this thread a little push.

                          Yesterday I had another crash because of this issue. Although I was aware of the issue this time, it still slipped my mind to add a new tpost.g in RRF when I was configuring new tools in my CAM software. I have about 30 tools in my library right now, and I would really like to avoid adding 50 tpost.g to my system folder just to be safe...

                          undefined 1 Reply Last reply 6 Feb 2023, 19:07 Reply Quote 0
                          • undefined
                            deckingman @MaxGyver
                            last edited by deckingman 2 Jun 2023, 19:10 6 Feb 2023, 19:07

                            @MaxGyver What do your tool change macros actually do and are they similar for every tool? The reason I ask is that I use the same "universal" tool change macros for every tool. The "universal" part is taken care of by using gcode meta commands and conditional statements - i.e. things like "tools[state.currentTool.name", and "heat.heaters[1].current" etc. These macros are named "ToolFree.g", "ToolPre.g" etc. Then every tfree(n).g simply has one command which is M98 P"ToolFree.g". Of course, one still has to create files for every tool but at it's a much simpler process.

                            EDIT - more info here if it's of any use https://forum.duet3d.com/topic/29646/universal-tool-change-files-on-steroids?_=1675705608001

                            Ian
                            https://somei3deas.wordpress.com/
                            https://www.youtube.com/@deckingman

                            undefined 1 Reply Last reply 21 Feb 2023, 10:53 Reply Quote 1
                            • undefined
                              MaxGyver @deckingman
                              last edited by MaxGyver 21 Feb 2023, 10:53

                              Is it possible to include object model parameters in an M291 message box?
                              This would allow me to use the same tpost#.g code for all tools.

                              "^ state.currentTool ^" works within an echo command, but not in M291?

                              M5 ;stop spindle
                              M291 P" " R"Please load Tool#""^ state.currentTool ^""" S4 K{"OK","Cancel"} ;display message box with "OK" and "Cancel"
                                if {input=1} ;
                                  echo "Toolchange cancelled, terminating programm..."
                                  M2 ; end programm
                                else ; continue macro if user presses "OK"
                                  echo "Tool#"^ state.currentTool ^" loaded"
                              
                              
                              undefined 1 Reply Last reply 21 Feb 2023, 17:24 Reply Quote 0
                              • undefined
                                OwenD @MaxGyver
                                last edited by 21 Feb 2023, 17:24

                                @MaxGyver
                                You need curly braces around the parameters if you wish to have it evaluated as an expression

                                M291 P" " R{"Please load Tool #"^ state.currentTool} S4 K{"OK","Cancel"}
                                
                                undefined 1 Reply Last reply 22 Feb 2023, 12:50 Reply Quote 3
                                • undefined
                                  MaxGyver @OwenD
                                  last edited by 22 Feb 2023, 12:50

                                  @OwenD

                                  Thank you!

                                  This is the most recent version of my super simple universal tool change macro:

                                  M5 ;stop spindle
                                  
                                  M291 P" " R{"Please load Tool #"^ state.currentTool} S4 K{"Continue","Cancel"} ;display message box with "Continue" and "Cancel"
                                    if {input=1}
                                      if state.status="processing" ;check if a programm is running
                                        M2 ; end programm
                                        echo "Toolchange cancelled, terminating programm..."
                                      else 
                                        echo "Toolchange cancelled..."
                                    else ; continue macro if user presses "Continue"
                                      echo "Tool#"^ state.currentTool ^" loaded"
                                  
                                  1 Reply Last reply Reply Quote 0
                                  • First post
                                    Last post
                                  Unless otherwise noted, all forum content is licensed under CC-BY-SA