- Posts: 542
- Thank you received: 241
Mcode subroutine for automatic tool length measuring
- MaHa
- Offline
- Platinum Member
-
Less
More
6 years 2 months ago - 6 years 2 months ago #177803
by MaHa
Replied by MaHa on topic Mcode subroutine for automatic tool length measuring
From retracted Z (G53 Z0), you need to know the distance from spindle to trigger-point of toolsetter.
[strike](If possible, probe the spindle, #<P1> = #5063)[/strike]
(If possible, probe the spindle, #<P1> = [#5063 + #[5203 + [#5220 * 20]]])
Keep this as negative value, eg #<P1> = -350
[strike]After probing your tool, #<TOOL_L> = ABS[#<P1> - #5063][/strike]
After probing your tool, #<TOOL_L> = ABS[#<P1> - [#5063 + #[5203 + [#5220 * 20]]]]
EDIT:
Sorry i gave misleading information. As #5063 probe result is related to active Z-offset, the correct way to get the absolute position is:
Probe trigger point absolute position = [#5063 + #[5203 + [#5220 * 20]]]
or
on probe contact, then G28.1 before lift off from probe, #5163 should give the same result.
[strike](If possible, probe the spindle, #<P1> = #5063)[/strike]
(If possible, probe the spindle, #<P1> = [#5063 + #[5203 + [#5220 * 20]]])
Keep this as negative value, eg #<P1> = -350
[strike]After probing your tool, #<TOOL_L> = ABS[#<P1> - #5063][/strike]
After probing your tool, #<TOOL_L> = ABS[#<P1> - [#5063 + #[5203 + [#5220 * 20]]]]
EDIT:
Sorry i gave misleading information. As #5063 probe result is related to active Z-offset, the correct way to get the absolute position is:
Probe trigger point absolute position = [#5063 + #[5203 + [#5220 * 20]]]
or
on probe contact, then G28.1 before lift off from probe, #5163 should give the same result.
Last edit: 6 years 2 months ago by MaHa. Reason: Incorrect information
The following user(s) said Thank You: simonmn
Please Log in or Create an account to join the conversation.
- simonmn
- Offline
- Senior Member
-
Less
More
- Posts: 40
- Thank you received: 4
6 years 2 months ago #178044
by simonmn
Replied by simonmn on topic Mcode subroutine for automatic tool length measuring
Thanks for the quick response! Sorry for the late reply.
Played around with the code today, but need some help with understanding it, especially the "[#5063 + #[5203 + [#5220 * 20]]]]" part.
Got the distance "Spindle nose to toolsetter" and saved it in the ini file, so i can pull it with #<_ini[toolsetter]z_skip_height>.
I got the code working like I wanted to with " #500 = [#5063 - #<_ini[toolsetter]z_skip_height>] ", but like you pointed out, this only works if the active offset (G54) is set to 0 at G53 Z0. Which isn't ideal.
The above code gave me the tool length in positive, which is nice. But when I tried " #500 = ABS[#<_ini[toolsetter]z_skip_height> -[#5063 + #[5203 + [#5220 * 20]]]] " I get a somewhat random number. Say the tool is 170mm, then the above would give me a 132mm or something like that.
Thanks again
Played around with the code today, but need some help with understanding it, especially the "[#5063 + #[5203 + [#5220 * 20]]]]" part.
Got the distance "Spindle nose to toolsetter" and saved it in the ini file, so i can pull it with #<_ini[toolsetter]z_skip_height>.
I got the code working like I wanted to with " #500 = [#5063 - #<_ini[toolsetter]z_skip_height>] ", but like you pointed out, this only works if the active offset (G54) is set to 0 at G53 Z0. Which isn't ideal.
The above code gave me the tool length in positive, which is nice. But when I tried " #500 = ABS[#<_ini[toolsetter]z_skip_height> -[#5063 + #[5203 + [#5220 * 20]]]] " I get a somewhat random number. Say the tool is 170mm, then the above would give me a 132mm or something like that.
Thanks again
Please Log in or Create an account to join the conversation.
- MaHa
- Offline
- Platinum Member
-
Less
More
- Posts: 542
- Thank you received: 241
6 years 2 months ago #178057
by MaHa
Replied by MaHa on topic Mcode subroutine for automatic tool length measuring
To explain the parameters used:
#5220 - Coordinate System number 1 - 9 for G54 - G59.3. Persistent.
#5223 - Coordinate System 1, G54 for Z, Increase by 20 for next CS.
When #5220 = 1 (G54)
Z Value (G54) #[5203 + [#5220 * 20]] .... (#[5203 + [1 * 20]] equal #5223)
So you are free to work and probe with from G54 to G59.3
If you replace '#<P1>' by 'z_skip_height' and it is a negative number, from G53 Z0, the code should return the distance between spindle and toolsetter when probing. At least my imagination tells me that...
#5220 - Coordinate System number 1 - 9 for G54 - G59.3. Persistent.
#5223 - Coordinate System 1, G54 for Z, Increase by 20 for next CS.
When #5220 = 1 (G54)
Z Value (G54) #[5203 + [#5220 * 20]] .... (#[5203 + [1 * 20]] equal #5223)
So you are free to work and probe with from G54 to G59.3
If you replace '#<P1>' by 'z_skip_height' and it is a negative number, from G53 Z0, the code should return the distance between spindle and toolsetter when probing. At least my imagination tells me that...
Please Log in or Create an account to join the conversation.
- chris@cnc
- Offline
- Platinum Member
-
Less
More
- Posts: 529
- Thank you received: 140
6 years 2 months ago - 6 years 2 months ago #178981
by chris@cnc
Replied by chris@cnc on topic Mcode subroutine for automatic tool length measuring
Hello,
I have now also tried to measure my tools automatically. I also find it very good when the tool length has a real value as Simonmn shows in the picture. I don't understand your calculation with so many parameters. My solution is a little simpler. I calculate back to the machine zero point + the fixed distance from the probe point spindle nose and zero point. What do you say about it?
unfortunately the print commando does not work
example
(print, reference length is # 500)
Does anyone have an example?
I have now also tried to measure my tools automatically. I also find it very good when the tool length has a real value as Simonmn shows in the picture. I don't understand your calculation with so many parameters. My solution is a little simpler. I calculate back to the machine zero point + the fixed distance from the probe point spindle nose and zero point. What do you say about it?
unfortunately the print commando does not work
example
(print, reference length is # 500)
Does anyone have an example?
Code:
T1 M6
G49
G90 (Absolute mode)
G53 G00 Z-10
M101 ( Laser on)
G4 P1
G91 ( relative mode for probing)
G38.2 Z-150 F1000 (search tool nose )
G1 Z3 ( tool off)
G4 P1
G38.2 Z-5 F100 (probe tool with probe feed )
G28.1 ( set distance from Zero point to current postion to #5161-#5166)
#500=[102+#5163] ( calculate tool length)
G1 Z1 F100 ( tool off)
G10 L1 P1 Z#500 (set length in tooltable)
G43 H1 (call tool compensation)
o1 if [#5070 EQ 1]
M102 (Laser off)
(MSG, Tool set)
o1 else
(MSG, Tool not set)
o1 endif
G90
M2
Last edit: 6 years 2 months ago by chris@cnc.
Please Log in or Create an account to join the conversation.
- MaHa
- Offline
- Platinum Member
-
Less
More
- Posts: 542
- Thank you received: 241
6 years 2 months ago #178993
by MaHa
Replied by MaHa on topic Mcode subroutine for automatic tool length measuring
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)
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.
- simonmn
- Offline
- Senior Member
-
Less
More
- Posts: 40
- Thank you received: 4
6 years 2 months ago - 6 years 2 months ago #179085
by simonmn
Replied by simonmn on topic Mcode subroutine for automatic tool length measuring
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.
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.
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.
Code:
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: 6 years 2 months ago 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: 3.266 seconds