Machsupport Forum

Support => Downloads => MACH TOOL BOX => Topic started by: vmax549 on August 04, 2009, 09:44:38 PM

Title: Macro, Thread milling NPT thread, Inside/outside
Post by: vmax549 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
Title: Re: Macro, Thread milling NPT thread, Inside/outside
Post by: Jeff E. on November 17, 2011, 11:19:18 AM
Can someone tell what FUP is in the macro?

Thanks,

Jeff E.
Title: Re: Macro, Thread milling NPT thread, Inside/outside
Post by: RICH on November 17, 2011, 05:38:50 PM
Jeff, not sure what you mean by FUP.
RICH
Title: Re: Macro, Thread milling NPT thread, Inside/outside
Post by: budman68 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

Title: Re: Macro, Thread milling NPT thread, Inside/outside
Post by: RICH 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
Title: Re: Macro, Thread milling NPT thread, Inside/outside
Post by: BR549 on November 18, 2011, 10:37:02 PM
Mach3 manual section 10.5.3.4

FUP(round up)

(;-) TP
Title: Re: Macro, Thread milling NPT thread, Inside/outside
Post by: shanren 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?
Title: Re: Macro, Thread milling NPT thread, Inside/outside
Post by: Tweakie.CNC 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.
Title: Re: Macro, Thread milling NPT thread, Inside/outside
Post by: shanren 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
Title: Re: Macro, Thread milling NPT thread, Inside/outside
Post by: Tweakie.CNC 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.
Title: Re: Macro, Thread milling NPT thread, Inside/outside
Post by: RICH on June 06, 2017, 08:48:40 AM
what's the 'resolution of thread' means?

Never tried or used the macro. Based on my poor programming skills, my"guess" is as follows: ::)
The threads as straight line segments NOT arcs, so the resolution is how closely the length of many straight line paths  would be fitting inside / outside of 360 degrees of a diameter.

Setvar(18, question("Resolution of thread"))
Code"#10=[360 / #18]"  
Code"#109=#10"

RICH
Quote
I am sure Rich will be able to answer that question.
  :D
Title: Re: Macro, Thread milling NPT thread, Inside/outside
Post by: shanren on June 06, 2017, 08:54:54 AM
Never tried or used the macro. Based on my poor programming skills, my"guess" is as follows: ::)
The threads as straight line segments NOT arcs, so the resolution is how closely the length of many straight line paths  would be fitting inside / outside of 360 degrees of a diameter.

Thanks Rich,
actually I am not trying to cut thread, I want to cut a cone hole of 1.75" large side at high of 0.5" at angle 2.
I can't find any way in Mach3 to do it.
would you please lead me some new ideas?
Best
Adam

Title: Re: Macro, Thread milling NPT thread, Inside/outside
Post by: RICH on June 06, 2017, 05:56:18 PM
You will need A CAD/CAM program to generate the code. Cambam, Fusion 360, there are others.
Enjoy the learning curve.

RICH
Title: Re: Macro, Thread milling NPT thread, Inside/outside
Post by: shanren on June 07, 2017, 08:34:18 AM
You will need A CAD/CAM program to generate the code. Cambam, Fusion 360, there are others.
Enjoy the learning curve.

Thank you very much Rich, I don't have a CAM yet, I'll try. Just wonder if any body can help?
Adam
Title: Re: Macro, Thread milling NPT thread, Inside/outside
Post by: BR549 on December 08, 2017, 10:38:22 AM
IF you set teh resolution close enough you can machine a taper hole or a cone. Just bare in mine that it cannot remove teh excess material and you have to account for that in cutting the feature