//M31 probing macro double Zmin = -100; //Max.Z depth double FeedrateFast = 300; //Feedrate for probing double FeedrateSlow = 40; //Feedrate for probing double SafeZ = 100; double retractheight = 10; //The retract height double retractforsecondmeasurement = 1; double newZ = 32.45; //The new Z DRO value after probing bool dodualcycle = true; //Do probing from 2 cycles, first with Fast and second with Slow feedrates 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("Axlarna har inte nollats, nolla axlarna innan mätning av verktyg!"); exec.Stop(); return; } while(exec.IsMoving()){} exec.Wait(200); double Xoriginalpos = exec.GetXmachpos(); // Get the current machine coordinates double Yoriginalpos = exec.GetYmachpos(); // Get the current machine coordinates if(dodualcycle) { exec.Code("G31 Z" + Zmin + "F" + FeedrateFast); // Do the Z probing with Fast feedrate first while(exec.IsMoving()){} exec.Wait(200); exec.Code("G91 G0 Z" + retractforsecondmeasurement); exec.Code("G90"); } exec.Code("G31 Z" + Zmin + "F" + FeedrateSlow); // Do the Z probing again with Slow Feedrate to get a more accurate reading while(exec.IsMoving()){} exec.Wait(200); exec.ChangeaxisDROvalue(2, newZ.ToString()); //Change the DRO value exec.Wait(200); //Safety wait for the UC100 syncronisation if(!exec.Ismacrostopped()) // If tool change was not interrupted with a stop only then validate new tool number { exec.Code("G44 H1"); // Load tool offset one, note the tool lenght is defined in the tools menu while(exec.IsMoving()){} exec.Wait(1000); double Zup = exec.GetZmachpos() + retractheight; if(Zup > SafeZ) { Zup = SafeZ; } exec.Code("G00 G53 Z" + Zup); // Move 10mm above probe plate while(exec.IsMoving()){} exec.Wait(1000); }