Hello Guest it is March 29, 2024, 11:30:50 AM

Author Topic: Lathe tool turret macro  (Read 901 times)

0 Members and 1 Guest are viewing this topic.

Lathe tool turret macro
« on: April 20, 2021, 10:06:37 AM »
I am having some trouble getting my Lathe's tool change macro to work. Any help would be appreciated.
 System(s):
 (1) Computer: Dell Optiplex 780, Windows 7 64bit home, 4gb Ram, 250gb Solid State HardDrive, intel core duo 3ghz processor. Using Mach3.
 (2) External Motion Controller: Warp9's Smooth stepper, With C25S - Dual Port SmoothStepper Board(Push Lock Terminals) Breakout board, and 5vdc 1amp power supply.
 (3) Machine: Retrofit Lablond cnc lathe, With Gecko Drives and Automatic tool turret(Which is where my problem is).

Problem(s):
 (1): After entering M6T(Tool Number (ex.M6T3)) Mach 3 clears the current tool and then asks me to enter current tool and then desired tool.
 (2): After tool change is complete, the tool current tool is updated but the offsets are not.

The tool turret is a simple 4 station mechanical one that uses CW to rotate one tool position and then CCW to lock it into place, the process is repeated until the desired tool  is reached.

The Macro I have been using is one I found on this forum and then modified slightly to fit my needs.

'Tool change macro for 4 tool turret
Sub Main()
   'Sets variable OldTool to what is currently loaded
   OldTool=GetCurrentTool()
   
   'Sets Variable MaxToolNum to the max number of tools possible
   MaxToolNum=4
   
   'Sets variable Newtool to the one being selected with M6 T#
   tool = GetSelectedTool()
        NewTool = tool   
   
   'Get positions before moving to do tool change
   x = GetToolChangeStart( 0 )
   y = GetToolChangeStart( 1 )
   z = GetToolChangeStart( 2 )
   a = GetToolChangeStart( 3 )
   b = GetToolChangeStart( 4 )
   c = GetToolChangeStart( 5 )
   
   'If the current tool loaded is 0 or greater than 4 then tool has been lost
   'so need to ask what tool is currently loaded
   While OldTool=0 Or OldTool>4
   OldTool=Question ("Current tool unknown, enter tool in spindle 1 to " & MaxToolNum)
   Wend
   
   'Sets CurrentTool to Oldtool in case it was lost and entered above
   SetCurrentTool(OldTool)

   'When the tool asked for is invalid then this makes you select a valid tool
   While NewTool > MaxToolNum Or NewTool <1
   NewTool = Question ("Invalid tool chosen, enter tool number 1 to " & MaxToolNum)
   Wend
   
        'If the tool asked for is the same one that is already loaded then exit macro
   If NewTool=OldTool Then
   Message "Tool already loaded or tool not specified with T# (ex:M6 T4)"
      Exit Sub
   End If

'Turn off soft limits if they are on
If GetOEMLED(23) Then
DoOEMButton(119)
End If

'Sets ChangeNums to 0 for safety in case it is not at 0
ChangeNums=0

'Makes the magic happen and moves the proper number of times if new tool is higher than old
If NewTool>OldTool Then
   For ChangeNums=1 To NewTool-OldTool
   
   'Moves Z axis to the top of tool change
   ActivateSignal(Output2)
   Sleep 3000
   DeActivateSignal(Output2)
   Sleep 500

   'Moves back to bottom of tool change area
   ActivateSignal(Output3)
   Sleep 2000
   DeActivateSignal(Output3)
   Sleep 500
   
   Next
   
'Makes the magic happen and moves the proper number of times if new tool is lower than old   
Else
   For ChangeNums=(OldTool-NewTool) To 3
   
   'Moves Z axis to the top of tool change
   ActivateSignal(Output2)
   Sleep 3000
   DeActivateSignal(Output2)
   Sleep 500


   'Moves back to bottom of tool change area
   ActivateSignal(Output3)
   Sleep 2000
   DeActivateSignal(Output3)
   Sleep 500

   Next
End If
   
'Should be a succesful tool change at this point so this sets the NewTool as the current tool
SetCurrentTool(NewTool)

'Turn back on soft limits
DoOEMButton(119)
End Sub           

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: Lathe tool turret macro
« Reply #1 on: April 20, 2021, 12:09:38 PM »
on a lathe toolchange is started by f.e.  M6TXXYY (T0203) for tool 2 offset 3.

then it should not and set the Offsets.
 
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: Lathe tool turret macro
« Reply #2 on: April 20, 2021, 04:19:24 PM »
Thank You so much, I have been working on this problem for the last few days. Your fix really made my day.
 

Offline fast89

*
  •  154 154
    • View Profile
Re: Lathe tool turret macro
« Reply #3 on: April 23, 2021, 07:19:15 PM »
I don't put m6 in my programs. Just T0101 and the macro does the changing.