threading macro help

Moderators: TomKerekes, dynomotion

turbothis
Posts: 325
Joined: Fri Mar 15, 2019 4:07 pm
Location: southern oregon

threading macro help

Post by turbothis » Mon Jan 22, 2024 5:36 pm

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
Attachments
macro.JPG

User avatar
TomKerekes
Posts: 2676
Joined: Mon Dec 04, 2017 1:49 am

Re: threading macro help

Post by TomKerekes » Mon Jan 22, 2024 6:17 pm

I think at the end instead of always moving Z back to 0 move to #10
Regards,

Tom Kerekes
Dynomotion, Inc.

turbothis
Posts: 325
Joined: Fri Mar 15, 2019 4:07 pm
Location: southern oregon

Re: threading macro help

Post by turbothis » Mon Jan 22, 2024 7:08 pm

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



turbothis
Posts: 325
Joined: Fri Mar 15, 2019 4:07 pm
Location: southern oregon

Re: threading macro help

Post by turbothis » Mon Jan 22, 2024 7:15 pm

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

User avatar
TomKerekes
Posts: 2676
Joined: Mon Dec 04, 2017 1:49 am

Re: threading macro help

Post by TomKerekes » Mon Jan 22, 2024 9:21 pm

GCode trigonometric function parameters are in degrees not radians.
Regards,

Tom Kerekes
Dynomotion, Inc.

turbothis
Posts: 325
Joined: Fri Mar 15, 2019 4:07 pm
Location: southern oregon

Re: threading macro help

Post by turbothis » Mon Jan 22, 2024 9:36 pm

i figured there would be something like this way over my head!

User avatar
TomKerekes
Posts: 2676
Joined: Mon Dec 04, 2017 1:49 am

Re: threading macro help

Post by TomKerekes » Mon Jan 22, 2024 9:59 pm

Just remove the * 0.0174533 (PI/180) which is converting from degrees to radians
Regards,

Tom Kerekes
Dynomotion, Inc.

turbothis
Posts: 325
Joined: Fri Mar 15, 2019 4:07 pm
Location: southern oregon

Re: threading macro help

Post by turbothis » Mon Jan 22, 2024 11:46 pm

ok
what is the (PI/180) ?

Moray
Posts: 288
Joined: Thu Apr 26, 2018 10:16 pm

Re: threading macro help

Post by Moray » Tue Jan 23, 2024 12:04 am

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.

turbothis
Posts: 325
Joined: Fri Mar 15, 2019 4:07 pm
Location: southern oregon

Re: threading macro help

Post by turbothis » Tue Jan 23, 2024 1:09 am

oh boy i made it angry again
Attachments
Capture.JPG

Post Reply