Skip to content

Commit

Permalink
Set DT Constants
Browse files Browse the repository at this point in the history
  • Loading branch information
will1742 committed Jul 21, 2021
1 parent 222f9a8 commit 4789375
Showing 1 changed file with 86 additions and 18 deletions.
104 changes: 86 additions & 18 deletions Haas_Next_Generation/Bechtel DT.cps
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ properties = {/*
{title: "Patterns", id: "patterns"}
],
group: 3,
value: "allOperations",
value: "none",
scope: "post"
},/*
writeMachine: {
Expand Down Expand Up @@ -495,6 +495,8 @@ staticProperties = {
// VF4 specific
const MAX_TOOL_LENGTH = 7;
const MAX_TOOL_DIAM = 2;
const X_TRAVEL_LIMIT = 20;
const Y_TRAVEL_LIMIT = 16;

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 @@ -1290,6 +1293,14 @@ function onOpen() {
}
}

writeln("");
writeBlock(gFormat.format(0),
gFormat.format(17),
gFormat.format(40),
gFormat.format(49),
gFormat.format(80),
gFormat.format(90), formatComment("Reset work plane, cancel all cycles and offsets"));

// 6/21/21 | Gavin Williams | will1742
// Probing now required. Using P9995.
// optionally cycle through all tools
Expand All @@ -1309,20 +1320,16 @@ function onOpen() {

// 6/21/21 | Gavin Williams | will1742
writeComment("Load and probe tools");
writeBlock(gFormat.format(0),
gFormat.format(17),
gFormat.format(40),
gFormat.format(49),
gFormat.format(80),
gFormat.format(90), formatComment("Reset work plane, cancel all cycles and offsets"));

displayMedia("Net Share/Media/toolProbeReminder.jpg");
writeBlock(mFormat.format(0));

let parsedTools = [];

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 +1365,19 @@ function onOpen() {
}

for (var i = 0; i < tools.getNumberOfTools(); i++) {
var tool = tools.getTool(i);
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 +1404,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 @@ -2263,6 +2272,19 @@ function setAbsoluteMode(xyz, abc) {
}

function onSection() {
if (isFirstSection()) {
writeln("");
writeComment("STOCK PREP");
var Stock_X_55 = (stockUpperX - stockLowerX)/2;
writeln(macroFormat.format(100) + "=[" + (Stock_X_55.toFixed(4) + "-" + macroFormat.format(5241)) + "]");
writeWords("IF [" + macroFormat.format(100) + " LT 0] THEN " + macroFormat.format(100) + "=0");
writeWords("IF [" + macroFormat.format(100) + " GT " + X_TRAVEL_LIMIT + "] THEN " + macroFormat.format(100) + "=" + X_TRAVEL_LIMIT);
writeBlock(gFormat.format(53), "X" + macroFormat.format(100), yOutput.format(0));
writeBlock(mFormat.format(0));
displayMedia("loadStock.jpg");
}


// 07/06/21 | Gavin Williams | will1742
// 002 Improved Probing
// uses pencil to verify WCS, prompts user
Expand All @@ -2274,7 +2296,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,10 +2308,10 @@ 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"));
/*
displayMedia("Net Share/Media/checkPrompt.jpg");
gotoRef = takeInput("Is the pencil touching the center of your stock? [Y/N]", ['N', 'Y']);
Expand Down Expand Up @@ -2346,6 +2368,12 @@ function onSection() {
setWorkPlane(new Vector(0, 0, 0)); // reset working plane
}
}

if (!isFirstSection()) {
displayMedia("checkPartTool.jpg");
writeBlock(mFormat.format(0));
writeBlock(mFormat.format(131));
}

if (hasParameter("operation-comment")) {
var comment = getParameter("operation-comment");
Expand All @@ -2360,7 +2388,11 @@ function onSection() {
writeln("");
}

if (staticProperties.showNotes && hasParameter("notes")) {
if (hasParameter("notes") && getParameter("notes").indexOf("approved") <= -1) {
//throw "Operation \"" + getParameter("operation-comment") + "\" not approved. See a TA."
}

if (staticProperties.showNotes) {
var notes = getParameter("notes");
if (notes) {
var lines = String(notes).split("\n");
Expand Down Expand Up @@ -2714,7 +2746,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 +2786,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 +4457,8 @@ function writeProbingToolpathInformation(cycleDepth) {
}

function onClose() {
if (isDPRNTopen) {
writeln("DPRNT[END]");
writeBlock("PCLOS");
Expand All @@ -4440,9 +4474,43 @@ function onClose() {

onCommand(COMMAND_STOP_SPINDLE);
onCommand(COMMAND_COOLANT_OFF);
writeBlock(mFormat.format(0));

// 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 4789375

Please sign in to comment.