Hood
This is the code I hope some body can help.
Old_tool = GetCurrentTool()
New_Tool = GetSelectedTool()
If GetSelectedTool <1 Then 'If tool called is less than 1
MsgBox("Tool Out Of Range") 'show message
End 'End macro
End If
If GetSelectedTool >8 Then 'If selected tool is greater than 12
MsgBox("Tool Out Of Range") 'Show message
End 'End macro
End If
If GetselectedTool = GetCurrentTool Then 'If selected tool is the same as current tool then end macro
End
End If
If GetSelectedTool=1 Then 'If selected tool = 1
Do 'Start loop
Call ActivateSignal(output4) 'start turret indexing
If IsActive(Input1) And Not IsActive(Input2) And Not IsActive(Input3) And Not IsActive(Input4) Then Exit Do 'Correct tool in position signal from PLC and exit loop
Loop 'Continue loop if above signal is not present
End If
Call DeActivateSignal(OutPut4) 'Stops turret Indexing
If GetSelectedTool=2 Then
Do
Call ActivateSignal(output4)
If IsActive(Input1) And IsActive(Input2) And Not IsActive(Input3) And Not IsActive(Input4) Then Exit Do
Loop
End If
Call DeActivateSignal(OutPut4)
If GetSelectedTool=3 Then
Do
Call ActivateSignal(output4)
If Not IsActive(Input1) And IsActive(Input2) And Not IsActive(Input3) And Not IsActive(Input4) Then Exit Do
Loop
End If
Call DeActivateSignal(OutPut4)
If GetSelectedTool=4 Then
Do
Call ActivateSignal(output4)
If Not IsActive(Input1) And IsActive(Input2) And IsActive(Input3) And Not IsActive(Input4) Then Exit Do
Loop
End If
Call DeActivateSignal(OutPut4)
If GetSelectedTool=5 Then
Do
Call ActivateSignal(output4)
If Not IsActive(Input1) And Not IsActive(Input2) And IsActive(Input3) And Not IsActive(Input4) Then Exit Do
Loop
End If
Call DeActivateSignal(OutPut4)
If GetSelectedTool=6 Then
Do
Call ActivateSignal(output4)
If Not IsActive(Input1) And Not IsActive(Input2) And IsActive(Input3) And IsActive(Input4) Then Exit Do
Loop
End If
Call DeActivateSignal(OutPut4)
If GetSelectedTool=7 Then
Do
Call ActivateSignal(output4)
If Not IsActive(Input1) And Not IsActive(Input2) And Not IsActive(Input3) And IsActive(Input4) Then Exit Do
Loop
End If
Call DeActivateSignal(OutPut4)
If GetSelectedTool=8 Then
Do
Call ActivateSignal(output4)
If IsActive(Input1) And Not IsActive(Input2) And Not IsActive(Input3) And IsActive(Input4) Then Exit Do
Loop
End If
Call DeActivateSignal(OutPut4)
CJ