Mach3 - rigid tapping and multipass

Forum for Discussing Mach3/4 related issues

Mach3 - rigid tapping and multipass

Postby Olivier-CNC » Mon Apr 21, 2025 10:15 am

I have two questions for rigid tapping with Mach3 :

1) Using this Rigid tapping macro :

Code: Select all
SetUserDRO(1200, Param1())   'P parameter = Z end
SetUserDRO(1201, Param2())   'Q parameter = pitch
NotifyPlugins(10200)      'Load parameter
SetUserDRO(1202, 0)         'Start Rigid tapping
While(GetUserDRO(1202) = 0)   'Wait for finish rigid tapping
   Sleep(50)
   NotifyPlugins(10201)
Wend 


How to do multipass tapping ? is there a third hidden R parameter for multipass ?

Or do i need to implement multipass myself in the macro ?


2) How is managed M3 and M4 commands ? Are they sent automatically from the plugin ?

Thanks for helping.
Olivier-CNC
 
Posts: 13
Joined: Sat Jun 25, 2022 2:43 pm

Re: Mach3 - rigid tapping and multipass

Postby cncdrive » Wed Apr 23, 2025 8:12 pm

Multipass is not implemented in that macro, you have to implement it yourself.
Or you can try UCCNC, it can do rigid tapping with multi passes.
cncdrive
Site Admin
 
Posts: 5163
Joined: Tue Aug 12, 2014 11:17 pm

Re: Mach3 - rigid tapping and multipass

Postby Olivier-CNC » Thu Apr 24, 2025 10:00 am

Thanks.

Spindle direction and control is not clear for me. I have two questions here :

1) How to choose CW or CCW tapping ?

Do we need to start the spindle with M3 or M4 before calling the NotifyPlugins(10200) function ? Then the plugin reverse direction at Zend ?

2) Is it possible to change spindle speed for retracts ? For retracts, it is common to choose a faster spindle speed to save time, 4 times faster is a common value.


Here is a Rigid Tapping macro i wrote with R parameter for multipass tapping. Let me know if i'm right. To test this macro i disabled the plugin code, because my spindle encoder is not yet ready to test that on the machine. Then it is not fully tested yet.

If someone can test it i would be interested to know the results.

There is some code inside to avoid running the macro if another one was running before. This is a protection i use inside my macros to limit crashes if another macro did not end correctly. This is especially useful during testing to check that there is no runaway macros.


Code: Select all
Option Explicit

Const RunningMacroLED = 1242 ' Modify according to screenset

Sub Main()

'Rigid Tapping Macro - CNCDrive - Olivier ADLER 2025

'P parameter = Z end
'Q parameter = pitch (positive number)
'P & Q parameters must be specified for each successive tapping

'R parameter = pass depth for multipass tapping (must be a positive number)

'R parameter is permanent until mach3 restart (does not need to be specified for each succesive tapping)
'Use R0 to set back single pass tapping


'-----------------------------------------------------------------------------
'//////// Variables
'-----------------------------------------------------------------------------

Dim Multipass, MultipassDepth, Zend, Z_Axis_Pos, ZDepth, OtherMacroRunning


'-----------------------------------------------------------------------------
'//////// Pre processing
'-----------------------------------------------------------------------------

Message "" 'Clear message line

If GetUserLED(RunningMacroLED) Then 'If User LED 1242 is on, another macro is runing, take measures

   If Question ("Another macro is running, enter 1 to force execution") = 0 Then
      If Question ("Enter 1 to clear the macro runnning LED") = 1 Then
         SetUserLED(RunningMacroLED,0) 'Clear the macro runnning indicator LED
      End If
      Message "Another macro is running, exiting !"
      Exit Sub
   End If
   OtherMacroRunning = 1

End If

If param2() <= 0 Then 'if Q parameter is not a positive value then exit macro
   MsgBox ("Parameter Q must be a positive value, exiting macro")
   Exit Sub
End If

If param1() = -1 Then 'P parameter is probably not defined, ask and exit macro (-1 value is the default for unset parameters)
   If Question ("Enter 1 to confirm P : Z end = -1, or 0 to exit macro") = 0 Then
      Exit Sub
   End If
End If

Z_Axis_Pos = GetOEMDRO(186)
If param1() > (Z_Axis_Pos - param2())  Then 'Zend is higher than Z axis position or thread with less than one turn, exit macro
MsgBox ("Zend is higher than Z axis position or thread with less than one turn, exit macro")
      Exit Sub
End If

If param3() > 0 Then 'If R parameter is defined then enable multipass mode
   Multipass = 1
   MultipassDepth = param3()
   Message "Multipass Tapping"
End If


SetUserLED(RunningMacroLED,1) 'Enable the macro runnning indicator LED


'-----------------------------------------------------------------------------
'//////// Processing
'-----------------------------------------------------------------------------

If Multipass = 0 Then

   SetUserDRO(1200, Param1())   'P parameter = Z end
   SetUserDRO(1201, Param2())   'Q parameter = pitch
   Sleep (250) 'Could be necessary
   NotifyPlugins(10200)      'Load parameter
   SetUserDRO(1202, 0)         'Start Rigid tapping
   While(GetUserDRO(1202) = 0)   'Wait for finish rigid tapping
      Sleep(50)
      NotifyPlugins(10201)
   Wend

Else 'Multipass Tapping
   Zend = Param1() 'P parameter = Z end
   
   ZDepth = Z_Axis_Pos - MultipassDepth
   If ZDepth < Zend Then
      ZDepth = Zend
   End If
   
   
   'SetUserDRO(1201, Param2())   'Q parameter = pitch
   Do

      SetUserDRO(1200, ZDepth)   'P parameter = pitch
      Sleep (250) 'Could be necessary
      NotifyPlugins(10200)      'Load parameter
      SetUserDRO(1202, 0)         'Start Rigid tapping
      While(GetUserDRO(1202) = 0)   'Wait for finish rigid tapping
         Sleep(50)
         NotifyPlugins(10201)
      Wend
      Sleep(250)      

      'MsgBox ("ZDepth= " & ZDepth)

      If ZDepth <= (Zend + 0.0001) Then
         Exit Do
      End If
      ZDepth = ZDepth - MultipassDepth
      If ZDepth < Zend Then
         ZDepth = Zend
      End If
      
   Loop While(ZDepth >= Zend)
   
End If

Sleep (250)
MsgBox ("P =" & param1() & " Q =" & param2() & " R =" & param3() & " Multipass =" & Multipass)

'-----------------------------------------------------------------------------
'//////// Post Processing
'-----------------------------------------------------------------------------

If OtherMacroRunning = 0 Then
   SetUserLED(RunningMacroLED,0) 'Disable the macro runnning indicator LED
Else
   If Question ("Another macro was running, enter 1 to clear the macro runnning LED") = 1 Then
      SetUserLED(RunningMacroLED,0) 'Disable the macro runnning indicator LED
   End If
End If

End Sub 'End Main Sub

Olivier-CNC
 
Posts: 13
Joined: Sat Jun 25, 2022 2:43 pm


Return to Mach3/4 Discussions

Who is online

Users browsing this forum: No registered users and 2 guests