M31 Tool length macro edit

This is where you talk about Macros, show examples of your macro scripting and SHARE handy segments of script code as examples.

M31 Tool length macro edit

Postby spumco » Mon Jan 29, 2018 4:40 am

All,

I've got my spindle probe set in the table as #96. I have, once or twice, forgotten to do the G43 H96 in MDI before using the auto tool length macro and wound up with incorrect Z-heights. No crashes so far, but it's only a mater of time with me.

I'd like to edit the M31 macro so that a particular tool offset is applied before the probing begins.

I'm thinking exec.Setcurrenttool(96) is the correct line to add to the macro, but I'm not sure where to put it.

Can someone help me edit M31 so I can avoid certain doom when I'm not paying attention?

Thanks much,
Ralph
spumco
 
Posts: 306
Joined: Mon Oct 03, 2016 10:10 pm

Re: M31 Tool length macro edit

Postby spumco » Mon Jan 29, 2018 5:18 am

Maybe this would be better?

exec.code (G43 H96)
spumco
 
Posts: 306
Joined: Mon Oct 03, 2016 10:10 pm

Re: M31 Tool length macro edit

Postby spumco » Thu Feb 01, 2018 4:46 am

Well, neither of those worked (by themselves or together) when I put them here in the M31 macro:


bool domoveXY = false; //Enable XY movement
bool dodualcycle = true; //Do probing from 2 cycles, first with Fast and second with Slow feedrates

exec.Setcurrenttool(96); //sets tool to #96
exec.Code("G43 H96"); //Sets tool offset to #96 probe


if(!exec.GetLED(56)||!exec.GetLED(57)||!exec.GetLED(58)) // If machine was not homed then it is unsafe to move in machine coordinates, stop here...
{
MessageBox.Show("The machine was not yet homed, home the machine before run to parking position!");
exec.Stop();
return;


Anyone have any suggestions on how to set the desired tool number automatically?
spumco
 
Posts: 306
Joined: Mon Oct 03, 2016 10:10 pm

Re: M31 Tool length macro edit

Postby cncdrive » Thu Feb 01, 2018 8:16 am

I've tested the mentioned codes and they work just fine.
You probably don't understand what those codes are doing and so you do not see that they work.
I'm attaching a few printscreens for you to let you see what these codes are doing.

The code exec.Setcurrenttool(96); sets the tool number for the UCCNC, so the software will know that the currently selected tool is the 96. in this example. When the code is executed then the tool number DRO on the RUN page changes the number to the newly selected tool.
The exec.Code("G43 H96"); selectes the tool length offset of the tool in the H parameter, the 96. in this case, so it puts the offset into the Tool offset DRO.
Attachments
settool1.png
cncdrive
Site Admin
 
Posts: 4719
Joined: Tue Aug 12, 2014 11:17 pm

Re: M31 Tool length macro edit

Postby cncdrive » Thu Feb 01, 2018 8:17 am

more pics
Attachments
settool2.png
cncdrive
Site Admin
 
Posts: 4719
Joined: Tue Aug 12, 2014 11:17 pm

Re: M31 Tool length macro edit

Postby cncdrive » Thu Feb 01, 2018 8:17 am

More pics
Attachments
settool3.png
cncdrive
Site Admin
 
Posts: 4719
Joined: Tue Aug 12, 2014 11:17 pm

Re: M31 Tool length macro edit

Postby spumco » Thu Feb 01, 2018 11:23 am

That's exactly what I checked after testing the exec.Code change. Ran the macro and then checked the offsets page and the tool offset was still at zero.

I noticed that there's a line near the end of the macro:

exec.Code("G44 H1"); // Load tool offset one, note the tool lenght is defined in the tools menu

I changed this line to G43 H1 since my tools are all positive numbers and the macro didn't run properly.

What is this line doing, and should I get rid of it or use it to set the tool length to #96?
spumco
 
Posts: 306
Joined: Mon Oct 03, 2016 10:10 pm

Re: M31 Tool length macro edit

Postby cncdrive » Thu Feb 01, 2018 11:31 am

It works fine at me with both G43 and G44.
The Tool offset on the offset page will be 0 if the value of the Tool Z offset of the tool defined with the H parameter was 0 when you executed the G43 or G44.
If you want to ged rid of that code depends on what and how you want to do about the tool change and handling of the lenghts etc.
cncdrive
Site Admin
 
Posts: 4719
Joined: Tue Aug 12, 2014 11:17 pm

Re: M31 Tool length macro edit

Postby spumco » Thu Feb 01, 2018 9:15 pm

I'm using the M31 tool length feature as a Z-height probe function. I'm putting my spindle probe in and touching off on the top of the part to set Z0 in the work coordinate.

I have the probe length in the tool table so if I set the tool offset to #96 (G43 H96) and run the macro then all my tools in the table are ready to go, having set them off-line with a height gauge. I am using the Tormach Tooling System holders, so the tool length is repeatable when I swap tools.

I do not do tool length measurements during a program, nor do I have an ATC.

I just want the macro to apply offset #96 automatically whenever it's called, and before the probing starts.
spumco
 
Posts: 306
Joined: Mon Oct 03, 2016 10:10 pm

Re: M31 Tool length macro edit

Postby cncdrive » Thu Feb 01, 2018 10:05 pm

The G43 H96 code simply writes the 96th tool's height data into the Tool Z offset in the offset table.
The tool height data is read from the tooltable and is written to the offset table at the time when you executing the G43 H96.
So, what is in the tool table will be written into the offset table.
The function is very simple in my opinion.
cncdrive
Site Admin
 
Posts: 4719
Joined: Tue Aug 12, 2014 11:17 pm

Next

Return to Macros

Who is online

Users browsing this forum: No registered users and 6 guests