Hello Guest it is July 14, 2020, 07:40:05 PM

Author Topic: Tool change macro  (Read 6609 times)

0 Members and 1 Guest are viewing this topic.

Offline N4NV

*
  •  396 396
    • View Profile
Tool change macro
« on: January 31, 2009, 04:42:17 PM »
I have a Hardinge CHNC with a tool turret.  I am controlling the tool change with a PLC.  Mach sends the requested tool to the PLC and the PLC takes care of the tool change.  There is a brain that tells the PLC what tool Mach is requesting.  Sometimes the tool turret does not seat properly.  There is a sensor in the turret that detects this.  I have this sensor wired to input 11 of my BOB.  What I would like to happen is if the sensor detects that the turret did not seat all the way, mach will not proceed.  Currently my tool change macro looks like this:
  Code ("G53 G00 Z-0.200")
  Code ("G4 P3")   
  tool = GetSelectedTool()
  SetCurrentTool( tool )
This moves the saddle to the tool change position then does the change.  I have the G4 command to give the turret PLC time to make the tool change.  I think what I would like is instead of the G4 command, Mach would look at input 11 and if it were true, then it knows the tool change has taken place and proceed.  If input 11 is not true, then Mach would wait until the operator did something to fix the problem.

Any suggestions on what the tool change macro should look like?

Thanks

Vince

Offline Hood

*
  •  25,846 25,846
  • Carnoustie, Scotland
    • View Profile
Re: Tool change macro
« Reply #1 on: January 31, 2009, 05:27:09 PM »
Vince, here is first tool part of the macro I use for my turret

If GetSelectedTool=1  Then               'If selected tool = 1
 Do                                       'Start loop
 Call SetModOutput (9,1)                  'Toolchange signal to PLC to start turret indexing
 If GetInput (0) Then Exit Do             'Correct tool in position signal from PLC and exit loop
 Loop                                     'Continue loop if above signal is not present
 End If
 Call SetModOutput (9,0)     

So as you can see modout 9 is the signal to the PLC that starts the toolchange and also stops it, it will however keep roatating until it sees the correct signal from the PLC for that tool.

Hood

Offline zealous

*
  •  492 492
  • HI!
    • View Profile
    • Artsoft Solutions
Re: Tool change macro
« Reply #2 on: January 31, 2009, 05:41:15 PM »
You can mix this in with Hood's code for the MESSAGE BOX to let the operator activate the process again.


Code: [Select]
'////MOVE THE MACHINE FOR TOOLCHANGE////
Code ("G53 G00 Z-0.200")'Move Z to position
While IsMoving()' Wait for machine to stop
SLEEP(250)'Slow down cycle time for CPU resources
Wend

'////GET SET TOOL////
tool = GetSelectedTool() 'Gettool
SetCurrentTool( tool )'Set tool
SLEEP(500)'Wait to see if input becomes active

'////CHECK INPUT/////
If Not(IsActive(INPUT1)) Then 'Is the imput active

'///Message box////
msg = "Please reseat tool and continue?"   ' Define message
title = "Tool Changer"   ' Define title
buttons = 1
response = MsgBox(msg,buttons, title)

'///Responce was YES
If response = 1 Then   ' User chose Yes.

   ' Perform recheck issue has been fixed.
   Print"yep"
   
'///Responce was NO
Else

   ' Estop system ecit.
      Print"nope"
     
End If'exit message

End If 'Input was active exit
« Last Edit: February 01, 2009, 03:17:07 PM by zealous »

Offline N4NV

*
  •  396 396
    • View Profile
Re: Tool change macro
« Reply #3 on: January 31, 2009, 06:49:46 PM »
Hood, the way my tool turret works will not work with your modout 9 signal. 

Jason, I think what you have will work for me.   

What programing language are the macros written in?

Thanks

Vince

Offline Hood

*
  •  25,846 25,846
  • Carnoustie, Scotland
    • View Profile
Re: Tool change macro
« Reply #4 on: January 31, 2009, 07:06:01 PM »
VB

Offline N4NV

*
  •  396 396
    • View Profile
Re: Tool change macro
« Reply #5 on: January 31, 2009, 07:42:32 PM »
Jason, I ran your macro and here are the results:

The turret starts rotating before the carriage gets to the tool change position G53 Z-.2.  Not OK
It can take up to 4 seconds to go through all 8 tools so I changed the Sleep 500 to sleep 4000. OK
If the turret does not seat, the window opens that ask the operator to re-seat the tool.  If I re-seat the tool and click yes, then another window behind Mach opens that is called Mach3scripts.  In that window it says "yep".  The program stops until I click OK in that window as well, then the program continues.   Is there a way to skip the Mach3Scripts pop up window? 

What I would like is the carriage to move to the tool change position before the get tool command is sent.  Also, if input 1 (pin 11) shows that the turret is done, skip the full 4 seconds.  If the tool was close it may take only a second to index to the new tool. 

Thanks for your help

Vince

Offline zealous

*
  •  492 492
  • HI!
    • View Profile
    • Artsoft Solutions
Re: Tool change macro
« Reply #6 on: February 01, 2009, 02:59:42 PM »
The code was more for a outline but will work.

I have a message popup for "YEP" to verify that the code is working but left this for you to decide what to do...just comment out "PRINT "YEP" and/or add a result.

Let me know what part isn’t working right and I can modify it:

I'll break it down here with description ...

1. Move Z to toolchange position:

Code: [Select]
'////MOVE THE MACHINE FOR TOOLCHANGE////
Code ("G53 G00 Z-0.200")'Move Z to position

2. Wait for Z to get to position:

Code: [Select]
While IsMoving() ' Wait for machine to stop
SLEEP(250)'Slow down cycle time for CPU resources
Wend

3. Get requested tool and activate turret with Brain:

Code: [Select]
'//GET SET TOOL////
tool = GetSelectedTool() 'Gettool
SetCurrentTool( tool )'Set tool

4. Wait 4 seconds and then Check to see if Input 1
*****************************Rather then waiting 4 seconds why dont we loop and check for INPUT1 to be active....if after 4 seonds it is not active popup message to user?

Code: [Select]
SLEEP(500)'Wait to see if input becomes active
5. If Input doesn't activate popup message:

Code: [Select]
'////CHECK INPUT/////
If Not(IsActive(INPUT1)) Then 'Is the imput active

Message box settings:

Code: [Select]
'///Message box////
msg = "Please reseat tool and continue?"   ' Define message
title = "Tool Changer"   ' Define title
buttons = 1
response = MsgBox(msg,buttons, title)

***6. If the user is finished resetting and presses the "OK" button then do this(HEre you can comment out  ("Print"yep"):

Code: [Select]
'///Responce was YES
If response = 1 Then   ' User chose Yes.

   ' Perform recheck issue has been fixed.
   Print"yep"


7. The user pressed "Cancel" you should estop the sytem and turn things off:

Code: [Select]
'///Responce was NO
Else

   ' Estop system ecit.
      Print"nope"
     
End If'exit message

8. Input was active and just continue running tool changer:

Code: [Select]
End If 'Input was active exit
« Last Edit: February 01, 2009, 03:17:32 PM by zealous »

Offline zealous

*
  •  492 492
  • HI!
    • View Profile
    • Artsoft Solutions
Re: Tool change macro
« Reply #7 on: February 01, 2009, 03:19:41 PM »
OOOPPPs :-\ :-\  :o :o  was wondering why you stated the turret was rotating before the machine got into position....I have a error in my code:
was missing the "()"...
While IsMoving() ' Wait for machine to stop
SLEEP(250)'Slow down cycle time for CPU resources
Wend

give me a sec and will post the complete code with the 4 second check for INPUT1 one to be active

Offline N4NV

*
  •  396 396
    • View Profile
Re: Tool change macro
« Reply #8 on: February 01, 2009, 03:24:49 PM »
I saw the missing () in the ismoving line and added them and it still starts the turret rotating before the Z axis gets to the tool change position. 

Vince

Offline zealous

*
  •  492 492
  • HI!
    • View Profile
    • Artsoft Solutions
Re: Tool change macro
« Reply #9 on: February 01, 2009, 03:59:48 PM »
whats in your Brain?

Here timmer that waits for 4 seconds for INPUT1 to become active after that the message will appear and if "OK "is pressed continue if "cancel" is press will Estop the sytem.

Code: [Select]
i=0'Reset timmer

Do 'Run timmer

SLEEP(500)'timmer 1/2 second intervals

 i= i+1'increment
 
 
If (IsActive(INPUT1)) Then'INPUT is active
 
  Exit Do  'exit function Continue
 
ELSEIf i>8 Then'if we have reached 4 seconds
 
 
'///Message box////
msg = "Please reseat tool and continue?"   ' Define message
title = "Tool Changer"   ' Define title
buttons = 1

response = MsgBox(msg,buttons, title)'Display message box

'///Responce was YES
If response = 1 Then' User chose Yes.

   'OK has been pressed continue
   
Else'///Responce was NO

     DoOEMButton(1021)'Estop system
     
     
End If'exit message


Exit Do  'exit function
 
End If 'INPUT ACTIVE
 
Loop