Hello Guest it is April 26, 2024, 05:05:33 PM

Show Posts

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.


Messages - TPS

2201
General Mach Discussion / Re: CNC Lathe turret tool changer help?
« on: October 18, 2015, 11:20:46 AM »
made small modification,
because if tool = 8 then turretpos must be 1

else tool must be turretpos-1


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
' 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

 
Dim ActTurretPos As Long
ActTurretPos = 0

'get actual starttime
Starttime = Timer

Message "Moving to Tool# " &GetselectedTool()

tryagain:

   ActivateSignal(output5)  'unlocks stop dog
   Sleep(1000)              'wait for a second
   ActivateSignal(OutPut6)  'turn air motor on
  
   While ActTurretPos <> tool 'turn until we are in the wright position
      ActTurretPos = GetTurret()

      'give the other inputs a chance
      If ActTurretPos <> 0 Then
        Sleep(50)
        ActTurretPos = GetTurret() 'read Turretpos again
      End if
      
      Akttime = Timer
      If Akttime - Starttime > 20 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
  
   DeActivateSignal(output5)    'locks stop dog
   Sleep(1000)                  'wait for a second
   DeActivateSignal(OutPut6)    'turn air motor off
   sleep(1000)


   'recheck the turretpos and retry
   If tool <> 8 then
      If  (GetTurret()-1) <> tool then ' from tool is 1-7 toolno -1
goto tryagain
      End If
   Else
      If  GetTurret() <> 1 then ' if tool = 8 then turretpos must be 1
goto tryagain
      End If
   End If  


    'look for OEMTRIG1
    If Not IsActive(OEMTRIG1) 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 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
    


2202
General Mach Discussion / Re: CNC Lathe turret tool changer help?
« on: October 18, 2015, 09:02:00 AM »
ok with recheck and retry, not tested

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
' 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

 
Dim ActTurretPos As Long
ActTurretPos = 0

'get actual starttime
Starttime = Timer

Message "Moving to Tool# " &GetselectedTool()

tryagain:

   ActivateSignal(output5)  'unlocks stop dog
   Sleep(1000)              'wait for a second
   ActivateSignal(OutPut6)  'turn air motor on
   
   While ActTurretPos <> tool 'turn until we are in the wright position
      ActTurretPos = GetTurret()

      'give the other inputs a chance
      If ActTurretPos <> 0 Then
        Sleep(50)
        ActTurretPos = GetTurret() 'read Turretpos again
      End if
     
      Akttime = Timer
      If Akttime - Starttime > 20 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
   
   DeActivateSignal(output5)    'locks stop dog
   Sleep(1000)                  'wait for a second
   DeActivateSignal(OutPut6)    'turn air motor off
   sleep(1000)


   'recheck the turretpos and retry
   If  (GetTurret()-1) <> tool then
goto tryagain
   End If


    'look for OEMTRIG1
    If Not IsActive(OEMTRIG1) 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 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
   

2203
General Mach Discussion / Re: CNC Lathe turret tool changer help?
« on: October 18, 2015, 08:15:39 AM »
try to reduce:

      'give the other inputs a chance
      If ActTurretPos <> 0 Then
        Sleep(200)       
       ActTurretPos = GetTurret() 'read Turretpos again
      End if

to Sleep(50)

2204
General Mach Discussion / Re: CNC Lathe turret tool changer help?
« on: October 18, 2015, 08:02:16 AM »
corrected version

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
' 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

 
Dim ActTurretPos As Long
ActTurretPos = 0

'get actual starttime
Starttime = Timer

Message "Moving to Tool# " &GetselectedTool()

   ActivateSignal(output5)  'unlocks stop dog
   Sleep(1000)              'wait for a second
   ActivateSignal(OutPut6)  'turn air motor on
   
   While ActTurretPos <> tool 'turn until we are in the wright position
      ActTurretPos = GetTurret()

      'give the other inputs a chance
      If ActTurretPos <> 0 Then
        Sleep(200)
        ActTurretPos = GetTurret() 'read Turretpos again
      End if
     
      Akttime = Timer
      If Akttime - Starttime > 20 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
   
   DeActivateSignal(output5)    'locks stop dog
   Sleep(1000)                  'wait for a second
   DeActivateSignal(OutPut6)    'turn air motor off
   sleep(1000)

    'look for OEMTRIG1
    If Not IsActive(OEMTRIG1) 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 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
   


2205
Hi,

you are "dancing" on two parties (threads) now.

have a look for the origin thread.

2206
General Mach Discussion / Re: CNC Lathe turret tool changer help?
« on: October 18, 2015, 04:31:45 AM »
Hi,

after a while of thinking my idea is that the switches will never be activated
simultanius.

so for example Turretpos = 3 then Input1 and Input2 have to be on.
but if Input1 ist only 10ms earlier it will read Pos = 1.

so i modified my code a little bit to give the inputs a chance (200ms):

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
' 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

 
Dim ActTurretPos as long
ActTurretPos = 0

'get actual starttime
Starttime = Timer

Message "Moving to Tool# " &GetselectedTool()

   ActivateSignal(output5)  'unlocks stop dog
   Sleep(1000)              'wait for a second
   ActivateSignal(OutPut6)  'turn air motor on
   
   While ActTurretPos <> tool 'turn until we are in the wright position
      ActTurretPos = GetTurret()

      'give the other inputs a chance
      If ActTurretPos <> 0 Then
        Sleep(200)
        ActTurretPos = GetTurret() 'read Turretpos again
      Endif
     
      Akttime = Timer
      If Akttime - Starttime > 20 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
   
   DeActivateSignal(output5)    'locks stop dog
   Sleep(1000)                  'wait for a second
   DeActivateSignal(OutPut6)    'turn air motor off
   sleep(1000)

    'look for OEMTRIG1
    if not IsActive(OEMTRIG1) then
        DOButton(3)
        Messagebox("Tool changer not seated!")
        End
    End If   

    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
   


Thomas

2207
General Mach Discussion / Re: CNC Lathe turret tool changer help?
« on: October 18, 2015, 04:06:09 AM »
Sorry,

i debugged with T0101

it gives you not Tool 1 Offest 1

the GetSelectedTool() gives you 101 as Tool number.

i know the difference between binary and decimal.

That is whant my subfunction:
Code: [Select]
'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


it convertes binary inputs to a decimal value.

but i have seen you are trying an other way in an other thread.

Thomas



 

2208
Hi,

While IsMoving()
Wend

is only used if any axis is moving (XYZABC)

so:
Code: [Select]
DeActivateSignal(Output5) 'Trigger Stop Dawg

Message"Triggering Stop Dawg"

While IsMoving()

Sleep 2000  **********************it does not wait

Wend


DeActivateSignal(Output6) 'Lowering and stopping air motor



should be:

Code: [Select]
DeActivateSignal(Output5) 'Trigger Stop Dawg

Message"Triggering Stop Dawg"

Sleep 2000  **********************it does not wait

DeActivateSignal(Output6) 'Lowering and stopping air motor



Thomas


2209
General Mach Discussion / Re: CNC Lathe turret tool changer help?
« on: October 17, 2015, 05:26:43 AM »
 t0101  ???

your tool numbers can only be T1 - T8

whow should the program know in witch place t0101 is located.

Thomas

2210
General Mach Discussion / Re: HOTKEY TO OUTPUT RELAY
« on: October 16, 2015, 03:22:59 AM »
OK,

put this code in macropump script:
Code: [Select]
If GetOEMLed(77) then ' Output4 is on
    If Timer - GetOEMDRO(1500) > 5 then
        DeActivateSignal(Output4)
    End if
Else
    SetOEMDRO(1500,Timer)
End If


make sure macropump is enabled in general config
restart Mach

Thomas