Mcode subroutine for automatic tool length measuring

More
22 Aug 2020 13:16 #178993 by MaHa
I agree, i shouldn't have posted a sequence from my probing routine, because there,the first reference is table surface. The reason why: It can be used for probing tool length or probing z-offset (with previously probed tool), where i can place the probe on the table, part or where ever. In that case the calculation is related to that surface, (or the accurate tripping height from toolsetter to spindle).
The parameter stuff is just a way to do it, beside G28.1 / #5163. But i think i just generated a general confusion with that.

change (print, reference length is # 500) to (debug, reference length is #500)

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

More
23 Aug 2020 09:56 - 23 Aug 2020 10:02 #179085 by simonmn
Just wanted to do a final update, since I now got it to work how I wanted to. Although I ended up using a Gmoccapy macro program shortcut instead of a Mcode.

Here is the code I have been playing with for the past week, and what I would call the final code for me.
Wrote comments on most of the lines, so that it could help anyone else that would like to use it.
O<set_tool_length> sub
(Tool length setting program)

M5 (Turn off spindle if active)
G90 (Absolute mode)
G53 G00 Z0 (Go to Z home)
G53 G00 X#<_ini[toolsetter]x_position> Y#<_ini[toolsetter]y_position> (Go to tool setter position coordinates, saved in the INI file)
G4  P0.5
G53 G00 Z#<_ini[toolsetter]z_safe_height> (Go to safe height above tool setter)
G4  P0.5

G91 (Incremental mode)

M50 P0 (Turn of feed override, to get consident speed)

G38.2 Z-200 F#<_ini[toolsetter]tool_find_speed> (Seek toolsetter, with speed saved in the INI file)

G01 Z4 F1000 (When the toolsetter triggers, jump 4mm up again to prepare for fine set)

G38.2 Z-6 F#<_ini[toolsetter]tool_set_speed> (Goes down till it touches the toolsetter, with fine speed saved in the INI file)

G90 (Absolute mode)

G30.1 (Saves machine coordinates in G30, where the Z distance can be pulled with macro #5183 )

#<TOOL_M_L> = [#5183 - #<_ini[toolsetter]z_skip_height>] (Calculates the tool measured length, with the set distance between spindle nose and toolsetter saved in the INI file)

G10 L1 P#5400 Z#<TOOL_M_L> (Reads #5400 to get active tool, and saves the value from TOOL_M_L in that active tools Z height)

G91 (Incremental mode)
G01 Z10 F1500 (Jogs free from the tool setter)

M50 p1 (Reactivates the feed override function)

G90
G53 G00 Z0 (And goes home in Z again)

(Next line in brackets, displays a message saying example "Tool 4 length measured")
(DEBUG, Tool #5400 length measured)

O<set_tool_length> endsub
M2

(

#5400 = Active tool
#5183 = G30 Z saved value


And in the INI file, i made a section that looks like this:

[TOOLSETTER]
X_POSITION      =   45.000
Y_POSITION      =    5.000
Z_SAFE_HEIGHT   =  -150.00
Z_SKIP_HEIGHT	=  -404.3578
TOOL_FIND_SPEED =   750
TOOL_SET_SPEED  =   50





This below, is because I use Gmoccapy, and wanted a shortcut

[MACROS]
MACRO = Set_tool_length

)

Couldn't understand the calculations well enough (the *20 part), so I chose to go the G30/G28 example you gave Maha, and It worked great. I also ended up using debug, just instead of msg.


Thanks again for the help and examples.
Last edit: 23 Aug 2020 10:02 by simonmn.
The following user(s) said Thank You: anfänger, ChironFZ16, spacemanspiffee

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

Time to create page: 0.056 seconds
Powered by Kunena Forum