Hello Guest it is October 20, 2021, 10:03:14 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

1901
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
   


1902
Hi,

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

have a look for the origin thread.

1903
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

1904
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



 

1905
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


1906
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

1907
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

1908
General Mach Discussion / Re: HOTKEY TO OUTPUT RELAY
« on: October 15, 2015, 08:58:56 AM »
Hello DAS,

as far i know, it is not possible to switch a output only while the key is pressed.

the macro is only trigged once when the key is pressed, not when the key ist released.
for the moment i know no way to realise this.

Thomas

1909
Hi Mark,

attached a small excelfile, try it not tested in all conditions.

m = (YEnd-YStart) / (XEnd-XStart)
q = YStart - m * XStart

XPre  =  XStart + 10
YPre =  m * XPre + q

Thomas

1910
General Mach Discussion / Re: HOTKEY TO OUTPUT RELAY
« on: October 15, 2015, 03:52:32 AM »
Hi Das,

put this little script into the button


'GetOEMLed(77) -> Output4
'GetOEMLed(78) -> Output5
'GetOEMLed(79) -> Output6

If GetOEMLed(79) Then
   DeActivateSignal(Output6)
Else
   ActivateSignal(Output6)
End If


but dont forget to activate the output in port's & pin's

Thomas