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 tracar » Tue Dec 03, 2019 3:42 am

ger21 wrote:You're running a Morbidelli with UCCNC?


actually just starting my build , i have the machine,, so why not UCCNC right :) , im not using the stock air electric 10 tool changer (removed ), or the 30 whatever boring head (removed saturday also) as there waaaaaayyyyyy too many I/O to connect, and i already have a ISO30 - 90 degree saw/spindle head. along with the proprietary pneumatic electric saw mounted in the back ... so i will simplify everything by gutting non essential components. there will defiantly be some eBay items left over for later :)

aside from picking up a 15hp 3phase 220 rotary tomorrow morning i think i have everything to start the build.
tracar
 
Posts: 39
Joined: Sun Jun 18, 2017 6:37 pm

Re: linear tool change macro

Postby Battwell » Tue Dec 03, 2019 10:50 am

you should have kept the drilling head on it. i have done a fair few conversions on these machines with dead controls.
i have macros for drill blocks etc.
you can run all the io for drill head via modbus/arduino to save cable runs
Uc300eth on router and mill.
UK uccnc powered machine sales. https://cncrouter.uk/atc-cnc-routers.htm
Automateanything/duzzit cnc/mercury cnc
Battwell
 
Posts: 819
Joined: Sun Sep 25, 2016 7:39 pm
Location: South Wales. Uk

Re: linear tool change macro

Postby Robertspark » Tue Dec 03, 2019 11:06 am

oops.... slight coding error.... (a " where it should not be...)

AGAIN I CANNOT TEST THIS CODE, USE WITH CAUTION, IT IS BASED UPON THE STANDARD UCCNC M6 MACRO

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!");
}

Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: linear tool change macro

Postby Robertspark » Tue Dec 03, 2019 4:50 pm

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!");
}
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: linear tool change macro

Postby tracar » Wed Dec 04, 2019 4:39 am

its close but missing something,

it should be closer to this:

********************************
cutting project with tool #1 from slot 1.

M6T2 is called in the code.

remember current tool and position.

raise Z to 15 and stop spindle at same time. // safe z is 15 (machine coordinates)

then move directly to tool 1 slot 1 preload area = (X55,Y0,z15) // tool 1 slot 1 preload area.

lower to z5 = (X55,Y0,Z5) //step before sliding iso30 to the right into the clip slot 1.

check spindle speed wait for zero speed = 0

move x to the right (X60,Y0,Z5) //places iso30 tool 1 into slot 1.

chuck open // chuck is open.

move z up (X60,Y0,Z10) //lifts away from iso30 in slot 1.

move to slot 2 = (X60,Y5,Z10) // moves to slot 2, tool 2.

lowers on the iso30 tool 2 slot 2 = (X60,Y5,Z5)

chuck closes //chuck is closed.

moves to the left 5 = (X55,Y5,Z5) // removes iso30 tool 2 from slot 2.

raises Z to 15 = (X55,Y5,Z15)

returns to cutting.








all tool change cooordinates are in ( machine coordinates )

all tools are at x60.

all tool preload areas are X55,Z5

all tools are 5 apart on y > y5 y10 y15...

all tool preload area is 5 left of all tools on y axis. ( X55,Y10,Z5 IS tool 2 preload )

all tools pickup and release are at Z5.

all chuck open and cloaed are at Z5

all tool to tool travel is at Z10.

z safe travel just set to 15


i can change the park2 button to a "tool dump" button

If a power failure happens,or just restarted uccnc, i can press it and it homes all, then unloads the tool to a special "dump" clip before a .nc is loaded leaving the spindle empty.

i can then manually remove the tool from the dump clip and place it in the proper slot..


i need to check if there is a sensor in the spindle to check if a tool is loaded.....
tracar
 
Posts: 39
Joined: Sun Jun 18, 2017 6:37 pm

Re: linear tool change macro

Postby Battwell » Wed Dec 11, 2019 12:04 pm

Use ask a question. What tool is in spindle. Then use that for return to correct slot.
I use it in my changer script if it has been halted during a change to confirm so nothing gets crashed.
I also save each change to profile so tool rack display is always populated even on startup.
Uc300eth on router and mill.
UK uccnc powered machine sales. https://cncrouter.uk/atc-cnc-routers.htm
Automateanything/duzzit cnc/mercury cnc
Battwell
 
Posts: 819
Joined: Sun Sep 25, 2016 7:39 pm
Location: South Wales. Uk

Re: linear tool change macro

Postby tracar » Thu Dec 12, 2019 3:54 pm

as i said before, i truly only understand about 20 percent of the scripts content, writing code is not my thing. lol
tracar
 
Posts: 39
Joined: Sun Jun 18, 2017 6:37 pm

Re: linear tool change macro

Postby tracar » Thu Dec 12, 2019 10:01 pm

why doesnt someone write a bit o code that can determine where to put the tool acording to sensors in the tool holder clips, telling the system where the empty slots are. along with what it has for a record of stored tools.
tracar
 
Posts: 39
Joined: Sun Jun 18, 2017 6:37 pm

Re: linear tool change macro

Postby Battwell » Wed Dec 18, 2019 12:36 pm

it doesnt require sensors. the m6 macro can store and change slot status on a simply edited screen.
heres mine from when i first implemented the rack
https://www.youtube.com/watch?v=aGVZdg98cfI
Uc300eth on router and mill.
UK uccnc powered machine sales. https://cncrouter.uk/atc-cnc-routers.htm
Automateanything/duzzit cnc/mercury cnc
Battwell
 
Posts: 819
Joined: Sun Sep 25, 2016 7:39 pm
Location: South Wales. Uk

Re: linear tool change macro

Postby Vmax549 » Wed Dec 18, 2019 2:12 pm

One thing to keep in mind is there are 5 different tool change functions involved.

IS = in slot tool
OS = out of slot tool

1 IS >>> IS
2 IS >>> OS
3 OS >>> OS
4 OS >>> IS
5 initialize the ATC

This way you can make FULL use of the tool table. Also I just tested teh reading of teh extended tool table and parts of reading it are still broken so it cannot be used. Also you cannot write to teh extended table to update it. Without that you will have to create your OWN swap table to track slots if that is what you wanted.

Just a thought (;-) TP
Vmax549
 
Posts: 331
Joined: Sun Nov 22, 2015 3:25 am
Location: USA

PreviousNext

Return to Macros

Who is online

Users browsing this forum: Google [Bot] and 3 guests