584,842 active members*
4,506 visitors online*
Register for free
Login
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2006
    Posts
    670

    Lathe turret macro

    Hi guys, I'm currently building a turret for my lathe and could use some help with the macro. It's a ratchet type turret which indexes and backs up onto the ratchet. Any ways, i'm not good at coding at all and could use some help. I've saved the following code to the M6start macro but I get a compile error anytime I try to do a tool change. I have no idea what's wrong and could use another set of eyes on it. Any help would be greatly appreciated.


    Dim Num_Tools As Integer
    Dim Ang_Move As Integer
    Dim Req_Tool As Integer
    Dim Current_Tool As Integer
    Dim Lock_Move As Integer
    Dim CW_Feed As Integer
    Dim CCW_Feed As Integer
    Dim Moves As Integer


    Num_Tools = 12 'number of tools on turret
    Ang_Move = 360/Num_Tools 'angular rotation per tool
    Req_Tool = GetSelectedTool()
    Current_Tool = GetCurrentTool()
    Lock_Move=15 'distance to move back onto paw to lock
    CW_Feed=100
    CCW_Feed=50

    'Start tool change

    If Req_Tool < 1 Then
    Message"Tool number too low"
    Code "M30"
    End If

    If Req_Tool = Current_Tool Then
    'do nothing
    Else
    'do tool change
    If Req_Tool > Current_Tool Then Moves = (Req_Tool - Current_Tool) * Ang_Move
    Else
    If Req_Tool < Current_Tool Then Moves = (Num_Tools - Current_Tool + Req_Tool) * Ang_Move
    End If

    'move to safe position
    Code "G0 G53 X-.25 Z-.25"
    Code "G04 P0.5"
    'index turret
    Code "G91 G94"
    Code "G01 A" & Moves + 10 & "F" & CW_Feed
    Code "G01 A-" & Lock_Move & "F" & CCW_Feed
    While IsMoving()
    Sleep(10)
    Wend

    SetCurrentTool Req_Tool
    SetUserDRO 1500 , Req_tool
    Code "G90"
    Code "F" & Current_Feed

  2. #2
    Join Date
    Aug 2006
    Posts
    670

    Re: Lathe turret macro

    for anyone interested here's the working code:


    Dim Num_Tools As Integer
    Dim Ang_Move As Integer
    Dim Req_Tool As Integer
    Dim Current_Tool As Integer
    Dim Lock_Move As Integer
    Dim CW_Feed As Integer
    Dim CCW_Feed As Integer
    Dim Moves As Integer


    Num_Tools = 12 'number of tools on turret
    Ang_Move = 360/Num_Tools 'angular rotation per tool
    Req_Tool = GetSelectedTool()
    Current_Tool = GetCurrentTool()
    Lock_Move = 15 'distance to move back onto paw to lock
    CW_Feed = 100
    CCW_Feed = 50

    'Start tool change

    If Req_Tool < 1 Then
    Message"Tool number too low"
    Code "M30"
    End If

    If Req_Tool = Current_Tool Then
    'do nothing
    Else
    'do tool change
    If Req_Tool > Current_Tool Then
    Moves = (Req_Tool - Current_Tool) * Ang_Move
    End If
    If Req_Tool < Current_Tool Then
    Moves = (Num_Tools - Current_Tool + Req_Tool) * Ang_Move
    End If
    End If

    'move to safe position
    Code "G0 G53 X-.25 Z-.25"
    Code "G04 P0.5"
    'index turret
    Code "G91 G94"
    Code "G01 A" & Moves + 10 & "F" & CW_Feed
    Code "G01 A-" & Lock_Move & "F" & CCW_Feed
    While IsMoving()
    Sleep(10)
    Wend

    SetCurrentTool Req_Tool
    SetUserDRO 1500 , Req_tool
    Code "G90"
    Code "F" & Current_Feed

Similar Threads

  1. Replies: 7
    Last Post: 03-01-2019, 06:30 PM
  2. Converting my Engine Lathe to an 8-Station Turret Lathe!
    By widgitmaster in forum Uncategorised MetalWorking Machines
    Replies: 95
    Last Post: 08-09-2018, 04:56 PM
  3. Macro for turret toolchanger needed for boxford TCL
    By richmond in forum Mach Wizards, Macros, & Addons
    Replies: 4
    Last Post: 05-28-2017, 01:00 PM
  4. Replies: 2
    Last Post: 12-19-2012, 01:28 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •