1335
« on: April 26, 2019, 06:16:41 AM »
this would bo the complete code, with refernce check and X/Z move.
Public NewTool As Integer
Sub Main
'//Declarations
Dim StartTime, ActTime As Single
MaxToolNum = 4 'Max number of tools for the changer
OldTool = GetCurrentTool()
Tool = GetSelectedTool()
If OldTool = Tool Then
Message ("Selected Tool already loaded")
Exit Sub
End If
If Tool > MaxToolNum Then
Tool = Question ("Enter New Tool Number up to " & MaxToolNum)
End If
'X-Axis not in reference
If GetOEMLED(807) Then
DoButton(3)
Sleep(500)
Message ("X-Axis not referenced -> Abort !!")
Exit Sub
End If
'Z-Axis not in reference
If GetOEMLED(809) Then
DoButton(3)
Sleep(500)
Message ("Z-Axis not referenced -> Abort !!")
Exit Sub
End If
Message "ATC X-Axis to TC position"
Code "G90 G53 G0 X2"
While IsMoving()
Sleep(15)
Wend
Message "ATC Z-Axis to TC position"
Code "G90 G53 G0 Z2"
While IsMoving()
Sleep(15)
Wend
doagain:
Call StartTool
While NewTool <> Tool
Call CheckPins
Wend
Call StopTool
're check
Call CheckPins
If NewTool <> Tool Then
GoTo doagain
End If
SetCurrentTool(NewTool)
End Sub
'//// Subroutines /////////
Sub StartTool
ActivateSignal(Output8)
End Sub
Sub CheckPins
If GetCsmioIn(91,6) = True Then
NewTool = 1
End If
If GetCsmioIn(91,5) = True Then
NewTool = 2
End If
If GetCsmioIn(91,4) = True Then
NewTool = 3
End If
If GetCsmioIn(91,3) = True Then
NewTool = 4
End If
End Sub
Sub Stoptool
DeActivateSignal(Output8)
ActivateSignal(Output9)
'wait for input 23 or timeout
StartTime = Timer
While GetCsmioIn(91,7) = False
Sleep(20)
ActTime = Timer
If ActTime > StartTime + 3 Then
DeActivateSignal(Output9)
MsgBox "Timeout Input23!!"
DoButton(3)
Sleep(300)
Exit Sub
End If
Wend
DeActivateSignal(Output9)
End Sub
'CSMIO Eingang lesen
Function GetCsmioIn (ByVal adr As Integer, ByVal n As Integer) As Boolean
If(GetInBit(adr, n)) Then
GetCsmioIn = true
Else
GetCsmioIn = false
End If
End Function
IMPORTANT:
it will move first X than Z axis!
the values of this two code lines:
Code "G90 G53 G0 X2"
Code "G90 G53 G0 Z2"
are in machine coord's and maybe Need to be adjusted.