Author Topic: CNC Lathe turret tool changer help?  (Read 9518 times)

0 Members and 1 Guest are viewing this topic.

Offline TPS

  • Active Member
  • Posts: 1,133
    • View Profile
Re: CNC Lathe turret tool changer help?
« Reply #60 on: October 19, 2015, 08:55:10 AM »
Ok let's try and error

please change

    'look for OEMTRIG1
    If Not IsActive(OEMTRIG1) Then

to

    'look for OEMTRIG1
    If IsActive(OEMTRIG1) = False Then

should be the same put try please.

Thomas
anything is possible, just try it.
if you find some mistakes, in my bad bavarian english,they are yours.

herr schmeiß hirn vom himmel

Offline mike^3

  • Active Member
  • Posts: 117
    • View Profile
Re: CNC Lathe turret tool changer help?
« Reply #61 on: October 19, 2015, 09:01:28 AM »
WORKs!

Here Is my final code, I cant thank you enough! THANK YOU!

Sub Main()
' -------------------------------------------------------------------------------
' TPS 19.10.2015 
' Toolchange for a 8 place turret (single step)
' V 5.0.1
' -------------------------------------------------------------------------------

' pin2 is mapped to Input1
' pin3 is mapped to Input2
' pin4 is mapped to Input3
' pin5 is mapped to Input4
' charger seated is mapped to OEMTRIG1

'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
 
If  tool > 8 Or tool < 1 Then 'check tool number to be in range
    Message (" Tool " & tool & " is not a valid Number 1-8 ONLY, ENDING Program RUN ")
    DoButton(3)
    End
End If


tryagain:

'get actual starttime
Starttime = Timer

Message "Moving to Tool# " &GetselectedTool()


   Akttime = Timer
   While Akttime - Starttime < 50 'try until timeout

    ActivateSignal(OutPut5)  'unlocks stop dog
    Sleep(100)              'wait for a second
    ActivateSignal(OutPut6)  'turn air motor on
    Sleep(100)              'wait for a second
    DeActivateSignal(OutPut5)    'locks stop dog
    Sleep(200)              'wait for a second
    DeActivateSignal(OutPut6)    'turn air motor off
    Sleep(300)

    'check the position
    If GetTurret() = tool Then
       GoTo finished
    End If   
       
    Akttime = Timer
    If Akttime - Starttime > 40 Then 'Timeout 20s
       Message("Turret timeout")
       DeActivateSignal(output5)    'locks stop dog
       Sleep(1000)                  'wait for a second
       DeActivateSignal(OutPut6)    'turn air motor off
       End
    End If
   Wend
   
finished:

   'recheck the turretpos and retry
   If  GetTurret() <> tool Then
        GoTo tryagain
   End If


    'look for OEMTRIG1
    If Not IsActive(OEMTRIG1) = false Then
        DOButton(3)
        MsgBox("Tool changer not seated!")
        End
    End If   

    Message("Tool " & tool & " Loaded")
    SetCurrentTool( tool )
   
End Sub

 

'function to get the actual turret position
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
   


Offline TPS

  • Active Member
  • Posts: 1,133
    • View Profile
Re: CNC Lathe turret tool changer help?
« Reply #62 on: October 19, 2015, 09:21:46 AM »
Ok,

sounds good.

Thomas
anything is possible, just try it.
if you find some mistakes, in my bad bavarian english,they are yours.

herr schmeiß hirn vom himmel

Offline mike^3

  • Active Member
  • Posts: 117
    • View Profile
Re: CNC Lathe turret tool changer help?
« Reply #63 on: October 19, 2015, 09:40:04 AM »