linear tool change macro

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

Re: linear tool change macro

Postby Battwell » Mon Dec 23, 2019 1:04 pm

on mine i made 10 text fields on the screen.(simple 2 minute edit) i update the text boxes with the tool number which can also be saved to profile.
text fields made it simple as these can be edited simply on screen when tools are inserted manually into the rack ready for the job to be run.
in destructor macro i also save all these text fields to profile so they can be re read at startup by constructor macro and re populated with the correct tools.
has worked very well .
in the m6 macro these text fields are queried for matching numbers of old tool and new tool so the correct drop off and pick up slots are found simply. this also allows any tool number to be used, not just 1 to 10 so im not constantly updating tool settings in my cam system.
Uc300eth on router and mill
If they say it can't be done- I find a way!
Battwell
 
Posts: 614
Joined: Sun Sep 25, 2016 7:39 pm
Location: South Wales. Uk

Re: linear tool change macro

Postby NikolayUA24 » Tue Mar 16, 2021 8:59 pm

Hi.
Question about the auto change of the instrument.
int Chuckopenport = 1; int Chuckopenpin = 16; do we connect a pneumatic valve to this port and pin?
And the question on the photo, where to connect the sensor, the cartridge is closed, the cartridge is open.
Attachments
3056.jpg
3056.jpg (15.67 KiB) Viewed 775 times
I use Google Translator.
NikolayUA24
 
Posts: 101
Joined: Tue Mar 20, 2018 2:50 pm
Location: Ukraine

Re: linear tool change macro

Postby NikolayUA24 » Sun Mar 21, 2021 11:16 am

Robertspark wrote:try again :D .... commented out Currenttool == 0 for testing.... {need to add in a Question popup asking if a tool is loaded and what it's current number is in order to unload it first..... say there was a power cut at restart tool "0" would be listed.....

Code: Select all
//Example linear toolchanger code

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

double[] ToolY = new double[11];

double Xtoolload = 0; // Z tool load and unload (in machine coordinates)

double ToolX = -10; // Tool1 X position

ToolY[0] = 0; // Tool0 Y position
ToolY[1] = 5; // Tool1 Y position
ToolY[2] = 10; // Tool2 Y position
ToolY[3] = 15; // Tool3 Y position
ToolY[4] = 20; // Tool4 Y position
ToolY[5] = 25; // Tool5 Y position
ToolY[6] = 30; // Tool6 Y position
ToolY[7] = 35; // Tool7 Y position
ToolY[8] = 40; // Tool8 Y position
ToolY[9] = 45; // Tool9 Y position
ToolY[10] = 50; // Tool10 Y position

double SafeZ = 0;  // Safe retract at Z home height (in machine coordinates)

double Ztoolload = -5; // Z tool load and unload (in machine coordinates)

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 >10) // 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()){}

/*
if(Currenttool==0)
{
// ASK if you want to unload the current tool within a slot...... OR confirm no tool is presently loaded.....
  MessageBox.Show("Tool Zero Currently Loaded will need to be unloaded before inserting next tool");
  exec.Stop();
  return;
}
*/

// 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("G00 G53 Z"+ SafeZ); // Move Z up
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 X" + Xtoolload + " Y" + ToolY[Currenttool]);
  while(exec.IsMoving()){}
    exec.Code("G00 G53 Z" + Ztoolload);
  while(exec.IsMoving()){}
  exec.Code("G00 G53 X" + ToolX);
  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"+ SafeZ); // Move Z up
  while(exec.IsMoving()){}
}

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

exec.Code("G00 G53 Z" + Ztoolload); // 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 X" + Xtoolload);
while(exec.IsMoving()){}
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
  MessageBox.Show("Tool change done.");
}
else
{
  exec.StopWithDeccel();
  MessageBox.Show("Tool change was interrupted by user!");
}

How to add an option to your macro so that it returns the cutter to the slot at the end of the program execution, and returns to 0 without the cutter.
I use Google Translator.
NikolayUA24
 
Posts: 101
Joined: Tue Mar 20, 2018 2:50 pm
Location: Ukraine

Previous

Return to Macros

Who is online

Users browsing this forum: No registered users and 5 guests