Protocol when using G43 with ATC spindle?

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

Protocol when using G43 with ATC spindle?

Postby dimmaz88 » Sun Sep 25, 2022 3:20 pm

Hi all, I'm having trouble knowing the proper protocol when setting up an ATC spindle.

When I power on my machine it doesn't know there's a tool in the spindle, for now I just manually remove it and put it back in the rack. That's problem 1.

I'm also not sure where the offset of the tools should be relative to, do I have to create a tool zero? I'm sure I've seen that mentioned somewhere but can't find it now.

What would be the proper protocol after firing up the machine and doing the homing sequence? Do I need to do any zeroing or can it all be saved from the previous session?
dimmaz88
 
Posts: 27
Joined: Mon Jun 13, 2022 9:22 am

Re: Protocol when using G43 with ATC spindle?

Postby dezsoe » Mon Sep 26, 2022 8:07 am

Hi,

Here is how to restore the tool number on startup.

You may have anything to reference to. You can use a reference tool, but in most cases the spindle itself is the reference point. Of course, it works only if you can lower the spindle enough to touch the probe.

The work offsets are saved on exit, so you only need to home your machine to get your offsets back. Note that G52/G92 is temporary offset (in fact they are the same, but use different parameters) and they are not saved.
dezsoe
 
Posts: 2093
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Protocol when using G43 with ATC spindle?

Postby dimmaz88 » Mon Sep 26, 2022 9:26 pm

Thank you Dezsoe, I'll give this a try.
dimmaz88
 
Posts: 27
Joined: Mon Jun 13, 2022 9:22 am

Re: Protocol when using G43 with ATC spindle?

Postby dimmaz88 » Wed Sep 28, 2022 3:46 pm

I tried adding the line to my M6 and then adding a macroloop, but it doesn't work.

Here is my M6...

Code: Select all
//Example linear toolchanger code

//Tool positions definition
int Chuckopenport = 1;
int Chuckopenpin = 14;

double[] ToolX = new double[11];
double[] ToolY = new double[11];
ToolX[0] = 0; // Tool0 X position
ToolY[0] = 0; // Tool0 Y position

ToolX[1] = 1447.14; // Tool1 X position
ToolY[1] = 192; // Tool1 Y position
ToolX[2] = 1447.14; // Tool2 X position
ToolY[2] = 342; // Tool2 Y position
ToolX[3] = 1447.14; // Tool3 X position
ToolY[3] = 492; // Tool3 Y position
ToolX[4] = 1447.14; // Tool4 X position
ToolY[4] = 642; // Tool4 Y position
ToolX[5] = 1447.14; // Tool5 X position
ToolY[5] = 792; // Tool5 Y position
ToolX[6] = 1447.14; // Tool6 X position
ToolY[6] = 942; // Tool6 Y position
ToolX[7] = 1447.14; // Tool7 X position
ToolY[7] = 1092; // Tool7 Y position
ToolX[8] = 1447.14; // Tool8 X position
ToolY[8] = 1242; // Tool8 Y position
ToolX[9] = 1447.14; // Tool9 X position
ToolY[9] = 1392; // Tool9 Y position
ToolX[10] = 1447.14; // Tool10 X position
ToolY[10] = 1542; // Tool10 Y position

double SafeZ = 145;
double pickupSafeZ = 75;
double Ztoolrelease = -61;
double Ztoolpickup = -61;

int Newtool = exec.Getnewtool();
int Currenttool = exec.Getcurrenttool();

if(Newtool == -1) // If new tool number is -1 means a missing T code, so we need to stop here...
return;

if(Newtool <1 || Newtool >6) // Tool number is out of range, so we need to stop here...
return;

if(Newtool == Currenttool) // Same tool was selected, so do nothing, stop here...
return;

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, do homing before executing a tool change!");
  exec.Stop();
  return;
}

while(exec.IsMoving()){}

// Get current XY machine coordinates to return to this position at the end of the macro

double Xoriginalpos = exec.GetXmachpos();
double Yoriginalpos = exec.GetYmachpos();

// Stop spindle if running and Move Z up

exec.Stopspin();
exec.Code("G49G00 G53 Z"+ SafeZ);          // Move Z up safe
while(exec.IsMoving()){}

if(Currenttool!=0) // No need to drop down tool if current tool number is zero
{
  // Move to old tool position on XY plane

  exec.Code("G00 G53 Y" + ToolY[Currenttool]);
  exec.Code("G00 G53 X" + ToolX[Currenttool]);
  while(exec.IsMoving()){}

  // Drop current tool
 
  exec.Code("G00 G53 Z"+ Ztoolrelease); // Move Z axis down to tool holder position
  while(exec.IsMoving()){}
  exec.Setoutpin(Chuckopenport, Chuckopenpin); // Open the chuck with pneumatic valve
  exec.Wait(1000); // Wait one 1000msec
  exec.Code("G00 G53 Z"+ pickupSafeZ); // Move Z up
  exec.Clroutpin(Chuckopenport, Chuckopenpin);      // added solenoid close
  while(exec.IsMoving()){}
}

// Move to new tool position on XY plane    
exec.Code("G00 G53 X" + ToolX[Newtool] + " Y" + ToolY[Newtool]);
while(exec.IsMoving()){}


// Pick new tool

exec.Setoutpin(Chuckopenport, Chuckopenpin);    //added solenoid open
exec.Code("G00 G53 Z"+ Ztoolpickup); // Move Z axis down to tool holder position
while(exec.IsMoving()){}
exec.Clroutpin(Chuckopenport, Chuckopenpin); // Close the chuck with pneumatic valve
exec.Wait(1000); // Wait one 1000msec
exec.Code("G00 G53 Z"+ SafeZ); // Move Z up
while(exec.IsMoving()){}


// Move back to start point

//exec.Code("G00 G53 X" + Xoriginalpos + " Y" + Yoriginalpos);
while(exec.IsMoving()){}

// Measure new tool will go here....

exec.Code("G43 H"+Newtool); // Load new tool offset

exec.Wait(200);
while(exec.IsMoving()){}
if(!exec.Ismacrostopped()) // If tool change was not interrupted with a stop only then validate new tool number
{
 
exec.Setcurrenttool(Newtool); //Set the current tool -> the new tool
exec.Writekey("LastTool", "ToolNumber", NewTool.ToString()); // Save tool number
 
  //MessageBox.Show("Tool change done.");
}
else
{
  exec.StopWithDeccel();
  MessageBox.Show("Tool change was interrupted by user!");
}




This M6 has been butchered together, please point out anything that looks iffy :D

I also added the macroloop, but rather than set the previous tool it just sets tool 0.

In the error log I get "CS0103 | in line: 129 | error text: The name 'NewTool' does not exist in the current context"

Any help appreciated
dimmaz88
 
Posts: 27
Joined: Mon Jun 13, 2022 9:22 am

Re: Protocol when using G43 with ATC spindle?

Postby dezsoe » Wed Sep 28, 2022 6:47 pm

NewTool is not the same as Newtool. In the line you inserted change NewTool to Newtool.
dezsoe
 
Posts: 2093
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Protocol when using G43 with ATC spindle?

Postby dimmaz88 » Wed Sep 28, 2022 7:23 pm

Aaaahhhh, great thank you.
dimmaz88
 
Posts: 27
Joined: Mon Jun 13, 2022 9:22 am

Re: Protocol when using G43 with ATC spindle?

Postby dimmaz88 » Thu Sep 29, 2022 8:33 am

I've just changed the spelling error but I still have the same issue. It just writes the tool to 0 on startup.
dimmaz88
 
Posts: 27
Joined: Mon Jun 13, 2022 9:22 am

Re: Protocol when using G43 with ATC spindle?

Postby dezsoe » Thu Sep 29, 2022 9:23 am

Check your profile. There should be (at the end) 2 lines:

Code: Select all
[LastTool]
ToolNumber=1

The ToolNumber should be the number that you used in the last M6. If it is there then the M6 part is OK. Also check if you have the other macro set as a macroloop and set it to auto run. When you first release the reset then the tool number should change to the tool number in the profile.
dezsoe
 
Posts: 2093
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Protocol when using G43 with ATC spindle?

Postby dimmaz88 » Thu Sep 29, 2022 10:47 am

By profile do you mean the .pro file? If so it does not appear to be writing it to there. The macro is set as a macroloop saved as M12, it starts once I click reset but says "Tool number 0 restored".
dimmaz88
 
Posts: 27
Joined: Mon Jun 13, 2022 9:22 am


Return to Macros

Who is online

Users browsing this forum: No registered users and 8 guests