... [RS274NGC] ... # REMAPPING REMAP=g74 modalgroup=1 argspec=xzk py=g740 ... [PYTHON] TOPLEVEL = python/toplevel.py PATH_PREPEND = python ...
#!/usr/bin/python import remap
#!/usr/bin/python import sys import linuxcnc from interpreter import INTERP_OK import math def g740(self, **words): # G74 is typically called like so: # G74 x ? z ? k ? (x = diameter, usually 0; z = hole endpoint; k = peck length) # get current position, in current G20/21 units and offsets x_start = self.params[5420] z_start = self.params[5422] if 'z' in words: z_end = words['z'] else: z_end = z_start if 'k' in words: peck_length = words['k'] else: peck_length = 0 z_range = z_end - z_start if peck_length > 0: num_pecks = int(math.fabs(z_range / peck_length)) else: num_pecks = 0 self.status = linuxcnc.stat() self.status.poll() if (self.status.gcodes[5] == 210): # if is_metric backoff_length = 0.50 # mm else: backoff_length = 0.020 # inch for i in range(num_pecks): z_target = z_start - ((i + 1) * peck_length) self.execute("G1 Z %s" % z_target) z_backoff = z_target + backoff_length self.execute("G0 Z %s" % z_backoff) self.execute("G1 Z %s" % z_end) self.execute("G0 Z %s" % z_start) return INTERP_OK
The above is just a simple peck drilling routine. The X parameter (maybe more) and face grooving still need to be defined and implemented. A section in Peter Smid's book "CNC Programming Handbook, 3rd Edition" Page 222, covering G74 was used as a reference: https://books.google.com/books?id=w7-jBgAAQBAJ&pg=PA222
... [RS274NGC] ... # REMAPPING REMAP=g74 modalgroup=1 argspec=xzk ngc=g740 ...
o<g740>sub (Peck Drill) (capture start position) #<x_start> = #5420 (Current X Location) #<z_start> = #5422 (Current Z Location) #<z_end> = #<z> #<peck> = #<k> #<z_range> = [ABS[#<z_end> - #<z_start>]] #<num_pecks> = [#<z_range> / #<peck>] o10 if [#<peck> GT 0] #<num_pecks> = [#<z_range> / #<peck>] o10 else #<num_pecks> = 0 o10 endif o20 if [#<_metric>] #<back_off> = 0.500 (mm) o20 else #<back_off> = 0.0200 (inch) o20 endif #<pass> = 1 o30 repeat [#<num_pecks>] #<z_target> = [#<z_start> - [#<pass> * #<peck>]] G1 Z #<z_target> G0 Z [#<z_target> + #<back_off>] #<pass> = [#<pass> + 1] o30 endrepeat G1 Z #<z_end> G0 Z #<z_start> o<g740> endsub M2
#!/usr/bin/python import sys import linuxcnc from interpreter import INTERP_OK import math import emccanon def g740(self, **words): # G74 is typically called like so: # G74 x ? z ? k ? (x = diameter, usually 0; z = hole endpoint; k = peck length) # get machine G30 position in current G20/21 units x_start = self.params[5420] z_start = self.params[5422] if 'z' in words: z_end = words['z'] else: z_end = z_start if 'k' in words: peck_length = words['k'] else: peck_length = 0 z_range = z_end - z_start if peck_length > 0: num_pecks = int(math.fabs(z_range / peck_length)) else: num_pecks = 0 if (self.params['_metric']): # if is_metric backoff_length = 0.50 # mm else: backoff_length = 0.020 # inch for i in range(num_pecks): #""" z_target = z_start - ((i + 1) * peck_length) line = i * 2 emccanon.STRAIGHT_FEED(line,x_start,0,z_target,0,0,0,0,0,0) emccanon.STRAIGHT_TRAVERSE(line + 1,x_start,0,(z_target + backoff_length),0,0,0,0,0,0) emccanon.STRAIGHT_FEED(line + 1,x_start,0,z_end,0,0,0,0,0,0) emccanon.STRAIGHT_TRAVERSE(line + 2,x_start,0,(z_start),0,0,0,0,0,0) #""" """ z_target = z_start - ((i + 1) * peck_length) self.execute("G1 Z %s" % z_target) z_backoff = z_target + backoff_length self.execute("G0 Z %s" % z_backoff) self.execute("G1 Z %s" % z_end) self.execute("G0 Z %s" % z_start) #""" return INTERP_OK