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
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
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