- Tool list
//////////////////////////////////////////////////////////////////////////
//14.08.2022 BKG //
//Using toolslot, u nead to ad tool 0 in profile file //
//Using 9 Linear slot slot 9 is spessial //
//Al tools in slot 0 is komming up as manual toolchange //
//probing in the end, no toolcomp load //
//remember use fullstop and not , for Stockoffset //
//Use at your own risk
//
//It neads checkbox345 for detekt if You are using dustshoe //
//////////////////////////////////////////////////////////////////////////
//////////////////////////
//Slot0=0 //
//Description0= //
//Type0= //
//Material0= //
//////////////////////////
int Chuckopenport = 3;
int Chuckopenpin = 2;
int Chuckblowerport = 3;
int Chuckblowerpin = 3;
int Airport = 3;
int Airpin = 8;
//Tool positions definition
double[] ToolX = new double[11];
double[] ToolY = new double[11];
double DustbootX1;
double DustbootY1;
// Var for Z Probe
double probeX = 1487.0000;
double probeY = 28.1150;
double probeY_Large1 = 11.0000; //Tool 9
double probeZ = -79.0000; // -60
double Zmin = -200;
double FeedrateFast = 800;
double FeedrateSlow = 50;
double SafeZ = 0;
double retractheight = 50;
double retractforsecondmeasurement = 1;
double newZ = 19.7500; //Touchoff plate thickness //BK Manual tool
bool domoveXY = true; //Enable XY movement
bool dodualcycle = true; //Do probing from 2 cycles, first with Fast and second with Slow feedrates
// End of Z probe var
//CHANGE Possisjones
ToolX[0] = 997.00; // Tool9 X position
ToolY[0] = -450.00; // Tool9 Y position
ToolX[1] = 232.1993; // Tool1 X position
ToolY[1] = 86.5331; // Tool1 Y position
ToolX[2] = 356.9993; // Tool2 X position
ToolY[2] = 86.5331; // Tool2 Y position
ToolX[3] = 473.3393; // Tool3 X position
ToolY[3] = 86.5331; // Tool3 Y position
ToolX[4] = 595.7571; // Tool4 X position
ToolY[4] = 86.531; // Tool4 Y position
ToolX[5] = 717.6851; // Tool5 X position
ToolY[5] = 86.5331; // Tool5 Y position
ToolX[6] = 834.6951; // Tool6 X position
ToolY[6] = 86.5331; // Tool6 Y position
ToolX[7] = 955.7842; // Tool7 X position
ToolY[7] = 86.5331; // Tool7 Y position
ToolX[8] = 1074.7317; // Tool8 X position
ToolY[8] = 88.0000; // Tool8 Y position
ToolX[9] = 49.2949; // Tool9 X position
ToolY[9] = 86.9570; // Tool9 Y position
ToolX[10] = 600.0000; // Tool10 X position
ToolY[10] = -973.0000; // Tool10 Y position
DustbootX1 = 2044.0000; // Dustboot X position
DustbootY1 = -1100.0000; // Dustboot Y position
//CHANGE
// Table1
double Ztoolrelease = -255.5000; //-236.0450
double Ztoolpickup = -256.1450;
double YtoolSafeDivePoss_Table1 = -46.945; // the distanse for Y to stop outside the tool holder Table1 BK
// Table2
double Ztoolrelease_Table2 = -255.5000; //-236.0450
double Ztoolpickup_Table2 = -256.1450;
//TableManual
double Ztoolrelease_TableManual = -10.00;
double Ztoolpickup_TableManual = -20.00;
double YtoolSafeDivePoss_Table2 = 0.0; // the distanse for Y to stop outside the tool holder table2 BK
int Newtool = exec.Getnewtool();
int Currenttool = exec.Getcurrenttool();
//Prosess begin
exec.Stopspin(); // BK
exec.Wait(2000); // Wait one 2000msec BK
//BK_Multiple tool storage............................................................................................................
//int New_toolpos = Convert.ToInt16(exec.Readkey("Tooltablevalues","Slot","")+Newtool;
//int Current_toolpos = Convert.ToInt16(exec.Readkey("Tooltablevalues","Slot","")+Newtool;
string SNew_toolpos = exec.Readkey("Tooltablevalues","Slot"+Newtool, "");
string SCurrent_toolpos = exec.Readkey("Tooltablevalues","Slot"+Currenttool, "");
double DNew_toolpos;
double DCurrent_toolpos;
int New_toolpos;
int Current_toolpos;
DNew_toolpos = Convert.ToDouble(SNew_toolpos); //BK String to Double
DCurrent_toolpos = Convert.ToDouble(SCurrent_toolpos); //BK String to Double
New_toolpos = Convert.ToInt16(DNew_toolpos);//BK Double to int
Current_toolpos = Convert.ToInt16(DCurrent_toolpos);//BK Double to int
// MessageBox.Show(SCurrent_toolpos);
//MessageBox.Show(SNew_toolpos);
//BK_Multiple tool storage............................................................................................................
if(New_toolpos == -1) // If new tool number is -1 means a missing T code, so we need to stop here...
return;
if(New_toolpos >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 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()){}
//// Airpressure chk
if(!exec.GetLED(13))
{
MessageBox.Show("No airpressure for toolcange");
exec.Stop();
return;
while(exec.IsMoving()){}
}
//BK Dustboot
bool Dust = AS3.Getcheckboxstate(345);
if (Dust)
{
exec.Code("G00 G53 X"+ (DustbootX1 + "Y"+DustbootY1));
//exec.Code("G00 G53 X 1165.0000 y -406.0000"); // Dustchange poss
MessageBox.Show("Remove Dustboot.");exec.Stopspin();
while(exec.IsMoving()){}
}
else
{
MessageBox.Show("Uten Dustboot.");
}
//End BK Dustboot
//BK Toolslot 0
if(Current_toolpos ==0) //Go to manualcange
{
exec.Code("G00 G53 X" + ToolX[Current_toolpos] + " Y" + (ToolY[Current_toolpos])); // Possition for Slot 0
while(exec.IsMoving()){}
exec.Code("G00 F1000 G53 Z"+ Ztoolrelease_TableManual); // Move Z axis to change position
while(exec.IsMoving()){}
MessageBox.Show("Remove tool "+Currenttool+" from spindle");
exec.Code("G00 G53 Z"+ SafeZ); // Move Z up
while(exec.IsMoving()){}
}
//End BK Toolslot 0
else
//BK toolpos for Table1
{
if(Currenttool!=0) // Only if current tool number is unlike zero
{
if(Current_toolpos <9) //Start of toolpos for Table1 //BK
{
exec.Code("G00 G53 X" + ToolX[Current_toolpos] + " Y" + (ToolY[Current_toolpos] + YtoolSafeDivePoss_Table1)); // safe diving poss outside of the toolholderfork table1 BK
while(exec.IsMoving()){}
// Drop current tool Table1
exec.Code("G00 G53 Z"+ Ztoolrelease); // Move Z axis down to tool holder position
while(exec.IsMoving()){}
exec.Code("G01 F1000 G53 Y" + ToolY[Current_toolpos]); // going in to the fork BK
while(exec.IsMoving()){}
}
//BK End of toolpos for Table1
if(Current_toolpos >8) //Start of toolpos for Table2
{
exec.Code("G00 G53 X" + ToolX[Current_toolpos] + " Y" + (ToolY[Current_toolpos] + YtoolSafeDivePoss_Table2)); // diving poss of the toolholderTable2 BK
while(exec.IsMoving()){}
exec.Code("G00 F1000 G53 Z"+ Ztoolrelease_Table2); // Move Z axis down to tool holder position
while(exec.IsMoving()){}
exec.Code("G01 F1000 G53 Y" + ToolY[Current_toolpos]); // going in to the fork BK
while(exec.IsMoving()){}
}
//End of toolpos for Table2
// Drop current tool
exec.Setoutpin(Airport, Airpin); // Enable Air syst for blower BK
exec.Setoutpin(Chuckopenport, Chuckopenpin); // Open the chuck with pneumatic valve
exec.Setoutpin(Chuckblowerport, Chuckblowerpin); // Starts dustremoval BK
exec.Wait(2000); // Wait one 2000msec
exec.Code("G01 F3000 G53 Z"+ SafeZ); // Move Z up redused feed BK
exec.Clroutpin(Chuckblowerport, Chuckblowerpin); // Stops dustremoval BK
exec.Clroutpin(Chuckopenport, Chuckopenpin); // Close the chuck with pneumatic valve
exec.Clroutpin(Airport, Airpin); // Disable Air syst for blower BK
while(exec.IsMoving()){}
}
}
if (New_toolpos ==0) { //Manual change
exec.Code("G00 G53 X" + ToolX[New_toolpos] + " Y" + ToolY[New_toolpos]);
while(exec.IsMoving()){}
exec.Code("G00 F1000 G53 Z"+ Ztoolpickup_TableManual); // Move Z axis to change position
while(exec.IsMoving()){}
MessageBox.Show("Insert tool"+ Newtool);
exec.Code("G00 G53 Z"+ SafeZ); // Move Z up
while(exec.IsMoving()){}
}
else
{
if (Newtool!=0) { // Only if current tool number is unlike zero
if (New_toolpos <9) {
exec.Code("G00 G53 X" + ToolX[New_toolpos] + " Y" + ToolY[New_toolpos]);
while(exec.IsMoving()){}
// Pick new tool
exec.Setoutpin(Airport, Airpin); // Enable Air syst for blower BK
exec.Setoutpin(Chuckblowerport, Chuckblowerpin); // Starts dustremoval BK
exec.Setoutpin(Chuckopenport, Chuckopenpin); // Open the chuck with pneumatic valve BK Mod
exec.Code("G00 G53 Z"+ Ztoolpickup); // Move Z axis down to tool holder position
while(exec.IsMoving()){}
exec.Clroutpin(Chuckblowerport, Chuckblowerpin); // Stopping dustremoval BK
exec.Clroutpin(Chuckopenport, Chuckopenpin); // Close the chuck with pneumatic valve
exec.Clroutpin(Airport, Airpin); // Enable Air syst for blower BK
exec.Wait(1500); // Wait one 1500msec
while(exec.IsMoving()){}
exec.Code("G01 F600 G53 Y" + (ToolY[New_toolpos] + YtoolSafeDivePoss_Table1)); // safe diving poss outside of the tollholderfork BK
while(exec.IsMoving()){}
exec.Code("G00 G53 Z"+ SafeZ); // Move Z up
while(exec.IsMoving()){}
}
if (New_toolpos >8) {
exec.Code("G00 G53 X" + ToolX[New_toolpos] + " Y" + ToolY[New_toolpos]);
while(exec.IsMoving()){}
// Pick new tool
exec.Setoutpin(Airport, Airpin); // Enable Air syst for blower BK
exec.Setoutpin(Chuckblowerport, Chuckblowerpin); // Starts dustremoval BK
exec.Setoutpin(Chuckopenport, Chuckopenpin); // Open the chuck with pneumatic valve BK Mod
exec.Code("G00 G53 Z"+ Ztoolpickup_Table2); // Move Z axis down to tool holder position
while(exec.IsMoving()){}
exec.Clroutpin(Chuckblowerport, Chuckblowerpin); // Stopping dustremoval BK
exec.Clroutpin(Chuckopenport, Chuckopenpin); // Close the chuck with pneumatic valve
exec.Clroutpin(Airport, Airpin); // Enable Air syst for blower BK
exec.Wait(1500); // Wait one 1500msec
while(exec.IsMoving()){}
exec.Code("G01 F600 G53 Y" + (ToolY[New_toolpos] + YtoolSafeDivePoss_Table2)); // safe diving poss outside of the tollholderfork BK
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
//BK sets tool in use into the profile file for load if reeset..............................................................................................................................
string SNewtool;
SNewtool = Convert.ToString(Newtool);
exec.Writekey("Tooltablevalues","ToolInUse", SNewtool);// BK sets tool in use into the profile fiile for load if reeset
//MessageBox.Show(SNewtool);
//BK sets tool in use into the profile fiile for load if reeset..............................................................................................................................
// Z Probe beginn BK
if (Newtool!=0) {
if(domoveXY) // Make XY movement only if enabled
{
exec.Code("G00 G53 Z" + SafeZ); // Move Z up first
while(exec.IsMoving()){}
if (Newtool <9) {
exec.Code("G00 G53 X" + probeX +" Y" + probeY +" Z" + probeZ); // Move to the probe sensor position in XYZ
while(exec.IsMoving()){}
}
if (Newtool >8) {
exec.Code("G00 G53 X" + probeX +" Y" + probeY_Large1 +" Z" + probeZ); // Move to the probe sensor position in XYZ
while(exec.IsMoving()){}
}
}
if(dodualcycle)
{
exec.Code("G31 Z" + Zmin + "F" + FeedrateFast); // Do the Z probing with Fast feedrate first
while(exec.IsMoving()){}
exec.Code("G91 G0 Z" + retractforsecondmeasurement);
exec.Code("G90");
}
while(exec.IsMoving()){}
exec.Code("G31 Z" + Zmin + "F" + FeedrateSlow); // Do the Z probing again with Slow Feedrate to get a more accurate reading
while(exec.IsMoving()){}
string stNominal = exec.TextQuestion("To probe from the Spoilboard surface, enter the nominal thickness of the material. Enter '0' or leave blank if probing from the material surface (mm)"); //BKHoydekomp
double Nominal = 0; //BKHoydekomp
if(!(stNominal == "")) //BKHoydekomp
{
Nominal = Convert.ToDouble(stNominal); //BKHoydekomp
} //BKHoydekomp
if(!exec.Ismacrostopped()) // If tool change was not interrupted with a stop only then validate new tool number
{
//BK_REM exec.Code("G44 H1"); // Load tool offset one, note the tool lenght is defined in the tools menu BK Manual tool
double newZBK = newZ - Nominal;
exec.ChangeaxisDROvalue(2, newZBK.ToString()); //Change the DRO value BK Manual tool
exec.Wait(200); //Safety wait for the UC100 syncronisation //BK Manual tool
while(exec.IsMoving()){}
exec.Wait(200);
double Zup = exec.GetZmachpos() + retractheight;
if(Zup > SafeZ)
{
Zup = SafeZ;
}
exec.Code("G00 G53 Z" + SafeZ); // Move Z up first
while(exec.IsMoving()){}
// Z probe end
//BK Dustboot
bool DustMount = AS3.Getcheckboxstate(345);
if (DustMount)
{
exec.Code("G00 G53 X"+ (DustbootX1 + "Y"+DustbootY1)); // DustMount Possisjon
MessageBox.Show("Mount Dustboot.");exec.Stopspin();
while(exec.IsMoving()){}
}
else
{
//BK Dustboot
MessageBox.Show("Uten Dustboot.");
}
// if(domoveXY) // Make XY movement back to start position only if XY movement is enabled
// {
// exec.Code("G00 G53 X" + Xoriginalpos +" Y" + Yoriginalpos); // Move back to the original XY position
// while(exec.IsMoving()){}
// }
}
}
// exec.Code("G00 G53 X" + Xoriginalpos + " Y" + Yoriginalpos);
// while(exec.IsMoving()){}
}
else
{
exec.StopWithDeccel();
MessageBox.Show("Tool change was interrupted by user!");
}