#### maguilera

##### Plastic

- Joined
- Jan 4, 2022

The shift in Z for each pass is calculated by multiplying the DOC of Nth pass by the tangent of the infeed angle.

I would really appreciate the community feedback on this.

Cheers.

This is the python code:

import numpy as np

rsc = input('External Thread (E) or Internal Thread (I):')

dn = float(input('Thread Diameter (mm): '))

feed = float(input('Thread Pitch (mm): '))

zi = float(input('Z Initial Position (mm): '))

zf = float(input('Z Final Position (mm): '))

nap = int(input('Number of Passes: '))

alpha = 30 # INFEED ANGLE

ap = 2 # CLEARANCE IN X

if rsc.upper() == "E":

xap = dn + ap # APPROACH DIAMETER

ap = 0.61343 * feed # THREAD DEPTH

ap1 = (ap / (nap - 1) ** .5) * (0.3 ** 0.5) # DOC FIRST PASS

x1 = round(dn - 2 * ap1, 3) # DIAMETER OF FIRST PASS

print('G0 X' + str(xap), 'Z' + str(zi))

print('X' + str(x1))

print('G32 Z-' + str(zf), 'F' + str(feed))

print('G0 X' + str(xap))

print('Z' + str(zi))

i = 2

while i <= nap:

apx = (ap / (nap - 1) ** .5) * ((i - 1) ** 0.5)

xp = round(dn - 2 * apx, 3)

zs = (apx - ap1) * np.tan(np.deg2rad(alpha)) # SHIFT ON Z

z = round(zi + zs, 3) # Z SHIFTED FROM INITIAL Z

i = i + 1

print('G0 X' + str(xp), 'Z' + str(z))

print('G32 Z-' + str(zf), 'F' + str(feed))

print('G0 X' + str(xap))

print('Z' + str(zi))

else:

dh = dn-feed # HOLE DIAMETER

xap = dh - ap # APPROACH DIAMETER

ap = 0.54127 * feed # THREAD DEPTH

ap1 = (ap / (nap - 1) ** .5) * (0.3 ** 0.5) # DOC FIRST PASS

x1 = round(dh + 2 * ap1, 3) # DIAMETER OF FIRST PASS

print('G0 X' + str(xap), 'Z' + str(zi))

print('X' + str(x1))

print('G32 Z-' + str(zf), 'F' + str(feed))

print('G0 X' + str(xap))

print('Z' + str(zi))

i = 2

while i <= nap:

apx = (ap / (nap - 1) ** .5) * ((i - 1) ** 0.5)

xp = round(dh + 2 * apx, 3)

zs = (apx - ap1) * np.tan(np.deg2rad(alpha)) # SHIFT ON Z

z = round(zi + zs, 3) # Z SHIFTED FROM INITIAL Z

i = i + 1

print('G0 X' + str(xp), 'Z' + str(z))

print('G32 Z-' + str(zf), 'F' + str(feed))

print('G0 X' + str(xap))

print('Z' + str(zi))

This is what it spits out for cutting with 6 passes a M25x1.5 external thread with an infeed angle of 30 degrees.

G0 X27.0 Z5.0

X24.549

G32 Z-10.0 F1.5

G0 X27.0

Z5.0

G0 X24.177 Z5.107

G32 Z-10.0 F1.5

G0 X27.0

Z5.0

G0 X23.836 Z5.206

G32 Z-10.0 F1.5

G0 X27.0

Z5.0

G0 X23.575 Z5.281

G32 Z-10.0 F1.5

G0 X27.0

Z5.0

G0 X23.354 Z5.345

G32 Z-10.0 F1.5

G0 X27.0

Z5.0

G0 X23.16 Z5.401

G32 Z-10.0 F1.5

G0 X27.0

Z5.0