Hello Guest it is November 19, 2019, 10:50:43 PM

Author Topic: Macro, Thread milling NPT thread, Inside/outside  (Read 17899 times)

0 Members and 1 Guest are viewing this topic.

vmax549

*
Macro, Thread milling NPT thread, Inside/outside
« on: August 04, 2009, 09:44:38 PM »
Here is a macro that does thread milling of NPT tapered pipe threds.  IT is for a single point tool and does the threads as straight line segments NOT arcs. It will allow you to cut inside or outside threads . It does a standard thread taper angle

It has a programable front end that asks all the important questions to set up for each type thread. You set up major diam, tool diam , thread depth,etc

Please test before using to do something important. It works better on some computers better than others(;-) Different Ver of mach may react differently.

(;-) TP



'Macro Thread Mill NPT taper pipe thread
Sub Main()
Setvar(21,Getdro(0))
Setvar(23,Getdro(1))
Setvar(30,Getdro(2))
Setvar(22,question("Threads per inch"))
Setvar(28,question("Tool Diameter"))
Setvar(27,question("Start Major Diameter"))
Setvar(9,question("Feed Rate"))
Setvar(18, question("Resolution of thread"))
Setvar(29,question("Thread Depth"))
Setvar(26,(getvar(30)-Getvar(29)))

N0:
Setvar(31,question("InsideThread(0)....OutsideThread(1)"))

 
If getvar(31)=0 Then GoTo N1
If Getvar(31)=1 Then GoTo N2
If Getvar(31)>1 Then MsgBox"Selection OUT OF RANGE"
GoTo N0

N1:
Code" #1=[[#27/2]-[#28/2]]"
COde" #8= [1+[-1*[FUP[#26/[1/#22]]]]]"
Code"#3=0.0"
Code"#10=[360 / #18]"
Code"#109=#10"
Code"#110=[1 / #22]"
Code"#111=[0.0625 / #22]"
Code"#3=#18"
Code"G00 X#21 Y#23"
Code"G01 Z[#30-#29] F#9"
Code"#19=[#1 + #21]"
Code"G01 X#19 Y#23 F#9"
GoTo N3

N2:
Code" #1=[[#27/2]+[#28/2]]"
COde" #8= [1+[-1*[FUP[#26/[1/#22]]]]]"
Code"#3=0.0"
Code"#10=[360 / #18]"
Code"#109=#10"
Code"#110=[1 / #22]"
Code"#111=[-0.0625 / #22]"
Code"#3=#18"
Code"G00 X#21 Y#23"
Code"#19=[#1 + #21]"
Code"G01 X#19 Y#23 F#9"
Code"G01 Z[#30-#29] F#9"
GoTo N4
 
N3:
Do While Getvar(3) < 360.00000 * Getvar(8)
'*****
Code"#26=[#26 + [#110 / #109]]"
Code"#24=[COS[ #3 ] * #1]"
Code"#25=[SIN[ #3 ] * #1]"
Code"#24=[#24 + #21]"
Code"#25=[#25 + #23]"
Code"G01 X#24 Y#25 Z#26 F#9"
Code"#3=[#3 + #18]"
Code"#1=[#1 + [#111 / #109]]"
GoTo N3
Exit Do
loop
'*****
Code"G01 X#21 Y#23 F10"
Code"G00 Z1 M09"
Code"M30"
GoTo N5

N4:
Do While Getvar(3) < 360.00000 * Getvar(8)
'*****
Code"#26=[#26 + [#110 / #109]]"
Code"#24=[COS[ #3 ] * #1]"
Code"#25=[SIN[ #3 ] * #1]"
Code"#24=[#24 + #21]"
Code"#25=[#25 + #23]"
Code"G01 X#24 Y#25 Z#26 F#9"
Code"#3=[#3 + #18]"
Code"#1=[#1 + [#111 / #109]]"
GoTo N4
Exit Do
Loop
'*****
Code"G00 Z1 M09"
Code"G01 X#21 Y#23 F10"
Code"M30"
GoTo N5

N5:
End Sub
End
Re: Macro, Thread milling NPT thread, Inside/outside
« Reply #1 on: November 17, 2011, 11:19:18 AM »
Can someone tell what FUP is in the macro?

Thanks,

Jeff E.

Offline RICH

*
  • *
  •  7,371 7,371
    • View Profile
Re: Macro, Thread milling NPT thread, Inside/outside
« Reply #2 on: November 17, 2011, 05:38:50 PM »
Jeff, not sure what you mean by FUP.
RICH

Offline budman68

*
  • *
  •  2,360 2,360
    • View Profile
Re: Macro, Thread milling NPT thread, Inside/outside
« Reply #3 on: November 18, 2011, 04:51:06 AM »
Hi Rich,

When looking through the code, there are instances where it says:

COde" #8= [1+[-1*[FUP[#26/[1/#22]]]]]"

Dave

----------------------------------------------------------------------
Just because I'm a Global Moderator, don't assume that I know anything !

Dave->    ;)

Offline RICH

*
  • *
  •  7,371 7,371
    • View Profile
Re: Macro, Thread milling NPT thread, Inside/outside
« Reply #4 on: November 18, 2011, 06:22:45 AM »
Thanks Bud...time for a new pair of glasses and don't what it means  Jeff.
RICH

Offline BR549

*
  •  6,916 6,916
    • View Profile
Re: Macro, Thread milling NPT thread, Inside/outside
« Reply #5 on: November 18, 2011, 10:37:02 PM »
Mach3 manual section 10.5.3.4

FUP(round up)

(;-) TP
Re: Macro, Thread milling NPT thread, Inside/outside
« Reply #6 on: May 29, 2017, 07:49:23 PM »
Hi vmax549,
I am trying to run your code under VBS, and return 'COMPILE ERROR: SYNTAX ERROR' at :
Do While Getvar(3) < 360.00000 * Getvar?
why?

Offline Tweakie.CNC

*
  • *
  •  8,003 8,003
  • Super Kitty
    • View Profile
    • Tweakie.CNC
Re: Macro, Thread milling NPT thread, Inside/outside
« Reply #7 on: May 30, 2017, 04:14:55 AM »
Hi Shanren,

I think that line of code should read :-

Code: [Select]
Do While Getvar(3) < 360.000 * Getvar(8)
Tweakie.
Success consists of going from failure to failure without loss of enthusiasm.  Winston Churchill.
Re: Macro, Thread milling NPT thread, Inside/outside
« Reply #8 on: June 05, 2017, 08:04:21 PM »

Hi Tweakie.

you are right, thanks.

another question, what's the 'resolution of thread' means? what should fill in for 1/4 NPT?
Best
Shanren

Offline Tweakie.CNC

*
  • *
  •  8,003 8,003
  • Super Kitty
    • View Profile
    • Tweakie.CNC
Re: Macro, Thread milling NPT thread, Inside/outside
« Reply #9 on: June 06, 2017, 02:32:32 AM »
Quote
another question, what's the 'resolution of thread' means? what should fill in for 1/4 NPT?

I have absolutely no idea - I am sure Rich will be able to answer that question.

Tweakie.
Success consists of going from failure to failure without loss of enthusiasm.  Winston Churchill.