1341
VB and the development of wizards / Re: macro for 4 slot tool change hep
« on: April 25, 2019, 06:08:47 AM »
here a new Version.
-all debug code deleted (faster Operation)
-Input 23 now used to stop reverse run
-after finish re check and retry
-all debug code deleted (faster Operation)
-Input 23 now used to stop reverse run
-after finish re check and retry
Code: [Select]
OldTool = GetCurrentTool()
Tool = GetSelectedTool()
MaxToolNum = 4 'Max number of tools for the changer
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)
'//// 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
While GetCsmioIn(91,7) = True
Sleep(20)
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