... [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): print "---kaw - g740 words = ", words # G74 is typically called like so: # G74 x ? z ? k ? (x = diameter, usually 0; z = hole endpoint; k = peck length) self.status = linuxcnc.stat() #get status channel instantiated self.status.poll() # 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 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") """ self.execute("G1 Z %s" % z_end) self.execute("G0 Z %s" % z_start) """ sys.stdout.flush() 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