[Home]G74 - Peck Drilling/Face Grooving

LinuxCNCKnowledgeBase | G74 - Peck Drilling | RecentChanges | PageIndex | Preferences | LinuxCNC.org

Showing revision 2

Notes on creating a new lathe g-code, G74 Drill Peck/Face Groove using Python remaping

(Page started 2015/06/27 Kirk Wallace)

.ini file entry


... [RS274NGC] ... # REMAPPING REMAP=g74 modalgroup=1 argspec=xzk py=g740 ... [PYTHON] TOPLEVEL = python/toplevel.py PATH_PREPEND = python ...

So, far the parameters are:
x = (not used)
z = The z endpoint. The start point is from the previous move.
k = The peck length. Pecks start from the Z start point. The last peck length is the distance between the z endpoint and the last full peck length.

toplevel.py

#!/usr/bin/python

import remap

remap.py

#!/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


LinuxCNCKnowledgeBase | G74 - Peck Drilling | RecentChanges | PageIndex | Preferences | LinuxCNC.org
This page is read-only. Follow the BasicSteps to edit pages. | View other revisions | View current revision
Edited June 27, 2015 3:28 pm by Kirk Wallace (diff)
Search:
Published under a Creative Commons License