From 4d60e5c19741edcba22b7b147870749184b62a50 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Fri, 23 Jul 2021 23:39:25 +0300 Subject: [PATCH] - fixed errors in the Roland preprocessors - fixed CNCJob plot scaling when using Roland preprocessors - in Roland preprocessors added the use of spindlespeed - made sure that the preprocessors that don't use the gcode_header still use the start gcode --- CHANGELOG.md | 8 ++++++++ appObjects/FlatCAMCNCJob.py | 25 +++++++++++-------------- camlib.py | 4 ++-- preprocessors/Roland_MDX_20.py | 18 +++++++++++++----- preprocessors/Roland_MDX_540.py | 18 +++++++++++++----- 5 files changed, 47 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f5223763..57d90c07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ CHANGELOG for FlatCAM beta ================================================= +23.07.2021 + +- fixed errors in the Roland preprocessors +- fixed CNCJob plot scaling when using Roland preprocessors +- in Roland preprocessors added the use of spindlespeed +- made sure that the preprocessors that don't use the gcode_header still use the start gcode + + 21.07.2021 - when using the NCCAD9 preprocessor (for Kosy machines) at GCode save the .knc extension will be automatically preselected diff --git a/appObjects/FlatCAMCNCJob.py b/appObjects/FlatCAMCNCJob.py index 2d5ab838..e2cba114 100644 --- a/appObjects/FlatCAMCNCJob.py +++ b/appObjects/FlatCAMCNCJob.py @@ -1014,21 +1014,18 @@ class CNCJobObject(FlatCAMObj, CNCjob): else: gcode += self.gcode - g = preamble + '\n' + gcode + '\n' + postamble + # g = self.gc_start + '\n' + preamble + '\n' + gcode + '\n' + postamble + g = '' + end_gcode = self.gcode_footer() if self.app.defaults['cncjob_footer'] is True else '' + if preamble != '' and postamble != '': + g = self.gc_start + '\n' + preamble + '\n' + gcode + '\n' + postamble + '\n' + end_gcode + if preamble == '': + g = self.gc_start + '\n' + gcode + '\n' + postamble + '\n' + end_gcode + if postamble == '': + g = self.gc_start + '\n' + preamble + '\n' + gcode + '\n' + end_gcode + if preamble == '' and postamble == '': + g = self.gc_start + '\n' + gcode + '\n' + end_gcode else: - # search for the GCode beginning which is usually a G20 or G21 - # fix so the preamble gets inserted in between the comments header and the actual start of GCODE - # g_idx = gcode.rfind('G20') - # - # # if it did not find 'G20' then search for 'G21' - # if g_idx == -1: - # g_idx = gcode.rfind('G21') - # - # # if it did not find 'G20' and it did not find 'G21' then there is an error and return - # if g_idx == -1: - # self.app.inform.emit('[ERROR_NOTCL] %s' % _("G-code does not have a units code: either G20 or G21")) - # return - # detect if using multi-tool and make the Gcode summation correctly for each case if self.multitool is True: # for the case that self.tools is empty: old projects diff --git a/camlib.py b/camlib.py index 72902b81..33655a3a 100644 --- a/camlib.py +++ b/camlib.py @@ -6324,8 +6324,8 @@ class CNCjob(Geometry): match_z = re.search(r"^Z(\s*-?\d+\.\d+?),(\s*\s*-?\d+\.\d+?),(\s*\s*-?\d+\.\d+?)*;$", gline) if match_z: command['G'] = 0 - command['X'] = float(match_z.group(1).replace(" ", "")) * 0.025 - command['Y'] = float(match_z.group(2).replace(" ", "")) * 0.025 + command['X'] = float(match_z.group(1).replace(" ", "")) * 0.01 + command['Y'] = float(match_z.group(2).replace(" ", "")) * 0.01 command['Z'] = float(match_z.group(3).replace(" ", "")) * 0.025 elif 'hpgl' in self.pp_excellon_name or 'hpgl' in self.pp_geometry_name: diff --git a/preprocessors/Roland_MDX_20.py b/preprocessors/Roland_MDX_20.py index 6781ab37..d736e846 100644 --- a/preprocessors/Roland_MDX_20.py +++ b/preprocessors/Roland_MDX_20.py @@ -74,9 +74,9 @@ class Roland_MDX_20(PreProc): def linear_code(self, p): if p.units.upper() == 'IN': - z = p.z / 25.4 + z = p.z_cut / 25.4 else: - z = p.z + z = p.z_cut gcode = self.feedrate_code(p) + '\n' gcode += self.position_code(p).format(**p) + ',' + str(float(z * 40.0)) + ';' return gcode @@ -121,10 +121,18 @@ class Roland_MDX_20(PreProc): return 'V' + str(self.feedrate_format % fr_sec) + ';' def spindle_code(self, p): - return '!MC1' + speed = int(p.spindlespeed) + if speed > 8388607: + speed = 8388607 + if speed < 0: + speed = 0 + + gcode = '!MC1;\n' + gcode += '!RC%d;' % speed + return gcode def dwell_code(self, p): - return'' + return '' def spindle_stop_code(self, p): - return '!MC0' + return '!MC0;' diff --git a/preprocessors/Roland_MDX_540.py b/preprocessors/Roland_MDX_540.py index b20c35c7..6060b7d4 100644 --- a/preprocessors/Roland_MDX_540.py +++ b/preprocessors/Roland_MDX_540.py @@ -72,9 +72,9 @@ class Roland_MDX_540(PreProc): def linear_code(self, p): if p.units.upper() == 'IN': - z = p.z / 25.4 + z = p.z_cut / 25.4 else: - z = p.z + z = p.z_cut gcode = self.feedrate_code(p) + '\n' gcode += self.position_code(p).format(**p) + ',' + str(float(z * 100.0)) + ';' return gcode @@ -119,10 +119,18 @@ class Roland_MDX_540(PreProc): return 'V' + str(self.feedrate_format % fr_sec) + ';' def spindle_code(self, p): - return '!MC1' + speed = int(p.spindlespeed) + if speed > 8388607: + speed = 8388607 + if speed < 0: + speed = 0 + + gcode = '!MC1;\n' + gcode += '!RC%d;' % speed + return gcode def dwell_code(self, p): - return'' + return '' def spindle_stop_code(self, p): - return '!MC0' + return '!MC0;'