2019-12-16 17:24:50 +00:00
|
|
|
# ##########################################################
|
2019-03-10 13:22:16 +00:00
|
|
|
# FlatCAM: 2D Post-processing for Manufacturing #
|
|
|
|
# http://flatcam.org #
|
|
|
|
# File Author: Marius Adrian Stanciu (c) #
|
|
|
|
# Date: 3/10/2019 #
|
|
|
|
# MIT Licence #
|
2019-12-16 17:24:50 +00:00
|
|
|
# ##########################################################
|
2019-03-10 13:22:16 +00:00
|
|
|
|
2020-06-03 17:35:59 +00:00
|
|
|
from appPreProcessor import *
|
2019-02-20 20:46:46 +00:00
|
|
|
|
|
|
|
|
2020-06-02 15:29:45 +00:00
|
|
|
class Paste_1(AppPreProcTools):
|
2019-02-20 20:46:46 +00:00
|
|
|
|
2019-12-15 22:12:04 +00:00
|
|
|
include_header = True
|
2019-02-20 20:46:46 +00:00
|
|
|
coordinate_format = "%.*f"
|
|
|
|
feedrate_format = '%.*f'
|
|
|
|
|
|
|
|
def start_code(self, p):
|
|
|
|
units = ' ' + str(p['units']).lower()
|
2019-07-08 17:06:41 +00:00
|
|
|
coords_xy = [float(eval(a)) for a in p['xy_toolchange'].split(",") if a != '']
|
2019-02-21 21:48:13 +00:00
|
|
|
|
2019-02-20 20:46:46 +00:00
|
|
|
gcode = ''
|
|
|
|
|
|
|
|
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'])
|
|
|
|
|
2019-02-21 21:48:13 +00:00
|
|
|
gcode += '(TOOL DIAMETER: ' + str(p['options']['tool_dia']) + units + ')\n'
|
|
|
|
gcode += '(Feedrate_XY: ' + str(p['frxy']) + units + '/min' + ')\n'
|
|
|
|
gcode += '(Feedrate_Z: ' + str(p['frz']) + units + '/min' + ')\n'
|
|
|
|
gcode += '(Feedrate_Z_Dispense: ' + str(p['frz_dispense']) + units + '/min' + ')\n'
|
2019-02-20 20:46:46 +00:00
|
|
|
|
2019-02-21 21:48:13 +00:00
|
|
|
gcode += '(Z_Dispense_Start: ' + str(p['z_start']) + units + ')\n'
|
|
|
|
gcode += '(Z_Dispense: ' + str(p['z_dispense']) + units + ')\n'
|
|
|
|
gcode += '(Z_Dispense_Stop: ' + str(p['z_stop']) + units + ')\n'
|
|
|
|
gcode += '(Z_Travel: ' + str(p['z_travel']) + units + ')\n'
|
|
|
|
gcode += '(Z Toolchange: ' + str(p['z_toolchange']) + units + ')\n'
|
2019-02-20 20:46:46 +00:00
|
|
|
|
2019-12-05 13:18:54 +00:00
|
|
|
gcode += '(X,Y Toolchange: ' + "%.*f, %.*f" % (p.decimals, coords_xy[0],
|
|
|
|
p.decimals, coords_xy[1]) + units + ')\n'
|
2019-02-20 20:46:46 +00:00
|
|
|
|
2019-02-21 21:48:13 +00:00
|
|
|
if 'Paste' in p.pp_solderpaste_name:
|
2019-12-06 21:00:43 +00:00
|
|
|
gcode += '(Preprocessor SolderPaste Dispensing Geometry: ' + str(p.pp_solderpaste_name) + ')\n' + '\n'
|
2019-02-20 20:46:46 +00:00
|
|
|
|
|
|
|
gcode += '(X range: ' + '{: >9s}'.format(xmin) + ' ... ' + '{: >9s}'.format(xmax) + ' ' + units + ')\n'
|
|
|
|
gcode += '(Y range: ' + '{: >9s}'.format(ymin) + ' ... ' + '{: >9s}'.format(ymax) + ' ' + units + ')\n\n'
|
|
|
|
|
2019-02-21 21:48:13 +00:00
|
|
|
gcode += '(Spindle Speed FWD: %s RPM)\n' % str(p['speedfwd'])
|
|
|
|
gcode += '(Spindle Speed REV: %s RPM)\n' % str(p['speedrev'])
|
|
|
|
gcode += '(Dwell FWD: %s RPM)\n' % str(p['dwellfwd'])
|
|
|
|
gcode += '(Dwell REV: %s RPM)\n' % str(p['dwellrev'])
|
2019-02-20 20:46:46 +00:00
|
|
|
|
|
|
|
gcode += ('G20\n' if p.units.upper() == 'IN' else 'G21\n')
|
|
|
|
gcode += 'G90\n'
|
|
|
|
gcode += 'G94\n'
|
|
|
|
return gcode
|
|
|
|
|
|
|
|
def lift_code(self, p):
|
2019-12-16 17:24:50 +00:00
|
|
|
return 'G00 Z' + self.coordinate_format % (p.coords_decimals, float(p['z_travel']))
|
2019-02-21 21:48:13 +00:00
|
|
|
|
|
|
|
def down_z_start_code(self, p):
|
2019-12-16 17:24:50 +00:00
|
|
|
return 'G01 Z' + self.coordinate_format % (p.coords_decimals, float(p['z_start']))
|
2019-02-21 21:48:13 +00:00
|
|
|
|
|
|
|
def lift_z_dispense_code(self, p):
|
2019-12-16 17:24:50 +00:00
|
|
|
return 'G01 Z' + self.coordinate_format % (p.coords_decimals, float(p['z_dispense']))
|
2019-02-20 20:46:46 +00:00
|
|
|
|
2019-02-21 21:48:13 +00:00
|
|
|
def down_z_stop_code(self, p):
|
2019-12-16 17:24:50 +00:00
|
|
|
return 'G01 Z' + self.coordinate_format % (p.coords_decimals, float(p['z_stop']))
|
2019-02-20 20:46:46 +00:00
|
|
|
|
|
|
|
def toolchange_code(self, p):
|
2019-02-28 16:02:29 +00:00
|
|
|
z_toolchange = float(p['z_toolchange'])
|
2019-07-08 17:06:41 +00:00
|
|
|
toolchangexy = [float(eval(a)) for a in p['xy_toolchange'].split(",") if a != '']
|
2019-02-20 20:46:46 +00:00
|
|
|
|
|
|
|
if toolchangexy is not None:
|
2019-02-28 16:02:29 +00:00
|
|
|
x_toolchange = toolchangexy[0]
|
|
|
|
y_toolchange = toolchangexy[1]
|
2019-02-20 20:46:46 +00:00
|
|
|
else:
|
2019-12-05 13:18:54 +00:00
|
|
|
x_toolchange = 0.0
|
|
|
|
y_toolchange = 0.0
|
|
|
|
|
|
|
|
toolC_formatted = '%.*f' % (p.decimals, float(p['toolC']))
|
2019-02-20 20:46:46 +00:00
|
|
|
|
2019-02-21 21:48:13 +00:00
|
|
|
if toolchangexy is not None:
|
|
|
|
gcode = """
|
2019-02-28 16:02:29 +00:00
|
|
|
G00 Z{z_toolchange}
|
|
|
|
G00 X{x_toolchange} Y{y_toolchange}
|
2019-02-20 20:46:46 +00:00
|
|
|
T{tool}
|
|
|
|
M6
|
2019-02-21 21:48:13 +00:00
|
|
|
(MSG, Change to Tool with Nozzle Dia = {toolC})
|
|
|
|
M0
|
2019-12-06 21:00:43 +00:00
|
|
|
G00 Z{z_toolchange}
|
2019-02-28 16:02:29 +00:00
|
|
|
""".format(x_toolchange=self.coordinate_format % (p.coords_decimals, x_toolchange),
|
|
|
|
y_toolchange=self.coordinate_format % (p.coords_decimals, y_toolchange),
|
|
|
|
z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
|
2019-02-21 21:48:13 +00:00
|
|
|
tool=int(int(p.tool)),
|
|
|
|
toolC=toolC_formatted)
|
|
|
|
|
|
|
|
else:
|
|
|
|
gcode = """
|
2019-02-28 16:02:29 +00:00
|
|
|
G00 Z{z_toolchange}
|
2019-02-20 20:46:46 +00:00
|
|
|
T{tool}
|
|
|
|
M6
|
2019-02-21 21:48:13 +00:00
|
|
|
(MSG, Change to Tool with Nozzle Dia = {toolC})
|
|
|
|
M0
|
2019-12-06 21:00:43 +00:00
|
|
|
G00 Z{z_toolchange}
|
2019-02-28 16:02:29 +00:00
|
|
|
""".format(z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
|
2019-02-21 21:48:13 +00:00
|
|
|
tool=int(int(p.tool)),
|
|
|
|
toolC=toolC_formatted)
|
2019-02-20 20:46:46 +00:00
|
|
|
|
2019-02-21 21:48:13 +00:00
|
|
|
return gcode
|
2019-02-20 20:46:46 +00:00
|
|
|
|
|
|
|
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):
|
2019-02-21 21:48:13 +00:00
|
|
|
return ('G00 ' + self.position_code(p)).format(**p) + '\nG00 Z' + \
|
2019-12-16 17:24:50 +00:00
|
|
|
self.coordinate_format % (p.coords_decimals, float(p['z_travel']))
|
2019-02-20 20:46:46 +00:00
|
|
|
|
|
|
|
def linear_code(self, p):
|
|
|
|
return ('G01 ' + self.position_code(p)).format(**p)
|
|
|
|
|
|
|
|
def end_code(self, p):
|
2020-02-26 02:43:54 +00:00
|
|
|
coords_xy = [float(eval(a)) for a in p['xy_end'].split(",") if a != '']
|
2019-12-16 17:24:50 +00:00
|
|
|
gcode = ('G00 Z' + self.feedrate_format % (p.fr_decimals, float(p['z_toolchange'])) + "\n")
|
2019-02-20 20:46:46 +00:00
|
|
|
|
2020-02-28 15:59:15 +00:00
|
|
|
if coords_xy and coords_xy != '':
|
2019-02-20 20:46:46 +00:00
|
|
|
gcode += 'G00 X{x} Y{y}'.format(x=coords_xy[0], y=coords_xy[1]) + "\n"
|
|
|
|
return gcode
|
|
|
|
|
2019-02-21 21:48:13 +00:00
|
|
|
def feedrate_xy_code(self, p):
|
2019-12-16 17:24:50 +00:00
|
|
|
return 'G01 F' + str(self.feedrate_format % (p.fr_decimals, float(p['frxy'])))
|
2019-02-20 20:46:46 +00:00
|
|
|
|
2019-02-28 16:02:29 +00:00
|
|
|
def z_feedrate_code(self, p):
|
2019-12-16 17:24:50 +00:00
|
|
|
return 'G01 F' + str(self.feedrate_format % (p.fr_decimals, float(p['frz'])))
|
2019-02-21 21:48:13 +00:00
|
|
|
|
|
|
|
def feedrate_z_dispense_code(self, p):
|
2019-12-16 17:24:50 +00:00
|
|
|
return 'G01 F' + str(self.feedrate_format % (p.fr_decimals, float(p['frz_dispense'])))
|
2019-02-20 20:46:46 +00:00
|
|
|
|
2019-02-21 21:48:13 +00:00
|
|
|
def spindle_fwd_code(self, p):
|
2019-02-20 20:46:46 +00:00
|
|
|
if p.spindlespeed:
|
2019-02-21 21:48:13 +00:00
|
|
|
return 'M03 S' + str(float(p['speedfwd']))
|
2019-02-20 20:46:46 +00:00
|
|
|
else:
|
|
|
|
return 'M03'
|
|
|
|
|
2019-02-21 21:48:13 +00:00
|
|
|
def spindle_rev_code(self, p):
|
|
|
|
if p.spindlespeed:
|
|
|
|
return 'M04 S' + str(float(p['speedrev']))
|
|
|
|
else:
|
|
|
|
return 'M04'
|
2019-02-20 20:46:46 +00:00
|
|
|
|
2019-12-16 17:24:50 +00:00
|
|
|
def spindle_off_code(self, p):
|
2019-02-20 20:46:46 +00:00
|
|
|
return 'M05'
|
2019-02-21 21:48:13 +00:00
|
|
|
|
|
|
|
def dwell_fwd_code(self, p):
|
|
|
|
if p.dwelltime:
|
|
|
|
return 'G4 P' + str(float(p['dwellfwd']))
|
|
|
|
|
|
|
|
def dwell_rev_code(self, p):
|
|
|
|
if p.dwelltime:
|
|
|
|
return 'G4 P' + str(float(p['dwellrev']))
|