Manual tool change + tool lengh touch off

More
28 Nov 2010 14:42 #5692 by axel88
My emc2 version is 2.3.5 , too. And calling a subroutine from a ngc file works as you sad. Except when line number are in front of the o :( I have to tell my postprocessor to leave them away...

But I've got troubles with the hal:

The mill machine doesn't stop if it reaches the probe. I'm not sure if probe-in or motion.probe.input is the pivotal signal?

In the hal from the stepconf.wizard it is linked as followed:
net probe-in => motion.probe-input
(...)
outputs
(...)
net probe-in <= parport.0.pin-10-in-not

Every time I try to change my hal I get errors, it would be nice if you could help me again.

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

More
28 Nov 2010 14:45 #5693 by axel88
ok I had luck:
unlinkp parport.0.pin-10-in-not
unlinkp motion.probe-input
net probe-in => motion.probe-input
loadrt debounce cfg=1
addf debounce.0 base-thread
setp debounce.0.delay  10
net probe-raw parport.0.pin-10-in-not => debounce.0.0.in
net probe-in <= debounce.0.0.out

so it worked.
The following user(s) said Thank You: Sadmeatball

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

More
28 Nov 2010 15:03 #5696 by andypugh
axel88 wrote:

Every time I try to change my hal I get errors, it would be nice if you could help me again.


This message has a very brief intro to hal that I wrote in reply to another question. It might help you understand the basics of HAL

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

More
28 Nov 2010 15:14 #5697 by axel88
I'm close to the final test it's just a disfigurement but why doesn't Axis cope with the G53 command as I think it should:
o<first-tool> sub
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
G90 G53 G0 Z0
G90 G53 G0 X0 Y0
G91 G38.3 Z-100 F500
G91 G38.5 Z10 F15
G43.1 k[#5063-#1000]
G90 G53 G0 Z0
G90 G53 G0 X50 Y50
o<auto-tool-change> endsub
M02
testfile:
o<first-tool> call
o<auto-tool-change> call
M2

If I open and run the testfile Axis tells me this would cross the lower z limit value. If I affirm it and it runs it works as it should. My Z axis is defined from -180 to 0.

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

More
28 Nov 2010 19:20 #5703 by andypugh
Can you use G53 instead of G91 for the probe moves? (I am not sure it would help)
Alternatively, perhaps you need to run to Z -179.99 ?

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

More
28 Nov 2010 20:00 - 28 Nov 2010 20:43 #5706 by axel88
No G53 just works with G00 or G01. Z-179.99 wouldn't work either, because he sais the Z distance would be 260mm. So there's a "huge" distance out of the limits.


EDIT:

I changed in auto-tool-change.ngc G91 G38.3 Z-100 F500 to G91 G38.3 Z-180 F500 and added a M06 now Axis thinks to be in the limits and it works really fine!

Thanks a lot for the help!

As bonus I'll try to get the Tool number out of the postprocessor into the M06 command then it's perfekt :)
Last edit: 28 Nov 2010 20:43 by axel88.

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

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.

Time to create page: 0.120 seconds
Powered by Kunena Forum