diff --git a/FlatCAMApp.py b/FlatCAMApp.py index 9189e8f8..36c06ba9 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -1001,7 +1001,7 @@ class App(QtCore.QObject): 'box, center_x, center_y, columns, combine, connect, contour, default, ' 'depthperpass, dia, diatol, dist, drilled_dias, drillz, dwelltime, ' 'extracut_length, ' - 'feedrate_z, grbl_11, grbl_laser, gridoffsety, gridx, gridy, has_offset, ' + 'feedrate_z, grbl_11, GRBL_laser, gridoffsety, gridx, gridy, has_offset, ' 'holes, hpgl, iso_type, line_xyz, margin, marlin, method, milled_dias, ' 'minoffset, name, offset, opt_type, order, outname, overlap, ' 'passes, postamble, pp, ppname_e, ppname_g, preamble, radius, ref, rest, ' @@ -1290,7 +1290,7 @@ class App(QtCore.QObject): # Excellon Options "excellon_drillz": self.ui.excellon_defaults_form.excellon_opt_group.cutz_entry, "excellon_travelz": self.ui.excellon_defaults_form.excellon_opt_group.travelz_entry, - "excellon_endz": self.ui.excellon_defaults_form.excellon_opt_group.eendz_entry, + "excellon_endz": self.ui.excellon_defaults_form.excellon_opt_group.endz_entry, "excellon_feedrate": self.ui.excellon_defaults_form.excellon_opt_group.feedrate_z_entry, "excellon_spindlespeed": self.ui.excellon_defaults_form.excellon_opt_group.spindlespeed_entry, "excellon_dwell": self.ui.excellon_defaults_form.excellon_opt_group.dwell_cb, @@ -1368,14 +1368,14 @@ class App(QtCore.QObject): "geometry_ppname_g": self.ui.geometry_defaults_form.geometry_opt_group.pp_geometry_name_cb, "geometry_toolchange": self.ui.geometry_defaults_form.geometry_opt_group.toolchange_cb, "geometry_toolchangez": self.ui.geometry_defaults_form.geometry_opt_group.toolchangez_entry, - "geometry_endz": self.ui.geometry_defaults_form.geometry_opt_group.gendz_entry, + "geometry_endz": self.ui.geometry_defaults_form.geometry_opt_group.endz_entry, "geometry_depthperpass": self.ui.geometry_defaults_form.geometry_opt_group.depthperpass_entry, "geometry_multidepth": self.ui.geometry_defaults_form.geometry_opt_group.multidepth_cb, # Geometry Advanced Options "geometry_toolchangexy": self.ui.geometry_defaults_form.geometry_adv_opt_group.toolchangexy_entry, "geometry_startz": self.ui.geometry_defaults_form.geometry_adv_opt_group.gstartz_entry, - "geometry_feedrate_rapid": self.ui.geometry_defaults_form.geometry_adv_opt_group.cncfeedrate_rapid_entry, + "geometry_feedrate_rapid": self.ui.geometry_defaults_form.geometry_adv_opt_group.feedrate_rapid_entry, "geometry_extracut": self.ui.geometry_defaults_form.geometry_adv_opt_group.extracut_cb, "geometry_extracut_length": self.ui.geometry_defaults_form.geometry_adv_opt_group.e_cut_entry, "geometry_z_pdepth": self.ui.geometry_defaults_form.geometry_adv_opt_group.pdepth_entry, @@ -2263,7 +2263,7 @@ class App(QtCore.QObject): 'box', 'center_x', 'center_y', 'columns', 'combine', 'connect', 'contour', 'default', 'depthperpass', 'dia', 'diatol', 'dist', 'drilled_dias', 'drillz', 'dwelltime', 'extracut_length', - 'feedrate_z', 'grbl_11', 'grbl_laser', 'gridoffsety', 'gridx', 'gridy', + 'feedrate_z', 'grbl_11', 'GRBL_laser', 'gridoffsety', 'gridx', 'gridy', 'has_offset', 'holes', 'hpgl', 'iso_type', 'line_xyz', 'margin', 'marlin', 'method', 'milled_dias', 'minoffset', 'name', 'offset', 'opt_type', 'order', 'outname', 'overlap', 'passes', 'postamble', 'pp', 'ppname_e', 'ppname_g', diff --git a/FlatCAMObj.py b/FlatCAMObj.py index fdc45475..f7faf045 100644 --- a/FlatCAMObj.py +++ b/FlatCAMObj.py @@ -2814,7 +2814,7 @@ class FlatCAMExcellon(FlatCAMObj, Excellon): "dwell": self.ui.dwell_cb, "dwelltime": self.ui.dwelltime_entry, "startz": self.ui.estartz_entry, - "endz": self.ui.eendz_entry, + "endz": self.ui.endz_entry, "ppname_e": self.ui.pp_excellon_name_cb, "z_pdepth": self.ui.pdepth_entry, "feedrate_probe": self.ui.feedrate_probe_entry, @@ -3475,13 +3475,23 @@ class FlatCAMExcellon(FlatCAMObj, Excellon): except AttributeError: pass - self.ui.travelzlabel.setText('%s:' % _("Focus Z")) + if 'marlin' in current_pp.lower(): + self.ui.travelzlabel.setText('%s:' % _("Focus Z")) + self.ui.endz_label.show() + self.ui.endz_entry.show() + else: + self.ui.travelzlabel.hide() + self.ui.travelz_entry.hide() + + self.ui.endz_label.hide() + self.ui.endz_entry.hide() try: self.ui.frzlabel.hide() self.ui.feedrate_z_entry.hide() except AttributeError: pass + self.ui.dwell_cb.hide() self.ui.dwelltime_entry.hide() @@ -3503,6 +3513,12 @@ class FlatCAMExcellon(FlatCAMObj, Excellon): self.ui.travelzlabel.setText('%s:' % _('Travel Z')) + self.ui.travelzlabel.show() + self.ui.travelz_entry.show() + + self.ui.endz_label.show() + self.ui.endz_entry.show() + try: self.ui.frzlabel.show() self.ui.feedrate_z_entry.show() @@ -4082,7 +4098,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): "travelz": self.ui.travelz_entry, "feedrate": self.ui.cncfeedrate_entry, "feedrate_z": self.ui.feedrate_z_entry, - "feedrate_rapid": self.ui.cncfeedrate_rapid_entry, + "feedrate_rapid": self.ui.feedrate_rapid_entry, "spindlespeed": self.ui.cncspindlespeed_entry, "dwell": self.ui.dwell_cb, "dwelltime": self.ui.dwelltime_entry, @@ -4095,7 +4111,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): "extracut_length": self.ui.e_cut_entry, "toolchange": self.ui.toolchangeg_cb, "toolchangez": self.ui.toolchangez_entry, - "endz": self.ui.gendz_entry, + "endz": self.ui.endz_entry, "cnctooldia": self.ui.addtool_entry }) @@ -4225,10 +4241,10 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): self.ui.addtool_btn.hide() self.ui.copytool_btn.hide() self.ui.deltool_btn.hide() - # self.ui.endzlabel.hide() - # self.ui.gendz_entry.hide() + # self.ui.endz_label.hide() + # self.ui.endz_entry.hide() self.ui.fr_rapidlabel.hide() - self.ui.cncfeedrate_rapid_entry.hide() + self.ui.feedrate_rapid_entry.hide() self.ui.extracut_cb.hide() self.ui.e_cut_entry.hide() self.ui.pdepth_label.hide() @@ -5228,10 +5244,10 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): if 'marlin' in current_pp.lower() or 'custom' in current_pp.lower(): self.ui.fr_rapidlabel.show() - self.ui.cncfeedrate_rapid_entry.show() + self.ui.feedrate_rapid_entry.show() else: self.ui.fr_rapidlabel.hide() - self.ui.cncfeedrate_rapid_entry.hide() + self.ui.feedrate_rapid_entry.hide() if 'laser' in current_pp.lower(): self.ui.cutzlabel.hide() @@ -5242,13 +5258,23 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): except AttributeError: pass - self.ui.travelzlabel.setText('%s:' % _("Focus Z")) + if 'marlin' in current_pp.lower(): + self.ui.travelzlabel.setText('%s:' % _("Focus Z")) + self.ui.endz_label.show() + self.ui.endz_entry.show() + else: + self.ui.travelzlabel.hide() + self.ui.travelz_entry.hide() + + self.ui.endz_label.hide() + self.ui.endz_entry.hide() try: self.ui.frzlabel.hide() self.ui.feedrate_z_entry.hide() except AttributeError: pass + self.ui.dwell_cb.hide() self.ui.dwelltime_entry.hide() @@ -5270,6 +5296,12 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): self.ui.travelzlabel.setText('%s:' % _('Travel Z')) + self.ui.travelzlabel.show() + self.ui.travelz_entry.show() + + self.ui.endz_label.show() + self.ui.endz_entry.show() + try: self.ui.frzlabel.show() self.ui.feedrate_z_entry.show() diff --git a/README.md b/README.md index 38b752bc..f727c607 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,9 @@ CAD program, and create G-Code for Isolation routing. 8.02.2020 -- added a new preprocessor for using laser on a Marlin 3D printer named 'Marlin_laser' +- added a new preprocessor for using laser on a Marlin 3D printer named 'Marlin_laser_use_Spindle_pin' - modified the Geometry UI when using laser preprocessors +- added a new preprocessor file for using laser on a Marlin motion controller but with the laser connected to one of the FAN pins, named 'Marlin_laser_use_FAN_pin' 5.02.2020 @@ -2772,7 +2773,7 @@ CAD program, and create G-Code for Isolation routing. - added options for trace segmentation that can be useful for auto-levelling (code snippet from Lei Zheng from a rejected pull request on FlatCAM https://bitbucket.org/realthunder/ ) - added shortcut key 'L' for creating 'New Excellon' - added shortcut key combo 'SHIFT+S' for Running a Script. -- modified grbl_laser postprocessor file so it includes a Sxxxx command on the line with M03 (laser active) whenever a value is enter in the Spindlespeed entry field +- modified GRBL_laser postprocessor file so it includes a Sxxxx command on the line with M03 (laser active) whenever a value is enter in the Spindlespeed entry field - remade the EDIT -> PREFERENCES window, the Excellon and Gerber sections. Created a new section named TOOLS 26.01.2019 @@ -2780,7 +2781,7 @@ CAD program, and create G-Code for Isolation routing. - fixed grbl_11 postprocessor in linear_code() function - added icons to the Project Tab context menu - added new entries to the Canvas context menu (Copy, Delete, Edit/Save, Move, New Excellon, New Geometry, New Project) -- fixed grbl_laser postprocessor file +- fixed GRBL_laser postprocessor file - updated function for copy of an Excellon object for the case when the object has slots - updated FlatCAMExcellon.merge() function to work in case some (or all) of the merged objects have slots @@ -2800,8 +2801,8 @@ CAD program, and create G-Code for Isolation routing. - added the Copy entry to the Project context menu - made the functions behind Disable and Enable project context menu entries, non-threaded to fix a possible issue - added multiple object selection on Open ... and Import ... (idea and code snippet came from Travers Carter, BitBucket user https://bitbucket.org/travc/) -- fixed 'grbl_laser' postprocessor bugs (missing functions) -- fixed display geometry for 'grbl_laser' postprocessor +- fixed 'GRBL_laser' postprocessor bugs (missing functions) +- fixed display geometry for 'GRBL_laser' postprocessor - Excellon Editor - added possibility to create an linear drill array rotated at an custom angle - added the Edit and Properties entries to the Project context menu diff --git a/camlib.py b/camlib.py index 217e3ef5..e3002d8a 100644 --- a/camlib.py +++ b/camlib.py @@ -4067,6 +4067,13 @@ class CNCjob(Geometry): command['Z'] = 1 else: command['Z'] = 0 + + match_lsr_pos_2 = re.search(r"^(M10[6|7])", gline) + if match_lsr_pos_2: + if 'M107' in match_lsr_pos_2.group(1): + command['Z'] = 1 + else: + command['Z'] = 0 elif self.pp_solderpaste_name is not None: if 'Paste' in self.pp_solderpaste_name: match_paste = re.search(r"X([\+-]?\d+.[\+-]?\d+)\s*Y([\+-]?\d+.[\+-]?\d+)", gline) diff --git a/flatcamGUI/ObjectUI.py b/flatcamGUI/ObjectUI.py index 0a08d60b..1bac450d 100644 --- a/flatcamGUI/ObjectUI.py +++ b/flatcamGUI/ObjectUI.py @@ -992,23 +992,23 @@ class ExcellonObjectUI(ObjectUI): self.grid3.addWidget(self.estartz_entry, 9, 1) # End move Z: - self.eendz_label = QtWidgets.QLabel('%s:' % _("End move Z")) - self.eendz_label.setToolTip( + self.endz_label = QtWidgets.QLabel('%s:' % _("End move Z")) + self.endz_label.setToolTip( _("Height of the tool after\n" "the last move at the end of the job.") ) - self.eendz_entry = FCDoubleSpinner(callback=self.confirmation_message) - self.eendz_entry.set_precision(self.decimals) + self.endz_entry = FCDoubleSpinner(callback=self.confirmation_message) + self.endz_entry.set_precision(self.decimals) if machinist_setting == 0: - self.eendz_entry.set_range(0.0, 9999.9999) + self.endz_entry.set_range(0.0, 9999.9999) else: - self.eendz_entry.set_range(-9999.9999, 9999.9999) + self.endz_entry.set_range(-9999.9999, 9999.9999) - self.eendz_entry.setSingleStep(0.1) + self.endz_entry.setSingleStep(0.1) - self.grid3.addWidget(self.eendz_label, 11, 0) - self.grid3.addWidget(self.eendz_entry, 11, 1) + self.grid3.addWidget(self.endz_label, 11, 0) + self.grid3.addWidget(self.endz_entry, 11, 1) # Feedrate X-Y self.frxylabel = QtWidgets.QLabel('%s:' % _('Feedrate X-Y')) @@ -1748,23 +1748,23 @@ class GeometryObjectUI(ObjectUI): # self.grid3.addWidget(self.gstartz_entry, 8, 1) # The Z value for the end move - self.endzlabel = QtWidgets.QLabel('%s:' % _('End move Z')) - self.endzlabel.setToolTip( + self.endz_label = QtWidgets.QLabel('%s:' % _('End move Z')) + self.endz_label.setToolTip( _("Height of the tool after\n" "the last move at the end of the job.") ) - self.gendz_entry = FCDoubleSpinner(callback=self.confirmation_message) - self.gendz_entry.set_precision(self.decimals) + self.endz_entry = FCDoubleSpinner(callback=self.confirmation_message) + self.endz_entry.set_precision(self.decimals) if machinist_setting == 0: - self.gendz_entry.set_range(0, 9999.9999) + self.endz_entry.set_range(0, 9999.9999) else: - self.gendz_entry.set_range(-9999.9999, 9999.9999) + self.endz_entry.set_range(-9999.9999, 9999.9999) - self.gendz_entry.setSingleStep(0.1) + self.endz_entry.setSingleStep(0.1) - self.grid3.addWidget(self.endzlabel, 9, 0) - self.grid3.addWidget(self.gendz_entry, 9, 1) + self.grid3.addWidget(self.endz_label, 9, 0) + self.grid3.addWidget(self.endz_entry, 9, 1) # Feedrate X-Y self.frlabel = QtWidgets.QLabel('%s:' % _('Feedrate X-Y')) @@ -1804,16 +1804,16 @@ class GeometryObjectUI(ObjectUI): "It is useful only for Marlin,\n" "ignore for any other cases.") ) - self.cncfeedrate_rapid_entry = FCDoubleSpinner(callback=self.confirmation_message) - self.cncfeedrate_rapid_entry.set_precision(self.decimals) - self.cncfeedrate_rapid_entry.set_range(0, 99999.9999) - self.cncfeedrate_rapid_entry.setSingleStep(0.1) + self.feedrate_rapid_entry = FCDoubleSpinner(callback=self.confirmation_message) + self.feedrate_rapid_entry.set_precision(self.decimals) + self.feedrate_rapid_entry.set_range(0, 99999.9999) + self.feedrate_rapid_entry.setSingleStep(0.1) self.grid3.addWidget(self.fr_rapidlabel, 12, 0) - self.grid3.addWidget(self.cncfeedrate_rapid_entry, 12, 1) + self.grid3.addWidget(self.feedrate_rapid_entry, 12, 1) # default values is to hide self.fr_rapidlabel.hide() - self.cncfeedrate_rapid_entry.hide() + self.feedrate_rapid_entry.hide() # Cut over 1st point in path self.extracut_cb = FCCheckBox('%s:' % _('Re-cut')) diff --git a/flatcamGUI/PreferencesUI.py b/flatcamGUI/PreferencesUI.py index 92e06f69..33c23ab3 100644 --- a/flatcamGUI/PreferencesUI.py +++ b/flatcamGUI/PreferencesUI.py @@ -3128,21 +3128,21 @@ class ExcellonOptPrefGroupUI(OptionsGroupUI): grid2.addWidget(self.toolchangez_entry, 3, 1) # End Move Z - endzlabel = QtWidgets.QLabel('%s:' % _('End move Z')) - endzlabel.setToolTip( + endz_label = QtWidgets.QLabel('%s:' % _('End move Z')) + endz_label.setToolTip( _("Height of the tool after\n" "the last move at the end of the job.") ) - self.eendz_entry = FCDoubleSpinner() - self.eendz_entry.set_precision(self.decimals) + self.endz_entry = FCDoubleSpinner() + self.endz_entry.set_precision(self.decimals) if machinist_setting == 0: - self.eendz_entry.set_range(0.0000, 9999.9999) + self.endz_entry.set_range(0.0000, 9999.9999) else: - self.eendz_entry.set_range(-9999.9999, 9999.9999) + self.endz_entry.set_range(-9999.9999, 9999.9999) - grid2.addWidget(endzlabel, 4, 0) - grid2.addWidget(self.eendz_entry, 4, 1) + grid2.addWidget(endz_label, 4, 0) + grid2.addWidget(self.endz_entry, 4, 1) # Feedrate Z frlabel = QtWidgets.QLabel('%s:' % _('Feedrate Z')) @@ -4055,24 +4055,24 @@ class GeometryOptPrefGroupUI(OptionsGroupUI): grid1.addWidget(self.toolchangez_entry, 5, 1) # End move Z - endzlabel = QtWidgets.QLabel('%s:' % _('End move Z')) - endzlabel.setToolTip( + endz_label = QtWidgets.QLabel('%s:' % _('End move Z')) + endz_label.setToolTip( _("Height of the tool after\n" "the last move at the end of the job.") ) - self.gendz_entry = FCDoubleSpinner() + self.endz_entry = FCDoubleSpinner() if machinist_setting == 0: - self.gendz_entry.set_range(0.000, 9999.9999) + self.endz_entry.set_range(0.000, 9999.9999) else: - self.gendz_entry.set_range(-9999.9999, 9999.9999) + self.endz_entry.set_range(-9999.9999, 9999.9999) - self.gendz_entry.set_precision(self.decimals) - self.gendz_entry.setSingleStep(0.1) - self.gendz_entry.setWrapping(True) + self.endz_entry.set_precision(self.decimals) + self.endz_entry.setSingleStep(0.1) + self.endz_entry.setWrapping(True) - grid1.addWidget(endzlabel, 6, 0) - grid1.addWidget(self.gendz_entry, 6, 1) + grid1.addWidget(endz_label, 6, 0) + grid1.addWidget(self.endz_entry, 6, 1) # Feedrate X-Y frlabel = QtWidgets.QLabel('%s:' % _('Feedrate X-Y')) @@ -4207,14 +4207,14 @@ class GeometryAdvOptPrefGroupUI(OptionsGroupUI): "It is useful only for Marlin,\n" "ignore for any other cases.") ) - self.cncfeedrate_rapid_entry = FCDoubleSpinner() - self.cncfeedrate_rapid_entry.set_range(0, 99999.9999) - self.cncfeedrate_rapid_entry.set_precision(self.decimals) - self.cncfeedrate_rapid_entry.setSingleStep(0.1) - self.cncfeedrate_rapid_entry.setWrapping(True) + self.feedrate_rapid_entry = FCDoubleSpinner() + self.feedrate_rapid_entry.set_range(0, 99999.9999) + self.feedrate_rapid_entry.set_precision(self.decimals) + self.feedrate_rapid_entry.setSingleStep(0.1) + self.feedrate_rapid_entry.setWrapping(True) grid1.addWidget(fr_rapid_label, 4, 0) - grid1.addWidget(self.cncfeedrate_rapid_entry, 4, 1) + grid1.addWidget(self.feedrate_rapid_entry, 4, 1) # End move extra cut self.extracut_cb = FCCheckBox('%s' % _('Re-cut')) diff --git a/preprocessors/Berta_CNC.py b/preprocessors/Berta_CNC.py index 784f0cd0..6da9d5d6 100644 --- a/preprocessors/Berta_CNC.py +++ b/preprocessors/Berta_CNC.py @@ -22,7 +22,7 @@ class Berta_CNC(FlatCAMPostProc): def start_code(self, p): units = ' ' + str(p['units']).lower() coords_xy = p['xy_toolchange'] - gcode = '' + gcode = '(This preprocessor is used with a BERTA CNC router.)\n\n' xmin = '%.*f' % (p.coords_decimals, p['options']['xmin']) xmax = '%.*f' % (p.coords_decimals, p['options']['xmax']) @@ -80,7 +80,7 @@ class Berta_CNC(FlatCAMPostProc): gcode += 'G54\n' gcode += 'G0\n' gcode += '(Berta)\n' - gcode += 'G94\n' + gcode += 'G94' return gcode diff --git a/preprocessors/grbl_laser.py b/preprocessors/GRBL_laser.py similarity index 92% rename from preprocessors/grbl_laser.py rename to preprocessors/GRBL_laser.py index a3f4da7d..6c7a7c34 100644 --- a/preprocessors/grbl_laser.py +++ b/preprocessors/GRBL_laser.py @@ -12,7 +12,7 @@ from FlatCAMPostProc import * # is compatible with almost any version of Grbl. -class grbl_laser(FlatCAMPostProc): +class GRBL_laser(FlatCAMPostProc): include_header = True coordinate_format = "%.*f" @@ -20,7 +20,8 @@ class grbl_laser(FlatCAMPostProc): def start_code(self, p): units = ' ' + str(p['units']).lower() - gcode = '' + gcode = '(This preprocessor is used with a motion controller loaded with GRBL firmware. )\n' + gcode += '(It is for the case when it is used together with a LASER connected on the SPINDLE connector.)\n\n' xmin = '%.*f' % (p.coords_decimals, p['options']['xmin']) xmax = '%.*f' % (p.coords_decimals, p['options']['xmax']) @@ -55,7 +56,7 @@ class grbl_laser(FlatCAMPostProc): return '' def lift_code(self, p): - return 'M05 S0' + return 'M5' def down_code(self, p): sdir = {'CW': 'M03', 'CCW': 'M04'}[p.spindledir] @@ -68,7 +69,7 @@ class grbl_laser(FlatCAMPostProc): return '' def up_to_zero_code(self, p): - return 'M05' + return 'M5' def position_code(self, p): return ('X' + self.coordinate_format + ' Y' + self.coordinate_format) % \ @@ -106,4 +107,4 @@ class grbl_laser(FlatCAMPostProc): return '' def spindle_stop_code(self, p): - return 'M05' + return 'M5' diff --git a/preprocessors/ISEL_CNC.py b/preprocessors/ISEL_CNC.py index 7753669c..c32b4272 100644 --- a/preprocessors/ISEL_CNC.py +++ b/preprocessors/ISEL_CNC.py @@ -17,7 +17,7 @@ class ISEL_CNC(FlatCAMPostProc): def start_code(self, p): units = ' ' + str(p['units']).lower() coords_xy = p['xy_toolchange'] - gcode = '' + gcode = '(This preprocessor is used with a ISEL CNC router.)\n\n' xmin = '%.*f' % (p.coords_decimals, p['options']['xmin']) xmax = '%.*f' % (p.coords_decimals, p['options']['xmax']) diff --git a/preprocessors/ISEL_ICP_CNC.py b/preprocessors/ISEL_ICP_CNC.py index 5898437e..ca820d8f 100644 --- a/preprocessors/ISEL_ICP_CNC.py +++ b/preprocessors/ISEL_ICP_CNC.py @@ -15,7 +15,7 @@ class ISEL_ICP_CNC(FlatCAMPostProc): def start_code(self, p): units = ' ' + str(p['units']).lower() coords_xy = p['xy_toolchange'] - gcode = '' + gcode = '; This preprocessor is used with a ISEL ICP CNC router.\n\n' xmin = '%.*f' % (p.coords_decimals, p['options']['xmin']) xmax = '%.*f' % (p.coords_decimals, p['options']['xmax']) diff --git a/preprocessors/Marlin.py b/preprocessors/Marlin.py index 65428e8f..128d1937 100644 --- a/preprocessors/Marlin.py +++ b/preprocessors/Marlin.py @@ -66,8 +66,7 @@ class Marlin(FlatCAMPostProc): gcode += ';Spindle Speed: ' + str(p['spindlespeed']) + ' RPM' + '\n' + '\n' gcode += ('G20' if p.units.upper() == 'IN' else 'G21') + "\n" - gcode += 'G90\n' - gcode += 'G94\n' + gcode += 'G90' return gcode @@ -219,8 +218,11 @@ G0 Z{z_toolchange} return sdir def dwell_code(self, p): + gcode = 'G4 P' + str(p.dwelltime) if p.dwelltime: - return 'G4 P' + str(p.dwelltime) + return gcode def spindle_stop_code(self, p): - return 'M5' + gcode = 'M400\n' + gcode += 'M5' + return gcode diff --git a/preprocessors/Marlin_laser_use_FAN_pin.py b/preprocessors/Marlin_laser_use_FAN_pin.py new file mode 100644 index 00000000..36d958a4 --- /dev/null +++ b/preprocessors/Marlin_laser_use_FAN_pin.py @@ -0,0 +1,120 @@ +# ########################################################## +# FlatCAM: 2D Post-processing for Manufacturing # +# Website: http://flatcam.org # +# File Author: Marius Adrian Stanciu (c) # +# Date: 8-Feb-2020 # +# License: MIT Licence # +# ########################################################## + +from FlatCAMPostProc import * + + +class Marlin_laser_use_FAN_pin(FlatCAMPostProc): + + include_header = True + coordinate_format = "%.*f" + feedrate_format = '%.*f' + feedrate_rapid_format = feedrate_format + + def start_code(self, p): + units = ' ' + str(p['units']).lower() + coords_xy = p['xy_toolchange'] + 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 one of the FAN pins.\n\n' + + xmin = '%.*f' % (p.coords_decimals, p['options']['xmin']) + xmax = '%.*f' % (p.coords_decimals, p['options']['xmax']) + ymin = '%.*f' % (p.coords_decimals, p['options']['ymin']) + ymax = '%.*f' % (p.coords_decimals, p['options']['ymax']) + + gcode += ';Feedrate: ' + str(p['feedrate']) + units + '/min' + '\n' + gcode += ';Feedrate rapids: ' + str(p['feedrate_rapid']) + units + '/min' + '\n\n' + + gcode += ';Z Focus: ' + str(p['z_move']) + units + '\n' + + gcode += ';Steps per circle: ' + str(p['steps_per_circle']) + '\n' + + if str(p['options']['type']) == 'Excellon' or str(p['options']['type']) == 'Excellon Geometry': + gcode += ';Preprocessor Excellon: ' + str(p['pp_excellon_name']) + '\n' + else: + gcode += ';Preprocessor Geometry: ' + str(p['pp_geometry_name']) + '\n' + '\n' + + gcode += ';X range: ' + '{: >9s}'.format(xmin) + ' ... ' + '{: >9s}'.format(xmax) + ' ' + units + '\n' + gcode += ';Y range: ' + '{: >9s}'.format(ymin) + ' ... ' + '{: >9s}'.format(ymax) + ' ' + units + '\n\n' + + gcode += ';Laser Power (Spindle Speed): ' + str(p['spindlespeed']) + '\n' + '\n' + + gcode += ('G20' if p.units.upper() == 'IN' else 'G21') + "\n" + gcode += 'G90' + + return gcode + + def startz_code(self, p): + if p.startz is not None: + return 'G0 Z' + self.coordinate_format % (p.coords_decimals, p.z_move) + else: + return '' + + def lift_code(self, p): + gcode = 'M400\n' + gcode += 'M107' + return gcode + + def down_code(self, p): + if p.spindlespeed: + return '%s S%s' % ('M106', str(p.spindlespeed)) + else: + return 'M106' + + def toolchange_code(self, p): + return '' + + def up_to_zero_code(self, p): + gcode = 'M400\n' + gcode += 'M107' + return gcode + + def position_code(self, p): + return ('X' + self.coordinate_format + ' Y' + self.coordinate_format) % \ + (p.coords_decimals, p.x, p.coords_decimals, p.y) + + def rapid_code(self, p): + return ('G0 ' + self.position_code(p)).format(**p) + " " + self.feedrate_rapid_code(p) + + def linear_code(self, p): + return ('G1 ' + self.position_code(p)).format(**p) + " " + self.inline_feedrate_code(p) + + def end_code(self, p): + coords_xy = p['xy_toolchange'] + gcode = ('G0 Z' + self.feedrate_format % (p.fr_decimals, p.z_end) + " " + self.feedrate_rapid_code(p) + "\n") + + if coords_xy is not None: + gcode += 'G0 X{x} Y{y}'.format(x=coords_xy[0], y=coords_xy[1]) + " " + self.feedrate_rapid_code(p) + "\n" + + return gcode + + def feedrate_code(self, p): + return 'G1 F' + str(self.feedrate_format % (p.fr_decimals, p.feedrate)) + + def z_feedrate_code(self, p): + return 'G1 F' + str(self.feedrate_format % (p.fr_decimals, p.z_feedrate)) + + def inline_feedrate_code(self, p): + return 'F' + self.feedrate_format % (p.fr_decimals, p.feedrate) + + def feedrate_rapid_code(self, p): + return 'F' + self.feedrate_rapid_format % (p.fr_decimals, p.feedrate_rapid) + + def spindle_code(self, p): + if p.spindlespeed: + return '%s S%s' % ('M106 ', str(p.spindlespeed)) + else: + return 'M106' + + def dwell_code(self, p): + return '' + + def spindle_stop_code(self, p): + gcode = 'M400\n' + gcode += 'M107' + return gcode diff --git a/preprocessors/Marlin_laser.py b/preprocessors/Marlin_laser_use_Spindle_pin.py similarity index 93% rename from preprocessors/Marlin_laser.py rename to preprocessors/Marlin_laser_use_Spindle_pin.py index e67e9bb5..a1f7fb1e 100644 --- a/preprocessors/Marlin_laser.py +++ b/preprocessors/Marlin_laser_use_Spindle_pin.py @@ -9,7 +9,7 @@ from FlatCAMPostProc import * -class Marlin_laser(FlatCAMPostProc): +class Marlin_laser_use_Spindle_pin(FlatCAMPostProc): include_header = True coordinate_format = "%.*f" @@ -19,7 +19,8 @@ class Marlin_laser(FlatCAMPostProc): def start_code(self, p): units = ' ' + str(p['units']).lower() coords_xy = p['xy_toolchange'] - gcode = '' + 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\n' xmin = '%.*f' % (p.coords_decimals, p['options']['xmin']) xmax = '%.*f' % (p.coords_decimals, p['options']['xmax']) @@ -44,8 +45,7 @@ class Marlin_laser(FlatCAMPostProc): gcode += ';Laser Power (Spindle Speed): ' + str(p['spindlespeed']) + '\n' + '\n' gcode += ('G20' if p.units.upper() == 'IN' else 'G21') + "\n" - gcode += 'G90\n' - gcode += 'G94' + gcode += 'G90' return gcode @@ -57,7 +57,7 @@ class Marlin_laser(FlatCAMPostProc): def lift_code(self, p): gcode = 'M400\n' - gcode += 'M5 S0' + gcode += 'M5' return gcode def down_code(self, p): diff --git a/preprocessors/Repetier.py b/preprocessors/Repetier.py index c149513c..fa760dfd 100644 --- a/preprocessors/Repetier.py +++ b/preprocessors/Repetier.py @@ -19,7 +19,7 @@ class Repetier(FlatCAMPostProc): def start_code(self, p): units = ' ' + str(p['units']).lower() coords_xy = p['xy_toolchange'] - gcode = '' + gcode = ';This preprocessor is used with a motion controller loaded with REPETIER firmware.\n\n' xmin = '%.*f' % (p.coords_decimals, p['options']['xmin']) xmax = '%.*f' % (p.coords_decimals, p['options']['xmax']) diff --git a/preprocessors/Toolchange_Probe_MACH3.py b/preprocessors/Toolchange_Probe_MACH3.py index 38371154..424848f8 100644 --- a/preprocessors/Toolchange_Probe_MACH3.py +++ b/preprocessors/Toolchange_Probe_MACH3.py @@ -18,7 +18,7 @@ class Toolchange_Probe_MACH3(FlatCAMPostProc): def start_code(self, p): units = ' ' + str(p['units']).lower() coords_xy = p['xy_toolchange'] - gcode = '' + gcode = '(This preprocessor is used with MACH3 with probing height.)\n\n' xmin = '%.*f' % (p.coords_decimals, p['options']['xmin']) xmax = '%.*f' % (p.coords_decimals, p['options']['xmax']) diff --git a/preprocessors/default.py b/preprocessors/default.py index e57ed812..ce4bd85b 100644 --- a/preprocessors/default.py +++ b/preprocessors/default.py @@ -18,7 +18,8 @@ class default(FlatCAMPostProc): def start_code(self, p): units = ' ' + str(p['units']).lower() coords_xy = p['xy_toolchange'] - gcode = '' + gcode = '(This preprocessor is the default preprocessor used by FlatCAM.)\n' + gcode += '(It is made to work with MACH3 compatible motion controllers.)\n\n' xmin = '%.*f' % (p.coords_decimals, p['options']['xmin']) xmax = '%.*f' % (p.coords_decimals, p['options']['xmax']) @@ -66,7 +67,7 @@ class default(FlatCAMPostProc): gcode += ('G20\n' if p.units.upper() == 'IN' else 'G21\n') gcode += 'G90\n' - gcode += 'G94\n' + gcode += 'G94' return gcode diff --git a/preprocessors/grbl_11.py b/preprocessors/grbl_11.py index 9a53c0ab..a8a03b88 100644 --- a/preprocessors/grbl_11.py +++ b/preprocessors/grbl_11.py @@ -18,7 +18,8 @@ class grbl_11(FlatCAMPostProc): def start_code(self, p): units = ' ' + str(p['units']).lower() coords_xy = p['xy_toolchange'] - gcode = '' + gcode = '(This preprocessor is used with a motion controller loaded with GRBL firmware.)\n' + gcode += '(It is configured to be compatible with almost any version of GRBL firmware.)\n\n' xmin = '%.*f' % (p.coords_decimals, p['options']['xmin']) xmax = '%.*f' % (p.coords_decimals, p['options']['xmax'])