From 4bbc94dd1ff1a4f25f87f05095c154d72d5bc6d1 Mon Sep 17 00:00:00 2001 From: will1742 Date: Mon, 21 Jun 2021 16:53:40 -0400 Subject: [PATCH] added tool probing, cleaned code --- .gitignore | 2 + Haas_Next_Generation/haas vf2.cps | 83 +++++++++++++++++-------------- 2 files changed, 49 insertions(+), 36 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e45abea --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +Old/haas next generation.cps diff --git a/Haas_Next_Generation/haas vf2.cps b/Haas_Next_Generation/haas vf2.cps index f5d022f..507b1c1 100644 --- a/Haas_Next_Generation/haas vf2.cps +++ b/Haas_Next_Generation/haas vf2.cps @@ -226,7 +226,7 @@ properties = { value: false, scope: "post" }, - optionallyMeasureToolsAtStart: { + measureToolsAtStart: { title: "Optionally measure tools at start", description: "Measure each tool used at the beginning of the program when block delete is turned off.", group: 2, @@ -438,7 +438,7 @@ staticProperties = { useG187: false, homePositionCenter: false, optionallyCycleToolsAtStart: false, - optionallyMeasureToolsAtStart: false, + measureToolsAtStart: true, forceHomeOnIndexing: true, toolBreakageTolerance: 0.1, fastToolChange: false, @@ -709,13 +709,14 @@ function prepareForToolCheck() { } function writeToolMeasureBlock(tool, preMeasure) { - var writeFunction = measureTool ? writeBlock : writeOptionalBlock; + // var writeFunction = measureTool ? writeBlock : writeOptionalBlock; + var writeFunction = writeBlock; var comment = measureTool ? formatComment("MEASURE TOOL") : ""; if (!preMeasure) { prepareForToolCheck(); } - if (true) { // use Macro P9023 to measure tools + if (false) { // use Macro P9023 to measure tools var probingType = getHaasProbingType(tool.type, true); writeFunction( gFormat.format(65), @@ -727,7 +728,7 @@ function writeToolMeasureBlock(tool, preMeasure) { comment ); } else { // use Macro P9995 to measure tools - writeFunction("T" + toolFormat.format(tool.number), mFormat.format(6)); // get tool + // writeFunction("T" + toolFormat.format(tool.number), mFormat.format(6)); // get tool writeFunction( gFormat.format(65), "P9995", @@ -1106,23 +1107,36 @@ function onOpen() { } } + // 6/21/21 | Gavin Williams | will1742 + // Probing now required. Using P9995. + // optionally cycle through all tools - if (staticProperties.optionallyCycleToolsAtStart || staticProperties.optionallyMeasureToolsAtStart) { + if (staticProperties.optionallyCycleToolsAtStart || staticProperties.measureToolsAtStart) { var tools = getToolTable(); if (tools.getNumberOfTools() > 0) { writeln(""); - + /* writeOptionalBlock(mFormat.format(0), formatComment(localize("Read note"))); // wait for operator writeComment(localize("With BLOCK DELETE turned off each tool will cycle through")); writeComment(localize("the spindle to verify that the correct tool is in the tool magazine")); - if (staticProperties.optionallyMeasureToolsAtStart) { + if (staticProperties.measureToolsAtStart) { writeComment(localize("and to automatically measure it")); } writeComment(localize("Once the tools are verified turn BLOCK DELETE on to skip verification")); - + */ + + // 6/21/21 | Gavin Williams | will1742 + 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")); + writeComment("Load and probe tools"); + for (var i = 0; i < tools.getNumberOfTools(); ++i) { var tool = tools.getTool(i); - if (staticProperties.optionallyMeasureToolsAtStart && (tool.type == TOOL_PROBE)) { + if (staticProperties.measureToolsAtStart && (tool.type == TOOL_PROBE)) { continue; } var comment = "T" + toolFormat.format(tool.number) + " " + @@ -1133,7 +1147,10 @@ function onOpen() { } comment += " - " + getToolTypeName(tool.type); writeComment(comment); - if (staticProperties.optionallyMeasureToolsAtStart) { + if (staticProperties.measureToolsAtStart) { + writeBlock("T" + toolFormat.format(tool.number), mFormat.format(6)); //Changes Tool + writeBlock(mFormat.format(0), formatComment("Load Tool")); //Pause until operator loads tool + //writeToolMeasureOPT(tool); writeToolMeasureBlock(tool, true); } else { writeToolCycleBlock(tool); @@ -1143,7 +1160,7 @@ function onOpen() { writeln(""); } - if (false /*useDWO*/) { + if (staticProperties.useDWO) { var failed = false; var dynamicWCSs = {}; for (var i = 0; i < getNumberOfSections(); ++i) { @@ -2084,7 +2101,7 @@ function onSection() { // 6/18/21 | Gavin Williams | will1742 // Terminate any media that may have been active at beginning of section // Issue 001: Input and validation - cancelMedia(); + writeBlock(mFormat.format(131), formatComment("End multimedia")); if (insertToolCall || operationNeedsSafeStart) { @@ -2407,7 +2424,7 @@ function onSection() { displayMedia("Net Share/Media/checkDistance.png"); // Allow door to be opened - linePrint("M0" + " (Halt program)"); + writeBlock(mFormat.format(0), formatComment("Open door")); displayMedia("Net Share/Media/arrowDown.png"); // asks user if measured height is accurate to displayed @@ -2418,8 +2435,8 @@ function onSection() { writeComment("END VALIDATION SECTION") // initialize spindle and engage coolant if heights are correct - writeln("N" + gotoRef[1][1] + " M131 (End Multimedia)"); - linePrint("M" + (tool.clockwise ? 3 : 4) + " (Restart spindle)"); + writeln("N" + nFormat.format(gotoRef[1][1]) + " " + mFormat.format(131) + " " + formatComment("End Multimedia")); + writeBlock(mFormat.format((tool.clockwise ? 3 : 4)), formatComment("Restart spindle")); // Modified 06/09/21 | Gavin Williams | will1742 // Issue 000 Init coolant after positioning @@ -2430,25 +2447,17 @@ function onSection() { subprogramDefine(initialPosition, abc, retracted, zIsOutput); } -// print with sequence number -function linePrint(message) { - writeln("N" + sequenceNumber + " " + message); - sequenceNumber += staticProperties.sequenceNumberIncrement; -} - // Added 6/14/21 | Gavin Williams | will1742 // Issue 001 Input and Validation // Displays a file: MP4, MOV, PNG, JPEG. 1920x1080 // Input: Absolute path to file function displayMedia(file) { - linePrint("M130 (" + file + ")"); + writeBlock(mFormat.format(130), formatComment(file)); } // Ends displayed media -function cancelMedia() { - linePrint("M131" + " (End multimedia)"); -} +// TODO: switch to map for gotoref // Added 6/14/21 | Gavin Williams | will1742 // Issue 001 Input and Validation // Takes input from the user @@ -2464,20 +2473,20 @@ function takeInput(prompt, options) { if (macroNumber > 549) macroNumber = 500; // init macro var to 0 - writeln("#" + macroNumber + "=0" + " (Initialize macro variable)"); + writeln("#" + macroNumber + "=0" + " " + formatComment("Initialize macro variable")); // disply prompt and save response - writeln("N" + sequenceNumber + " M109 " + "P" + macroNumber + " (" + prompt + ")"); - var gotoRef = sequenceNumber; + writeBlock(mFormat.format(109), "P" + nFormat.format(macroNumber), formatComment(prompt)); + var gotoRef = sequenceNumber - staticProperties.sequenceNumberIncrement; // wait for input - writeln("IF[#" + macroNumber + " EQ 0.] GOTO" + gotoRef + " (NULL)"); + writeln("IF[#" + macroNumber + " EQ 0.] GOTO" + nFormat.format(gotoRef) + " " + formatComment("NULL")); // print if's and goto's var gotoMap =[]; var gotoInc = 1; options.forEach(function (element) { - writeln("IF[#" + macroNumber + " EQ " + element.charCodeAt(0) + ".] GOTO" + (sequenceNumber + gotoInc) + " (" + element + ")"); + writeln("IF[#" + macroNumber + " EQ " + element.charCodeAt(0) + ".] GOTO" + nFormat.format(sequenceNumber + gotoInc) + " (" + element + ")"); gotoMap.push([element, (sequenceNumber + gotoInc)]); gotoInc += 1; }); @@ -2488,7 +2497,7 @@ function takeInput(prompt, options) { } // return to input until valid option is entered - writeln("GOTO" + gotoRef + " (INVALID INPUT)") + writeln("GOTO" + nFormat.format(gotoRef) + " " + formatComment("INVALID INPUT")) // increase var number, iterate sequence number macroNumber += 1; @@ -2500,10 +2509,12 @@ function takeInput(prompt, options) { // Issue 001 Input and validation // Halts program until TA arrives. Returns to beginning of onSection function getTA(file, seqNum, gotoRef) { - writeln("N" + seqNum + " G53 G0 Z0." + " (Retract spindle)"); - writeln("M130 (" + file + ")"); - writeln("M0" + " (Halt program)"); - writeln("GOTO" + gotoRef + " (Return to beginning of operation)"); + writeln("N" + nFormat.format(seqNum) + " " + + gFormat.format(53) + " " + gFormat.format(0) + " " + zOutput.format(0.) + " " + + formatComment("Retract spindle")); + writeln(mFormat.format(130) + " " + formatComment(file)); + writeln(mFormat.format(0) + " " + formatComment("Halt Program")); + writeln("GOTO" + nFormat.format(gotoRef) + " " + formatComment("Return to beginning of operation")); } function onDwell(seconds) {