[Home]G74 - Peck Drilling/Face Grooving

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

Showing revision 5

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

(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


Another Approach - Using .ngc

.ini


... [RS274NGC] ... # REMAPPING REMAP=g74 modalgroup=1 argspec=xzk ngc=g740 ...

g740.ngc

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

The above could use some input parameter checking. The loop does a needless back-off if the the peck length fits evenly in the Z range. Maybe a while z_target > z_end loop would be better.

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 28, 2015 6:55 am by Kirk Wallace (diff)
Search:
Published under a Creative Commons License