Skip to content

Commit

Permalink
Added coolant support to grbl_post
Browse files Browse the repository at this point in the history
Improved canned cycles

Added/translated comments
  • Loading branch information
Schildkroet committed Mar 2, 2020
1 parent b73cc1a commit 51c1897
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/Mod/Path/PathScripts/PathDrilling.py
Expand Up @@ -162,6 +162,7 @@ def circularHoleExecute(self, obj, holes):

# Perform and cancel canned drilling cycle
self.commandlist.append(Path.Command(cmd, params))
self.commandlist.append(Path.Command('G80'))
self.commandlist.append(Path.Command('G0', {'Z': obj.SafeHeight.Value}))


Expand Down
34 changes: 31 additions & 3 deletions src/Mod/Path/PathScripts/post/grbl_post.py
Expand Up @@ -3,6 +3,7 @@
# * *
# * (c) sliptonic (shopinthewoods@gmail.com) 2014 *
# * (c) Gauthier Briere - 2018, 2019 *
# * (c) Schildkroet - 2019-2020 *
# * *
# * This file is part of the FreeCAD CAx development system. *
# * *
Expand Down Expand Up @@ -108,7 +109,7 @@
# ***************************************************************************
MOTION_COMMANDS = ['G0', 'G00', 'G1', 'G01', 'G2', 'G02', 'G3', 'G03'] # Motion gCode commands definition
RAPID_MOVES = ['G0', 'G00'] # Rapid moves gCode commands definition
SUPPRESS_COMMANDS = ['G98', 'G80'] # These commands are ignored by commenting them out
SUPPRESS_COMMANDS = [] # These commands are ignored by commenting them out
COMMAND_SPACE = " "
# Global variables storing current position
CURRENT_X = 0
Expand Down Expand Up @@ -208,6 +209,7 @@ def export(objectslist, filename, argstring):
global UNIT_FORMAT
global UNIT_SPEED_FORMAT
global MOTION_MODE
global SUPPRESS_COMMANDS

print("Post Processor: " + __name__ + " postprocessing...")
gcode = ""
Expand All @@ -217,6 +219,13 @@ def export(objectslist, filename, argstring):
gcode += linenumber() + "(Exported by FreeCAD)\n"
gcode += linenumber() + "(Post Processor: " + __name__ + ")\n"
gcode += linenumber() + "(Output Time:" + str(datetime.datetime.now()) + ")\n"

# Check canned cycles for drilling
if TRANSLATE_DRILL_CYCLES:
if len(SUPPRESS_COMMANDS) == 0:
SUPPRESS_COMMANDS = ['G98', 'G80']
else:
SUPPRESS_COMMANDS += ['G98', 'G80']

# Write the preamble
if OUTPUT_COMMENTS:
Expand Down Expand Up @@ -259,6 +268,17 @@ def export(objectslist, filename, argstring):
gcode += linenumber() + "(Begin operation: " + obj.Label + ")\n"
for line in PRE_OPERATION.splitlines(True):
gcode += linenumber() + line

# turn coolant on if required
if hasattr(obj, "CoolantMode"):
coolantMode = obj.CoolantMode
if OUTPUT_COMMENTS:
if not coolantMode == 'None':
gcode += linenumber() + '(Coolant On:' + coolantMode + ')\n'
if coolantMode == 'Flood':
gcode += linenumber() + 'M8' + '\n'
if coolantMode == 'Mist':
gcode += linenumber() + 'M7' + '\n'

# Parse the op
gcode += parse(obj)
Expand All @@ -269,6 +289,14 @@ def export(objectslist, filename, argstring):
for line in POST_OPERATION.splitlines(True):
gcode += linenumber() + line

# turn coolant off if required
if hasattr(obj, "CoolantMode"):
coolantMode = obj.CoolantMode
if not coolantMode == 'None':
if OUTPUT_COMMENTS:
gcode += linenumber() + '(Coolant Off:' + coolantMode + ')\n'
gcode += linenumber() +'M9' + '\n'

# do the post_amble
if OUTPUT_BCNC:
gcode += linenumber() + "(Block-name: post_amble)\n"
Expand Down Expand Up @@ -380,7 +408,7 @@ def parse(pathobj):
# store the latest command
lastcommand = command

# Memorise la position courante pour calcul des mouvements relatis et du plan de retrait
# Memorizes the current position for calculating the related movements and the withdrawal plan
if command in MOTION_COMMANDS:
if 'X' in c.Parameters:
CURRENT_X = Units.Quantity(c.Parameters['X'], FreeCAD.Units.Length)
Expand All @@ -398,7 +426,7 @@ def parse(pathobj):
if TRANSLATE_DRILL_CYCLES:
if command in ('G81', 'G82', 'G83'):
out += drill_translate(outstring, command, c.Parameters)
# Efface la ligne que l'on vient de translater
# Erase the line we just translated
del(outstring[:])
outstring = []

Expand Down

0 comments on commit 51c1897

Please sign in to comment.