Page 1 of 2

threading macro help

Posted: Mon Jan 22, 2024 5:36 pm
by turbothis
chatbots got me mostly there but i cant get the Z increment on the start side of the cut

Code: Select all

( threading starts at Z zero )
G20 G18 
G00 X1.0 Z0.0  ( Clear plane )
M04 S500       ( Set spindle speed to 500 RPM )
G04 P3         ( Dwell for 3 seconds )

#1=[0.0025]    ( Depth of Cut  )
#2=[0.040]     ( Total depth of thread )
#3=[0.560]     ( Length of thread / start position )
#4=[0.0394]    ( Thread pitch / per rotation )
#5=[0.0025]    ( Increment for Z-axis per pass )

#9=0           ( DOC so far )
#10=0          ( Cumulative Z-axis movement )

M100

M98 P100 L[#2/#1]  ( Number of passes = total depth / DOC )
M2

O100
#9=[#9+#1]       ( Increment DOC )
#10=[#10+#5]     ( Increment cumulative Z-axis movement )
X-#9     
G32 Z[#3+#10] F#4
G0 X0.200 
Z0.0
M99

Re: threading macro help

Posted: Mon Jan 22, 2024 6:17 pm
by TomKerekes
I think at the end instead of always moving Z back to 0 move to #10

Re: threading macro help

Posted: Mon Jan 22, 2024 7:08 pm
by turbothis
excellent!

Code: Select all

( threading starts at Z zero )
G20 G18 
G00 X0.5 Z0.0  ( Clear plane )
M04 S500       ( Set spindle speed to 500 RPM )
G04 P3         ( Dwell for 3 seconds )

#1=[0.0025]    ( Depth of Cut  )
#2=[0.040]     ( Total depth of thread )
#3=[0.560]     ( Length of thread / start position )
#4=[0.0394]    ( Thread pitch / per rotation )
#5=[-0.0014]   ( Increment for Z-axis per pass )
               

#9=0           ( DOC so far )
#10=0          ( Cumulative Z-axis movement )

M100

M98 P100 L[#2/#1]  ( Number of passes = total depth / DOC )
M2





O100
X-#9     
#9=[#9+#1]       ( Increment DOC )
#10=[#10+#5]     ( Increment cumulative Z-axis movement )
G32 Z#3 F#4
G0 X0.200 
Z-#10            ( Increment cumulative Z-axis movement )
M99



Re: threading macro help

Posted: Mon Jan 22, 2024 7:15 pm
by turbothis
i had chatbot modify it further to make it more user friendly in that an angle can be directly input and the macro would do the math but i think it is too much as it does not work

Code: Select all

( threading starts at Z zero )
G20 G18 
G00 X0.5 Z0.0  ( Clear plane )
M04 S500       ( Set spindle speed to 500 RPM )
G04 P3         ( Dwell for 3 seconds )

#1=[0.0025]    ( Depth of Cut )
#2=[0.040]     ( Total depth of thread )
#3=[0.560]     ( Length of thread / start position )
#4=[0.0394]    ( Thread pitch / per rotation )
#6=[29]        ( Desired angle in degrees )

#9=0           ( DOC so far )
#10=0          ( Cumulative Z-axis movement )

( Calculate the Z increment based on the angle and DOC )
#5=[tan[#6 * 0.0174533] * #1]  ( Increment for Z-axis per pass )

M100

M98 P100 L[#2/#1]  ( Number of passes = total depth / DOC )
M2

O100
X-#9     
#9=[#9+#1]       ( Increment DOC )
#10=[#10+#5]     ( Increment cumulative Z-axis movement )
G32 Z#3 F#4
G0 X0.200 
Z-#10            ( Increment cumulative Z-axis movement )
M99

Re: threading macro help

Posted: Mon Jan 22, 2024 9:21 pm
by TomKerekes
GCode trigonometric function parameters are in degrees not radians.

Re: threading macro help

Posted: Mon Jan 22, 2024 9:36 pm
by turbothis
i figured there would be something like this way over my head!

Re: threading macro help

Posted: Mon Jan 22, 2024 9:59 pm
by TomKerekes
Just remove the * 0.0174533 (PI/180) which is converting from degrees to radians

Re: threading macro help

Posted: Mon Jan 22, 2024 11:46 pm
by turbothis
ok
what is the (PI/180) ?

Re: threading macro help

Posted: Tue Jan 23, 2024 12:04 am
by Moray
turbothis wrote:
Mon Jan 22, 2024 11:46 pm
ok
what is the (PI/180) ?
Pi/180 = 0.0174533
It's how you convert between Degrees and Radians.

Re: threading macro help

Posted: Tue Jan 23, 2024 1:09 am
by turbothis
oh boy i made it angry again