Hello Guest it is March 28, 2024, 02:23:34 PM

Author Topic: ATC Macro works 95% of the time  (Read 3121 times)

0 Members and 1 Guest are viewing this topic.

ATC Macro works 95% of the time
« on: June 24, 2016, 07:31:21 AM »
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 ??? ???
 
Re: ATC Macro works 95% of the time
« Reply #1 on: June 24, 2016, 07:45:13 AM »
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
Re: ATC Macro works 95% of the time
« Reply #2 on: June 25, 2016, 03:38:18 AM »
ok its not the proximity sensor :(