// M3100 //------ // 3 axis zero macro for UCCNC, requires a touch off block. //------ // Robertspark - 08/07/2016 (rev A - corrected clearance moves around block) // Robertspark - 15/07/2016 (rev B - added touch plate height & tool diameter correction) // Robertspark - 29/07/2016 (rev C - advanced centering algorithm) // 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 ToolDia = 5; // enter your tool diameter ("0" or negative numbers will be ignored). // when exec.Question and exec.TextQuestion begin to work, I'll add a query to allow // the user to enter the tool diameter double thH = 5; // enter your Touch Plate Thickness / Height ("0" or negative numbers will be ignored). 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 if(exec.GetLED(37)) // If probe input is triggered, stop here... { MessageBox.Show("Probe Input Is Enabled, Probe Is Touching Block", "check!!!" ); return; } 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) { // when exec.Question and exec.TextQuestion begin to work, I'll add a query to allow // the user to enter the tool diameter /* double TD = exec.Question("Tool Diameter?"); if ( TD > 0 ) { ToolDia = TD; } */ 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(); if (thH > 0) { exec.Code("G92 Z" + thH ); // touch plate thichness / height Correction } else { 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 X0 Y" + SafeY); // Safe Y move to clear the probe block & 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); if (ToolDia > 0) { ToolDia = ToolDia / 2; exec.Code("G92 X" + ToolDia + " Y" + ToolDia ); // Tool Diameter Correction } 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"); }