Hello Guest it is March 28, 2024, 12:51:43 PM

Author Topic: macro for 4 slot tool change hep  (Read 7396 times)

0 Members and 1 Guest are viewing this topic.

Re: macro for 4 slot tool change hep
« Reply #20 on: April 25, 2019, 03:48:55 AM »
I have tried the test. And it won't read the input. :(
 but i get the input on the ip-a controller)
Re: macro for 4 slot tool change hep
« Reply #21 on: April 25, 2019, 04:08:50 AM »
are i missing a mach or a ipa config ?
Re: macro for 4 slot tool change hep
« Reply #22 on: April 25, 2019, 04:14:23 AM »
hmm

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: macro for 4 slot tool change hep
« Reply #23 on: April 25, 2019, 04:35:58 AM »
oh sh**t, missed that we are on a CSMIO Controller, sorry.
here the modified code:

Code: [Select]
OldTool = GetCurrentTool()
Tool = GetSelectedTool()
MaxToolNum = 4      'Max number of tools for the changer
debug = true

If debug = true Then
Message "OldTool: " & OldTool & " NewTool: " & Tool
Sleep(200)
End If

If OldTool = Tool Then
Message ("Selected Tool already loaded")
Exit Sub
End If

While Tool > MaxToolNum
Tool = Question ("Enter New Tool Number up to " & MaxToolNum)
Wend

Call StartTool

While NewTool <> Tool
   Call CheckPins
   While IsMoving()
   Wend
Wend

Call StopTool

SetCurrentTool(NewTool)

'//// Subroutines /////////

Sub StartTool
   ActivateSignal(Output8)
   If debug = true Then
Message "Output8 On"
Sleep(200)
   End If
   'Code "G4 P4.0"    'Wait for the tool to rotate past the sensor
      While IsMoving()
      Wend
End Sub

Sub CheckPins
   If GetCsmioIn(91,6) = True Then
      NewTool = 1
      End If
   If GetCsmioIn(91,5) = True Then
      NewTool = 2
      End If
   If GetCsmioIn(91,4) = True Then
      NewTool = 3
      End If
   If GetCsmioIn(91,3) = True Then
      NewTool = 4
      End If
  If debug = true Then
Message "NewTool= " & NewTool
Sleep(200)
  End If
End Sub

Sub Stoptool
   DeActivateSignal(Output8)
   If debug = true Then
Message "Output8 Off"
Sleep(200)
   End If
      While IsMoving()
      Wend
   ActivateSignal(Output9) 
   If debug = true Then
Message "Output9 On"
Sleep(200)
   End If
      Code "G4 P1.0"    'Wait for the tool to rotate onto ratchet stop
      While IsMoving()
      Wend
   DeActivateSignal(Output9)
   If debug = true Then
Message "Output9 Off"
Sleep(200)
   End If
      While IsMoving()
      Wend
End Sub 

'CSMIO Eingang lesen
Function GetCsmioIn (ByVal adr As Integer, ByVal n As Integer) As Boolean
If(GetInBit(adr, n)) Then
GetCsmioIn = true
Else
GetCsmioIn = false
End If
End Function
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: macro for 4 slot tool change hep
« Reply #24 on: April 25, 2019, 04:37:23 AM »
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: macro for 4 slot tool change hep
« Reply #25 on: April 25, 2019, 05:49:11 AM »
that is a different ball game  ;)
now it works almost as intended.


it is possible to get output 8 to stop faster.
Half of the time it jumps over the tool and locks on the next tool. no error ditekted 
 
perhaps a security system to lock.
 i have a micro swich on input23 which indicates the spindel is locked.

in the locked state, the tool number is on(input19-22) and Safety lock (input23) is on.
if not rotate again (outout 8 )

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: macro for 4 slot tool change hep
« Reply #26 on: April 25, 2019, 06:08:47 AM »
here a new Version.
-all debug code deleted (faster Operation)
-Input 23 now used to stop reverse run
-after finish re check and retry

Code: [Select]
OldTool = GetCurrentTool()
Tool = GetSelectedTool()
MaxToolNum = 4      'Max number of tools for the changer

If OldTool = Tool Then
Message ("Selected Tool already loaded")
Exit Sub
End If

If Tool > MaxToolNum Then
Tool = Question ("Enter New Tool Number up to " & MaxToolNum)
End If

doagain:

Call StartTool

While NewTool <> Tool
   Call CheckPins
Wend

Call StopTool

're check
Call CheckPins
If NewTool <> Tool Then
goto doagain
End If

SetCurrentTool(NewTool)

'//// Subroutines /////////

Sub StartTool
   ActivateSignal(Output8)
End Sub

Sub CheckPins
   If GetCsmioIn(91,6) = True Then
      NewTool = 1
      End If
   If GetCsmioIn(91,5) = True Then
      NewTool = 2
      End If
   If GetCsmioIn(91,4) = True Then
      NewTool = 3
      End If
   If GetCsmioIn(91,3) = True Then
      NewTool = 4
      End If
End Sub

Sub Stoptool
   DeActivateSignal(Output8)
   ActivateSignal(Output9)
   'wait for input 23   
   While GetCsmioIn(91,7) = True
Sleep(20)
   Wend
   DeActivateSignal(Output9)
End Sub 

'CSMIO Eingang lesen
Function GetCsmioIn (ByVal adr As Integer, ByVal n As Integer) As Boolean
If(GetInBit(adr, n)) Then
GetCsmioIn = true
Else
GetCsmioIn = false
End If
End Function
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: macro for 4 slot tool change hep
« Reply #27 on: April 25, 2019, 06:13:30 AM »
sorry

While GetCsmioIn(91,7) = True

Needs to be

While GetCsmioIn(91,7) = False
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: macro for 4 slot tool change hep
« Reply #28 on: April 25, 2019, 07:20:20 AM »
it works

But the security lock needs an extra thing. :)

if I disassemble (input23) the spindle continues to drive up against the lock. it is OK
but it must stop after 3 sec. and activate a fault atc not locked (estop) otherwise i think the engine will burn :)

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: macro for 4 slot tool change hep
« Reply #29 on: April 26, 2019, 02:24:38 AM »
ok sorry for the delay.
here the code with a 3 second timeout for input23

Code: [Select]
Sub Main
'//Declarations
Dim StartTime, ActTime As Single
MaxToolNum = 4      'Max number of tools for the changer

OldTool = GetCurrentTool()
Tool = GetSelectedTool()

If OldTool = Tool Then
Message ("Selected Tool already loaded")
Exit Sub
End If

If Tool > MaxToolNum Then
Tool = Question ("Enter New Tool Number up to " & MaxToolNum)
End If

doagain:

Call StartTool

While NewTool <> Tool
Call CheckPins
Wend

Call StopTool

're check
Call CheckPins
If NewTool <> Tool Then
goto doagain
End If

SetCurrentTool(NewTool)
End Sub


'//// Subroutines /////////

Sub StartTool
   ActivateSignal(Output8)
End Sub

Sub CheckPins
   If GetCsmioIn(91,6) = True Then
      NewTool = 1
      End If
   If GetCsmioIn(91,5) = True Then
      NewTool = 2
      End If
   If GetCsmioIn(91,4) = True Then
      NewTool = 3
      End If
   If GetCsmioIn(91,3) = True Then
      NewTool = 4
      End If
End Sub

Sub Stoptool
   DeActivateSignal(Output8)
   ActivateSignal(Output9)
   'wait for input 23   or timeout
StartTime = Timer

   
   While GetCsmioIn(91,7) = False
Sleep(20)
ActTime = Timer
If ActTime > StartTime + 3 Then
MsgBox "Timeout Input23!!"
DoButton(3)
Sleep(300)
Exit Sub
End If
   Wend
   DeActivateSignal(Output9)
End Sub 

'CSMIO Eingang lesen
Function GetCsmioIn (ByVal adr As Integer, ByVal n As Integer) As Boolean
If(GetInBit(adr, n)) Then
GetCsmioIn = true
Else
GetCsmioIn = false
End If
End Function

IMHO i think for a save TC on a lathe some more things are necessary.

1. homing Limit Switches
   machine should have homing Limits to have the possibillity to drive TC to a defined Position
   (in machine coords) to be save for rotate the TC

here some code witch check' that X and Y axis are referenced
Code: [Select]
'X-Axis not in reference
If GetOEMLED(807) Then
DoButton(3)
Sleep(500)
Message ("X-Axis not referenced -> Abort !!")
Exit Sub
End If

'Z-Axis not in reference
If GetOEMLED(809) Then
DoButton(3)
Sleep(500)
Message ("Z-Axis not referenced -> Abort !!")
Exit Sub
End If

2. drive Z and X axis to a defined Position (in machine coords)

here some code:
Code: [Select]
Message "ATC X-Axis to TC position"
Code "G90 G53 G0 X2"
While IsMoving()
Sleep(15)
Wend

Message "ATC Z-Axis to TC position"
Code "G90 G53 G0 Z2"
While IsMoving()
Sleep(15)
Wend







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