291
VB and the development of wizards / Re: ATC FOR CINCINNATI MILL
« on: January 21, 2022, 11:45:30 AM »
is OEMTRIGGER(11) on or off if the carousel is in position for locking?
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.
''Sequence to determine the least travel to move for TC, CW or CCW
'atp = Actual tool position, rtp = Requested tool positon
'Sub LeastTravel()
NewTool = GetSelectedTool()
OldTool = GetCurrentTool()
NewTool = 10
OldTool = 12
NTool =24 ' Number of tools changer holds
CWPos = NewTool - OldTool ' Assume a CW move
If CWPos < 0 Then ' CWPos < 0 ==> rtp < atp
CWPos = CWPos + NTool
End If
CCWPos = NTool - CWPos
If CWPos < CCWPos Then
Call CW(CWPos)
Else
Call CCW(CCWPos)
End If
'End Sub
Function CW(ByVal Pos As Integer)'Rotation CW
Dim x As Integer
ActivateSignal(OUTPUT16)'UnLock Pin
While IsActive(OEMTRIG12)
Wend
ActivateSignal(OUTPUT15)'Turns Carousel CW
For x=1 To Pos
While IsActive(OEMTRIG11)
Sleep(50)
Wend
While Not IsActive(OEMTRIG11)
Sleep(50)
Wend
Next x
CTPos=x
DeactivateSignal(OUTPUT15)
Deactivatesignal(OUTPUT16)
End Function
Function CCW(ByVal Pos as Integer)'Rotation CCW
Dim y As Integer
ActivateSignal(Output16)'UnLock Pin
While IsActive (OEMTRIG12)
Wend
Activatesignal(OUTPUT14)'Turn Carousel CCW
For y=1 To Pos
While IsActive(OEMTRIG11)
Sleep(50)
Wend
While Not IsActive(OEMTRIG11)
Sleep(50)
Wend
Next y
DeactivateSignal(OUTPUT14)
Deactivatesignal(OUTPUT16)
End Function
'get new tool number
newtool = GetSelectedTool()
'select Offset by toolnumber
If newtool = 1 Then
Code "G54"
End If
If newtool = 2 Then
Code "G55"
End If
If newtool = 3 Then
Code "G56"
End If
If newtool = 4 Then
Code "G57"
End If
If newtool = 5 Then
Code "G58"
End If
If newtool = 6 Then
Code "G59"
End If
If newtool = 7 Then
Code "G59P7"
End If
SetCurrentTool(newtool)
Code "G43H" 6 newtool
'get new tool number
newtool = GetSelectedTool()
'select Offset by toolnumber
If newtool = 1 Then
Code "G54"
End If
If newtool = 2 Then
Code "G55"
End If
If newtool = 3 Then
Code "G56"
End If
If newtool = 4 Then
Code "G57"
End If
If newtool = 5 Then
Code "G58"
End If
If newtool = 6 Then
Code "G59"
End If
If newtool = 7 Then
Code "G59P7"
End If