Try again.... should work this time.
Rob
you will need to set up your units values correctly to whatever units you are using (eg inches).
Its a bit longer than my last attempt and there probably could have been a quicker way to write it, but if it works, it works...(not sure if you can write c# functions in macros? )
Code:
// M3100
//------
// 3 axis zero macro for UCCNC, requires a touch off block.
//------
// Robertspark - 08/07/2016 (rev A - corrected clearance moves around block)
// edit and use as you see fit, at you're own risk of course
// M31 uccnc macro used as a base code....
//setup notes:
//
// - all inputs must be considered in your chosen value of units "100" in in/min may be too fast for a probe routine (1.7"/sec)
// - setup... you will need to job the tool / probe over to the top of the block
// - sequence ... z-axis, x-axis, y-axis
double SafeX = 100; // enter your X-axis clearance probing distance.
double SafeY = 100; // enter your Y-axis clearance probing distance.
double SafeZ = 20; // enter your Safe Z distance.
double Xmin = -100; // enter your X-xis probing distance,
double Ymin = -100; // enter your Y-xis probing distance,
double Zmin = -100; // enter your Z-xis probing distance,
double ProbeFeedrate = 100; // enter your probe feedrate... make sure not to break the probe / tool!
double XYProbeHeight = -10; // enter the X and Y probe height.... (basically just below the top of the touch off block).
double XYClearance = 20; // enter the X and Y probe clearance distance, before Z retract
DialogResult result;
result = MessageBox.Show("Is Your Probe / Tool positioned over your touch off block?", "check!!!" , MessageBoxButtons.YesNo);
if (result == System.Windows.Forms.DialogResult.Yes)
{
exec.Code("G92 X0 Y0 Z0"); // Zero the work co-ordinates
// z-axis probe
exec.Code("G31 Z" + Zmin + " F" + ProbeFeedrate); // Do the Z probing with Probe Feedrate
while(exec.IsMoving()){}
exec.Wait(100);
Console.Beep();
exec.Code("G92 Z0"); // Zero the Z axis
exec.Code("G00 Z" + SafeZ); // Safe Z retract
while(exec.IsMoving()){}
exec.Wait(100);
exec.Code("G00 X" + SafeX); // Safe X and Y move to clear the probe block.
while(exec.IsMoving()){}
exec.Wait(100);
exec.Code("G00 Z" + XYProbeHeight); // Lower Z axis to X and Y probe plane
while(exec.IsMoving()){}
exec.Wait(100);
// x-axis probe
exec.Code("G31 X" + Xmin + " F" + ProbeFeedrate); // Do the X probing with Probe Feedrate
while(exec.IsMoving()){}
exec.Wait(100);
Console.Beep();
exec.Code("G92 X0"); // Zero the X-axis
exec.Code("G00 X" + XYClearance); // Safe X retract
while(exec.IsMoving()){}
exec.Wait(100);
// Y-axis probe
exec.Code("G00 Z" + SafeZ); // Safe Z retract
while(exec.IsMoving()){}
exec.Wait(100);
exec.Code("G00 Y" + SafeY); // Safe Y move to clear the probe block.
while(exec.IsMoving()){}
exec.Wait(100);
exec.Code("G00 X0"); // Realign to block edge
while(exec.IsMoving()){}
exec.Wait(100);
exec.Code("G00 Z" + XYProbeHeight); // Lower Z axis to X and Y probe plane
while(exec.IsMoving()){}
exec.Wait(100);
exec.Code("G31 Y" + Ymin + " F" + ProbeFeedrate); // Do the Y probing with Probe Feedrate
while(exec.IsMoving()){}
exec.Wait(100);
Console.Beep();
exec.Code("G92 Y0"); // Zero the Y-axis
exec.Code("G00 Y" + XYClearance); // Safe Y retract
while(exec.IsMoving()){}
exec.Wait(100);
exec.Code("G00 Z" + SafeZ); // Safe Z retract
while(exec.IsMoving()){}
exec.Wait(100);
exec.Code("G00 X0 Y0"); // Move to 0,0 at Safe Z, which should be the top RHS tip of the block.
while(exec.IsMoving()){}
exec.Wait(100);
Console.Beep();
Console.Beep();
}
if (result == System.Windows.Forms.DialogResult.No)
{
MessageBox.Show("Jog the tool over thee touchoff block and Restart");
}