Manual tool change + tool lengh touch off
Please Log in or Create an account to join the conversation.
I reworked it to remove unneccessary code and parameters, I think the ini file is a better place to set parameters than gcode file.
Still Work in Progress, mostly for documentation, but I made some manual tool changes and everything goes fine.
I produces extensive output while it's WiP, one can remove PRINT to reduce verbosity.
I'm new in LinuxCNC, have some exeprience in gCode as I 3D print since several years now but had to RTFM again and again to understand some features.
Don't hesitate to make any remark.
( see: http://www.linuxcnc.org/index.php/english/forum/10-advanced-configuration/5596-manual-tool-change--tool-lengh-touch-off?start=120#227008 )
( 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 = macros )
( REMAP=M6 modalgroup=6 ngc=tool-change )
( 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 )
( For multiple probe inputs, the following can be used, in this case a MESA 7i96 is controlling a NO probe, and a NC Toolsetter )
( net probe-in <= hm2_7i96.0.gpio.005.in )
( net length-in <= hm2_7i96.0.gpio.009.in_not )
( net probe-in => or2.0.in0 )
( net length-in => or2.0.in1 )
( net probe-or-length <= or2.0.out => motion.probe-input )
( The following tool change pins are required as well; )
( loadusr -W hal_manualtoolchange )
( net tool-change iocontrol.0.tool-change => hal_manualtoolchange.change )
( net tool-changed iocontrol.0.tool-changed <= hal_manualtoolchange.changed )
( net tool-number iocontrol.0.tool-prep-number => hal_manualtoolchange.number )
( net tool-prepare-loopback iocontrol.0.tool-prepare => iocontrol.0.tool-prepared )
( In addition I have had to modify the post-processor for the following; )
( Eliminate G43 call outs after tool changes )
( Use G53 instead of G28, typically just a check box when post processing )
( Set machine home for Z in F360 machine setup to be -.250, my machine Zero is at top of travel )
( Usage: M6 in the g-code will invoke a manual tool change with automatic tool height adjustment. )
( My sequence of Running; )
( 1. Use a T99, a .250" Rod, to touch off X, Y, and Z of WCS as modeled in CAM )
( 2. Manually call an M6 T99, tool will touch off on toolsetter and store tool height )
( 3. Load program and run, M6 in program will prompt tool change, after changing, tool will touch off and Z will adjust )
( 4. Run any and all code using the same desired Z height for the WCS as designed )
( 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. )
( 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. )
( )
O<tool_change> SUB
(PRINT,tool change routine BEGIN)
(PRINT,current tool is #<_current_tool>)
(PRINT,selected tool is #<_selected_tool>)
O100 IF [ #<_selected_tool> EQ #<_current_tool> ]
#4921 = 0 (PRINT,LinuxCNC starting, initialize value)
O100 ELSE
(PRINT,save current position in WCS )
#<xpos> = #<_x> (PRINT,X=#<_x>)
#<ypos> = #<_y> (PRINT,X=#<_y>)
#<prevtool> = #<_current_tool>
#<tsx> = #<_ini[TOOLSENSOR]X>
#<tsy> = #<_ini[TOOLSENSOR]Y>
#<tsz> = #<_ini[TOOLSENSOR]Z>
#<trv> = #<_ini[TOOLSENSOR]TRAVELZ>
#<chx> = #<_ini[CHANGE_POSITION]X>
#<chy> = #<_ini[CHANGE_POSITION]Y>
#<chz> = #<_ini[CHANGE_POSITION]Z>
O101 IF [EXISTS[#4920]]
O101 ELSE
#4920 = #5220 (PRINT,save WCS id)
O101 ENDIF
O102 IF [ #<_metric> EQ 1 ] (PRINT,set probe feeds according to units )
#<fast> = 150.0 (PRINT,selected speed unit mm/mn )
#<slow> = 30.0
#<retract> = 3.0 (PRINT,mm )
O102 ELSE
#<fast> = 6.0 (PRINT,selected speed unit in/mn )
#<slow> = 1.2
#<retract> = 0.1 (PRINT,in )
O102 ENDIF
M9 (PRINT,turn off coolant, will be restored on return if it was on )
M5 (PRINT,turn off spindle, cannot be on during the probe )
M70 (PRINT,save current modal state )
G40 (PRINT,turn cutter radius compensation off here )
G49 (PRINT,clear tool length compensation )
G90 (PRINT,use absolute positioning here )
G94 (PRINT,use feedrate in units/min )
G53 G0 Z[#<trv>] (PRINT,moves to safe height for travelling)
G53 G0 X[#<chx>] Y[#<chy>]
G53 G0 Z[#<chz>] (PRINT,moves to desired potion for manual tool change )
M6 (PRINT,do the normal M6 stuff )
G53 G0 Z[#<trv>] (PRINT,go to high travel level on Z )
#<zDelta>=[#<_z>-#<trv>] (PRINT,retrieve absolute offset )
G53 G0 X[#<tsx>] Y[#<tsy>] (PRINT,to tool setter )
G38.2 Z[#<_ini[AXIS_Z]MIN_LIMIT>+#<zDelta>] F[#<fast>] (PRINT,trip switch slowly )
G91 (PRINT,relative move )
G0 Z[#<retract>] (PRINT,move away )
G0 Z-[#<retract>/2] (PRINT,go forward )
G38.2 Z-[#<retract>] F[#<slow>] (PRINT,trip switch very slowly )
G90 (PRINT,absolute moves )
O103 IF [ #<prevtool> EQ 0 OR #4920 NE #5220 OR #<_current_tool> EQ 99 ] (PRINT,first tool load or WCS change )
#4921 = #5063 (PRINT,save trip point )
#4920 = #5220 (PRINT,save WCS )
G53 G0 Z[#<trv>] (PRINT,return to safe level )
M72 (PRINT,restore modal state )
O103 ELSE
G53 G0 Z[#<trv>] (PRINT,return to high travel level )
M72 (PRINT,restore modal state )
G43.1 Z[#5063 - #4921] (PRINT,apply offset to Z height after Modal reset )
O103 ENDIF
G0 X[#<xpos>] Y[#<ypos>] (PRINT,return to where we were in X=#<xpos> Y=#<ypos> )
(PRINT,tool change routine END)
O100 ENDIF
O<tool-change> ENDSUB
M2
Please Log in or Create an account to join the conversation.
I can't get rid of huge backlash on my machine (mechanical issue), the opposite move naturally compensate this backlash and makes no difference (I guess) on a well calibrated machine.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
it goes through all the motions; moves to position> asks for tool> checks tool height etc. all fine.
The problem is it isnt storing the offset in the tool table or showing in the bottom of axis. I can see the numbers are being written to the .var file but then it doesnt seem to do anything with it. The only way i can get it to update the offset is by manually pressing the tool touchoff button in the axis gui.
Im new to linux and linuxcnc and cnc in general so i know ive probably done (or not done) something dumb!
any help or direction in which to look would be appreciated.
edit to add relevent info from hal/ini etc.
in hal added-
net probe-in => motion.probe-input
net probe-in <= nyx.0.in-11-not
loadusr -W hal_manualtoolchange
In postgui added-net tool-change iocontrol.0.tool-change => hal_manualtoolchange.change
net tool-changed iocontrol.0.tool-changed <= hal_manualtoolchange.changed
net tool-number iocontrol.0.tool-prep-number => hal_manualtoolchange.number
net tool-prepare-loopback iocontrol.0.tool-prepare => iocontrol.0.tool-prepared
in ini added-
SUBROUTINE_PATH = /home/russ/linuxcnc/nc_files
REMAP =M6 modalgroup=6 ngc=tool-change
REMAP = M600 modalgroup=6 ngc=tool-job-begin
TOOL_CHANGE_AT_G30 = 0
in tool-change.ngc I changed params to suit machine and nothing else.
Please Log in or Create an account to join the conversation.
it goes to the correct height if I manually input the correct offset into the tool table.
and it goes to the correct height if I disable the tool table.
Any ideas please? everything looks like it works as it should except the tool table isnt getting changed. (if that is how it should work??)
Ive done ok so far, I litterally started for the first with LCNC about 3 weeks ago and have manually set up the machine without using the configs wizards ( i cant because im using unsuported servos with an obscure controller) and have been trying to get this tool setter to work for the last 4 days (as in 8am to 6pm days) and it now has me stumped.
Please Log in or Create an account to join the conversation.
After eg. T99 is used to touchoff X Y Z , and afterwards probed, it is reverenced with #<_ToolZRef> = #5063
All following probed tools getting offset from first tool with G43.1 Z[#<_ToolZ> - #<_ToolZRef>]
linuxcnc.org/docs/2.8/html/gcode/g-code.html#gcode:g43.1
That is why tooltable is not used for length and G43 is not needed in gcode. DIAM entrys should be done, if cuttercompensation used.
from tool-change:
( My sequence of Running; )
( 1. Use a T99, a .250" Rod, to touch off X, Y, and Z of WCS as modeled in CAM )
( 2. Manually input M600 ) or just enter #<_ToolDidFirst> = 0 in MDI
( 3. Manually call an M6 T99, tool will touch off on toolsetter and store tool height )
( 4. Load program and run, M6 in program will prompt tool change, after changing, tool will touch off and Z will adjust )
( 5. Run any and all code using the same desired Z height for the WCS as designed )
( 6. For new WCS repeat from Step #1 )
Please Log in or Create an account to join the conversation.
I had just spent the last few hours trying to get gcode to update the tool table but ill just disable it and make sure I number my tools properly. now I can at least put this part to bed, now i need to start looking into a debounce feature since the toolsetter is re-triggering sometimes after detection.
Please Log in or Create an account to join the conversation.
I don't need to probe tool lengths as my machine has repeatable tool holders. (What spindle are you using? Given the effort that you are going to in the rest of the router build I would be surprised if you were not using a tool-changing spindle)
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.