Hello Guest it is March 29, 2024, 06:55:41 AM

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

0 Members and 1 Guest are viewing this topic.

macro for 4 slot tool change hep
« on: April 16, 2019, 07:43:16 AM »
macro for 4 slot tool change

Hi I'm new to macros. and I'm trying to get my atc to work for my lathe. and i need some help
my atc macro. must control the following.
(output 8.) unlock rotates ccw
(output 9) rotate cw for lock
(input 23) lock contact
(input 22) tool 1
(input 21) tool 2
(input 20) tool 3
(input 19) tool 4
i have found a macro that i believe will work but nothing happens when i save it in m6start what am i missing? i have put atc on.
i am also missing the (lock input 23)

OldTool = GetOEMDRO (1200)
Tool = GetSelectedTool()
MaxToolNum = 4      'Max number of tools for the changer

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

Call SetUserDRO (1200, NewTool)
SetCurrentTool(NewTool)

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

Sub StartTool
   ActivateSignal(Output8)
   'Code "G4 P4.0"    'Wait for the tool to rotate past the sensor
      While IsMoving()
      Wend
End Sub

Sub CheckPins
   If Not IsActive(Input22) Then
      NewTool = 1
      End If
   If Not IsActive(Input21) Then
      NewTool = 2
      End If
   If Not IsActive(Input20) Then
      NewTool = 3
      End If
   If Not IsActive(Input19) Then
      NewTool = 4
      End If
End Sub

Sub Stoptool
   DeActivateSignal(Output8)
      While IsMoving()
      Wend
   ActivateSignal(Output9) 
      Code "G4 P1.0"    'Wait for the tool to rotate onto ratchet stop
      While IsMoving()
      Wend
   DeActivateSignal(Output9)
      While IsMoving()
      Wend
End Sub 

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: macro for 4 slot tool change hep
« Reply #1 on: April 16, 2019, 09:07:33 AM »
how do you initiate toolchange

in lathe mode it is

M6 T0101 for example
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 #2 on: April 16, 2019, 09:18:40 AM »
how do you initiate toolchange

in lathe mode it is

M6 T0101 for example

i just change the tool nr. from 1-4.
or write m6 t0101 but nothing happens

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: macro for 4 slot tool change hep
« Reply #3 on: April 16, 2019, 09:22:45 AM »
add

msgbox ("M6 Start executed")

at the begin of the macro to see that the macro is called
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 #4 on: April 16, 2019, 09:25:56 AM »
do you have enabled in

Config -> General Config -> Tool Change -> Auto Tool Change
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 #5 on: April 16, 2019, 09:37:25 AM »
add

msgbox ("M6 Start executed")

at the begin of the macro to see that the macro is called

like this ?

msgbox ("M6 Start executed")
OldTool = GetOEMDRO (1200)
Tool = GetSelectedTool()
MaxToolNum = 4      'Max number of tools for the changer

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

Call SetUserDRO (1200, NewTool)
SetCurrentTool(NewTool)

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

Sub StartTool
   ActivateSignal(Output8)
   'Code "G4 P4.0"    'Wait for the tool to rotate past the sensor
      While IsMoving()
      Wend
End Sub

Sub CheckPins
   If Not IsActive(Input22) Then
      NewTool = 1
      End If
   If Not IsActive(Input21) Then
      NewTool = 2
      End If
   If Not IsActive(Input20) Then
      NewTool = 3
      End If
   If Not IsActive(Input19) Then
      NewTool = 4
      End If
End Sub

Sub Stoptool
   DeActivateSignal(Output8)
      While IsMoving()
      Wend
   ActivateSignal(Output9) 
      Code "G4 P1.0"    'Wait for the tool to rotate onto ratchet stop
      While IsMoving()
      Wend
   DeActivateSignal(Output9)
      While IsMoving()
      Wend
End Sub 

Re: macro for 4 slot tool change hep
« Reply #6 on: April 16, 2019, 09:40:35 AM »
do you have enabled in

Config -> General Config -> Tool Change -> Auto Tool Change

yes it is on :)

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: macro for 4 slot tool change hep
« Reply #7 on: April 16, 2019, 09:50:34 AM »
add

msgbox ("M6 Start executed")

at the begin of the macro to see that the macro is called

like this ?

msgbox ("M6 Start executed")
OldTool = GetOEMDRO (1200)
Tool = GetSelectedTool()
MaxToolNum = 4      'Max number of tools for the changer

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

Call SetUserDRO (1200, NewTool)
SetCurrentTool(NewTool)

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

Sub StartTool
   ActivateSignal(Output8)
   'Code "G4 P4.0"    'Wait for the tool to rotate past the sensor
      While IsMoving()
      Wend
End Sub

Sub CheckPins
   If Not IsActive(Input22) Then
      NewTool = 1
      End If
   If Not IsActive(Input21) Then
      NewTool = 2
      End If
   If Not IsActive(Input20) Then
      NewTool = 3
      End If
   If Not IsActive(Input19) Then
      NewTool = 4
      End If
End Sub

Sub Stoptool
   DeActivateSignal(Output8)
      While IsMoving()
      Wend
   ActivateSignal(Output9) 
      Code "G4 P1.0"    'Wait for the tool to rotate onto ratchet stop
      While IsMoving()
      Wend
   DeActivateSignal(Output9)
      While IsMoving()
      Wend
End Sub 




yes
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 #8 on: April 16, 2019, 09:53:43 AM »
you can copy all your code to

Operator -> VB Scripter Window

and use the >|| button to step through to see what is going on
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 #9 on: April 16, 2019, 11:04:07 AM »
you can copy all your code to

Operator -> VB Scripter Window

and use the >|| button to step through to see what is going on


my mach 3 just crash when i do that