1
General Mach Discussion / Re: In the Mach3Turn, how to get the lenght offset?
« on: December 31, 2008, 01:50:19 AM »
In order to help more people, I post my auto tool changer code, hope you can help!
'** File Name: M6Start.m1s
'** Created By: Edison_Pan
'** Created date: 2008-12-1
'** Version: 1.0
'** Descriptions: First version
Option Explicit
'Declaraciones
Const MaxToolNum = 4 'Max number of tools for the changer
Const CCWTime = 3
Const ChangTime = 10
Const T1 = Input1
Const T2 = Input2
Const T3 = Input3
Const T4 = Input4
Const CW = Output5
Const CCW = Output6
Dim OldTool,Tool,NewTool
Dim Tim
OldTool = GetOEMDRO (1111)
Tool = GetSelectedTool()
If OldTool = Tool Then
Message ("Selected Tool already loaded")
Exit Sub
End If
While Tool > MaxToolNum
Tool = Question ("Tool Error, Tool number to large Enter new tool number")
Wend
Call StartTool
SetTimer(1)
While NewTool <> Tool
Call CheckPins
While IsMoving()
Sleep(10)
Wend
Tim=GetTimer(1)
If Tim > ChangTime Then
DoOEMButton(156)
DoOEMButton(1021)
Message ("Tool Error,time out")
Exit Sub
End If
Wend
Call StopTool
Call SetUserDRO (1200, NewTool)
SetCurrentTool(NewTool)
'Code "G43 H" & NewTool
'Subroutines
Sub StartTool
ActivateSignal(CW)
While IsMoving()
Sleep(10)
Wend
End Sub
Sub CheckPins
If IsActive(T1) Then
NewTool = 1
End If
If IsActive(T2) Then
NewTool = 2
End If
If IsActive(T3) Then
NewTool = 3
End If
If IsActive(T4) Then
NewTool = 4
End If
End Sub
Sub Stoptool
DeActivateSignal(CW)'Stop the toolchange
While IsMoving()
Sleep(5)
Wend
Sleep(1000)
ActivateSignal(CCW) 'Lock tool
Code "G4 P" & CCWTime 'Lock time
While IsMoving()
Sleep(5)
Wend
DeActivateSignal(CCW)'Turn off the Lock
While IsMoving()
Sleep(5)
Wend
End Sub
'** File Name: M6Start.m1s
'** Created By: Edison_Pan
'** Created date: 2008-12-1
'** Version: 1.0
'** Descriptions: First version
Option Explicit
'Declaraciones
Const MaxToolNum = 4 'Max number of tools for the changer
Const CCWTime = 3
Const ChangTime = 10
Const T1 = Input1
Const T2 = Input2
Const T3 = Input3
Const T4 = Input4
Const CW = Output5
Const CCW = Output6
Dim OldTool,Tool,NewTool
Dim Tim
OldTool = GetOEMDRO (1111)
Tool = GetSelectedTool()
If OldTool = Tool Then
Message ("Selected Tool already loaded")
Exit Sub
End If
While Tool > MaxToolNum
Tool = Question ("Tool Error, Tool number to large Enter new tool number")
Wend
Call StartTool
SetTimer(1)
While NewTool <> Tool
Call CheckPins
While IsMoving()
Sleep(10)
Wend
Tim=GetTimer(1)
If Tim > ChangTime Then
DoOEMButton(156)
DoOEMButton(1021)
Message ("Tool Error,time out")
Exit Sub
End If
Wend
Call StopTool
Call SetUserDRO (1200, NewTool)
SetCurrentTool(NewTool)
'Code "G43 H" & NewTool
'Subroutines
Sub StartTool
ActivateSignal(CW)
While IsMoving()
Sleep(10)
Wend
End Sub
Sub CheckPins
If IsActive(T1) Then
NewTool = 1
End If
If IsActive(T2) Then
NewTool = 2
End If
If IsActive(T3) Then
NewTool = 3
End If
If IsActive(T4) Then
NewTool = 4
End If
End Sub
Sub Stoptool
DeActivateSignal(CW)'Stop the toolchange
While IsMoving()
Sleep(5)
Wend
Sleep(1000)
ActivateSignal(CCW) 'Lock tool
Code "G4 P" & CCWTime 'Lock time
While IsMoving()
Sleep(5)
Wend
DeActivateSignal(CCW)'Turn off the Lock
While IsMoving()
Sleep(5)
Wend
End Sub