2221
General Mach Discussion / Re: CNC Lathe turret tool changer help?
« on: October 09, 2015, 08:53:46 AM »
Hi,
found a mistake in my code:
copy and paste error
found a mistake in my code:
Code: [Select]
Sub Main()
' -------------------------------------------------------------------------------
' TPS 09.10.2015
' simple Test for Toolchange
' -------------------------------------------------------------------------------
' pin2 is mapped to Input1
' pin3 is mapped to Input2
' pin4 is mapped to Input3
' pin5 is mapped to Input4
'get the new tool ---------------------------------------------------------------
tool = GetSelectedTool()
' nothing to do
If GetSelectedTool() = GetCurrentTool() Then
message("Tool is the same NO tool change needed")
END
End If
Dim ActTurretPos as long
ActTurretPos = 0
Message "Moving to Tool# " &GetselectedTool()
ActivateSignal(OutPut6)
While ActTurretPos <> tool
ActTurretPos = GetTurret()
Wend
ActivateSignal(OutPut6)
Message("Tool " & tool & " Loaded")
SetCurrentTool( tool )
End Sub
'function to get the actual turret positiom
Function GetTurret() As Long
GetTurret = 0
If IsActive(Input1) Then
GetTurret = GetTurret + 1
End if
If IsActive(Input2) Then
GetTurret = GetTurret + 2
End if
If IsActive(Input3) Then
GetTurret = GetTurret + 4
End if
If IsActive(Input4) Then
GetTurret = GetTurret + 8
End if
End Function
copy and paste error