Manual tool change + tool lengh touch off

More
08 May 2011 20:02 - 09 May 2011 11:27 #9663 by billykid
Hello everyone, I tried to do this configuration, but this line
G43.1 k [# 5063 - # 1000] gives me error (K word without g2 g3) can someone help me?
The probe works well with G38 is all right
thanks
Last edit: 09 May 2011 11:27 by billykid.

Please Log in or Create an account to join the conversation.

More
03 Sep 2013 13:43 #38444 by the_muck
Hallo,
i think there is missing a G49
o<first-tool> sub
G21 G90 M9 M8 M5
G49
G90 G53 G0 Z0 
G53 G0 X0 Y0
G91 G38.3 Z-180 F500
G91 G38.5 Z10 F15
#1000=#5063
G90 G53 G0 Z0
G90 G53 G0 X50 Y50
o<first-tool> endsub
M02
o<auto-tool-change> sub
G21 G90 M9 M8 M5
G49
G90 G53 G0 Z0
G90 G53 G0 X0 Y0
G91 G38.3 Z-100 F500
G91 G38.5 Z10 F15
G43.1 Z[#5063-#1000]
G90 G53 G0 Z0
G90 G53 G0 X50 Y50
o<auto-tool-change> endsub
M02

And i changed G43.1 k[#5063-#1000] to G43.1 Z[#5063-#1000]. With the Hal-Meter you can see the offest in motion.tooloffset.z

Please Log in or Create an account to join the conversation.

More
25 Jun 2014 07:35 - 25 Jul 2014 15:31 #48235 by orangecat
Some great work here, but I couldn't find a tool change height adjustment subroutine that was generic enough just to safely use in almost all g-code.
I wanted the subroutine to be automatically called on M6.
The idea is to make sure all the modes are set correctly to accomplish the probe no matter what the state of the machine and then to put everything back as it was found before the subroutine was called including putting the tool back with the tip in exactly the same location.
In addition i wanted to ensure that travel was done in the safest manner possible while knowing nothing about the work.
I also wanted this to be easy to configure for different machines, using different home locations and to separate the location for tool changing from the location for height sensing and making both independent of the home location.

In the LinuxCNC .ini config file, under the [RS274NGC] section add:

# change/add/use SUBROUTINE_PATH to point to the location where these tool-change subroutines are located:
SUBROUTINE_PATH = /home/linuxcnc/linuxcnc/nc_files
REMAP=M6 modalgroup=6 ngc=tool-change
REMAP=M600 modalgroup=6 ngc=tool-job-begin

and under the [EMCIO] section add:

TOOL_CHANGE_AT_G30 = 0

and ensure neither TOOL_CHANGE_POSITION nor TOOL_CHANGE_QUILL_UP is set.

In the LinuxCNC .hal config file, map the appropriate input pin to be the probe input, e.g.:

net probe-z parport.0.pin-12-in => motion.probe-input


In the tool-change.ngc file, the CONFIGURATION PARAMETERS section must be set to match your machine.

Usage:
M6 in the g-code will invoke a manual tool change with automatic tool height adjustment. There must be an M6 T... command at the beginning of the first g-code file of a job and any subsequent files where tool-changes are implied. The first M6 will measure the tool for reference, subsequent M6 commands will pause execution to allow the tool to be changed (prompt the user for next tool required), and when resumed, will measure the tool and set the tool height adjustment before returning to the work at hand.

M600 is used at the very beginning of the first g-code file of a job (before any M6) so that the next M6 will measure the tool for reference instead of calculating a tool length offset. It can also be invoked manually through the MDI before a job starts. Technically M600 need only be used between jobs. If you fail to call M600 before the first job (after starting LinuxCNC) it will behave the same as if you had called M600.

General theory of operation: touches each tool off to the tool height sensor. The first tool is used as the reference, all subsequent tools adjust the tool offset. The tip of the tool is always placed back at the position it started in before M6 was called. It is moved away by raising Z to _TravelZ before moving towards the switch, and when moving back from the switch again moves at height _TravelZ before going straight back down to the original position. Set all necessary modes to ensure correct operation no matter what state the program is in when this is called. We eliminate almost all side effects by saving and restoring the modal state.

Enjoy but use at your own risk. You can damage tools and your machine and suffer personal injury because there may be bugs, because it may be configured incorrectly, because the documentation may be incorrect, because it may not work for all installations and all versions of LinuxCNC, because it may not work for your CNC mill or for other reasons not listed here.

tool-change.ngc: called on M6
O<tool-change> SUB
( Filename: tool-change.ngc )
( LinuxCNC Manual Tool-Change Subroutines for Milling Machines version 1.1: subroutine 1/2 )
(  BEFORE USING CHANGE "CONFIGURATION PARAMETERS" BELOW FOR YOUR MACHINE! )
(  )
( In the LinuxCNC .ini config file, under the [RS274NGC] section add: )
(    # change/add/use SUBROUTINE_PATH to point to the location where these tool-change subroutines are located: )
(    SUBROUTINE_PATH = /home/linuxcnc/linuxcnc/nc_files )
(    REMAP=M6    modalgroup=6 ngc=tool-change )
(    REMAP=M600  modalgroup=6 ngc=tool-job-begin )
( and under the [EMCIO] section add: )
(    TOOL_CHANGE_AT_G30 = 0 )
( and ensure neither TOOL_CHANGE_POSITION nor TOOL_CHANGE_QUILL_UP is set. )
(  )
( In the LinuxCNC .hal config file, map some input pin to be the probe input, e.g.: )
(    net probe-z parport.0.pin-12-in => motion.probe-input )
(  )
( Usage: M6 in the g-code will invoke a manual tool change with automatic tool height adjustment. )
(        M600 is used at the beginning of the first g-code file of a job so that the next M6 will measure the tool for reference )
(             instead of caluculating a tool length offset. It can also be invoked manually through the MDI before a job starts. )
(  )
( General theory of operation: touches each tool off to the tool height sensor. The first tool is used as the reference, all )
(     subsequent tools adjust the tool offset. The tip of the tool is always placed back at the position it started in before )
(     any of the subroutines are called. It is moved away by raising Z to _TravelZ before moving towards the switch, and when )
(     moving back from the switch again moves at height _TravelZ before going straight back down to the original position. Set )
(     all necessary modes to ensure correct operation no matter what state the program is in when this is called. We eliminate )
(     almost all side effects by saving and restoring the modal state. )
(  )
( Side effects: sets G30, sets motion mode to G1. )

(------------------------------- CONFIGURATION PARAMETERS ----------------------------------------------)
#<_UseInches> =           0     ( set to 1 to use inches here, or 0 to use millimeters; should match units on tool.tbl dimensions )
#<_TravelZ> =          41.0     ( machine Z coordinate for travelling, typically near max Z to avoid ever hitting the work )
#<_TravelFeed> =     1000.0     ( feedrate used for general Z moves when avoiding G0 )
#<_ProbeX> =          145.0     ( machine X coordinate of switch/touch-off plate )
#<_ProbeY> =            0.0     ( machine Y coordinate of switch/touch-off plate )
#<_ProbeFastZ> =        5.0     ( machine Z coord to move to before starting probe, longest tool should not touch switch at this Z )
#<_ProbeMinZ> =       -37.0     ( machine Z coord to stop probe, shortest tool must touch switch at this Z, must be > min Z )
#<_ProbeRetract> =      1.5     ( small distance to retract before approaching switch/touch-off plate second time )
#<_ProbeFastFeed> =   400.0     ( feed rate for moving to _ProbeFastZ )
#<_ProbeFeed1> =       80.0     ( feed rate for touching switch/touch-off plate first time )
#<_ProbeFeed2> =       10.0     ( feed rate for touching switch/touch-off plate second time )
#<_ToolChangeX> =       0.0     ( machine X coordinate to pause at for manual tool changing )
#<_ToolChangeY> =     -50.0     ( machine Y coordinate to pause at for manual tool changing )
#<_MistOnDuringProbe> =   1     ( set to 1 for mist, or 2 for coolant, or 0 for nothing during probing, to clear switch of swarf )
(-------------------------------------------------------------------------------------------------------)

O100 IF [ EXISTS[#<_ToolDidFirst>] EQ 0 ]
        #<_ToolDidFirst> = 0
O100 ENDIF
O105 IF [ #<_ToolDidFirst> EQ 0 ]
   G49                                         ( clear tool length compensation prior to saving state if this is first time )
O105 ENDIF

M6                                             ( do the normal M6 stuff )
M70                                            ( save current modal state )

M9                                             ( turn off coolant, will be restored on return if it was on )
M5                                             ( turn off spindle, cannot be on during the probe )
G[21 - #<_UseInches>]                          ( use inches or millimeters as required here, units will be restored on return )
G30.1                                          ( save current position in #5181-#5183... )
G49                                            ( clear tool length compensation )
G90                                            ( use absolute positioning here )
G94                                            ( use feedrate in units/min )
G40                                            ( turn cutter radius compensation off here )

O200 IF [ #<_ToolDidFirst> EQ 0 ]
  G53 G1 F[#<_TravelFeed>] Z[#<_TravelZ>]      ( go to high travel level on Z )
  G53 G0 X[#<_ProbeX>] Y[#<_ProbeY>]           ( to probe switch )
  G53 G1 F[#<_ProbeFastFeed>] Z[#<_ProbeFastZ>]( move tool closer to switch -- we shouldn't hit it )
  G54 G1 F[#<_ProbeFeed1>] G91                 ( use relative positioning )
  O101 IF [ #<_MistOnDuringProbe> EQ 1 OR #<_MistOnDuringProbe> EQ 2 ]
    M[7 + #<_MistOnDuringProbe> - 1]           ( turn on mist/coolant )
  O101 ENDIF
  G38.2 Z[#<_ProbeMinZ> - #<_ProbeFastZ>] F[#<_ProbeFeed1>]    ( trip switch slowly )
  G0 Z[#<_ProbeRetract>]                       ( go up slightly )
  G38.2 Z[#<_ProbeRetract>*-1.25] F[#<_ProbeFeed2>]   ( trip switch very slowly )
  M9                                           ( turn off mist )
  G90                                          ( use absolute positioning )
  #<_ToolZRef> = #5063                         ( save trip point )
  #<_ToolZLast> = #<_ToolZRef>                 ( save last tool Z position )
  G53 G1 F[#<_TravelFeed>] Z[#<_TravelZ>]      ( return to safe level )
  G53 G0 X[#5181] Y[#5182]                     ( return to where we were in X Y)
  G53 G1 F[#<_TravelFeed>] Z[#5183]            ( return to where we were in Z )
  M72                                          ( restore modal state )
  #<_ToolDidFirst> = 1                         ( we have been in this section to set reference value already )
O200 ELSE
  G53 G1 F[#<_TravelFeed>] Z[#<_TravelZ>]      ( go to high travel level on Z )
  G53 G0 X[#<_ToolChangeX>] Y[#<_ToolChangeY>] ( nice place for changing tool )
  O107 IF [#<_UseInches> EQ 1 ]
    #<ToolDiamIn> = #5410
    #<ToolDiamMM> = [ #<ToolDiamIn> * 25.4 ]
  O107 ELSE
    #<ToolDiamMM> = #5410
    #<ToolDiamIn> = [ #<ToolDiamMM> / 25.4 ]
  O107 ENDIF
  O102 IF [ #<_current_tool> EQ 0 AND #<ToolDiamIn> EQ 0 ]
    (MSG, Change tool then click Resume )
  O102 ELSE
    #<ToolDiamMM> = [ #<ToolDiamIn> * 25.4 ]
    (DEBUG, Change to tool #<_current_tool> with diameter #<ToolDiamMM>mm, #<ToolDiamIn>in then click Resume )
  O102 ENDIF
  M0                                           ( pause execution )
 
  G53 G0 X[#<_ProbeX>] Y[#<_ProbeY>]           ( to high place directly over switch )
  G53 G1 F[#<_ProbeFastFeed>] Z[#<_ProbeFastZ>]( move tool closer to switch -- we shouldn't hit it )
  G54 G1 F[#<_ProbeFeed1>] G91                 ( use relative positioning )
  O103 IF [ #<_MistOnDuringProbe> EQ 1 OR #<_MistOnDuringProbe> EQ 2 ]
    M[7 + #<_MistOnDuringProbe> - 1]           ( turn on mist/coolant )
  O103 ENDIF
  G38.2 Z[#<_ProbeMinZ> - #<_ProbeFastZ>] F[#<_ProbeFeed1>]     ( trip switch slowly )
  G0 Z[#<_ProbeRetract>]                       ( go up slightly )
  G38.2 Z[#<_ProbeRetract>*-1.25] F[#<_ProbeFeed2>]   ( trip switch very slowly )
  M9                                           ( turn off mist )
  G90                                          ( use absolute positioning )
  #<_ToolZ> = #5063                            ( save new tool length )
  G43.1 Z[#<_ToolZ> - #<_ToolZRef>]            ( set new tool length Z offset, we do this now to show operator even though it has to be set again after M72 )
  G53 G1 F[#<_TravelFeed>] Z[#<_TravelZ>]      ( return to high travel level )
  G53 G0 X[#5181] Y[#5182]                     ( return to where we were in X Y)
  G53 G1 F[#<_TravelFeed>] Z[#5183 - #<_ToolZLast> + #<_ToolZ>]   ( return to where we were in Z, ajusting for tool length change )
  #<_ToolZLast> = #<_ToolZ>                    ( save last tool length )
  
  M72                                          ( restore modal state )
  G43.1 Z[#<_ToolZ> - #<_ToolZRef>]            ( set new tool length Z offset )
O200 ENDIF

O<tool-change> ENDSUB
M2

tool-job-begin.ngc: called on M600
O<tool-job-begin> SUB
( Filename: tool-job-begin.ngc )
( LinuxCNC Manual Tool-Change Subroutines for Milling Machines version 1.1: subroutine 2/2 )
( Intended to be run as a remapped M600 command. Used to indicate that the next tool change, M6, is the first tool of a job. )

#<_ToolDidFirst> = 0                         ( new job, we haven't yet called <tool-change> for the first time )
G49                                          ( clear tool height adjustment )

O<tool-job-begin> ENDSUB
M2
Last edit: 25 Jul 2014 15:31 by orangecat.
The following user(s) said Thank You: billykid, koppi, harpia, jut, racedirector, jamwaffles, hancock, ikkuh, zfa, Sadmeatball and 2 other people also said thanks.

Please Log in or Create an account to join the conversation.

More
02 Jul 2014 06:42 #48377 by orangecat
I've updated the code and instructions in the previous post to work by remapping M6 instead of manually having to insert subroutine calls into the g-code.
The following user(s) said Thank You: jut, library, geoffs, ikkuh, Vector

Please Log in or Create an account to join the conversation.

More
25 Jul 2014 03:38 - 25 Jul 2014 03:46 #49106 by library
First off, orangecat I really appreciate the work you put into this and sharing.

It doesn't seem to behave like I would expect. Here are the steps I'm doing. My tool table is completely blank (no tool sizes, offsets, etc.) just a tool number.
  1. Load a drill bit in a collet into the tool holder. Machine thinks it has no tool
  2. Place a 123 block on top of the vice so there is two inches between the tip of the drill bit and the 123 block. Touch off and call that Z0. Remove the 123 block so if something goes wrong the tool and block won't get damaged.
  3. From the MDI call M600 (it simply returns, does nothing)
  4. From MDI call M6 T1. I leave the drill bit in the tool holder since this first measurement is the reference.
  5. The tip of the drill bit returns to the same spot, verified by sliding the 123 block underneath. TLO is 0
  6. From the MDI call M6 T2. I swap in a shorter tool, a 1/4" endmill when prompted. It is measured, the tip returns to the same spot. TLO is -.94
  7. From the MDI call M6 T3. I swap in an even shorter tool, a broken 1/8" endmill stub. It is measured, the tip is driven below the two inch location. TLO is -1.93 the Z location the tool stops at is listed as -.94, the same TLO of the previous tool.

Perhaps I'm misunderstanding something but I would expect tool 3 to return to the two inch, Z=0 location from the first tool. It's almost like the previous tool length offset is not being cleared before saving the Z height.
Last edit: 25 Jul 2014 03:46 by library. Reason: tool table info
The following user(s) said Thank You: orangecat

Please Log in or Create an account to join the conversation.

More
25 Jul 2014 06:43 - 25 Jul 2014 07:03 #49109 by orangecat
Thanks for reporting this problem library. Indeed, the code failed to place the tool back in exactly the same position after the 3rd tool change. I have updated the subroutines in the earlier post (to version 1.1) to correct for this problem and tested it for multiple tool changes with significant variations running both shorter and longer.
Last edit: 25 Jul 2014 07:03 by orangecat.
The following user(s) said Thank You: ruffle, library

Please Log in or Create an account to join the conversation.

More
26 Jul 2014 10:03 #49159 by library
Thanks, it works perfectly now. It's very cool to only have to touch off once and then have it automatic from then on.

Please Log in or Create an account to join the conversation.

More
01 Aug 2014 03:54 #49363 by billykid
Thanks Orangecat ! very good !

Please Log in or Create an account to join the conversation.

More
10 Feb 2016 09:28 #69917 by jut
Orangecat, excellent work, thank you very much! It work's perfectly on my machine.

Please Log in or Create an account to join the conversation.

More
06 Jul 2016 01:36 #77066 by hancock
Hello,

a huge thanks to Orangecat for the script - I was looking forever for something like this.

I only have the problem that it doesn't behave within a .ngc-file like it does when I use it with only MDI.

Maybe someone has an idea, as I have tried everything and just can't get it right. It either mills in the air or rams into the workpiece...

So this is my procedure:
1. Insert the first tool of the job-file
2. Touch the tool of on top of the workpiece to set Z0
3. Load the job-ngc-file
4. Hit M600
5. Start the job-file
6. Within the job.file I have a M6 command so it ask to insert the tool (already inserted and touched off the workpiece)
7. The job-file M6 command triggers the touch off
8. Milling is correct
9. Next M6 command within the job-file
10. Z-height is wrong - either milling in the air or way below the original Z0

This is a file I used for example
%
(VOLLPLATINE)
(T1  D=1. CR=0. - ZMIN=-0.1 - SCHAFTFRSER)
(T17  D=1. CR=0. - ZMIN=-0.2 - SCHAFTFRSER)
N10 G90 G94 G17 G91.1
N15 G21
N20 G53 G0 Z0.
(2D-TASCHE1)
N25 M9
N30 T1 M6
N35 S42000 M3
N40 G54
N45 M9
N55 G0 X2.379 Y11.374
N60 G43 Z15. H1
N65 G0 Z5.
N70 G1 Z2.5 F150.
N75 Z0.
...
N235 X8.568 Y11.35 Z-0.05 I-0.076 J-0.065
N240 G1 X8.56 Y11.356 Z-0.026
N245 X8.558 Y11.358 Z0.
N250 G0 Z15.
N260 M5
N265 G53 Z0.
(2D-TASCHE2)
N270 M9
N275 M1
N280 T17 M6
N285 S42000 M3
N290 M9
N300 G0 X2.379 Y11.374
...
%

Is there anything wrong with the .ngc-file that needs to be changed (post-processor) or is my order of touching off, etc. wrong?
Your help is truly appreciated!!!

Thanks & regards,
Hancock

Please Log in or Create an account to join the conversation.

Time to create page: 0.112 seconds
Powered by Kunena Forum