Retract rates for gcode files from exelon files

Issue #141 resolved
RayMJr created an issue

I have noticed that gcode files for isolation have a rapid retract rate (G00), but gcode files for drilling holes, generated from Excelon files, have the retract rate set at the feed rate (G01). See attached flies.

It would be nice if they all had the retract rate at the rapid (G00) rate.

Thank you!!!

Ray M

Comments (14)

  1. Juan Pablo Caram repo owner

    Shouldn't the feed rate be at G01 while the bit is inside the material and G00 after it is all the way out? I think pulling the bit out too quickly might be dangerous, break the bit, lift the board, etc.

  2. RayMJr reporter

    On a drilling cycle, you should not be cutting, just break the chip (if any), then getting out to move to the next hole.

    That is the way it works on the bridgeport mill I use for large parts, but that is from the CAM software, not the machine.

    Ray

    --J. Ray Mitchell Jr. jrmitchellj@gmail.com (818)324-7573

    The dogmas of the quiet past, are inadequate to the stormy present. The occasion is piled high with difficulty, and we must rise with the occasion. As our case is new, so we must think anew and act anew. We must disenthrall ourselves, and then we shall save our country.Abraham Lincoln http://www.quotationspage.com/quotes/Abraham_Lincoln/, Annual message to Congress, December 1, 1862 16th president of US (1809 - 1865)

  3. Marius Stanciu

    JP, may I suggest the following way to implement this feature?

    Case 1. In the GUI have an option (a check button) for retract rate with G01 (with the feedrate set in the program) while Z depth is negative then while Z depth is positive, to retract with G00 (fastest speed) until the router reach the travel depth.

    Case 2. An option in command line to override the above and set the retract speed with G00 from drill depth all the way to travel depth.

    Case 3. Keep the current setting as default (G01 for the down movement and also for the up movement).

    Reason for:

    Case 1. Your suggestion for this possibility is valid especially when drilling with small bits. It might help by avoiding accidents when drills get broken. I think this is a wonderful idea.

    Case 2. Sometime speed is essential. Also it is good to keep in mind that the drill bit has to stay as little as possible inside the hole due of the heat generated and the fact that at high speeds the resin of FR4 material (most modern PCB material is made out of fiber-glass, labeled as FR4) is melted and create friction. This friction is shortening the life span of the drill bit so it is always good to have the drill bit out of the hole as fast as possible. It is nice for the advanced user to at least have this possibility.

    Case 3. For the cases when drilling with very thin drill bits, the current setting might be useful. It is also the safest as you pointed out.

    Of course, the best way is to set this behavior independently for each drill bit but I think this will require a lot of changes since it will involve a tool database.

    Thank you!

  4. Marius Stanciu

    I have changed the generate_from_excellon_by_tool function found in the CNCjob class from camlib.py file as in the following and it works great for me.

    LE: I don't know yet how this will work when doing everything in INCH as the 0.6 constant is something related to metric system, not imperial units.

    I observed that the drill bits could be broken if the diameter of the drill bit is less than 0.6mm in combination with fast retract speeds so I made a threshold (should be a GUI parameter) from this value. If the drill diameter is less than 0.6mm then the up/down movement is broken into:

    • down movement with G01 and the feedrate that is set in the program

    • up to Z0 with G01

    • up movement to the traveling position Z (set in software) with G00 (very fast)

    If the diameter is more than 0.6mm then the up/down movement is made from:

    • down movement with G01

    • up movement with G00 (very fast)

    The code contain my other modifications such that at every toolchange event the drill bit will be moved at X0Y0 position and there it will start a sequence of movements with the purpose of making the manual toolchange easier for us hobbyists.

    Because I am afraid that those fast movements may cause my router to loose steps (my case) I also introduced a custom feedrate just for those movements to X0Y0 origin.

    It will be great if those two parameters will get introduced into the program GUI.

    def generate_from_excellon_by_tool(self, exobj, tools="all",
                                           toolchange=False, toolchangez=0.1):
            """
            Creates gcode for this object from an Excellon object
            for the specified tools.
    
            :param exobj: Excellon object to process
            :type exobj: Excellon
            :param tools: Comma separated tool names
            :type: tools: str
            :return: None
            :rtype: None
            """
    
            log.debug("Creating CNC Job from Excellon...")
            # Tools
            if tools == "all":
                tools = [tool for tool in exobj.tools]
            else:
                tools = [x.strip() for x in tools.split(",")]
                tools = filter(lambda i: i in exobj.tools, tools)
            log.debug("Tools are: %s" % str(tools))
    
            # Points (Group by tool)
            points = {}
            for drill in exobj.drills:
                if drill['tool'] in tools:
                    try:
                        points[drill['tool']].append(drill['point'])
                    except KeyError:
                        points[drill['tool']] = [drill['point']]
    
            log.debug("Found %d drills." % len(points))
            self.gcode = []
    
            # Basic G-Code macros
            t = "G00 " + CNCjob.defaults["coordinate_format"] + "\n"
            down = "G01 Z%.4f\n" % self.z_cut
            up_to_zero = "G01 Z0\n"
            up = "G00 Z%.4f\n" % self.z_move
            move_down_up = up
    
            # Variables
            self.diameter_threshold = 0.6  # should be a parameter in GUI
            self.feedrate_toolchange = 600  # should be a parameter in GUI
    
            # Initialization
            gcode = self.unitcode[self.units.upper()] + "\n"
            gcode += self.absolutecode + "\n"
            gcode += self.feedminutecode + "\n"
            gcode += "F%.2f\n" % self.feedrate
            gcode += "G00 Z%.4f\n" % self.z_move  # Move to travel height
    
            if self.spindlespeed is not None:
                gcode += "M03 S%d\n" % int(self.spindlespeed)  # Spindle start with configured speed
            else:
                gcode += "M03\n"  # Spindle start
    
            gcode += self.pausecode + "\n"
    
            for tool in points:
    
                # Tool change sequence (optional)
                if toolchange:
                    gcode += "G00 Z%.4f\n" % toolchangez
                    gcode += "F%.2f\n" % self.feedrate_toolchange   # A custom feedrate added so my CNC will not loose steps at this critical stage. 
                    gcode += "G00 X0Y0\n" #Go to X0 Y0 point
                    gcode += "F%.2f\n" % self.feedrate
                    gcode += "T%d\n" % int(tool)  # Indicate tool slot (for automatic tool changer)
                    gcode += "M5\n"  # Spindle Stop
                    gcode += "M6\n"  # Tool change
                    gcode += "(MSG, Change to tool dia=%.4f)\n" % exobj.tools[tool]["C"]
                    if  exobj.tools[tool]["C"] <= self.diameter_threshold:  # If tool diameter is less than 0.6mm
                        move_down_up = down + up_to_zero + up  # retract with G01 until Z=0 then retract with G00
                    else:
                        move_down_up = down + up   # retract all the way up with G00
                    gcode += "G01 Z0\n" # Go to zero depth (on Z axis) in order to adjust the drill bit height
                    gcode += "M0\n"  # Temporary machine stop
                    gcode += "G00 Z%.4f\n" % toolchangez # Go to toolchange position to tighten the nut
                    gcode += "M0\n"  # Temporary machine stop
    
                    gcode += "G01 Z%.4f\n" % self.z_move # Move to travel depth
                    if self.spindlespeed is not None:
                        gcode += "M03 S%d\n" % int(self.spindlespeed)  # Spindle start with configured speed
                    else:
                        gcode += "M03\n"  # Spindle start
    
                # Drillling!
                for point in points[tool]:
                    x, y = point.coords.xy
                    gcode += t % (x[0], y[0])
                    gcode += move_down_up
    
            gcode += "G00 Z%.4f\n" % toolchangez # Go to toolchange position as the final move, to remove the drill bit
            gcode += t % (0, 0)
            gcode += "M05\n"  # Spindle stop
    
            self.gcode = gcode
    
  5. Juan Pablo Caram repo owner
    • down movement with G01 and the feedrate that is set in the program

    • up to Z0 with G01

    • up movement to the traveling position Z (set in software) with G00 (very fast)

    I think this should be the way to do it all the time.

  6. Marius Stanciu

    It is up to you of course, but I think that it is quite safe to have an up movement with G00 for the diameters above 0.6 ... 0.7mm. It will also lower the usage and give a little extra life to the tool, due of lower exposure to the melted epoxy resin in the hole when drilling with high speeds.

  7. Marius Stanciu

    The following is the whole function generate_from_excellon_by_tool found in the CNCjob class from camlib.py

    It incorporate the changes due of #188 (tool ordered when drilling) and as you requested above, the following behaviour:

    • move down to drill depth with G01

    • move up to Z0 with G01

    • move up to traveling Z with G00

    I downloaded SourceTree but I did not found how to do a pull request .

    Anyway, here it is (without my other mods for manual toolchange):

        def generate_from_excellon_by_tool(self, exobj, tools="all",
                                           toolchange=False, toolchangez=0.1):
            """
            Creates gcode for this object from an Excellon object
            for the specified tools.
    
            :param exobj: Excellon object to process
            :type exobj: Excellon
            :param tools: Comma separated tool names
            :type: tools: str
            :return: None
            :rtype: None
            """
    
            log.debug("Creating CNC Job from Excellon...")
    
            # Tools
            if tools == "all":
                tools = [tool for tool in exobj.tools]
            else:
                tools = [x.strip() for x in tools.split(",")]
                tools = filter(lambda i: i in exobj.tools, tools)
            log.debug("Tools are: %s" % str(tools))
    
            # Points (Group by tool)
            points = {}
            for drill in exobj.drills:
                if drill['tool'] in tools:
                    try:
                        points[drill['tool']].append(drill['point'])
                    except KeyError:
                        points[drill['tool']] = [drill['point']]
    
            #log.debug("Found %d drills." % len(points))
            self.gcode = []
    
            # Basic G-Code macros
            t = "G00 " + CNCjob.defaults["coordinate_format"] + "\n"
            down = "G01 Z%.4f\n" % self.z_cut
            up = "G00 Z%.4f\n" % self.z_move
            up_to_zero = "G01 Z0\n"
    
            # Initialization
            gcode = self.unitcode[self.units.upper()] + "\n"
            gcode += self.absolutecode + "\n"
            gcode += self.feedminutecode + "\n"
            gcode += "F%.2f\n" % self.feedrate
            gcode += "G00 Z%.4f\n" % self.z_move  # Move to travel height
    
            if self.spindlespeed is not None:
                gcode += "M03 S%d\n" % int(self.spindlespeed)  # Spindle start with configured speed
            else:
                gcode += "M03\n"  # Spindle start
    
            gcode += self.pausecode + "\n"
    
            for tool in tools:  
    
                # Tool change sequence (optional)
                if toolchange:
                    gcode += "G00 Z%.4f\n" % toolchangez
                    gcode += "T%d\n" % int(tool)  # Indicate tool slot (for automatic tool changer)
                    gcode += "M5\n"  # Spindle Stop
                    gcode += "M6\n"  # Tool change
                    gcode += "(MSG, Change to tool dia=%.4f)\n" % exobj.tools[tool]["C"]
                    gcode += "M0\n"  # Temporary machine stop
                    if self.spindlespeed is not None:
                        gcode += "M03 S%d\n" % int(self.spindlespeed)  # Spindle start with configured speed
                    else:
                        gcode += "M03\n"  # Spindle start
    
                # Drillling!
                for point in points[tool]:
                    x, y = point.coords.xy
                    gcode += t % (x[0], y[0])
                    gcode += down + up_to_zero + up
    
            gcode += t % (0, 0)
            gcode += "M05\n"  # Spindle stop
    
            self.gcode = gcode
    
  8. Marius Stanciu

    Hello JP,

    I know that you think that the retract rate should not be made with G00 when drilling but I went ahead and added the radio buttons in the GUI, made all the changes in all the files (quite hard using CTRl-F search function in each file) - took as a model the toolchange radio button - and made the thereshold 1mm for the drill bit. I think that little by little I start to understand a bit from the program.

    The 1mm threshold (above 1mm drill bits the retract rate from Cut Z to Travelling Z is done with G00) should be more than safe. I never managed to broke a tungsten carbide drill bit of 1mm except by hitting it hard from lateral.

    Also, other software like pcbgcode plugin for EagleCad are doing fast retracts with no problems whatsoever and that plugin is used by a lot of people. Even I used to dabble with it some time ago while I was using Eagle as my main EDA software. And had no problems.

    In any case the default setting is OFF so it's even safer.

    I also added in the GUI one other option (also working).

    I kept the original toolchange radio button but renamed it as "Tool change AUTO" and this is working as before. It will be useful for the guys that have automatic toolchanger.

    But I added a new tool change radio button, below the old one, and this one is named "Tool change MANUAL". All my other modifications mentioned before are present here, including a custom feedrate of 600mm per minute when moving to origin X0Y0.

    I still have to understand how to involve that factor and change the custom feedrate and the threshold of 1mm in inch and back. Right now they are in mm units. I will appreciate any advice.

    If you think that any of my efforts are worthy maybe you could explain to me how to make a pull request using the source tree software.

    Thank you, Marius

    Now the GUI interface look like this: flatcam_modified_excellon.jpg http://tinypic.com/m/jaz3ut/4

  9. Juan Pablo Caram repo owner

    @marius_stanciu I really appreciate your contribution to this issue. It would speed up thing a lot if you sent a proper pull request. That way it's much easier for me to review the changes and quickly accept them with a few clicks.

    The full docs on this are here: https://www.atlassian.com/git/tutorials/making-a-pull-request/example

    In short, you need to clone the whole FlatCAM project into your account, make changes, and then send me a "pull request", which is a request to merge back the changes you made. To get started, simply click on the "Clone" button on the top left of this page. Send me an internal message if you need more help setting this whole thing up.

  10. Juan Pablo Caram repo owner

    This is what was done:

    down movement with G01 and the feedrate that is set in the program

    up to Z0 with G01

    up movement to the traveling position Z (set in software) with G00 (very fast)

  11. Log in to comment