Manual Tool Change with Probing Screen

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

Manual Tool Change with Probing Screen

Postby BiuTse » Mon Nov 30, 2020 8:22 pm

Hi,
I am confused, there are a lot of different M6 macros out there but the one I am interested I couldn't find because I don't have a facebook account.
It is the probing macro from Daniel Collins (https://www.youtube.com/watch?v=Bdlkbb3uh-E&t=2s)

There is no problem using the probing screen manually (configured with fixed probe).
I start a new job put in first tool, then using the probing screen to define workpiece height.
The cnc then goes automatically to the toolsetter and measure the tool.

And now job begins till first M6.
There I would like the cnc to go to defined place, where I manually change the tool, then it should automatically measure the tool and continue the job

I tried to understand the macro syntax of uccnc but honestly without a lot of success.
Could someone help me, plz?
THX
by
BiuTse
BiuTse
 
Posts: 11
Joined: Sat Nov 28, 2020 7:10 pm

Re: Manual Tool Change with Probing Screen

Postby dezsoe » Mon Nov 30, 2020 10:06 pm

Hi BiuTse,

In fact, Daniel Collins uses a bit modified version of my macro, which was originally posted here in this forum. Here is the current, updated version:

Code: Select all
// ================================================================================================
// M6 manual tool change macro v1.0
// ================================================================================================

if (!exec.GetLED(308))                                                          // Mobile wp referenced
{
  exec.AddStatusmessage("The workpiece was not referenced.");
  return;
}

int CurrTool = exec.Getcurrenttool();
int NewTool = exec.Getnewtool();

if (NewTool == CurrTool) return;

bool wasCycleRunning = exec.GetLED(54);

if (wasCycleRunning)
{
  exec.Stop();
  while(exec.IsMoving()){}
  exec.Code("");
}

if (NewTool == -1)                                                              // -1 -> there was no T word
{
  exec.AddStatusmessage("There was no T word for the M6.");
  return;
}

string NewToolName = "T" + NewTool;

double cpX = exec.GetXmachpos();
double cpY = exec.GetYmachpos();
double cpZ = exec.GetZmachpos();

double cpwZ = exec.GetZpos();

if (!GotoMachPos(tcpX, tcpY, tcpZ)) return;

MessageBox.Show(exec.mainform, "Insert new tool " + NewToolName, "Change tool");
if (exec.Ismacrostopped()) return;

exec.Callbutton(801);                                                           // Tool probe
exec.Callbutton(841);                                                           // Mobile probe
exec.Callbutton(800);                                                           // Quick jump to probe screen

if (!AS3.Getbuttonstate(851)) exec.Callbutton(851);                             // Zero probed axes

exec.Callbutton(848);                                                           // Goto probe pos
if (exec.Ismacrostopped()) return;

exec.Callbutton(821);                                                           // Start probing
while (!AS3.Getbuttonstate(821) && !exec.Ismacrostopped()) Thread.Sleep(10);
while (AS3.Getbuttonstate(821) && !exec.Ismacrostopped()) Thread.Sleep(10);
exec.Wait(500);
if (exec.Ismacrostopped()) return;

AS3.selectlayer(2);

if (!GotoMachPos(cpX, cpY, GetMachFromWorkZ(cpwZ))) return;

exec.Setcurrenttool(NewTool);

if (wasCycleRunning) exec.Callbutton(128);                                      // Cycle start if it was started

return;

#Events

const double tcpX = 100;
const double tcpY = 25;
const double tcpZ = -15;

bool GotoMachPos(double x, double y, double z)
{
  List<string> codelist = new List<string>();                                   //Create a new List of strings.

  double limitPlus = AS3.Getfielddouble(42);                                    // Z axis softlimit +
  bool limitValid = (AS3.Getfielddouble(41) != limitPlus);                      // Softlimit valid if limit+ <> limit-

  double cZ = exec.GetZmachpos();
  double safeZ = AS3.Getfielddouble(2734);                                      // SafeZ
  double moveZ = cZ;

  if (limitValid && (z > limitPlus))                                            // Check for Z overtravel
  {
    if (MessageBox.Show(exec.mainform, "Destination Z is higher than Z soft limit.\nAllow move on Z soft limit?", "Z height warning!", MessageBoxButtons.YesNo) == DialogResult.Yes)
      z = limitPlus;                                                            // Set destination Z to limit+
    else
    {
      exec.Callbutton(130);                                                     // Stop!
      return false;
    }
  }

  bool limitTraverseSpeed = AS3.Getbuttonstate(875);                            // Limit traverse speed checkbox
  double traverseSpeedLimit = AS3.Getfielddouble(2737);                         // Traverse speed limit
  string startStr = "";
  string endStr = "";

  if (moveZ < safeZ) moveZ = safeZ;
  if (moveZ < z) moveZ = z;

  if (limitTraverseSpeed)
  {
    startStr = "G01";
    endStr = " F" + traverseSpeedLimit.ToString("F4");
  }
  else
  {
    startStr = "G00" + startStr;
  }

  if (cZ < moveZ)
    codelist.Add(startStr + " G53 Z" + moveZ.ToString("F6") + endStr);
  codelist.Add(startStr + " G53 X" + x.ToString("F6") + " Y" + y.ToString("F6") + endStr);
  codelist.Add(startStr + " G53 Z" + z.ToString("F6") + endStr);

  exec.Codelist(codelist);                                                      //Execute the List of g-codes.
  while (exec.IsMoving());

  return !exec.Ismacrostopped();
}

double GetMachFromWorkZ(double wz)
{
  double g92offset = AS3.Getfielddouble(502);
  double tooloffset = AS3.Getfielddouble(169);
  double workoffset = AS3.Getfielddouble(133 + 6 * (int)(exec.Getactualmodalcode(12) - 54) + 2);
  return (wz + workoffset + g92offset + tooloffset);
}

Change the following lines according your tool change position (machine coordinates!):

Code: Select all
const double tcpX = 100;
const double tcpY = 25;
const double tcpZ = -15;
dezsoe
 
Posts: 2093
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Manual Tool Change with Probing Screen

Postby BiuTse » Tue Dec 01, 2020 5:01 am

Hi, thx!

Exactly what I was looking for.
Now I try to better understand the macros
Code: Select all
exec.Callbutton(841);                                                           // Mobile probe

I was using the fixed Probe function, because my tool probe is fixed but I could just put in the same coodinates for the mobile, would be the same, wouldn't be ?

Or could I eventually change the Callbutton to the button of the fixed probe (842)?
Code: Select all
exec.Callbutton(842);                                                           // Fixed probe


Thx a lot
by
BiuTse
BiuTse
 
Posts: 11
Joined: Sat Nov 28, 2020 7:10 pm

Re: Manual Tool Change with Probing Screen

Postby dezsoe » Tue Dec 01, 2020 6:52 am

In the linked original post I wrote that use mobile probe mode. The fixed probe mode is a bad name, that mode is for using tool length offset and is not really finished yet. I'll rename it sooner or later.
dezsoe
 
Posts: 2093
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Manual Tool Change with Probing Screen

Postby BiuTse » Tue Dec 01, 2020 7:02 am

So means I stay with you version getting the 841 button state and not the 842 button state.

If I understand it right, defining a fix point for the mobile probe would be the same as the fixed probe mode? Or I am wrong? (talking about the screen, not the macro)
BiuTse
 
Posts: 11
Joined: Sat Nov 28, 2020 7:10 pm

Re: Manual Tool Change with Probing Screen

Postby dezsoe » Tue Dec 01, 2020 7:35 am

Forget the fixed probe mode, it's not your way. Use mobile probe mode. How do you set the workpiece Z0?
dezsoe
 
Posts: 2093
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Manual Tool Change with Probing Screen

Postby BiuTse » Tue Dec 01, 2020 7:46 am

sometimes manually and sometimes with a touch plate depend on the workpiece
BiuTse
 
Posts: 11
Joined: Sat Nov 28, 2020 7:10 pm

Re: Manual Tool Change with Probing Screen

Postby dezsoe » Tue Dec 01, 2020 9:26 am

Touch plate works fine. Position above the workpiece, place your touch plate, set and enable gage height to the plate thickness then press Reference probe as workpiece. This will zero your tool to the workpiece and goes to your other probe and probes there too. Now the program knows the difference between the workpiece and the probe, so the M6 macro will work.

If you want to reference the workpiece manually, without the touch plate, then you have to use UCCNC 1.2113 and download the latest probing plugin from here, because there's a bug in the probing plugin which may crash your tool while executing Reference current as workpiece. (This fixed plugin works only with 1.2113!) The starting procedure is the same, except for you have to touch the workpiece and then use Reference current as workpiece.
dezsoe
 
Posts: 2093
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Manual Tool Change with Probing Screen

Postby BiuTse » Tue Dec 01, 2020 12:17 pm

Thx
I am already using 1.2.113
and the PlugIn: 1.3.2.0 (the one you linked is newer than this one?)

I will try the macro tomorrow!
And I will have to read the 6 pages of the g68 macro thread. The second useful macro in my case

Thx a lot for your help
by
BiuTse
BiuTse
 
Posts: 11
Joined: Sat Nov 28, 2020 7:10 pm

Re: Manual Tool Change with Probing Screen

Postby dezsoe » Tue Dec 01, 2020 1:38 pm

Of course, the linked is newer. There was no new release of UCCNC since 1.2113, so I made this plugin downloadable because of the bug fix.
dezsoe
 
Posts: 2093
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Next

Return to Macros

Who is online

Users browsing this forum: No registered users and 0 guests