1331
General Mach Discussion / Re: Spindle Relay Configuration Questions
« on: May 02, 2019, 04:05:31 AM »
btw witch spindle Controller are you using?
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
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
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
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
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
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
MsgBox "Timeout Input23!!"
DeActivateSignal(Output9)
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
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
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
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
'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
GetVAR() is not a "legacy" function. It's the proper and only accurate way to read the trip point. And the majority of chinese controllers do not support it's use.