Tool length probing

Post anything you want to discuss with others about the software.

Tool length probing

Postby mephi » Sun Apr 09, 2023 4:51 pm

I'm trying to add a fixed tool length probe to my 3 axis CNC router.
I don't have an ATC or any way of indexing tools in my router, so I'm just looking to reference my tool changes against the first tool I started using.
So my current expected workflow will be:
1. Home machine
2. Get the initial tool length
3. Zero tool on workpiece
4. Run a program
5. Change tool
6. Get a new tool length
7. Run another program

Firstly, does that sound right?

I've been through the M31 script, and with a few minor tweaks I've got it to move to above the fixed probe location and touch off. It stops at the probe and everything is good there, but I'm not sure what it's supposed to do next.
The M31 script has G44 H1, but isn't that loading a tool offset rather than setting it? I've tried running the script as is, and it doesn't seem to update anything, the workpiece zero is still at the same point.

So I'm guessing I need to switch out G44 H1 for something else, any pointers as to what?

Thanks :-)
mephi
 
Posts: 8
Joined: Sun Apr 09, 2023 4:36 pm

Re: Tool length probing

Postby mephi » Mon Apr 10, 2023 12:09 pm

Ok, just to add to this question as I've been doing further reading and I'm starting to get somewhere.

I now think I need to do:
1. Home machine
2. Zero tool on workpiece
3. Run the M31 script to get the initial tool length
4. Run a program
5. Change tool
6. Run the M6 script to get the new tool length
7. Run another program

So I need to get the M31 script to set the original tool length, and then get the M6 script to update it.

I've got my M31 script to the point where it gets the tool length, I'm just not sure where to put it. This thread was useful in helping me get the values: https://www.forum.cncdrive.com/viewtopic.php?f=11&t=514

My main tweaks to the M31 script are:
Code: Select all
if(!exec.Ismacrostopped()) // If tool change was not interrupted with a stop only then validate new tool number
{
 double probedZwc = exec.Getvar(5063); // Get the current Z work coordinates //*****using var
 exec.AddStatusmessage("probe WC at   "+ probedZwc);
 double probedZmc = exec.GetZmachpos(); // Get the current Z machine coordinates
 exec.AddStatusmessage("probe MC at   "+ probedZmc);
 double toolLength = probedZmc - spindleZmin;
 exec.AddStatusmessage("tool length   "+ toolLength);
 AS3.Setfield(Toffset , (195+Tool));

 exec.Code("G00 G53 Z" + SafeZ); // Move back to save Z
 while(exec.IsMoving()){}

 if(domoveXY) // Make XY movement back to start position only if XY movement is enabled
 {
   exec.Code("G00 G53 X" + Xoriginalpos +" Y" + Yoriginalpos); // Move back to the original XY position
   while(exec.IsMoving()){}
 }

}
mephi
 
Posts: 8
Joined: Sun Apr 09, 2023 4:36 pm

Re: Tool length probing

Postby ger21 » Mon Apr 10, 2023 1:12 pm

Here's the way most of us do it.
1) You have a permanent fixed plate or tool setter, which is used as a reference position when changing tools.
2) You need a macro that sets Z zero, then touches the reference plate, and stores the reference plate location relative to Z zero.
3) After you change tools, you zero the new tool to the fixed plate, and set the offset value that was stored in the previous step.
Gerry
UCCNC 2022 Screenset - http://www.thecncwoodworker.com/2022.html
ger21
 
Posts: 2679
Joined: Sat Sep 03, 2016 2:17 am

Re: Tool length probing

Postby mephi » Mon Apr 10, 2023 5:48 pm

Thanks for responding, I think I'm nearly there...
I needed to use my machine this afternoon, so I did the process manually, where I updated the work coordinate Z by the difference between the previous tool probe value and the new one. So the process works, I just need to get UCCNC to do the sums for me :-)

1) Yep, I've got one of these:
Image

2) Currently my macro gets the difference between probed Machine Coordinate Z of the tool end and the the Machine Coordinate Z of the spindle end (stored as a variable in the macro). But I should be able to easily reference off any other value.
When you say "Sets Z zero" do you mean the work coordinate zero?
Also, when you say "stores the reference plate location" where should I do that? It looks like I could use the tool library, but as I'm not maintaining a library do I just use the first tool? The software seems to load with Tool 0, but there's not a Tool 0 in the library.

3) Ahhhh, ok that makes sense. I just need to work out where to store the value then...
mephi
 
Posts: 8
Joined: Sun Apr 09, 2023 4:36 pm

Re: Tool length probing

Postby ger21 » Mon Apr 10, 2023 10:53 pm

You can write it to a user field on the screen, or to a var.
Gerry
UCCNC 2022 Screenset - http://www.thecncwoodworker.com/2022.html
ger21
 
Posts: 2679
Joined: Sat Sep 03, 2016 2:17 am

Re: Tool length probing

Postby mephi » Tue Apr 11, 2023 10:36 am

Thanks "User field" was the term I was missing.

Is this documented anywhere?
I've looked in Macro_capability_detailed.htm, Fields_by_number.htm, and the manual PDF, there's no mention of user fields in any of them.

Right now I'm struggling with getting a user field, should this work?
Code: Select all
zOffset = Convert.ToDouble(exec.Readkey("UserTextfields", "20002", "0.000"));

I'm just getting "script error M31 has errors" so there's something wrong with it, but the error message doesn't give any clues and I can't find an error log anywhere...

I've picked a user field number above 20002, which *I think* is the right thing to do, but I don't know...

I'm then planning to update the field if it's 0 with the new one, and set the new WC Z height if it's not:
Code: Select all
 if(zOffset != 0){ // There is already an offset
   exec.Setvar(zOffset, 5063);
   exec.AddStatusmessage("offsetting Z height");
 } else {
   exec.AddStatusmessage("storing new offset");
   AS3.Setfield(zOffset, 20002);
 }


That'll work for now, then I can break it out to an additional M6 script once that's ok...
mephi
 
Posts: 8
Joined: Sun Apr 09, 2023 4:36 pm

Re: Tool length probing

Postby ger21 » Tue Apr 11, 2023 10:56 am

You'll need to use the screen editor and add a field to the screen. I don't remember the allowable values, but between 10,000 and 20,000 should be fine.
Code: Select all
AS3.Setfield(offsetvalue, fieldnumber);
AS3.Validatefield(fieldnumber);


To read it, use:

Code: Select all
 double fieldvalue = AS3.Getfielddouble(fieldnumber);
Gerry
UCCNC 2022 Screenset - http://www.thecncwoodworker.com/2022.html
ger21
 
Posts: 2679
Joined: Sat Sep 03, 2016 2:17 am

Re: Tool length probing

Postby mephi » Tue Apr 11, 2023 11:39 am

It works!!!! Thanks Gerry :-)

Your comment here: https://www.forum.cncdrive.com/viewtopic.php?f=11&t=2793 was the last piece of the puzzle in setting the Z height.

Next I'm going to split it out into M6 and M31 scripts, if that works ok, I'll do a write up of it all in case someone else stumbles upon this post later...
mephi
 
Posts: 8
Joined: Sun Apr 09, 2023 4:36 pm

Re: Tool length probing

Postby Abakker » Mon Apr 17, 2023 9:10 pm

Any luck here? I'm trying to figure out how to measure my tool offsets and populate the tool table. Have you had any luck with that part?
Abakker
 
Posts: 5
Joined: Sat Dec 10, 2022 2:58 am

Re: Tool length probing

Postby mephi » Sat May 20, 2023 7:59 pm

I'm not working it that way, as I don't have toolholders, just an ER collet.

My code works out the current probe offset from zero, and then each time you change tools you can tap the probe and reset the z height to the probe offset. So no tool table for me.

The reason I'd not updated this page with my code is that I was trying to get it to handle tool changes it properly with an M6, but that didn't fit well into my workflow of manually changing tools.
I tried it a few times and I couldn't get it working well I think it's because my spindle control is currently manual too, so the machine can't turn on/off the spindle before probing.

I've moved the M6 to a custom Macro, and so I've got manual control of everything now, which is working ok for me so far. I may well change it around again when I being in automatic spindle control...

I'm going to give it a goon a few more projects and if I'm happy with the new workflow I'll post it all up.
mephi
 
Posts: 8
Joined: Sun Apr 09, 2023 4:36 pm

Next

Return to General discussion about the UCCNC software

Who is online

Users browsing this forum: No registered users and 8 guests