Skip to content

Commit

Permalink
Added WCS Validation
Browse files Browse the repository at this point in the history
  • Loading branch information
will1742 committed Jul 19, 2021
1 parent c5eb21e commit 064e5ce
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 1 deletion.
91 changes: 90 additions & 1 deletion Haas_Gantry_BIDC/Bechtel SR.cps
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,22 @@ properties = {
value: 10,
scope: "post"
},
pencilWCSValidation: {
title: "WCS Validation",
description: "WCS validation. By turning this off, you accept responsibility for any resulting crashes.",
group: 99,
type: "boolean",
value: true,
scope: "post"
},
toolHeightValidation: {
title: "Tool Length Validation",
description: "Length validation. By turning this off, you accept responsibility for any resulting crashes.",
group: 99,
type: "boolean",
value: true,
scope: "post"
},
sequenceNumberIncrement: {
title: "Sequence number increment",
description: "The amount by which the sequence number is incremented by in each block.",
Expand Down Expand Up @@ -625,12 +641,16 @@ function BIDCWriteToolMeasureBlock(tool, rotating) {
writeBlock(gFormat.format(43), hFormat.format(tool.number), zOutput.format(tool.bodyLength + tool.holderLength));
if (rotating) {
writeBlock(gFormat.format(59), gFormat.format(0), xOutput.format(0), yOutput.format(tool.diameter/2));
writeBlock(sOutput.format(tool.spindleRPM), mFormat.format(!tool.clockwise ? 3 : 4));
writeBlock(sOutput.format(400), mFormat.format(!tool.clockwise ? 3 : 4));
} else {
writeBlock(gFormat.format(59), gFormat.format(0), xOutput.format(0), yOutput.format(0));
}
writeBlock(gFormat.format(37), hFormat.format(tool.number), zOutput.format(0), "F10.");
writeBlock(gFormat.format(91), gFormat.format(0), zOutput.format(.1), "F100.");
if (rotating) {
writeBlock(sOutput.format(800));
writeBlock(gFormat.format(4), "P1.");
}
writeBlock(gFormat.format(37), hFormat.format(tool.number), zOutput.format(0), "F2.");
onCommand(COMMAND_STOP_SPINDLE);
writeRetract(Z);
Expand Down Expand Up @@ -1357,11 +1377,34 @@ function printProbeResults() {
}

var probeOutputWorkOffset = 1;
var stockTopZ = -1;
var stockUpperX;
var stockLowerX;
var stockUpperY;
var stockLowerY;

function onParameter(name, value) {
if (name == "probe-output-work-offset") {
probeOutputWorkOffset = (value > 0) ? value : 1;
}

// Added 6/15/21 | Gavin Williams | will1742
// Issue 001 Input and Validation
if (name == "stock-upper-z") {
stockTopZ = value;
}
if (name == "stock-upper-x") {
stockUpperX = value;
}
if (name == "stock-lower-x") {
stockLowerX = value;
}
if (name == "stock-upper-y") {
stockUpperY = value;
}
if (name == "stock-lower-y") {
stockLowerY = value;
}
}

/** Returns true if the spatial vectors are significantly different. */
Expand Down Expand Up @@ -1607,6 +1650,22 @@ function setAbsoluteMode(xyz, abc) {
}

function onSection() {
if (isFirstSection() && getProperty("pencilWCSValidation")) {
var stockMidX = (stockUpperX + stockLowerX)/2;
var stockMidY = (stockUpperY + stockLowerY)/2;
writeln("");
writeComment("Verify WCS");
writeBlock("T" + toolFormat.format(19), mFormat.format(6)); //Changes Tool
writeBlock(gFormat.format(55), gFormat.format(0), xOutput.format(stockMidX), yOutput.format(stockMidY));
writeComment("Is the pencil centered above your stock?");
writeBlock(mFormat.format(0), formatComment("Open door"));
writeBlock(gFormat.format(55), gFormat.format(43), hFormat.format(19), zOutput.format(stockTopZ));
writeComment("Is the pencil touching your stock?");
writeBlock(mFormat.format(0), formatComment("Open door"));
}
var forceToolAndRetract = optionalSection && !currentSection.isOptional();
optionalSection = currentSection.isOptional();

Expand Down Expand Up @@ -1942,6 +2001,36 @@ function onSection() {
inspectionProcessSectionStart();
}
}

if (getProperty("toolHeightValidation")) {
writeComment("BEGIN VALIDATION SECTION");
// Added 06/15/21 | Gavin Williams | will1742
// Verifies tool-stock distance. Post fails if tool fails clearance standards
if (toolDistance < CLEARANCE_HEIGHT) {
throw "Error: Clearance height must be " + CLEARANCE_HEIGHT + " or more inches from stock";
}

if (toolDistance == Infinity) {
throw "Error: invalid tool distance. Contact a TA.";
}
var toolDistance = initialPosition.z - stockTopZ;

// Prompt user to check stock-tool distance
writeComment("Is your tool " + toolDistance.toPrecision(2).toString() + "in from your stock?");
writeBlock(mFormat.format(0), formatComment("Open door"));

writeComment("END VALIDATION SECTION");

// initialize spindle and engage coolant if heights are correct
if (tool.type != TOOL_PROBE) {
writeBlock(mFormat.format((tool.clockwise ? 3 : 4)), formatComment("Restart spindle"));
}
}

if (tool.type != TOOL_PROBE) {
setCoolant(tool.coolant);
}

// define subprogram
subprogramDefine(initialPosition, abc, retracted, zIsOutput);
}
Expand Down
2 changes: 2 additions & 0 deletions Haas_Next_Generation/Bechtel DT.cps
Original file line number Diff line number Diff line change
Expand Up @@ -2288,6 +2288,8 @@ function onSection() {
writeBlock(gFormat.format(55), gFormat.format(43), hFormat.format(19), zOutput.format(stockTopZ));
displayMedia("Net Share/Media/zWCSCheck.jpg");
writeBlock(mFormat.format(0), formatComment("Open door"));
writeBlock(mFormat.format(131), formatComment("End Multimedia"));
/*
displayMedia("Net Share/Media/checkPrompt.jpg");
gotoRef = takeInput("Is the pencil touching the center of your stock? [Y/N]", ['N', 'Y']);
Expand Down
2 changes: 2 additions & 0 deletions Haas_Next_Generation/Bechtel VF.cps
Original file line number Diff line number Diff line change
Expand Up @@ -2288,6 +2288,8 @@ function onSection() {
writeBlock(gFormat.format(55), gFormat.format(43), hFormat.format(19), zOutput.format(stockTopZ));
displayMedia("Net Share/Media/zWCSCheck.jpg");
writeBlock(mFormat.format(0), formatComment("Open door"));
writeBlock(mFormat.format(131), formatComment("End Multimedia"));
/*
displayMedia("Net Share/Media/checkPrompt.jpg");
gotoRef = takeInput("Is the pencil touching the center of your stock? [Y/N]", ['N', 'Y']);
Expand Down

0 comments on commit 064e5ce

Please sign in to comment.