Skip to content

Commit

Permalink
Tool Unloading + Machine Cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
will1742 committed Jul 20, 2021
1 parent 0b007d2 commit 0b43183
Showing 1 changed file with 52 additions and 12 deletions.
64 changes: 52 additions & 12 deletions Haas_Next_Generation/Bechtel VF.cps
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ properties = {/*
{title: "Yes", id: "true"},
{title: "Reversed", id: "reversed"}
],
value: "false",
value: "reversed",
scope: "post"
},
hasBAxis: {
Expand All @@ -108,7 +108,7 @@ properties = {/*
{title: "Yes", id: "true"},
{title: "Reversed", id: "reversed"}
],
value: "false",
value: "true",
scope: "post"
},/*
useDPMFeeds: {
Expand Down Expand Up @@ -495,6 +495,8 @@ staticProperties = {
// VF4 specific
const MAX_TOOL_LENGTH = 11;
const MAX_TOOL_DIAM = 5;
const X_TRAVEL_LIMIT = 50;
const Y_TRAVEL_LIMIT = 25;

var singleLineCoolant = false; // specifies to output multiple coolant codes in one line rather than in separate lines
// samples:
Expand All @@ -521,6 +523,7 @@ var mFormat = createFormat({prefix:"M", decimals:0});
var hFormat = createFormat({prefix:"H", decimals:0});
var dFormat = createFormat({prefix:"D", decimals:0});
var probeWCSFormat = createFormat({decimals:2, forceDecimal:true});
var macroFormat = createFormat({prefix:"#", decimals:0});

var xyzFormat = createFormat({decimals:(unit == MM ? 3 : 4), forceDecimal:true});
var rFormat = xyzFormat; // radius
Expand Down Expand Up @@ -1321,8 +1324,8 @@ function onOpen() {

function defaultFill() {
parsedTools = []
for (var i = 1; i <= tools.getNumberOfTools(); i++){
parsedTools.push(i);
for (var i = 0; i < tools.getNumberOfTools(); i++){
parsedTools[i] = tools.getTool(i).number;
}
}

Expand Down Expand Up @@ -1358,17 +1361,20 @@ function onOpen() {
}

for (var i = 0; i < tools.getNumberOfTools(); i++) {
var tool = tools.getTool(i);
writeComment(tool.description);
if (tool.bodyLength + tool.holderLength > MAX_TOOL_LENGTH) {
throw "Error: T" + tool.number + " length greater than machine max"
}

if (tool.diameter > MAX_TOOL_DIAM) {
throw "Error : T" + tool.number + " diameter greater than machine max"
}
var tool = tools.getTool(i);

if (parsedTools.indexOf(tool.number) <= -1) {
continue;
}

if (getProperty("measureToolsAtStart") && (tool.type == TOOL_PROBE)) {
continue;
}
Expand All @@ -1395,7 +1401,7 @@ function onOpen() {
writeComment(comment);
if (getProperty("measureToolsAtStart")) {
writeBlock("T" + toolFormat.format(tool.number), mFormat.format(6)); //Changes Tool
displayMedia("Net Share/Media/toolLoad" + tool.number + ".jpg");
displayMedia("toolLoad" + tool.number + ".jpg");
writeBlock(mFormat.format(0), formatComment("Load Tool")); //Pause until operator loads tool
writeToolMeasureBlock(tool, true);
} else {
Expand Down Expand Up @@ -2274,7 +2280,7 @@ function onSection() {
writeBlock("T" + toolFormat.format(19), mFormat.format(6)); //Changes Tool
writeBlock(gFormat.format(55), gFormat.format(0), xOutput.format(stockMidX), yOutput.format(stockMidY));
displayMedia("Net Share/Media/xyWCSCheck.jpg");
displayMedia("xyWCSCheck.jpg");
writeBlock(mFormat.format(0), formatComment("Open door"));
/*
displayMedia("Net Share/Media/checkPrompt.jpg");
Expand All @@ -2286,7 +2292,7 @@ function onSection() {
writeWords("N" + nFormat.format(gotoRef['Y']), mFormat.format(131), formatComment("End Multimedia"));
*/
writeBlock(gFormat.format(55), gFormat.format(43), hFormat.format(19), zOutput.format(stockTopZ));
displayMedia("Net Share/Media/zWCSCheck.jpg");
displayMedia("zWCSCheck.jpg");
writeBlock(mFormat.format(0), formatComment("Open door"));
writeBlock(mFormat.format(131), formatComment("End Multimedia"));
Expand Down Expand Up @@ -2714,7 +2720,7 @@ function onSection() {
var toolDistance = initialPosition.z - stockTopZ;

// Prompt user to check stock-tool distance
displayMedia("Net Share/Media/checkDistance" + toolDistance.toPrecision(2).toString().replace(".", "_") + ".jpg");
displayMedia("checkDistance" + toolDistance.toPrecision(2).toString().replace(".", "_") + ".jpg");
writeBlock(mFormat.format(0), formatComment("Open door"));
//displayMedia("Net Share/Media/checkPrompt.jpg");
writeBlock(mFormat.format(131), formatComment("End Multimedia"));
Expand Down Expand Up @@ -2754,7 +2760,7 @@ function onSection() {
// Displays a file: MP4, MOV, PNG, JPEG. 1920x1080
// Input: Absolute path to file
function displayMedia(file) {
writeBlock(mFormat.format(130), formatComment(file));
writeBlock(mFormat.format(130), formatComment("Net Share/Media/" + file));
}

// Added 6/14/21 | Gavin Williams | will1742
Expand Down Expand Up @@ -4425,6 +4431,8 @@ function writeProbingToolpathInformation(cycleDepth) {
}

function onClose() {
if (isDPRNTopen) {
writeln("DPRNT[END]");
writeBlock("PCLOS");
Expand All @@ -4438,12 +4446,44 @@ function onClose() {

optionalSection = false;

writeln("(CLOSE JOB AND CLEAN)");
onCommand(COMMAND_STOP_SPINDLE);
onCommand(COMMAND_COOLANT_OFF);

// retract
writeln("");
writeComment("UNLOAD TOOLS");
var tools = getToolTable();
if (tools.getNumberOfTools() > 0) {
for (var i = 0; i < tools.getNumberOfTools(); ++i) {
var tool = tools.getTool(i);
writeBlock("T" + toolFormat.format(tool.number), mFormat.format(6)); // get tool
writeBlock(mFormat.format(0));
}
}

function gotoWithMessage(xLoc, yLoc, fileName) {
writeBlock(gFormat.format(53), xOutput.format(xLoc), yOutput.format(yLoc));
displayMedia(fileName);
writeBlock(mFormat.format(0));
}

writeln("");
writeComment("CLEAN MACHINE");
writeRetract(Z);
gotoWithMessage(X_TRAVEL_LIMIT/2, 0, "airGunCLean.jpg");
displayMedia("floodCoolantOff.jpg")
writeBlock(mFormat.format(0));
setCoolant(COOLANT_FLOOD);
gotoWithMessage(0, Y_TRAVEL_LIMIT, "sprayLowerRight.jpg");
gotoWithMessage(X_TRAVEL_LIMIT, Y_TRAVEL_LIMIT, "sprayLowerLeft.jpg");
gotoWithMessage(0, 0, "sprayUpperRight.jpg")
gotoWithMessage(X_TRAVEL_LIMIT, 0, "sprayUpperLeft.jpg")
onCommand(COMMAND_COOLANT_OFF);
onCommand(COMMAND_START_CHIP_TRANSPORT);
gotoWithMessage(X_TRAVEL_LIMIT/2, Y_TRAVEL_LIMIT, "useAuger.jpg");
onCommand(COMMAND_STOP_CHIP_TRANSPORT);

writeln("");
// retract
if (!staticProperties.homePositionCenter || currentMachineABC.length != 0) {
writeRetract(X, Y);
}
Expand Down

0 comments on commit 0b43183

Please sign in to comment.