Hello Guest it is October 24, 2019, 01:17:05 AM

Author Topic: How to - code manual tool change?  (Read 10993 times)

0 Members and 1 Guest are viewing this topic.

How to - code manual tool change?
« on: October 20, 2014, 09:48:10 PM »
So, I'd like to run a single job that incorporates a manual tool change but I must admit I don't know how to make that happen. I was hoping someone could assist me with the process...

Below is the G-Code that has been produced and I see there is a tool change form a 1/4 to 1/8 bit (N258T2M6) but I need the machine to stop cutting, raise the Z axis, allow me to manually change the bit and them home the Z axis using the new bit and a touch off plate.

Any help or suggestions would be appreciated..

Adam,


Code: [Select]
%
O0000
(PROGRAM NAME - TABLETOP FINAL)
(DATE=DD-MM-YY - 20-10-12 TIME=HH:MM - 20:37)
N100G20
N102G0G17G40G49G80G90
( 1/4 FLAT ENDMILL TOOL - 1 DIA. OFF. - 1 LEN. - 1 DIA. - .25)
N104T1M6
N106G0G90G54X11.375Y12.45A0.S5000M3
N108G43H1Z.25
N110Z.275
N112G1X11.625Z-.1F75.
N114X12.45
N116Y8.8
N118X8.8
N120Y12.45
N122X10.625
N124X11.625
N126X11.875Z.275
N128Z0.F50.
N130G0Z.25
N132Z.275
N134X11.375Y12.5
N136G1X11.625Z-.1F75.
N138X12.5
N140Y8.75
N142X8.75
N144Y12.5
N146X10.625
N148X11.625
N150X11.875Z.275
N152Z0.F50.
N154G0Z.25
N156X11.375Y12.45
N158Z.175
N160G1X11.625Z-.2F75.
N162X12.45
N164Y8.8
N166X8.8
N168Y12.45
N170X10.625
N172X11.625
N174X11.875Z.175
N176Z-.1F50.
N178G0Z.25
N180X11.375Y12.5
N182Z.175
N184G1X11.625Z-.2F75.
N186X12.5
N188Y8.75
N190X8.75
N192Y12.5
N194X10.625
N196X11.625
N198X11.875Z.175
N200Z-.1F50.
N202G0Z.25
N204X11.375Y12.45
N206Z.125
N208G1X11.625Z-.25F75.
N210X12.45
N212Y8.8
N214X8.8
N216Y12.45
N218X10.625
N220X11.625
N222X11.875Z.125
N224Z-.15F50.
N226G0Z.25
N228X11.375Y12.5
N230Z.125
N232G1X11.625Z-.25F75.
N234X12.5
N236Y8.75
N238X8.75
N240Y12.5
N242X10.625
N244X11.625
N246X11.875Z.125
N248G0Z.25
N250M5
N252G91G28Z0.
N254G28X0.Y0.A0.
N256M01
( 1/8 FLAT ENDMILL TOOL - 2 DIA. OFF. - 2 LEN. - 2 DIA. - .125)
N258T2M6
N260G0G90G54X11.5Y12.5125A0.S5000M3
N262G43H2Z.25
N264Z.275
N266G1X11.625Z-.1F9.6
N268X12.5125
N270Y8.7375
N272X8.7375
N274Y12.5125
N276X10.625
N278X11.625
N280X11.75Z.275
N282Z0.F6.16
N284G0Z.25
N286Z.275
N288X11.5Y12.5625
N290G1X11.625Z-.1F9.6
N292X12.5625
N294Y8.6875
N296X8.6875
N298Y12.5625
N300X10.625
N302X11.625
N304X11.75Z.275
N306Z0.F6.16
N308G0Z.25
N310X11.5Y12.5125
N312Z.175
N314G1X11.625Z-.2F9.6
N316X12.5125
N318Y8.7375
N320X8.7375
N322Y12.5125
N324X10.625
N326X11.625
N328X11.75Z.175
N330Z-.1F6.16
N332G0Z.25
N334X11.5Y12.5625
N336Z.175
N338G1X11.625Z-.2F9.6
N340X12.5625
N342Y8.6875
N344X8.6875
N346Y12.5625
N348X10.625
N350X11.625
N352X11.75Z.175
N354Z-.1F6.16
N356G0Z.25
N358X11.5Y12.5125
N360Z.125
N362G1X11.625Z-.25F9.6
N364X12.5125
N366Y8.7375
N368X8.7375
N370Y12.5125
N372X10.625
N374X11.625
N376X11.75Z.125
N378Z-.15F6.16
N380G0Z.25
N382X11.5Y12.5625
N384Z.125
N386G1X11.625Z-.25F9.6
N388X12.5625
N390Y8.6875
N392X8.6875
N394Y12.5625
N396X10.625
N398X11.625
N400X11.75Z.125
N402G0Z.25
N404M5
N406G91G28Z0.
N408G28X0.Y0.A0.
N410M30
%
Re: How to - code manual tool change?
« Reply #1 on: October 21, 2014, 01:34:53 PM »
I see two possibilities: I had set up my tooltable with all the Z offsets (measured by touching), so I have only to code for a tool change:

G0 Zxx (move Z up)
G43 Hxx (apply offset)
Txx
M6

... that the easiest way. If your Tool has variable length, you'ld need some kind of probe and a macro. I just build my edgefinder and tool length probes, and I still have to write the macro. You'll have to have home switches on the machine, and I would try something like this:

- move to a safe z position
- change tool
- remove work offset (that you have absolute machine coordinates)
- move over the position of the tool probe
- make a G31 probe command to touch the probe
- if your machine is homed correctly and thus the Z position of the probe is known, calculate tool offset
- apply tool offset to the tool table or the work offset (no idea what would work)
- reapply work offset
- move to the last position prior to the tool change

I really should write one ...

Stephan
Re: How to - code manual tool change?
« Reply #2 on: October 21, 2014, 01:46:12 PM »
Thanks for the post.

Does that mean I should "insert" into the G-Code manually the tool change information?

Since I'm new to the "tool change" scenario I guess I'm looking for an example of how people are currently doing it?

Is the "tool change" something that can be programmed into the post process?

Adam,
Re: How to - code manual tool change?
« Reply #3 on: October 22, 2014, 04:59:29 AM »
Oh, I assume that you don't code manually ... since I started with a lathe and my first project was already too complicated for a CAM software, I write my gcode self. Just take a look at the GCode reference in the Mach3Mill Manual and perhaps here: http://www.cnccookbook.com/CCCNCGCodeCourse.htm

I would simply edit the code in a text editor.

So, if i look at the generated code ... the spindle is stopped (line 250: m5), so you go up a bit, something like

N251 G0 Z50

the next one is a return to home which you don't need and it just costs time, so delete the rows 252, 254, and 256 ... if you can change your tool anywhere.

the Line 258: T2M6 is the Tool change command, be sure that in the Mach3 General Options Tool Change command is set to "manually", so you're asked to press "Start cycle" after manually changing the tool.

Line 260: N260G0G90G54X11.5Y12.5125A0.S5000M3 returns to the previous position (not sure), set speed to 5000 and starts the spindle

Line 262: N262G43H2Z.25 applies the new tool offset and goes to the starting z position.

If I code manually, i would put the G43H2 command before the tool change, so you have the new tool length correction already in the DRO and you can test it by simply measuring the distance between tool and surface.

As I've written before, you'ld need a functioning tool table - and the very real risk is if something is wrong and the offsets aren't exact you can crash full on in your workpiece. As a safety measure, I often write the returning to the surface in two steps, to a safe distance with G0 speed and then at feed rate .. so you have a chance to push the emergency stop.

So, before you do anything without knowing what it really does, I propose a crash course in manual g code programming ... there're only a handful of basic commands ... because there're so much possibilities for a failure  >:D

« Last Edit: October 22, 2014, 05:02:01 AM by stephanbrunker »
Re: How to - code manual tool change?
« Reply #4 on: October 22, 2014, 02:11:35 PM »
I run my machine as if it had an automatic tool changer.  In the general setup screen I checked "stop and wait for run" or something like that.  It is in the top left corner.  After changing I hit the run button and it zeroes to the plate and continues to march.  I know it is possible in the 1024 screenset but I am using the 2010 screenset and the setup for touchoff in that screen is more straightforward.  I use the Mach 2/3 ATC inch post processor.
Re: How to - code manual tool change?
« Reply #5 on: October 22, 2014, 03:07:55 PM »
@Bob:
I think then the procedure (return to home / change tool / probing / zeroing) is directly encoded in the gcode - if there's a macro for that, it's not in the usual manuals ...

But I'll look at this after I have modified my BF20 to accept spindle speed commands only by tapping into the manual speed dial (includes four op-amps and an optocoupler ...)
« Last Edit: October 22, 2014, 03:12:02 PM by stephanbrunker »
Re: How to - code manual tool change?
« Reply #6 on: October 22, 2014, 05:46:06 PM »
Appreciate the posts.

I've been doing some digging around and I think I've found some macro's that I can add to the M6Start.mls but since I'm new to this I'm not 100% certain on where the functions are getting the represented information.

Hopefully the owners of the macro's won't mind me posting their work.

For instance, GetOemDRO(818) or GetOEMDRO(800) where does 818 and the 800 come from and how/where do I find it???

Do I need to save the current tool like in the last macro?

Why do you need to set the current tool? SetCurrentTool( tool )

Obviously this opens a can of questions from a greenie such as myself.

Adam,

 
Quote
Rem Auto Tool Zero Z- Metric Version
DownStroke = -25 'Set the down stroke to find probe
DownFeedRate = 100 'Set the down FeedRate
RetractStroke = 10 'Set the retract Stroke
RetractFeedRate = 300 'Set the retract FeedRate

CurrentFeed = GetOemDRO(818) 'Get the current feedrate to return to later
CurrentAbsInc = GetOemLED(48) 'Get the current G90/G91 state
CurrentGmode = GetOemDRO(819) 'Get the current G0/G1 state
PlateThickness = GetUserDRO(1151) 'Z-plate thickness DRO

If GetOemLed (825)=0 Then 'Check to see if the probe is already grounded or faulty
DoOEMButton (1010) 'zero the Z axis so the probe move will start from here
Code "G4 P2" ' this delay gives me time to get from computer to hold probe in place
Code "G90 G31 Z" &DownStroke &" F" &DownFeedRate 'probing move
While IsMoving() 'wait while it happens
Wend
ZProbePos = GetVar(2002) 'get the axact point the probe was hit
If Abs(ZprobePos) <= Abs(DownStroke)-0.1 Then 'Check if the probe has been found
Code "G0 Z" &ZProbePos 'go back to that point, always a very small amount of overrun
While IsMoving ()
Wend
Call SetDro (2, PlateThickness) 'set the Z axis DRO to whatever is set as plate thickness
Code "G4 P0.25" 'Pause for Dro to update.
Code "G1 Z" &PlateThickness + RetractStroke &" F" &RetractFeedRate 'retract
While IsMoving ()
Wend
Code "(Z axis is now zeroed)" 'puts this message in the status bar
Else
Code "G0 Z0" 'retract to start pos
While IsMoving ()
Wend
Code "(Z-Plate not found, check connection or stroke and try again)" 'puts this message in the status bar
End If
Else
Code "(Z-Plate is grounded, check connection and try again)" 'this goes in the status bar if applicable
End If
Code "F" &CurrentFeed 'Returns to prior feed rate
If CurrentAbsInc = 0 Then 'if G91 was in effect before then return to it
Code "G91"
End If
If CurrentGMode = 0 Then 'if G0 was in effect before then return to it
Code "G0"
End If
Exit Sub


Quote
Code("G0 Z35")
Code("G0 X0 Y-40")
tool = GetSelectedTool()
SetCurrentTool( tool )

PlateThickness = GetUserDRO(1151) 'Z-plate thickness DRO

If GetOemLed (825)=0 Then 'Check to see if the probe is already grounded or faulty
DoOEMButton (1010) 'zero the Z axis so the probe move will start from here
Code "G4 P5" ' this delay gives me time to get from computer to hold probe in place
Code "G31Z-40 F500" 'probing move, can set the feed rate here as well as how far to move
While IsMoving() 'wait while it happens
Wend
ZProbePos = GetVar(2002) 'get the axact point the probe was hit
Code "G0 Z" &ZProbePos 'go back to that point, always a very small amount of overrun
While IsMoving ()
Wend
Call SetDro (2, PlateThickness) 'set the Z axis DRO to whatever is set as plate thickness
Code "G4 P0.25" 'Pause for Dro to update.
Code "G0 Z25.4" 'put the Z retract height you want here
Code "(Z axis is now zeroed)" 'puts this message in the status bar
Else
Code "(Z-Plate is grounded, check connection and try again)" 'this goes in the status bar if aplicable
Exit Sub
End If


Quote
'M6 start macro with auto tool touch off

'M6Start.m1s
tool = GetselectedTool()
oldTool = GetOEMDRO(1212)
If (oldTool <>  tool) Then

Old_tool = GetCurrentTool()
New_Tool = GetSelectedTool()

 DoSpinStop()
 If getoemled(13) Then
   'coolant is on
   setuserled(1000,1)' set user led on
   Code "M9"
 Else
   'coolent is off
   setuserled(1000,0) ' set user led off
 End If

  'Get the tool change pos from the settings page
  ChangeX = GetOEMDRO(1200)
  ChangeY = GetOEMDRO(1201)
  ChangeZ = GetOEMDRO(1202)
 
  Code "G00 G54 Z.25"
  Code "G00 G53 X" & ChangeX & "Y" & ChangeY
  'Code "G00 G53 Z" & ChangeZ, You may want to use this.

 
     Response = MsgBox ( "Would you like to set your Z height automatically? If so, click OK", 1 )
     If Response = 1 Then
      CurrentFeed = GetOemDRO(818) 'Get the current feedrate.
       PlateThickness =0.062
       ProbeFeed = 5


       Code "G90 F" &ProbeFeed

       If GetOemLed (825)=0 Then
       'Code "G4 P5" 'Time to get to the z-plate
       Code "G31Z-5 F" &ProbeFeed
       While IsMoving()
       Wend
       Code "G4 P0.25"
       ZProbePos = GetVar(2002)
       Code "G0 Z" &ZProbePos
       While IsMoving ()
       Wend
       Call SetDro (2, PlateThickness)
       Code "G4 P0.5" 'Pause for Dro to update.
       Code "G0 Z0.25" 'Change the Z retract height here
       Code "(Z axis is now zeroed)"
       Code "F" &CurrentFeed
       Else
       Code "(Z-Plate is grounded, check connection and try again)"
       Exit Sub
       End If
    End If   
  SetCurrentTool( tool )                                   
 
End If




This is the M6 End Macro

'M6End.m1s

tool = GetDRO(24)
oldTool = GetOEMDRO(1212)

If getuserled(1000) Then ' check user led
   'coolant was on
   Code "M8"
End If

If (oldTool <>  tool) Then
SetOEMDRO(1212,tool)

End If

Offline ger21

*
  • *
  •  6,288 6,288
    • View Profile
    • The CNC Woodworker
Re: How to - code manual tool change?
« Reply #7 on: October 22, 2014, 05:54:05 PM »
Appreciate the posts.

I've been doing some digging around and I think I've found some macro's that I can add to the M6Start.mls but since I'm new to this I'm not 100% certain on where the functions are getting the represented information.

Hopefully the owners of the macro's won't mind me posting their work.

For instance, GetOemDRO(818) or GetOEMDRO(800) where does 818 and the 800 come from and how/where do I find it???

Do I need to save the current tool like in the last macro?

Why do you need to set the current tool? SetCurrentTool( tool )

Obviously this opens a can of questions from a greenie such as myself.

Adam,


DRO information is in the Wiki. http://www.machsupport.com/Mach3Wiki/index.php?title=OEM_DROs

If you're manually changing tools, you don't really need to mess with the tool #s at all.
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: How to - code manual tool change?
« Reply #8 on: October 22, 2014, 11:08:17 PM »
Thanks Gerry.

What about the other items and where the numbers come from?

PlateThickness = GetUserDRO(1151) 'Z-plate thickness DRO
DoOEMButton (1010) 'zero the Z axis so the probe move will start from here
ZProbePos = GetVar(2002) 'get the axact point the probe was hit

Offline ger21

*
  • *
  •  6,288 6,288
    • View Profile
    • The CNC Woodworker
Re: How to - code manual tool change?
« Reply #9 on: October 23, 2014, 07:12:17 AM »
THe User DRO is user defined. In this case it's for the thickness of the touch late being used.

The Var's are not very well documented. 2002 is the Z axis position where the probe hit occurs.

http://www.machsupport.com/Mach3Wiki/index.php?title=OEM_Buttons

http://www.machsupport.com/Mach3Wiki/index.php?title=OEM_LEDs
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html