Z 0 with tool change

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

Z 0 with tool change

Postby jedy » Fri Feb 12, 2021 11:58 am

Hello to the whole forum, I'm switching from mach3 to Uccnc and now I have reached the point of macros in particular the manual tool change. My machine has a fixed probe on a point of the work surface, what I did with mach3 was to move with the tool until it touches the workpiece zero or z axis and I started work, mach3 went to the fixed probe and measured the tool offset. Can you do the same thing with Uccnc? By zeroing the axes without the mobile probe?
jedy
 
Posts: 6
Joined: Sun Jan 10, 2021 5:38 pm

Re: Z 0 with tool change

Postby Battwell » Fri Feb 12, 2021 12:47 pm

i have a fixed probing macro that replaces standard m31 probe routine.
probes, saves tool length and applies offset ready to resume for that tool.
can also be added to the end of your m6 tool change macro.
so basically once you have set your work zero for your first tool you can then just continue on tool by tool.
Uc300eth on router and mill.
UK uccnc powered machine sales. https://cncrouter.uk/atc-cnc-routers.htm
Automateanything/duzzit cnc/mercury cnc
Battwell
 
Posts: 867
Joined: Sun Sep 25, 2016 7:39 pm
Location: South Wales. Uk

Re: Z 0 with tool change

Postby Battwell » Fri Feb 12, 2021 12:53 pm

Code: Select all
int headnumber = 1;     //hsd
int headdownport = 3;
int headdownpin = 6;
int head1downport = 3;
int head1downpin = 6;
int head2downport = 3;
int head2downpin = 7;//         dont worry about above- not used in this machine.
// Probing settings//
double Zmin = -200;
double Zmin2 = -3;
double Feedrate = 500;
double Feedrate2 = 30;
double SafeZ2 = -50;
double retractheight = 10;
double retractheight2 = 2.5;
int Newtool = exec.Getnewtool();
int stoppedled=11;
// ***set tool field number***

int Boxnumber = 195;// fieldnumber for tools 1-20 (field 196)
if (Newtool >20)
{
Boxnumber = 921-21;// fieldnumber for tools 21-96. minus 21 so tool increment is correct
}

// ***end of set tool field number***


double probeyes = exec.Getvar (1);


double ToolXchgpos = -200; // Toolchange X position
double ToolYchgpos = -36.5; // Toolchange Y position  // HSD
double probeheight = -150.71;// hsd // use m312 to get exact position of probe with no tool
double probeX = 4;          // these are machine co ordinates of probe position
double probeY = -36.5;

//M31 probing macro

if (AS3.GetLED(18) && !AS3.GetLED(stoppedled));      // check idle (18)-then check spindle stopped: relay on vfd
//if (probeyes <1)
               { // probe if #1=0 *********************


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(exec.mainform,"MACHINE NOT HOMED, home the machine before tool change!");
  exec.Stop();
  return;
}

while(exec.IsMoving()){}
exec.Wait(200);
if(exec.GetLED(37)) // if probe signal is on - probe stuck! stop here...
{
  MessageBox.Show(exec.mainform,"The probe signal isnt ready-check probe!");
exec.Setvar(0, 100);//stops manual change macroloop blocking the output for eject
  exec.Stop();
  return;
}

//HEAD DOWN
//exec.Setoutpin(headdownport,headdownpin);

double Zoriginalpos = exec.GetZmachpos(); // Get the current Z machine coordinates

exec.Setvar(5063,0);


exec.Code("G00 G53   Z-0.5");//  // Move above the probe sensor position in z
exec.Code("G00 G53  Y" + probeY + "Z-0.5");//  // Move to the probe sensor position in XY
while(exec.IsMoving()){}

//********switch to incremental *********
exec.Code("G91");

exec.Code("G31 Z" + Zmin + "F" + Feedrate); // Move to the probe sensor position in z
while(exec.IsMoving()){}

exec.Wait(100);
Console.Beep();


if(!exec.GetLED(244)) // if didnt hit probe  stop here...
{
  MessageBox.Show(exec.mainform,"The probe didnt hit!");
  exec.Stop();
  return;
}



double probed1 = exec.Getvar(5063); // Get the current Z  coordinates//*****using vars

//exec.AddStatusmessage("probe at   "+ probed1);
exec.Code("G90");
exec.Code("G01 f200  Z" + probed1 );
while(exec.IsMoving()){}
exec.Wait(100);
Console.Beep();



double Zoriginalposprobed = exec.GetZmachpos(); // Get the current Z machine coordinates

double Zoriginalposprobed2 = exec.GetZmachpos(); // Get the current Z machine coordinates



double probedpos= Zoriginalposprobed - Zoriginalpos;
double probedpos2= Zoriginalposprobed2 - Zoriginalpos;// *****using vars


//exec.AddStatusmessage("Tool length old method1  "+ probedpos);




exec.Code("G91");

//double backoff = exec.GetZmachpos() + retractheight2;

//exec.Code("G00 G53 Z" + backoff); // Move few mm?? above probe plate
exec.Code("G00  Z"+ retractheight2 ); // Move 2 mm?? above probe plate
 while(exec.IsMoving()){}
 exec.Wait(100);

exec.Setvar(5063,0);
//Console.Beep();

if(exec.GetLED(37)) // if probe signal is on- probe stuck! stop here...
{
  MessageBox.Show(exec.mainform,"The probe signal isnt ready-check probe!");
exec.Setvar(0, 100);//stops manual change macroloop blocking the output for eject
  exec.Stop();
  return;
}


exec.Code("G31 Z" + Zmin2 + "F" + Feedrate2); // slow probe
while(exec.IsMoving()){}

exec.Wait(100);
Console.Beep();

if(!exec.GetLED(244)) // if didnt hit probe  stop here...
{
  MessageBox.Show(exec.mainform,"The probe didnt hit!");
exec.Setvar(0, 100);//stops manual change macroloop blocking the output for eject
  exec.Stop();
  return;
}




double probed2 = exec.Getvar(5063); // Get the current Z  coordinates//*****using vars

//exec.AddStatusmessage("probed position   "+ probed2);
exec.Code("G90");
exec.Code("G01 f200  Z" + probed2 );
while(exec.IsMoving()){}
exec.Wait(100);
Console.Beep();
//Zoriginalposprobed2= exec.GetZmachpos(); // Get the current Z machine coordinates

//********switch to absolute *********
exec.Code("G90");


if(!exec.Ismacrostopped()) // If tool change was not interrupted with a stop only then validate
     {

 Zoriginalposprobed = exec.GetZmachpos(); // Get the current Z machine coordinates
double goodprobed = exec.Getvar(5060); // ****using vars
//exec.AddStatusmessage("probe good?    "+ goodprobed);


 probedpos= Zoriginalposprobed - Zoriginalpos;
exec.Wait(100);
//probedpos2= Zoriginalposprobed2 - Zoriginalpos;//*****using vars




double tooloffset=  Zoriginalposprobed - probeheight;


exec.AddStatusmessage("Tool length now  "+ tooloffset);


 exec.Code("G00 G53  Z-0.5");// // Move z to -0.5 from home switch
 while(exec.IsMoving()){}
 exec.Wait(100);
exec.Code("G00 G53  y200");// // Move y to +200mm from home switch
 while(exec.IsMoving()){}
 exec.Wait(100);





// **** Set tool table ****


int fieldtoset= (Boxnumber + Newtool);// different field numbers now with extra tools added in this version

AS3.Setfield(tooloffset, fieldtoset);
exec.Wait(100);
AS3.Validatefield(fieldtoset);
//exec.AddStatusmessage("field # "+ fieldtoset);


exec.Callbutton(168);// apply all settings
 exec.Wait(100);
exec.Callbutton(167);// save all settings
 exec.Wait(100);


AS3.Setfield(tooloffset, 169);//set tooloffset z

exec.Wait(200);
AS3.Validatefield(169); // this updates all settings with new z offset.

exec.Wait(100);
while(exec.IsMoving()){}

      
if(Newtool <96)
{
if(!exec.Ismacrostopped()) // If tool change was not interrupted with a stop only then validate new tool number
{
exec.Code("G0 G43 H"+ Newtool); // Load new tool offset
exec.Wait(100);
  exec.Setcurrenttool(Newtool); //Set the current tool -> the new tool
exec.Wait(100);
 // MessageBox.Show("Tool change done.");
exec.AddStatusmessage("Tool PROBED OK   Tool # "+ Newtool);

}
else
{
 exec.StopWithDeccel();
exec.Setvar(0, 100);//stops manual change macroloop blocking the output for eject
 MessageBox.Show("Tool change was interrupted by user!");
}
     }
}

      

               } //end of no probe loop *****************
Uc300eth on router and mill.
UK uccnc powered machine sales. https://cncrouter.uk/atc-cnc-routers.htm
Automateanything/duzzit cnc/mercury cnc
Battwell
 
Posts: 867
Joined: Sun Sep 25, 2016 7:39 pm
Location: South Wales. Uk

Re: Z 0 with tool change

Postby Battwell » Fri Feb 12, 2021 12:54 pm

if you use the code above. remove g49 from your post processor- so it doesnt cancel the tool length offset that has been applied.
Uc300eth on router and mill.
UK uccnc powered machine sales. https://cncrouter.uk/atc-cnc-routers.htm
Automateanything/duzzit cnc/mercury cnc
Battwell
 
Posts: 867
Joined: Sun Sep 25, 2016 7:39 pm
Location: South Wales. Uk

Re: Z 0 with tool change

Postby jedy » Fri Feb 12, 2021 2:40 pm

thank you very much as soon as I have some time I try it
jedy
 
Posts: 6
Joined: Sun Jan 10, 2021 5:38 pm

Re: Z 0 with tool change

Postby chrisdax » Wed Sep 18, 2024 11:38 am

i tried this M31 macro and i really want to thank you for sharing with us !!

exactely what i needed

I had to mod the code for my CNC ( Z movement ) , but i spent les than 30 minutes to make it work :-)

chris
chrisdax
 
Posts: 16
Joined: Fri Aug 30, 2024 12:28 pm

Re: Z 0 with tool change

Postby crjohnson » Thu Sep 19, 2024 2:37 am

Hi guys,

Am trying to learn more about this tool offset macro, apologies in advance if this has been covered before. I currently use the free version of fusion to create my tool paths, therefore cannot post programs which require tool changes (I run an axbb-e and UCCNC).

1) Do people here use this tool offset macro in between machining programs or whenever the program calls for a different tool? My programs usually have this for example: "T14 M6 (face mill D=50. 50mm Face Mill)" which I block out using brackets so it is ignored.

2) If I was to use this macro can it be used in between programs? Therefore I might finish and close the first operation, change the tool, hit M31, then start the new operation once its measured the tool?
crjohnson
 
Posts: 33
Joined: Wed Feb 23, 2022 4:46 am

Re: Z 0 with tool change

Postby chrisdax » Thu Sep 19, 2024 7:59 am

i'm using also free fusion to make the Gcode,

save each Gcode for each tool ( i saved every tool with same number 1 in fusion )

in UCCNC, on the main windows, " change Tool 1 " will execute the M6 macro, so in this macro you can set your moves before tool change and then execute M31 macro for tool measurement,

so i do the tool change and tool offset update manually with the change tool button

Chris
chrisdax
 
Posts: 16
Joined: Fri Aug 30, 2024 12:28 pm


Return to General discussion about the UCCNC software

Who is online

Users browsing this forum: No registered users and 15 guests

cron