Mcode subroutine for automatic tool length measuring

More
02 Mar 2020 08:43 - 02 Mar 2020 09:14 #158953 by simonmn
Hey guys.

I am working on a subroutine for automatic tool length measuring, but am a little uncertain how to best proceed.

What I want the machine to do is basically(I hope):

1. Operator calls a M106 T1 (or P1) to measure Tool 1
1.2. Either the machine changes to that tool, if not loaded. Or measures active tool and stores offset in Tool 1's offset.
2. Machine checks state of tool setter, to be sure its not smashing the tool down in a disconnected toolsetter.
3. Moves down at a fixed speed until it touches the tool setter.
4. Stores value.
5. Moves away, or to last X Y position

I'm hoping the subroutine could be converted into a breakage detection in the future.

I know there are a lot of automatic tool measuring threads, but I'm having some trouble finding the information I need.
Especially of point 3.
Writing a G01 Z-1000 F500 G(til sensor is active) seems wrong and dangerous, and I would very much like to know of a better way someone else has done it.

Here's what I have written so far.
o<M106> sub
(A suproutine for automatic tool length offset)


M5 (Stop spindle, if running)
M19 R0 (Orient spindle)


G49 (Cancel Tool Length Compensation)
G40 (Cancel tool Compensation)
G80 (Cancel Canned Cycle)
G90 (Absolute mode)
G17 (XY plane)



(G53 is Machine coordinate system)
G53 G0 Z0 (Move spindle to home position)

#<x-start-pos> = #5420 (Get X start position before move)
#<y-start-pos> = #5421 (Get Y start position before move)


G53 G0 X(Tool setter X Position) Y(Tool setter Y Position)
G4 P1 (Wait a second)


(Checks if the toolsetter is connectet properly. With a 3 seconds wait time)
M66 P7	L4 Q3	(Check if tool setter "set" state is correct. NC - LOW)
O100 if [#5399 LT 0]
     (abort, Tool Setter "Set" connection not connected properly)
O100 endif

M66 P8	L4 Q3	(Check if tool setter "overtravel" state is correct. NC - LOW)
O100 if [#5399 LT 0]
     (abort, Tool Setter "Overtravel" connection not connected properly)
O100 endif



M52 P0 (Cancel Adaptive Feed Control)
M50 P0 (Cancel Spindle Speed Override Control)


(Command to move the tool down until the toolsetter triggers) F1000

G91 (Incrementel mode)
G0 Z10

G90 (Absolute mode)

G01 (Zto toolsetter) F50

G10 L1 P#5400 (Active tool)




G53 G0 Z0 (Move spindle to home position)
G4 P1 (Wait a second) 

G53 G0 X#<x-start-pos> Y#<y-start-pos> (Go to X start position)


M02

Hope you can help me or point me in the right direction.
Last edit: 02 Mar 2020 09:14 by simonmn. Reason: Updated code a bit

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

More
02 Mar 2020 15:12 #158979 by bbsr_5a
lots of lines
its for most of us pritty simple
o<znullen> sub
G91                 ( relative mode for probing)
G38.2 Z-25 F100     ( trip switch on the way down)
G90                 ( absolute mode)
G92 Z0		  (set Z0 )
G1 Z3.5 F150		(move tool free)
o<znullen> endsub
M2

and this is started by button press or as of User-Mcode

The most interesting is that almost every mashine as well as every Company gots its own setup to behave toolmesurments
The following user(s) said Thank You: simonmn

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

More
02 Mar 2020 18:22 #159005 by MaHa
There are countless ways for toolprobing, hard to recommend a workflow.
My way, reducing the chance for crashing the toolseter, tool projection is in the cam tooldata. Then the tool is inserted as required. Previously this data is entered in tooltable, or is there already.
The travel distance to toolseter is calculated, according the tooltable entry. If the toolseter fails, the overshot is minimal. Feed and M52 can be adjusted just before measuring point.



Attachments:
The following user(s) said Thank You: simonmn

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

More
04 Mar 2020 13:45 #159192 by andypugh

Writing a G01 Z-1000 F500 G(til sensor is active) seems wrong and dangerous, and I would very much like to know of a better way


You need G38 (there are three versions, G38.1, G38.2, G38.3 and G38.4)
(Unfortunately I can't get to the LinuxCNC docs right now for some reason, so can't give a link)

G38 is a dedicated probing move.
The following user(s) said Thank You: simonmn

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

More
21 Apr 2020 13:11 #164960 by empireages
As andypush said, you want to make a protected move that will do 2 things :
1-Stop moving when it trip the toolsetter.
2- give you the coordinate of where it tripped.

G38 probing

Also if you want to measure thing like a 3 inch shell mill, before probing, move 1/2 time the diameter so your toolsetter will it on of the tool inserts.
With G38, you cant tell him to probe on a certain distance and if the toolsetter don't trip, then linuxCNC will alarm out. Protecting your machine of crashes.
But for that, i think you need to use the probing cycle based of an approximate distance that you can measure and enter in tooltable so it know x tool is approximately 1.25 inch, i go rapid to probe height + .15+ 1.25 then g38 for .5 then alarm if it don't touch or if the probe trip, calculate the real tool length.
This is how Mazak do their probing on their machine without renishaw tool setter.
My 2cents
The following user(s) said Thank You: simonmn

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

More
09 Aug 2020 11:32 #177743 by simonmn
Hope I can revive this post.

I took your suggestions and looked into G38. A lot more simple than I thought, and didn't take long to get something working.
Tested it first with bbsr_5a's code, to get a basis, but it seems like a "One tool, one offset" strategy with G92?
Made a fixed mount for the tool setter, so I don't need to pull in a touchplate to touch tools off.

I also really liked the idea of rough measuring your tool, and typing that into the tool table. aka, having the tool length being the distance from spindle nose, to tool tip. Kind of like MaHa showed and empireages talked about.


Now I'm a little unsure how to set this up on the machine. How do I make it so, that the tool length is the actual tool length from spindle to tip?

Here is the updated gcode I am playing around with, if it can help.
O1212
(Probe kode test program)

G90 (Absolute mode)
G53 G00 Z0
G53 G00 X#<_ini[toolsetter]x_position> Y#<_ini[toolsetter]y_position>
G4 P0.5
G53 G00 Z#<_ini[toolsetter]z_safe_height>
G4  P0.5

G91 (Incremental mode)

G38.2 Z-200 F#<_ini[toolsetter]tool_find_speed>

G01 Z4 F1000

G38.2 Z-6 F#<_ini[toolsetter]tool_set_speed>

G90 (Absolute mode)
G10 L1 P#5400 Z#5063 (Læs #5400, for at se hvilket værktøj er aktivt, og gem værdigen fra #5063 i det værktøjs længde)

G91 (Incremental mode)
G01 Z10 F1500

G90
G53 G00 Z0

(MSG, Tool length set)

M30
Am currently playing alot with macros, both at work and at home, hence the ini variable calls.

Hope you can point me in the right direction :)

Thanks for the help.
Attachments:

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

More
10 Aug 2020 07:53 - 12 Aug 2020 06:21 #177803 by MaHa
From retracted Z (G53 Z0), you need to know the distance from spindle to trigger-point of toolsetter.
(If possible, probe the spindle, #<P1> = #5063)
(If possible, probe the spindle, #<P1> = [#5063 + #[5203 + [#5220 * 20]]])
Keep this as negative value, eg #<P1> = -350
After probing your tool, #<TOOL_L> = ABS[#<P1> - #5063]
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: 12 Aug 2020 06:21 by MaHa. Reason: Incorrect information
The following user(s) said Thank You: simonmn

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

More
12 Aug 2020 16:46 #178044 by simonmn
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

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

More
12 Aug 2020 20:56 #178057 by MaHa
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...

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

More
22 Aug 2020 07:52 - 22 Aug 2020 08:16 #178981 by chris@cnc
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?
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: 22 Aug 2020 08:16 by chris@cnc.

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

Time to create page: 0.248 seconds
Powered by Kunena Forum