//M6 Macro for automatic tool measuring. First the machine moves to the tool change position, then to the fixed plate
//to measure the new tool length
double ToolChangeX = 200; //Tool change X position (all in machine coordinates)
double ToolChangeY = 200; //Tool change Y position
double ToolChangeZ = -1; //Tool change Z position
double FixedPlateX = 50; //Fixed plate X position (machine coordinate)
double FixedPlateY = 550; //Fixed plate Y position
double SafeZ = 0; //Safe Z in machine coordinates
double ZRetractHeight = 25; //Height above Z0 to which probe will retract
double CoarseRate = 400; //Feedrate for initial probing
double FineRate = 1; //Feedrate for fine probing
double Zmin = -180; //maximum probing distance
double PlateDifference = exec.GetCpos(); //Fetches the plate difference from the C axis DRO
// G91 Sets incremental mode,
// G90 Sets absolute distance mode
// G53 Sets move in absolute coordinate for that line
//int originaldistancemode = exec.actualdistmode; // remember the distance mode
//int originalmodalmode = exec.actualmodal; // remember the modal mode
exec.Stopspin(); //Turn off spindle
exec.Code ("G91"); //sets incremental mode for the whole macro
double XOriginalPos = exec.GetXmachpos(); // Get the current machine coordinates
double YOriginalPos = exec.GetYmachpos(); // Get the current machine coordinates
double ZOriginalPos = exec.GetZpos(); // Get the current machine coordinates
exec.Code ("G53 G00 Z" + ToolChangeZ); //Moves to tool change position
while (exec.IsMoving ()){}
exec.Wait (200);
exec.Code ("G53 G00 X" + ToolChangeX+ " Y" + ToolChangeY); //Moves to tool change position
while (exec.IsMoving ()){}
exec.Wait (200);
MessageBox.Show ("Press OK when toolchange is complete");
exec.Wait (200);
exec.Code ("G53 G00 X" + FixedPlateX + " Y" + FixedPlateY); //Move to Fixed Plate Position
while(exec.IsMoving()){}
exec.Wait(200);
exec.Miston(); //Turn Mist On
exec.Code("G31 Z" + Zmin + "F" + CoarseRate); // Probe Z quickly to get rough height
while(exec.IsMoving()){}
exec.Wait(200);
exec.Code ("G00 Z" + .10); // Retract .1" above the plate
while(exec.IsMoving()){}
exec.Wait(100);
exec.Code("G31 Z" + Zmin + "F" + FineRate); // Probe Z slowly for better resolution
while(exec.IsMoving()){}
exec.Wait(200);
exec.Stopcoolant(); // Turn Mist Off
//because we stopped at the fixed plate, we now want to update our DRO to the value of the plate difference
exec.mainform.sumoffsetcontrol1.G54.newCzinput(PlateDifference); // Set G54 to new Zzero
exec.mainform.sumoffsetcontrol1.G55.newCzinput(PlateDifference); // Set G55 to new Zzero
exec.mainform.sumoffsetcontrol1.G56.newCzinput(PlateDifference); // Set G56 to new Zzero
exec.mainform.sumoffsetcontrol1.G57.newCzinput(PlateDifference); // Set G57 to new Zzero
exec.mainform.sumoffsetcontrol1.G58.newCzinput(PlateDifference); // Set G58 to new Zzero
exec.mainform.sumoffsetcontrol1.G59.newCzinput(PlateDifference); // Set G59 to new Zzero
exec.Code ("G53 G00 Z" + SafeZ); //retracts Z
while(exec.IsMoving()){}
exec.Wait(100);
exec.Code ("G53 G00 X" + XOriginalPos + " Y" + YOriginalPos); //moves to original XY position
while(exec.IsMoving()){}
exec.Wait(100);
exec.Code ("G90"); //returns machine to absolute for Z move and rest of code
//exec.Code ("G00 Z" + ZOriginalPos);
//while(exec.IsMoving()){}
//exec.Wait(100);
//exec.Code("G" + originaldistancemode); // Set system back to the original distance mode
//exec.Code("G" + originalmodalmode); // Set system back to the original distance mode
exec.Code ("G90"); //returns machine to absolute
// Initial Z Probe for stock
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, home the machine before run to parking position!");
exec.Stop();
return;
}
exec.Callbutton(801); // select tool probe mode
exec.Callbutton(840); // select touch probe mode
exec.Callbutton(850); // Ref current as workpiece
exec.Miston();; //Turn Mist On
exec.Callbutton(821); // start probing
exec.Stopcoolant(); // Turn Mist Off
// Tool Change Macro
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, home the machine before run to parking position!");
exec.Stop();
return;
}
exec.Callbutton(801); // select tool probe mode
exec.Callbutton(842); // select Fixed tool probe mode
exec.Callbutton(848); // move to fixed probe pos
exec.Miston(); //Turn Mist On
exec.Callbutton(821); // start probing
exec.Stopcoolant(); // Turn Mist Off
exec.Code("M7"); //Mist On
exec.Code("M9"); // Mist Off
ger21 wrote:Again, are there any errors?
What does it do, when you say that it "doesn't work"?
Are you sure it's in the correct folder?
dezsoe wrote:Hi Karnage,
Could you explain in details what do you want to do? Running the probe screen functions from the M6 macro is a bit tricky, but it can be done. If you tell me all the details then I can make it for you.
(The problem is that the probe screen runs G-codes to move and probe. When cycle is started the probe screen will do nothing, because adding G-codes while other G-codes are executed would be a bit extreme. So, while you run a G-code the M6 calls the functions, but nothing will happen. You have to stop the code in M6, call the probing functions and restart the cycle. It works fine, I've already written this kind of M6 for somebody else.)
// Tool Change Macro
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, home the machine before run to parking position!");
exec.Stop();
return;
}
exec.Callbutton(801); // select tool probe mode
exec.Callbutton(842); // select Fixed tool probe mode
exec.Callbutton(848); // move to fixed probe pos
exec.Miston(); //Turn Mist On
exec.Callbutton(821); // start probing
exec.Stopcoolant(); // Turn Mist Off
One last question, i have used the callbutton with a hotkey to call the probing screen (800), is there a way to call page 2, page 3 and settings in the same way?
Return to General discussion about the UCCNC software
Users browsing this forum: No registered users and 18 guests