M06 Loose tool sign

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

M06 Loose tool sign

Postby BKG » Fri May 10, 2019 8:45 pm

Hello, I hawe a M06 code that dont hold the Setoutpin signal, it only giwe a on off signal i want it to hold the signal until the Clrsetoutpin

Code:
//Tool positions definition
int Chuckopenport = 3;
int Chuckopenpin = 2;

const bool ChuckopenportNeg = false;
const bool ChuckopenportPos = True;

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

//CHANGE

ToolX[1] = 0; // Tool1 X position
ToolY[1] = 0; // Tool1 Y position
ToolX[2] = 120; // Tool2 X position
ToolY[2] = 0; // Tool2 Y position
ToolX[3] = -452.6800; // Tool3 X position
ToolY[3] = 185; // Tool3 Y position
ToolX[4] = -328; // Tool4 X position
ToolY[4] = 185; // Tool4 Y position
ToolX[5] = -210.5000; // Tool5 X position
ToolY[5] = 185; // Tool5 Y position
ToolX[6] = -88.8000; // Tool6 X position
ToolY[6] = 185; // Tool6 Y position
ToolX[7] = 31.3300; // Tool7 X position
ToolY[7] = 185; // Tool7 Y position
ToolX[8] = 151.5300; // Tool8 X position
ToolY[8] = 185; // Tool8 Y position

//CHANGE
double SafeZ = 0;
double Ztoolrelease = -248.7050;
double Ztoolpickup = -248.7050;
double YtoolSafeDivePoss = -46.945; // the distanse for Y to stop outside the tool holder BK


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 >8) // 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 homeing 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("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" + ToolX[Currenttool] + " Y" + (ToolY[Currenttool] + YtoolSafeDivePoss)); // safe diving poss outside of the toolholderfork BK
while(exec.IsMoving()){}

// Drop current tool

exec.Code("G00 G53 Z"+ Ztoolrelease); // Move Z axis down to tool holder position
while(exec.IsMoving()){}
exec.Code("G01 F600 G53 Y" + ToolY[Currenttool]); // going in to the fork BK
while(exec.IsMoving()){}

exec.Setoutpin(Chuckopenport, Chuckopenpin); // Open the chuck with pneumatic valve[/b]
exec.Wait(1000); // Wait one 1000msec // Her kan jeg kanskje legge inn ett forsinket løft av z som en kompensajen for tool release BK
exec.Code("G00 G53 Z"+ SafeZ); // Move Z up
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
// Her bør Knife open være 1 BK
// her bør tool blower startes BK
exec.Code("G00 G53 Z"+ Ztoolpickup); // Move Z axis down to tool holder position
while(exec.IsMoving()){}

// Her bør toolblower Stanses BK
exec.Clroutpin(Chuckopenport, Chuckopenpin); // Close the chuck with pneumatic valve
exec.Wait(1000); // Wait one 1000msec
while(exec.IsMoving()){}
// Her bør Knipe open være 0 BK
exec.Code("G01 F600 G53 Y" + (ToolY[Newtool] + YtoolSafeDivePoss)); // safe diving poss outside of the tollholderfork BK
exec.Setcurrenttool(Newtool); //Set the current tool -> the new tool
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 // Moved this up to after picked tool and gone out of the toolfork BK
// MessageBox.Show("Tool change done.");
}
else
{
exec.StopWithDeccel();
MessageBox.Show("Tool change was interrupted by user!");
}
BKG
 
Posts: 6
Joined: Fri May 10, 2019 8:32 pm

Re: M06 Loose tool sign

Postby cncdrive » Fri May 10, 2019 9:55 pm

If the signal does not hold it's state for the Clr or Set outpin function can be because you have something configured to the same pin in the UCCNC and so the UCCNC sets the pin to a different state.
cncdrive
Site Admin
 
Posts: 2766
Joined: Tue Aug 12, 2014 11:17 pm

Re: M06 Loose tool sign

Postby BKG » Sat May 11, 2019 8:44 am

Thanks, that did fix the issue, there was an I/O sign for testing purpose, I removed it and it was OK :)
BKG
 
Posts: 6
Joined: Fri May 10, 2019 8:32 pm


Return to Macros

Who is online

Users browsing this forum: No registered users and 3 guests