- Drilling and Milling Tools: added support to choose the GCode for turning On the laser

This commit is contained in:
Marius Stanciu
2023-12-06 21:00:07 +02:00
parent 825a05d538
commit 569a30ee52
33 changed files with 329 additions and 241 deletions

View File

@@ -26,7 +26,7 @@ class GRBL_laser(PreProc):
'(This preprocessor makes no moves on the Z axis it will only move horizontally.)\n' \
'(The horizontal move is done with G0 - highest possible speed set in the GRBL controller.)\n' \
'(It assumes a manually focused laser.)\n' \
'(The laser is started with M3 command and stopped with the M5 command.)\n\n'
'(The laser is started with M3 or M4 command and stopped with the M5 command.)\n\n'
xmin = '%.*f' % (p.coords_decimals, p['obj_options']['xmin'])
xmax = '%.*f' % (p.coords_decimals, p['obj_options']['xmax'])
@@ -60,15 +60,15 @@ class GRBL_laser(PreProc):
def lift_code(self, p):
if float(p.laser_min_power) > 0.0:
# the formatted text: laser OFF must always be like this else the plotting will not be done correctly
return 'M3 S%s (laser OFF)\n' % str(p.laser_min_power)
return '%s S%s (laser OFF)\n' % (str(p.laser_on_code), str(p.laser_min_power))
else:
return 'M5'
def down_code(self, p):
if p.spindlespeed:
return '%s S%s' % ('M3', str(p.spindlespeed))
return '%s S%s' % (str(p.laser_on_code), str(p.spindlespeed))
else:
return 'M3'
return str(p.laser_on_code)
def toolchange_code(self, p):
return ''
@@ -115,9 +115,9 @@ class GRBL_laser(PreProc):
def spindle_code(self, p):
if p.spindlespeed:
return '%s S%s' % ('M3', str(p.spindlespeed))
return '%s S%s' % (str(p.laser_on_code), str(p.spindlespeed))
else:
return 'M3'
return str(p.laser_on_code)
def dwell_code(self, p):
return ''

View File

@@ -80,15 +80,15 @@ class GRBL_laser_z(PreProc):
def lift_code(self, p):
if float(p.laser_min_power) > 0.0:
# the formatted text: laser OFF must always be like this else the plotting will not be done correctly
return 'M3 S%s (laser OFF)\n' % str(p.laser_min_power)
return '%s S%s (laser OFF)\n' % (str(p.laser_on_code), str(p.laser_min_power))
else:
return 'M5'
def down_code(self, p):
if p.spindlespeed:
return '%s S%s' % ('M3', str(p.spindlespeed))
return '%s S%s' % (str(p.laser_on_code), str(p.spindlespeed))
else:
return 'M3'
return str(p.laser_on_code)
def toolchange_code(self, p):
return 'G0 Z' + self.coordinate_format % (p.coords_decimals, p.z_move)
@@ -135,9 +135,9 @@ class GRBL_laser_z(PreProc):
def spindle_code(self, p):
if p.spindlespeed:
return '%s S%s' % ('M3', str(p.spindlespeed))
return '%s S%s' % (str(p.laser_on_code), str(p.spindlespeed))
else:
return 'M3'
return str(p.laser_on_code)
def dwell_code(self, p):
return ''

View File

@@ -23,7 +23,7 @@ class Marlin_laser_FAN_pin(PreProc):
gcode += ';It is for the case when it is used together with a LASER connected on one of the FAN pins.\n'\
';This preprocessor makes no moves on the Z axis it will only move horizontally.\n' \
';It assumes a manually focused laser.\n' \
';The laser is started with M3 command and stopped with the M5 command.\n\n'
';The laser is started and stopped with M106 command.\n\n'
xmin = '%.*f' % (p.coords_decimals, p['obj_options']['xmin'])
xmax = '%.*f' % (p.coords_decimals, p['obj_options']['xmax'])

View File

@@ -23,7 +23,7 @@ class Marlin_laser_Spindle_pin(PreProc):
gcode += ';It is for the case when it is used together with a LASER connected on the SPINDLE connector.\n'\
';This preprocessor makes no moves on the Z axis it will only move horizontally.\n' \
';It assumes a manually focused laser.\n' \
';The laser is started with M3 command and stopped with the M5 command.\n\n'
';The laser is started with M3 or M4 command and stopped with the M5 command.\n\n'
xmin = '%.*f' % (p.coords_decimals, p['obj_options']['xmin'])
xmax = '%.*f' % (p.coords_decimals, p['obj_options']['xmax'])
@@ -64,7 +64,7 @@ class Marlin_laser_Spindle_pin(PreProc):
def lift_code(self, p):
if float(p.laser_min_power) > 0.0:
# the formatted text: laser OFF must always be like this else the plotting will not be done correctly
return 'M3 S%s ;laser OFF\n' % str(p.laser_min_power)
return '%s S%s ;laser OFF\n' % (str(p.laser_on_code).replace("0", ""), str(p.laser_min_power))
else:
gcode = 'M400\n'
gcode += 'M5'
@@ -72,9 +72,9 @@ class Marlin_laser_Spindle_pin(PreProc):
def down_code(self, p):
if p.spindlespeed:
return 'M3 S%s' % str(p.spindlespeed)
return '%s S%s' % (str(p.laser_on_code).replace("0", ""), str(p.spindlespeed))
else:
return 'M3'
return str(p.laser_on_code)
def toolchange_code(self, p):
return ''
@@ -125,11 +125,10 @@ class Marlin_laser_Spindle_pin(PreProc):
return 'F' + self.feedrate_rapid_format % (p.fr_decimals, p.feedrate_rapid)
def spindle_code(self, p):
sdir = {'CW': 'M3', 'CCW': 'M4'}[p.spindledir]
if p.spindlespeed:
return '%s S%s' % (sdir, str(p.spindlespeed))
return '%s S%s' % (str(p.laser_on_code).replace("0", ""), str(p.spindlespeed))
else:
return sdir
return str(p.laser_on_code).replace("0", "")
def dwell_code(self, p):
return ''

View File

@@ -22,6 +22,7 @@ class Marlin_laser_z(PreProc):
end_coords_xy = p['xy_end']
gcode = ';This preprocessor is used with a motion controller loaded with MARLIN firmware.\n'
gcode += ';It is for the case when it is used together with a LASER connected on the SPINDLE connector.\n' \
';The laser is started with M3 or M4 command and stopped with the M5 command.\n\n' \
';On toolchange event the laser will move to a defined Z height to change the laser dot size.\n\n'
xmin = '%.*f' % (p.coords_decimals, p['obj_options']['xmin'])
@@ -100,7 +101,7 @@ class Marlin_laser_z(PreProc):
def lift_code(self, p):
if float(p.laser_min_power) > 0.0:
# the formatted text: laser OFF must always be like this else the plotting will not be done correctly
return 'M3 S%s ;laser OFF\n' % str(p.laser_min_power)
return '%s S%s ;laser OFF\n' % (str(p.laser_on_code).replace("0", ""), str(p.laser_min_power))
else:
gcode = 'M400\n'
gcode += 'M5'
@@ -108,9 +109,9 @@ class Marlin_laser_z(PreProc):
def down_code(self, p):
if p.spindlespeed:
return '%s S%s' % ('M3', str(p.spindlespeed))
return '%s S%s' % (str(p.laser_on_code).replace("0", ""), str(p.spindlespeed))
else:
return 'M3'
return str(p.laser_on_code).replace("0", "")
def toolchange_code(self, p):
return 'G0 Z' + self.coordinate_format % (p.coords_decimals, p.z_move)
@@ -168,9 +169,9 @@ class Marlin_laser_z(PreProc):
def spindle_code(self, p):
if p.spindlespeed:
return '%s S%s' % ('M3', str(p.spindlespeed))
return '%s S%s' % (str(p.laser_on_code).replace("0", ""), str(p.spindlespeed))
else:
return 'M3'
return str(p.laser_on_code).replace("0", "")
def dwell_code(self, p):
return ''

View File

@@ -152,11 +152,11 @@ G00 X{x_toolchange} Y{y_toolchange}
(MSG, Change to Tool Dia = {toolC} ||| CONNECT THE PROBE ||| Drills for this tool = {t_drills})
M0
F{feedrate_probe}
G31 Z{z_pdepth}
G31 Z{z_p_depth}
G92 Z0
G00 Z{z_in_between}
F{feedrate_probe_slow}
G31 Z{z_pdepth}
G31 Z{z_p_depth}
G92 Z0
G00 Z{z_move}
(MSG, Remove any clips or other devices used for probing. CNC work is resuming ...)
@@ -168,7 +168,7 @@ M0
z_in_between=self.coordinate_format % (p.coords_decimals, p.z_move / 2),
feedrate_probe=str(self.feedrate_format % (p.fr_decimals, p.feedrate_probe)),
feedrate_probe_slow=str(self.feedrate_format % (p.fr_decimals, (p.feedrate_probe / 2))),
z_pdepth=self.coordinate_format % (p.coords_decimals, p.z_pdepth),
z_p_depth=self.coordinate_format % (p.coords_decimals, p.z_p_depth),
tool=int(p.tool),
t_drills=no_drills,
toolC=toolC_formatted)
@@ -181,11 +181,11 @@ G00 Z{z_toolchange}
(MSG, Change to Tool Dia = {toolC} ||| CONNECT THE PROBE ||| Drills for this tool = {t_drills})
M0
F{feedrate_probe}
G31 Z{z_pdepth}
G31 Z{z_p_depth}
G92 Z0
G00 Z{z_in_between}
F{feedrate_probe_slow}
G31 Z{z_pdepth}
G31 Z{z_p_depth}
G92 Z0
G00 Z{z_move}
(MSG, Remove any clips or other devices used for probing. CNC work is resuming ...)
@@ -195,7 +195,7 @@ M0
z_in_between=self.coordinate_format % (p.coords_decimals, p.z_move / 2),
feedrate_probe=str(self.feedrate_format % (p.fr_decimals, p.feedrate_probe)),
feedrate_probe_slow=str(self.feedrate_format % (p.fr_decimals, (p.feedrate_probe / 2))),
z_pdepth=self.coordinate_format % (p.coords_decimals, p.z_pdepth),
z_p_depth=self.coordinate_format % (p.coords_decimals, p.z_p_depth),
tool=int(p.tool),
t_drills=no_drills,
toolC=toolC_formatted)
@@ -215,11 +215,11 @@ G00 X{x_toolchange} Y{y_toolchange}
(MSG, Change to Tool Dia = {toolC} ||| CONNECT THE PROBE)
M0
F{feedrate_probe}
G31 Z{z_pdepth}
G31 Z{z_p_depth}
G92 Z0
G00 Z{z_in_between}
F{feedrate_probe_slow}
G31 Z{z_pdepth}
G31 Z{z_p_depth}
G92 Z0
G00 Z{z_move}
(MSG, Remove any clips or other devices used for probing. CNC work is resuming ...)
@@ -231,7 +231,7 @@ M0
z_in_between=self.coordinate_format % (p.coords_decimals, p.z_move / 2),
feedrate_probe=str(self.feedrate_format % (p.fr_decimals, p.feedrate_probe)),
feedrate_probe_slow=str(self.feedrate_format % (p.fr_decimals, (p.feedrate_probe / 2))),
z_pdepth=self.coordinate_format % (p.coords_decimals, p.z_pdepth),
z_p_depth=self.coordinate_format % (p.coords_decimals, p.z_p_depth),
tool=int(p.tool),
toolC=toolC_formatted)
else:
@@ -243,11 +243,11 @@ G00 Z{z_toolchange}
(MSG, Change to Tool Dia = {toolC} ||| CONNECT THE PROBE)
M0
F{feedrate_probe}
G31 Z{z_pdepth}
G31 Z{z_p_depth}
G92 Z0
G00 Z{z_in_between}
F{feedrate_probe_slow}
G31 Z{z_pdepth}
G31 Z{z_p_depth}
G92 Z0
G00 Z{z_move}
(MSG, Remove any clips or other devices used for probing. CNC work is resuming ...)
@@ -257,7 +257,7 @@ M0
z_in_between=self.coordinate_format % (p.coords_decimals, p.z_move / 2),
feedrate_probe=str(self.feedrate_format % (p.fr_decimals, p.feedrate_probe)),
feedrate_probe_slow=str(self.feedrate_format % (p.fr_decimals, (p.feedrate_probe / 2))),
z_pdepth=self.coordinate_format % (p.coords_decimals, p.z_pdepth),
z_p_depth=self.coordinate_format % (p.coords_decimals, p.z_p_depth),
tool=int(p.tool),
toolC=toolC_formatted)

View File

@@ -24,7 +24,7 @@ class default_laser(PreProc):
'(This preprocessor makes no moves on the Z axis it will only move horizontally.)\n' \
'(The horizontal move is done with G0 - highest possible speed set in MACH3.)\n' \
'(It assumes a manually focused laser.)\n' \
'(The laser is started with M3 command and stopped with the M5 command.)\n\n'
'(The laser is started with M3 or M4 command and stopped with the M5 command.)\n\n'
xmin = '%.*f' % (p.coords_decimals, p['obj_options']['xmin'])
xmax = '%.*f' % (p.coords_decimals, p['obj_options']['xmax'])
@@ -57,15 +57,15 @@ class default_laser(PreProc):
def lift_code(self, p):
if float(p.laser_min_power) > 0.0:
# the formatted text: laser OFF must always be like this else the plotting will not be done correctly
return 'M03 S%s (laser OFF)\n' % str(p.laser_min_power)
return '%s S%s (laser OFF)\n' % (str(p.laser_on_code), str(p.laser_min_power))
else:
return 'M05'
def down_code(self, p):
if p.spindlespeed:
return '%s S%s' % ('M03', str(p.spindlespeed))
return '%s S%s' % (str(p.laser_on_code), str(p.spindlespeed))
else:
return 'M03'
return str(p.laser_on_code)
def toolchange_code(self, p):
return ''
@@ -120,9 +120,9 @@ class default_laser(PreProc):
def spindle_code(self, p):
if p.spindlespeed:
return '%s S%s' % ('M03', str(p.spindlespeed))
return '%s S%s' % (str(p.laser_on_code), str(p.spindlespeed))
else:
return 'M03'
return str(p.laser_on_code)
def dwell_code(self, p):
return ''

View File

@@ -30,6 +30,7 @@ class grbl_laser_eleks_drd(PreProc):
gcode += '(which helps for centering the drill bit for manual drilling)\n'
gcode += '(The GRBL Controller has to support G2 commands)\n'
gcode += '(The moves are only on horizontal plane X-Y. There are no Z moves.)\n'
gcode += '(The moves are only on horizontal plane X-Y. There are no Z moves.)\n'
gcode += '(Assumes manual laser focussing.)\n\n'
xmin = '%.*f' % (p.coords_decimals, p['obj_options']['xmin'])
@@ -55,10 +56,7 @@ class grbl_laser_eleks_drd(PreProc):
# gcode += 'G94;Feedrate per minute\n'
gcode += 'G00 F' + str(self.feedrate_format % (p.fr_decimals, p.feedrate_rapid)) + '\n'
gcode += 'G01 F' + str(self.feedrate_format % (p.fr_decimals, p.feedrate)) + '\n' # Is Z-Feedrate for Excellon
if p.spindledir == 'CCW':
gcode += 'M04'
else:
gcode += 'M03'
gcode += p.laser_on_code
if p.spindlespeed:
gcode += ' ' + 'S%d' % p.spindlespeed
gcode += ';' + p.spindledir
@@ -71,10 +69,7 @@ class grbl_laser_eleks_drd(PreProc):
return 'M05;lift'
def down_code(self, p):
if p.spindledir == 'CCW':
gcode = 'M04'
else:
gcode = 'M03'
gcode = p.laser_on_code
gcode += ';down'
if str(p['obj_options']['type']) == 'Excellon' or str(p['obj_options']['type']) == 'Excellon Geometry':
gcode += '\n'