OK, I have updated the two macros ("XYZ Probe Zero" M20031 and "Tool Change" M6) to enable the use of multiple storage/retrieval methods. If you need to keep your C-Axis DRO "undisturbed" then you can use an alternate method. Here is how that works:
There is a variable in the configuration block named "StorageMethod":
- If it is set to "-1", then M6/M20031 will use the C-Axis DRO for storage/retrieval of the Plate Offset (this is the default method)
- If it is set to "-2", then the Plate Offset will be stored/retrieved in/from the currently running profile (file)
- if it is set to any other integer (i.e. "StorageMethod = 100"), then the corresponding internal variable will be used (0-5999, noting that 5060-5066 and 5039 are reserved and should not be used)
*** Note that the same "StorageMethod" must be defined in both M6 and M20031 for the pair to communicate properly
I have also made a few other changes to the files and cleaned them up a bit. Most notable:
- Both files now share a common "Configuration Block" such that it can be edited once and then copy/pasted between both macros. This means there are a couple of variables in the block which are only actually used by one macro or the other (as noted). They don't need to be deleted, they just wont serve any purpose in the Macro which doesn't actually need them...
- I added a delay timer ("OKDelay") such that you can have a few seconds (ms actually) between hitting "OK" and the start of the XYZ probing sequence. This will give you time to hold and stabilize the mobile plate if so desired. It can be set to "0" if you don't need/want this.
- I have added a configuration variable ("Do2ndYPass") to enable/disable the second Y Axis probe if so desired. The second Y-Axis probe is now disabled by default ("false"). You can turn it on ("true") if you want a bit of increased accuracy after the X-Axis probe centers the probe more precisely.
- I am now using a different Mobile Plate. It is a generic "Chinese" plate, is cheaper than the OpenBuilds plate, the XY hole is bigger, and less wiring is required. As such, the Mobile Plate characteristics in the attached files no longer represent the OpenBuilds plate. Please adjust your Mobile Plate characteristics accordingly if you are using the OpenBuilds plate. (You can find my OpenBuilds Mobile Plate characteristics in my original posting in this thread).
* Also, rather than posting a dedicated macro for testing the M6 function (previously M20006) I have decided it isn't really necessary (and was a bit confusing). (The only difference between M6 and M20006 was that M20006 had the Tool Number detection turned off so it could be tested with a custom button press). Moving forward, it is a lot less confusing (I think) to simply call the M6 macro from the UCCNC command line and just specify a dummy tool number if you want to test it. I.E. "M6 T1"
As always, please post any questions or suggestions to this thread. Thanks!
M20031 XYZ Probing Macro
- Code: Select all
// Custom M20031 PROBING MACRO
// Simulates Carbide Motion (Nomad, Shapeko) BITZERO Probing Function (X, Y, Z)
// Requires Both a Mobile Plate (For initial M31 Workspace X, Y, Z) and a Fixed Plate (to support ongoing automatic Zeroing in the Z axis after M6 tool changes)
// * Mobile Plate: An XYZ Touch Plate (with XY Hole) is used to simulate the Carbide3D BitZero functionality
// * Fixed Plate: Any standard Touch Plate may be affixed to the router bed
// * UCCNC must be specifically configured (in Settings) to run an M6 Macro (default setting = do nothing)
// * The design software post processor for the machine must be configured to support tool changes (a "UCCNC ATC" vectric post processor is also provided)
// The machine must be Homed prior to this activity
// The operator should use a cylindrical touch bit probe in the chuck (not a router bit) for best accuracy
// The operator should manually position the touch bit probe down into the approximate center of the XY Hole of the mobile plate before running this operation
// This macro will first run the X/Y probe inside the mobile plate XY Hole, then lift and reposition to perform a Z probe on the mobile plate
// The Y-Axis probe will run twice for increased accuracy after the approximate center is found (ie: Y probe, X probe, second Y probe)
// This macro will then transition to the location of the fixed plate to calculate the height difference between the Workspace and Fixed plates
// The Z Offset difference between the workspace and fixed plate is stored/maintained in the C-Axis DRO, as a Profile Entry, or an internal variable as specified by "StorageMethod".
// The companion M6 macro is required to retrieve the Mobile/Fixed Plate Difference (offset) and support the Fixed Plate and automatic Workspace Z Zeroing during tool changes
// Start Configuration Block: ***************************************************************************
// Can be directly copy/pasted (shared) between M20031 and M6 macros - as such some variables are not actually used by both macros
// MOBILE Plate Characteristics // (Only used by M20031)
double MobilePlateThickness = 5.10; // Thickness of the Probing Plate
double MobilePlateHoleDiameter = 14.7; // Diameter of Origin Hole (used for side probe limits)
double MobilePlateHoleDepth = 4.9; // Depth of the Origin Hole (used for retract: 2x)
double MobilePlateHoleOffsetX = 18; // Offset to Z Probe Point (Relative from Origin Center)
double MobilePlateHoleOffsetY = 18; // Offset to Z Probe Point (Relative from Origin Center)
// FIXED Plate Characteristics
double FixedPlateX = 364.4; // Fixed plate X position (machine coordinate)
double FixedPlateY = 20.7; // Fixed plate Y position (machine coordinate)
// TOOL CHANGE Location
double ToolChangeX = 180; // Tool change X position (machine coordinate)
double ToolChangeY = 0; // Tool change Y position (machine coordinate)
double ToolChangeZ = 0; // Tool change Z position (machine coordinate)
// Tuning Parameters
double SafeZ = 0; // Safe Z in (machine coordinate) Note: Machine homing should produce a Z=0 (Machine Coord) at Upper limit of Safe Z Travel
double RetractDistance = 1; // Height above Z0 to which probe will retract
double CoarseRate = 150; // Feed rate for initial probing
double FineRate = 25; // Feed rate for fine probing
double ZMaxProbeDist = 70; // maximum probing distance
bool DustShoe = true; // Pause/Prompt for Dust Shoe?
int StorageMethod = -1; // -1 to use C-Axis DRO, -2 to use Profile (file), or any other integer for internal variable (0-5999 excluding 5060-5066 and 5039 which are reserved)
int OKDelay = 5000; // Time to wait (ms) after "OK" on initial probe prompt (to allow manual stabilization of Mobile Touch Plate) (Only used by M20031)
bool Do2ndYPass = false; // Do a second Y Zero pass for increased accuracy (again after X Zero) (Only used by M20031)
bool ReturnToOriginalXY = true; // return to the same coordinates where the Tool Change was requested (Only used by M6)
bool PerformToolCheck = true; // Enable check for valid tool number (T#) (disable for manual testing) (Only used by M6)
bool ValidOffsetCheck = true; // Enable check for valid plate offset (non-zero) (Only used by M6)
// End Configuration Block: *****************************************************************************
// Macro ID (For use in title of Message Boxes)
string MacroID = "M20031";
// Calculated Parameters
double XYProbeRetract = MobilePlateHoleDepth * 2;
double DoubleRetractDistance = RetractDistance * 2;
// Working Variables
double XSave;
double YSave;
double ZSave;
double YMax;
double YMin;
double XMax;
double XMin;
double XCenter;
double YCenter;
double ZMobilePlate;
double ZFixedPlate;
double PlateOffset;
// Machine must be homed for safety
if(!exec.GetLED(56)||!exec.GetLED(57)||!exec.GetLED(58)) {
ShowMessage("The machine must be HOMED before this activity!", MacroID + ": Fatal Error!");
exec.Stop();
return;
}
// Get current X, Y, Z
XSave = exec.GetXmachpos();
YSave = exec.GetYmachpos();
ZSave = exec.GetZmachpos();
// Request Probe Action
if (DustShoe) ShowMessage("Please remove DUST SHOE and prepare MOBILE Probe (Attach Lead, Position the Probe and Spindle!)", MacroID + ": Prepare MOBILE Probe");
else ShowMessage("Please prepare MOBILE Probe (Attach Lead, Position the Probe and Spindle!)", MacroID + ": Prepare MOBILE Probe");
// Allow a few seconds for the operator to hold/stabilize the Mobile Touch Plate after clicking "OK"
exec.Wait(OKDelay);
// ***** Probe Y (Negative)
Probe_RC('Y', '-', MobilePlateHoleDiameter, RetractDistance, CoarseRate, FineRate);
// Get YMin
YMin = exec.GetYmachpos();
// Retract to Y starting Location (Machine Coords)
ExecAndWait("G53 G0 Y" + YSave);
// ***** Probe Y (Positive)
Probe_RC('Y', '+', MobilePlateHoleDiameter, RetractDistance, CoarseRate, FineRate);
// Get YMax
YMax = exec.GetYmachpos();
// Move Y to Calculated Center (Machine Coords)
YCenter = (YMax + YMin) / 2;
ExecAndWait("G53 G0 Y" + YCenter);
// ***** Probe X (Negative)
Probe_RC('X', '-', MobilePlateHoleDiameter, RetractDistance, CoarseRate, FineRate);
// Get XMin
XMin = exec.GetXmachpos();
// Retract to X starting Location (Machine Coords)
ExecAndWait("G53 G0 X" + XSave);
// ***** Probe X (Positive)
Probe_RC('X', '+', MobilePlateHoleDiameter, RetractDistance, CoarseRate, FineRate);
// Get XMax
XMax = exec.GetXmachpos();
// Move X to Calculated Center (Machine Coords)
XCenter = (XMax + XMin) / 2;
ExecAndWait("G53 G0 X" + XCenter);
if (Do2ndYPass) {
// Probe Y once again now that X has been centered (for better detail)
Probe_RC('Y', '-', MobilePlateHoleDiameter, RetractDistance, CoarseRate, FineRate);
// Get YMin
YMin = exec.GetYmachpos();
// Retract to Y starting Location (Machine Coords)
ExecAndWait("G53 G0 Y" + YCenter);
// ***** Probe Y (Positive)
Probe_RC('Y', '+', MobilePlateHoleDiameter, RetractDistance, CoarseRate, FineRate);
// Get YMax
YMax = exec.GetYmachpos();
// Move Y to Calculated Center (Machine Coords)
YCenter = (YMax + YMin) / 2;
ExecAndWait("G53 G0 Y" + YCenter);
}
// Set all workspaces to new X Zero
SetAllWorkspaceX(0);
// Set all workspaces to new Y Zero
SetAllWorkspaceY(0);
// Retract Z and move to Z probe Location (Relative)
exec.Code("G91");
ExecAndWait("G0 Z" + XYProbeRetract);
ExecAndWait("G0 X" + MobilePlateHoleOffsetX + " Y" + MobilePlateHoleOffsetY);
exec.Code("G90");
// ***** Probe Z
Probe_RC('Z', '-', XYProbeRetract, RetractDistance, CoarseRate, FineRate);
// Get ZProbe Height in machine coordinate
ZMobilePlate = exec.GetZmachpos();
// Set all workspaces to probed Z Height
SetAllWorkspaceZ(MobilePlateThickness);
// Request Probe Action
ExecAndWait("G53 G0 Z" + SafeZ);
ShowMessage("Please remove MOBILE Probe (Detach Lead!)", MacroID + ": Remove MOBILE Probe");
// ***** Probe the Fixed Plate
// Move to the Fixed Plate
SafeMove_MC(SafeZ, FixedPlateX, FixedPlateY, SafeZ);
// Request Probe Action
ShowMessage("Please prepare FIXED Probe (Attach Lead!)", MacroID + ": Prepare FIXED Probe");
// Probe Z
Probe_RC('Z', '-', ZMaxProbeDist, RetractDistance, CoarseRate, FineRate);
// Get the Z-value for the Fixed Plate
ZFixedPlate = exec.GetZmachpos();
// Calculate the difference between the fixed plate and Probed Zero
PlateOffset = ZFixedPlate - ZMobilePlate + MobilePlateThickness;
// PRESERVE Plate Difference using desired Storage Method
SavePlateOffset(PlateOffset, StorageMethod);
// Request Probe Action
ExecAndWait("G53 G0 Z" + SafeZ);
ShowMessage("Please disable FIXED Probe (Detach Lead!)", MacroID + ": Disable FIXED Probe");
// Prepare for Tool Change (If Needed)
SafeMove_MC(SafeZ, ToolChangeX, ToolChangeY, ToolChangeZ);
// Reinstall Dust Shoe?
if (DustShoe) ShowMessage("Please re-install DUST SHOE", MacroID + ": XYZ Probe Complete!");
// ***** Support FUNCTIONS **********************************************************
#Events
void ShowMessage(string Message, string Title="") {
MessageBox.Show(exec.mainform, Message, Title);
}
void SafeMove_MC(double SafeZ_MC, double X_MC, double Y_MC, double Z_MC, int msWait=200) {
// Retract to SafeZ
ExecAndWait("G53 G0 Z" + SafeZ_MC, msWait);
// Move to X, Y
ExecAndWait("G53 G0 X" + X_MC + " Y" + Y_MC, msWait);
// Move to Z
ExecAndWait("G53 G0 Z" + Z_MC, msWait);
}
void Probe_RC(char Axis, char Direction, double MaxDist, double RetractDist, double CoarseRate, double FineRate, int msWait=200) {
double FineDist = RetractDist * 2;
// Set Relative Mode for Probing
exec.Code("G91");
// Probe Quickly
if (Direction == '-') ExecAndWait("G31 " + Axis + '-' + MaxDist + "F" + CoarseRate, msWait);
else ExecAndWait("G31 " + Axis + MaxDist + "F" + CoarseRate, msWait);
// Retract (Reverse)
if (Direction == '-') ExecAndWait("G0 " + Axis + RetractDist, msWait);
else ExecAndWait("G0 " + Axis + '-' + RetractDist, msWait);
// Probe Slowly
if (Direction == '-') ExecAndWait("G31 " + Axis + '-' + FineDist + "F" + FineRate, msWait);
else ExecAndWait("G31 " + Axis + FineDist + "F" + FineRate, msWait);
// Reset Absolute Mode
exec.Code("G90");
}
double GetPlateOffset(int method = -1) {
// RETRIEVE the Plate Difference
switch(method) {
case -2: // From the running Profile
return Convert.ToDouble(exec.Readkey("XYZProbeData", "PlateOffset", "0.0000"));
case -1: // From the C axis DRO
return exec.GetCpos();
default: // From the specified internal variable
return exec.Getvar(method);
}
}
void SavePlateOffset(double offset, int method = -1) {
// PRESERVE the Plate Difference
switch(method) {
case -2: // To the running Profile
exec.Writekey("XYZProbeData", "PlateOffset", Convert.ToString(offset));
break;
case -1: // To the C axis DRO
SetAllWorkspaceC(offset);
break;
default: // To the specified internal variable
exec.Setvar(offset, method);
break;
}
return;
}
void ExecAndWait(string Command, int msWait=200) {
exec.Code(Command);
while(exec.IsMoving()){}
exec.Wait(msWait);
}
void SetAllWorkspaceX(double value) {
exec.mainform.sumoffsetcontrol1.G54.newCxinput(value);
exec.mainform.sumoffsetcontrol1.G55.newCxinput(value);
exec.mainform.sumoffsetcontrol1.G56.newCxinput(value);
exec.mainform.sumoffsetcontrol1.G57.newCxinput(value);
exec.mainform.sumoffsetcontrol1.G58.newCxinput(value);
exec.mainform.sumoffsetcontrol1.G59.newCxinput(value);
}
void SetAllWorkspaceY(double value) {
exec.mainform.sumoffsetcontrol1.G54.newCyinput(value);
exec.mainform.sumoffsetcontrol1.G55.newCyinput(value);
exec.mainform.sumoffsetcontrol1.G56.newCyinput(value);
exec.mainform.sumoffsetcontrol1.G57.newCyinput(value);
exec.mainform.sumoffsetcontrol1.G58.newCyinput(value);
exec.mainform.sumoffsetcontrol1.G59.newCyinput(value);
}
void SetAllWorkspaceZ(double value) {
exec.mainform.sumoffsetcontrol1.G54.newCzinput(value);
exec.mainform.sumoffsetcontrol1.G55.newCzinput(value);
exec.mainform.sumoffsetcontrol1.G56.newCzinput(value);
exec.mainform.sumoffsetcontrol1.G57.newCzinput(value);
exec.mainform.sumoffsetcontrol1.G58.newCzinput(value);
exec.mainform.sumoffsetcontrol1.G59.newCzinput(value);
}
void SetAllWorkspaceC(double value) {
exec.mainform.sumoffsetcontrol1.G54.newCcinput(value);
exec.mainform.sumoffsetcontrol1.G55.newCcinput(value);
exec.mainform.sumoffsetcontrol1.G56.newCcinput(value);
exec.mainform.sumoffsetcontrol1.G57.newCcinput(value);
exec.mainform.sumoffsetcontrol1.G58.newCcinput(value);
exec.mainform.sumoffsetcontrol1.G59.newCcinput(value);
}
M6 Tool Change Macro
- Code: Select all
// Custom M6 Manual TOOL CHANGE MACRO
// Simulates Carbide Motion (Nomad, Shapeko) BITZERO Probing Function (X, Y, Z)
// Requires Both a Mobile Plate (For initial M31 Workspace X, Y, Z) and a Fixed Plate (to support ongoing automatic Zeroing in the Z axis after M6 tool changes)
// * Mobile Plate: An XYZ Touch Plate (with XY Hole) is used to simulate the Carbide3D BitZero functionality
// * Fixed Plate: Any standard Touch Plate may be affixed to the router bed
// * UCCNC must be specifically configured (in Settings) to run an M6 Macro (default setting = do nothing)
// * The design software post processor for the machine must be configured to support tool changes (a "UCCNC ATC" vectric post processor is also provided)
// The machine must be Homed prior to this activity
// The macro will position the spindle at the desired location for a manual tool change
// The macro will then transition to the fixed plate to Z-Probe the new router bit and update the Workspace Z Zero.
// The Z Offset difference between the fixed plate and workspace Zero is stored/maintained in the C-Axis DRO, as a Profile Entry, or an internal variable as specified by "StorageMethod".
// The companion M31 macro is required to perform the initial probing and store the Workspace/Fixed Plate Z Offset as desired
// Start Configuration Block: ***************************************************************************
// Can be directly copy/pasted (shared) between M20031 and M6 macros - as such some variables are not actually used by both macros
// MOBILE Plate Characteristics // (Only used by M20031)
double MobilePlateThickness = 5.10; // Thickness of the Probing Plate
double MobilePlateHoleDiameter = 14.7; // Diameter of Origin Hole (used for side probe limits)
double MobilePlateHoleDepth = 4.9; // Depth of the Origin Hole (used for retract: 2x)
double MobilePlateHoleOffsetX = 18; // Offset to Z Probe Point (Relative from Origin Center)
double MobilePlateHoleOffsetY = 18; // Offset to Z Probe Point (Relative from Origin Center)
// FIXED Plate Characteristics
double FixedPlateX = 364.4; // Fixed plate X position (machine coordinate)
double FixedPlateY = 20.7; // Fixed plate Y position (machine coordinate)
// TOOL CHANGE Location
double ToolChangeX = 180; // Tool change X position (machine coordinate)
double ToolChangeY = 0; // Tool change Y position (machine coordinate)
double ToolChangeZ = 0; // Tool change Z position (machine coordinate)
// Tuning Parameters
double SafeZ = 0; // Safe Z in (machine coordinate) Note: Machine homing should produce a Z=0 (Machine Coord) at Upper limit of Safe Z Travel
double RetractDistance = 1; // Height above Z0 to which probe will retract
double CoarseRate = 150; // Feed rate for initial probing
double FineRate = 25; // Feed rate for fine probing
double ZMaxProbeDist = 70; // maximum probing distance
bool DustShoe = true; // Pause/Prompt for Dust Shoe?
int StorageMethod = -1; // -1 to use C-Axis DRO, -2 to use Profile (file), or any other integer for internal variable (0-5999 excluding 5060-5066 and 5039 which are reserved)
int OKDelay = 5000; // Time to wait (ms) after "OK" on initial probe prompt (to allow manual stabilization of Mobile Touch Plate) (Only used by M20031)
bool Do2ndYPass = false; // Do a second Y Zero pass for increased accuracy (again after X Zero) (Only used by M20031)
bool ReturnToOriginalXY = true; // return to the same coordinates where the Tool Change was requested (Only used by M6)
bool PerformToolCheck = true; // Enable check for valid tool number (T#) (disable for manual testing) (Only used by M6)
bool ValidOffsetCheck = true; // Enable check for valid plate offset (non-zero) (Only used by M6)
// End Configuration Block: *****************************************************************************
// Macro ID (For use in title of Message Boxes)
string MacroID = "M6";
// Working Variables
int Newtool;
int Currenttool;
double PlateOffset;
double XOriginal_MC;
double YOriginal_MC;
double ZOriginal_WC;
// Machine must be homed for safety
if(!exec.GetLED(56)||!exec.GetLED(57)||!exec.GetLED(58)) {
ShowMessage("The machine must be HOMED before this activity!", MacroID + ": Fatal Error!");
exec.Stop();
return;
}
Newtool = exec.Getnewtool();
Currenttool = exec.Getcurrenttool();
// Check/Process Tool Number (T#)
if(PerformToolCheck) {
// If new tool number is -1 means a missing T code
if(Newtool == -1) {
ShowMessage("No Tool Specified. Missing T code!", MacroID + ": Fatal Error!");
exec.Stopspin();
exec.Stop();
return;
}
// Same tool was selected, nothing to do...
if(Newtool == Currenttool) {
ShowMessage("Same Tool Requested. Nothing to do. Hit OK to continue...", MacroID + ": Info");
return;
}
}
// Turn off spindle
exec.Stopspin();
// Retrieve the plate difference from the chosen storage method
PlateOffset = GetPlateOffset(StorageMethod);
// If PlateOffset is EXACTLY zero, its EXTREMELY likely that the M20031 has not yet been run...
if(ValidOffsetCheck && (PlateOffset == 0.0)) {
ShowMessage("Plate Offset does not appear to be valid (0.00 exactly)! Has M20031 been run?", MacroID + ": Fatal Error!");
exec.Stop();
return;
}
// Get the current machine coordinates
XOriginal_MC = exec.GetXmachpos(); // (machine coordinate)
YOriginal_MC = exec.GetYmachpos(); // (machine coordinate)
ZOriginal_WC = exec.GetZpos(); // (workspace coordinate)
// Move to tool change position
SafeMove_MC(SafeZ, ToolChangeX, ToolChangeY, ToolChangeZ);
// Prompt: Tool Change
if (DustShoe) ShowMessage("TOOL " + Newtool + " Requested. Please remove DUST SHOE and perform TOOL CHANGE", MacroID + ": Perform Tool Change");
else ShowMessage("TOOL " + Newtool + " Requested. Please perform TOOL CHANGE", MacroID + ": Perform Tool Change");
//Move to Fixed Plate Position
SafeMove_MC(SafeZ, FixedPlateX, FixedPlateY, SafeZ);
// Prompt: Attach Probe
ShowMessage("Please Attach FIXED PLATE Probe", MacroID + ": Prepare FIXED Probe");
// Probe Z
Probe_RC('Z', '-', ZMaxProbeDist, RetractDistance, CoarseRate, FineRate);
// Update G54-G59 to new Z zero (Tip of the router bit is now at "PlateOffset")
SetAllWorkspaceZ(PlateOffset);
// Prompt: Detach Probe
SafeMove_MC(SafeZ, FixedPlateX, FixedPlateY, SafeZ);
if (DustShoe) ShowMessage("Please Remove FIXED PLATE Probe and install DUST SHOE", MacroID + ": Tool Change Complete!");
else ShowMessage("Please Remove FIXED PLATE Probe", MacroID + ": Tool Change Complete!");
// Return to Original X, Y or to Tool Change as desired (Machine Coords)
if(ReturnToOriginalXY) SafeMove_MC(SafeZ, XOriginal_MC, YOriginal_MC, SafeZ);
else SafeMove_MC(SafeZ, ToolChangeX, ToolChangeY, ToolChangeZ);
// ***** Support FUNCTIONS **********************************************************
#Events
void ShowMessage(string Message, string Title="") {
MessageBox.Show(exec.mainform, Message, Title);
}
void SafeMove_MC(double SafeZ_MC, double X_MC, double Y_MC, double Z_MC, int msWait=200) {
// Retract to SafeZ
ExecAndWait("G53 G0 Z" + SafeZ_MC, msWait);
// Move to X, Y
ExecAndWait("G53 G0 X" + X_MC + " Y" + Y_MC, msWait);
// Move to Z
ExecAndWait("G53 G0 Z" + Z_MC, msWait);
}
void Probe_RC(char Axis, char Direction, double MaxDist, double RetractDist, double CoarseRate, double FineRate, int msWait=200) {
double FineDist = RetractDist * 2;
// Set Relative Mode for Probing
exec.Code("G91");
// Probe Quickly
if (Direction == '-') ExecAndWait("G31 " + Axis + '-' + MaxDist + "F" + CoarseRate, msWait);
else ExecAndWait("G31 " + Axis + MaxDist + "F" + CoarseRate, msWait);
// Retract (Reverse)
if (Direction == '-') ExecAndWait("G0 " + Axis + RetractDist, msWait);
else ExecAndWait("G0 " + Axis + '-' + RetractDist, msWait);
// Probe Slowly
if (Direction == '-') ExecAndWait("G31 " + Axis + '-' + FineDist + "F" + FineRate, msWait);
else ExecAndWait("G31 " + Axis + FineDist + "F" + FineRate, msWait);
// Reset Absolute Mode
exec.Code("G90");
}
double GetPlateOffset(int method = -1) {
// RETRIEVE the Plate Difference
switch(method) {
case -2: // From the running Profile
return Convert.ToDouble(exec.Readkey("XYZProbeData", "PlateOffset", "0.0000"));
case -1: // From the C axis DRO
return exec.GetCpos();
default: // From the specified internal variable
return exec.Getvar(method);
}
}
void SavePlateOffset(double offset, int method = -1) {
// PRESERVE the Plate Difference
switch(method) {
case -2: // To the running Profile
exec.Writekey("XYZProbeData", "PlateOffset", Convert.ToString(offset));
break;
case -1: // To the C axis DRO
SetAllWorkspaceC(offset);
break;
default: // To the specified internal variable
exec.Setvar(offset, method);
break;
}
return;
}
void ExecAndWait(string Command, int msWait=200) {
exec.Code(Command);
while(exec.IsMoving()){}
exec.Wait(msWait);
}
void SetAllWorkspaceX(double value) {
exec.mainform.sumoffsetcontrol1.G54.newCxinput(value);
exec.mainform.sumoffsetcontrol1.G55.newCxinput(value);
exec.mainform.sumoffsetcontrol1.G56.newCxinput(value);
exec.mainform.sumoffsetcontrol1.G57.newCxinput(value);
exec.mainform.sumoffsetcontrol1.G58.newCxinput(value);
exec.mainform.sumoffsetcontrol1.G59.newCxinput(value);
}
void SetAllWorkspaceY(double value) {
exec.mainform.sumoffsetcontrol1.G54.newCyinput(value);
exec.mainform.sumoffsetcontrol1.G55.newCyinput(value);
exec.mainform.sumoffsetcontrol1.G56.newCyinput(value);
exec.mainform.sumoffsetcontrol1.G57.newCyinput(value);
exec.mainform.sumoffsetcontrol1.G58.newCyinput(value);
exec.mainform.sumoffsetcontrol1.G59.newCyinput(value);
}
void SetAllWorkspaceZ(double value) {
exec.mainform.sumoffsetcontrol1.G54.newCzinput(value);
exec.mainform.sumoffsetcontrol1.G55.newCzinput(value);
exec.mainform.sumoffsetcontrol1.G56.newCzinput(value);
exec.mainform.sumoffsetcontrol1.G57.newCzinput(value);
exec.mainform.sumoffsetcontrol1.G58.newCzinput(value);
exec.mainform.sumoffsetcontrol1.G59.newCzinput(value);
}
void SetAllWorkspaceC(double value) {
exec.mainform.sumoffsetcontrol1.G54.newCcinput(value);
exec.mainform.sumoffsetcontrol1.G55.newCcinput(value);
exec.mainform.sumoffsetcontrol1.G56.newCcinput(value);
exec.mainform.sumoffsetcontrol1.G57.newCcinput(value);
exec.mainform.sumoffsetcontrol1.G58.newCcinput(value);
exec.mainform.sumoffsetcontrol1.G59.newCcinput(value);
}