585,981 active members*
4,093 visitors online*
Register for free
Login
Results 1 to 5 of 5
  1. #1

    Thumbs up ATC Macro works 95% of the time

    Hi, I have written a m6start macro for my carousel type tool changer.

    It works flawlessly 95% of the time but unfortunately rarely grabs a tool 1 position out.

    Here is a copy of the macro.

    ANY help would be muchly apreciated.

    any questions about my macro im happy to answer.


    Sub Main()
    OldTool = GetCurrentTool() 'Tool In spindle DRO You must add this to your settings screen
    NewTool = GetSelectedTool()
    Z_changePos = -122 'z change position
    Z_safePos = 0
    MaxToolNum = 21 'Max number off tools for the changer
    If NewTool = OldTool Then
    Exit Sub 'exit if tool as same selected
    End If

    code "M5"

    If OldTool >= MaxToolNum Then
    Code "G00 G53 Z" & Z_safePos 'move z to carriage engage height
    While IsMoving()
    Wend
    MsgBox " Please remove TOOL #" & OldTool & Chr(13) & " Then press OK to Continue"
    OldTool = question ("Please enter current Tool carriage position then press OK to CYCLE START")
    GoTo spindlecheck
    End If


    chuckCheck:

    If IsActive(input2) = IsActive(input3) Then
    Code "G00 G53 Z" & Z_safePos 'move z to carriage engage height
    While IsMoving()
    Wend 'wait until its moved
    Else
    If IsActive(input2)=0 = IsActive(input3) Then
    code "G00 G53 Z" & Z_changePos
    While IsMoving()
    Wend
    End If
    End If


    spindlecheck:

    If IsActive(input4) Then 'check spindle rotation input
    GoTo engage
    Else
    GoTo spindleAlign
    End If

    spindleAlign:

    code "M3 S60" 'correct spindle rotation
    While IsActive(input4)=0
    Wend
    code "M5"
    sleep(2000)
    GoTo spindlecheck

    engage:

    SetOutBit(100,2) 'engage tool carriage
    sleep(100)
    ResetOutBit(100,2)
    sleep(100)
    While GetInBit(100,1)=0
    Wend 'wait for engagement
    sleep(100)

    SetOutBit(100,6) 'engage power tool bar / tool release
    While GetInBit(100,3)=0
    Wend 'wait for draw bar engaged / tool released

    Code "G53 Z" & Z_safePos 'move z to tool carriage spin height
    Code "G4 P.75"
    While IsMoving() 'wait for z to move
    Wend

    If NewTool >= MaxToolNum Then
    GoTo NewTooltoobig
    End If


    CWPos = NewTool - OldTool 'calculate CW distance
    If CWPos < 0 Then
    CWPos = CWPos + MaxToolNum
    End If 'invert number if minus

    CCWPos = MaxToolNum - CWPos 'calculate CCW distance

    If CWPos < CCWPos Then 'take shortest distance
    GoTo CW
    Else
    GoTo CCW
    End If 'goes to CW or CCW script

    CW: 'CW count sequence
    moved1 = 0

    starting1:
    SetOutBit(100,5)
    sleep(50)
    While IsActive(input1)
    Wend
    sleep(20)
    While IsActive(input1)=0
    Wend
    moved1 = moved1+1
    ResetOutBit(100,5)
    If CWPos = moved1 Then
    While IsActive(input1)=0
    Wend
    GoTo finish
    Else
    GoTo starting1
    End If 'end CW count sequence

    CCW: 'CCW count sequence
    moved2 = 0

    starting2:
    SetOutBit(100,4)
    sleep(50)
    While IsActive(input1)
    Wend
    sleep(20)
    While IsActive(input1)=0
    Wend
    moved2 = moved2+1
    ResetOutBit(100,4)
    If CCWPos = moved2 Then
    While IsActive(input1)=0
    Wend
    GoTo finish
    Else
    GoTo starting2
    End If 'end CCW count sequence

    NewTooltoobig:

    SetOutBit(100,3) 'disengage tool carriage
    sleep(100)
    ResetOutBit(100,6)
    While IsActive(input3)
    Wend 'disengage power draw bar / tool clamp
    ResetOutBit(100,3)
    sleep(100)
    While GetInBit(100,0)=0
    Wend 'wait for disengagement
    sleep(100)
    MsgBox " Please insert TOOL #" & NewTool & Chr(13) &" Then press OK to CYCLE START"
    sleep(500)
    SetCurrentTool(NewTool)
    GoTo theveryend


    finish:

    Code "G00 G53 Z" & Z_changePos 'move z to carriage engage height
    While IsMoving()
    Wend

    ResetOutBit(100,6) 'disengage draw bar
    sleep(600)
    If IsActive(input2) = IsActive(input3) Then 'check for good tool clamp
    DoOEMButton(1021)
    SetCurrentTool(NewTool) 'reset mach and give fail message
    MsgBox "TOOL CLAMP FAILURE "
    Exit Sub
    End If

    SetCurrentTool(NewTool) 'changes current tool DRO

    SetOutBit(100,3) 'disengage tool carriage
    sleep(100)
    ResetOutBit(100,3)
    sleep(100)
    While GetInBit(100,0)=0
    Wend 'wait for disengagement
    sleep(100)

    theveryend:
    SetCurrentTool(NewTool)
    code "G43"
    sleep(250)
    End Sub

    Thanks very much in advance!

    Ben Smith

  2. #2

    Re: ATC Macro works 95% of the time

    Im thinking my proximity sensor on the carosel might be just on the borderline of detecting the moves. Ill try move it a tiny bit closer and see if it fixes the problem

  3. #3

    Re: ATC Macro works 95% of the time

    ok its not the proximity sensor

  4. #4
    Join Date
    Apr 2016
    Posts
    1

    Re: ATC Macro works 95% of the time

    Is it? sorry! the english bad.
    Click image for larger version. 

Name:	images.jpg 
Views:	2 
Size:	7.6 KB 
ID:	324912

  5. #5

    Re: ATC Macro works 95% of the time

    yes thats it

Similar Threads

  1. Replies: 0
    Last Post: 05-01-2013, 05:00 PM
  2. M6 Command only works one time now with new computer setup
    By jevs in forum Mach Software (ArtSoft software)
    Replies: 1
    Last Post: 02-14-2013, 06:53 AM
  3. Retrieve machining time macro
    By Thomas Mantz. in forum UG NX
    Replies: 4
    Last Post: 05-11-2012, 02:15 PM
  4. Custom Macro for Finding Cycle time
    By yaji63 in forum G-Code Programing
    Replies: 8
    Last Post: 02-08-2011, 04:58 AM
  5. cycle time macro program
    By mcash3000 in forum CNC (Mill / Lathe) Control Software (NC)
    Replies: 1
    Last Post: 03-29-2006, 07:33 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
  •