// ----- // Purpose : Check probe for repeatability // Author : WHu // ----- // Date Version Remarks // 20180825 1.0 Base // ----- // // double Zmin = -100; //Max.Z depth double Feedrate = 200; //Feedrate for probing double retractheight = 20; //The retract height double MinimumZ= 1000000; // Min measured Z height double MaximumZ= -1000000; // Max measured Z Height double AverageZ= 0; // Average Z height double MaxDev=0; // Max registered deviation double Deviation=0; // intermediate value, actual deviation double MeasuredZ=0; // Actual measured Z height int i=0; // loop counter // for(i=0; i<10;i++) { exec.Code("G31 Z" + Zmin + "F" + Feedrate); // Start probing while(exec.IsMoving()){} // Wait until movement stopped exec.Wait(1000); // Safety wait for the UC100 syncronisation MeasuredZ=exec.GetZmachpos(); // read actual Z-height AverageZ= AverageZ + MeasuredZ; // Add to average if (MeasuredZMaximumZ) MaximumZ=MeasuredZ; // New maximum value ? Deviation= Math.Abs(AverageZ/(i+1) - MeasuredZ); if (Deviation > MaxDev) MaxDev = Deviation; MessageBox.Show("Probe[" + (i+1) + "]: "+ MeasuredZ+"\nMin value :"+MinimumZ+"\nMax value :"+MaximumZ+"\nMax Deviation :"+MaxDev); // Uncomment to show the intermediate value double Zup = exec.GetZmachpos() + retractheight;//Calculate the new coordinate for the retract of Z axis exec.Code("G00 G53 Z" + Zup); //Retract the Z-axis while(exec.IsMoving()){} // Wait until movement stopped } if(MaxDev<0.001) MaxDev=0; // Absurd to show these values. Even 0.001 is just a gimmick for the Stepcraft ... MessageBox.Show("Average value :"+AverageZ/10+"\nMin value :"+MinimumZ+"\nMax value :"+MaximumZ+"\nMax Deviation :"+MaxDev);