From b1bf74afa6f94a73f49d0fb67e61db733e685a53 Mon Sep 17 00:00:00 2001 From: will1742 Date: Fri, 16 Jul 2021 16:04:20 -0400 Subject: [PATCH] Added tool probing selection --- Haas_Next_Generation/1001.nc.failed | 26 ++++++ Haas_Next_Generation/Bechtel VF4.cps | 126 ++++++++++++++++++++++----- 2 files changed, 132 insertions(+), 20 deletions(-) create mode 100644 Haas_Next_Generation/1001.nc.failed diff --git a/Haas_Next_Generation/1001.nc.failed b/Haas_Next_Generation/1001.nc.failed new file mode 100644 index 0000000..aa628b9 --- /dev/null +++ b/Haas_Next_Generation/1001.nc.failed @@ -0,0 +1,26 @@ +% +O01001 +(will1742: 2D Ops v7~recovered) +(Friday, July 16, 2021 8:01:13 PM) +(Using G0 which travels along dogleg path.) +(T1 D=2. CR=0.102 - ZMIN=1.515 - face mill) +(T2 D=0.5 CR=0. - ZMIN=0.015 - flat end mill) +(T3 D=0.4219 CR=0. TAPER=140deg - ZMIN=0.4182 - drill) +(T4 D=0.25 CR=0. TAPER=45deg - ZMIN=0.425 - chamfer mill) +(T5 D=0.25 CR=0. TAPER=140deg - ZMIN=0.815 - drill) +(T6 D=0.25 CR=0. - ZMIN=0.815 - right hand tap) +(T7 D=0.375 CR=0. TAPER=140deg - ZMIN=0.815 - spot drill) +(T8 D=0.372 CR=0. - ZMIN=0.515 - thread mill) +(T9 D=0.1875 CR=0. TAPER=118deg - ZMIN=0.815 - center drill) +(T10 D=0.25 CR=0. - ZMIN=1.515 - flat end mill) +(T11 D=0.5 CR=0.015 - ZMIN=0.535 - bullnose end mill) +(T12 D=1.2598 CR=0.0312 - ZMIN=1.515 - face mill) +(T13 D=0.84 CR=0.015 TAPER=60deg - ZMIN=1.515 - dovetail mill) +(T14 D=0.25 CR=0.125 - ZMIN=0.515 - ball end mill) +(T15 D=0.313 CR=0.1565 - ZMIN=1.015 - lollipop mill) +(T17 D=1.9696 CR=0.0468 TAPER=45.5deg - ZMIN=1.515 - face mill) + +(Load and probe tools) +N10 G0 G17 G40 G49 G80 G90 (Reset work plane, cancel all cycles and offsets) +N15 M130 (Net Share/Media/toolProbeReminder.jpg) +!Error: Failed to post data. See log for details. diff --git a/Haas_Next_Generation/Bechtel VF4.cps b/Haas_Next_Generation/Bechtel VF4.cps index 29d9433..7a1b830 100644 --- a/Haas_Next_Generation/Bechtel VF4.cps +++ b/Haas_Next_Generation/Bechtel VF4.cps @@ -399,6 +399,14 @@ properties = {/* value: true, scope: "post" }*/ + toolsToLoad: { + title: "Tools to load and probe", + description: "List or provide a range of tools to probe e.g. 1, 2, 3 or 1-5. Leaving this empty will probe all tools", + group: 4, + type: "string", + value: "", + scope: "post" + }, toolHeightValidation: { title: "Tool Length Validation", description: "Length validation. By turning this off, you accept responsibility for any resulting crashes.", @@ -414,6 +422,14 @@ properties = {/* type: "boolean", value: true, scope: "post" + }, + measureToolsAtStart: { + title: "Tool Probing", + description: "Tool Probing. By turning this off, you accept responsibility for any resulting crashes.", + group: 99, + type: "boolean", + value: true, + scope: "post" } }; @@ -476,6 +492,10 @@ staticProperties = { const LENGTH_TOLERANCE = .25; const DIAM_TOLERANCE = .01; + // VF4 specific + const MAX_TOOL_LENGTH = 13; + const MAX_TOOL_DIAM = 5; + var singleLineCoolant = false; // specifies to output multiple coolant codes in one line rather than in separate lines // samples: // {id: COOLANT_THROUGH_TOOL, on: 88, off: 89} @@ -857,7 +877,7 @@ function writeToolMeasureBlock(tool, preMeasure) { prepareForToolCheck(); } if (!staticProperties.useP9995) { // use Macro P9023 to measure tools - var probingType = getHaasProbingType(tool.type, true); + var probingType = getHaasProbingTypeBIDC(tool.type, true); writeFunction( gFormat.format(65), "P9023", @@ -868,10 +888,10 @@ function writeToolMeasureBlock(tool, preMeasure) { comment ); } else { // use Macro P9995 to measure tools -writeFunction("T" + toolFormat.format(tool.number), mFormat.format(6)); // get tool -setMacro(1600 + tool.number, tool.numberOfFlutes, "Number of Flutes"); -var probeType = getHaasProbingTypeBIDC(tool, false); -writeFunction( + writeFunction("T" + toolFormat.format(tool.number), mFormat.format(6)); // get tool + setMacro(1600 + tool.number, tool.numberOfFlutes, "Number of Flutes"); + var probeType = getHaasProbingTypeBIDC(tool, false); + writeFunction( gFormat.format(65), "P9995", "A0.", @@ -1273,11 +1293,10 @@ function onOpen() { // 6/21/21 | Gavin Williams | will1742 // Probing now required. Using P9995. // optionally cycle through all tools - if (staticProperties.optionallyCycleToolsAtStart || staticProperties.measureToolsAtStart) { + if (staticProperties.optionallyCycleToolsAtStart || getProperty("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")); @@ -1296,13 +1315,78 @@ function onOpen() { gFormat.format(49), gFormat.format(80), gFormat.format(90), formatComment("Reset work plane, cancel all cycles and offsets")); - displayMedia("Net Share/Media/toolProbeReminder.jpg"); - for (var i = 0; i < tools.getNumberOfTools(); ++i) { + + let parsedTools = []; + + function defaultFill() { + parsedTools = [] + for (var i = 1; i <= tools.getNumberOfTools(); i++){ + parsedTools.push(i); + } + } + + function validateToolNum(toolNum) { + return (toolNum < 1 || toolNum > tools.getNumberOfTools() || tools.getTool(toolNum) == undefined); + } + + if (getProperty("toolsToLoad") != "") { + let toolNumArray = getProperty("toolsToLoad").split(','); + + for (var i = 0; i < toolNumArray.length; i++){ + toolNumArray[i] = toolNumArray[i].trim(); + + if (toolNumArray[i].indexOf("-") >= 0) { + let numRange = toolNumArray[i].split("-"); + if (validateToolNum(parseInt(numRange[0])) || validateToolNum(parseInt(numRange[1]))) { + defaultFill(); + break; + } + for(var j = numRange[0]; j <= numRange[1]; j++){ + parsedTools.push(parseInt(j)); + } + continue; + } + if (validateToolNum(parseInt(toolNumArray[i]))) { + defaultFill(); + break; + } + parsedTools.push(parseInt(toolNumArray[i])); + } + } else { + defaultFill(); + } + + + writeln(parsedTools); + + for (var i = 0; i < tools.getNumberOfTools(); 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 (staticProperties.measureToolsAtStart && (tool.type == TOOL_PROBE)) { + if (parsedTools.indexOf(tool.number) <= -1) { continue; } + if (getProperty("measureToolsAtStart") && (tool.type == TOOL_PROBE)) { + continue; + } + + // 07/16/21 | will1742 | Gavin Williams + // Verify tool numbers + if (tool.number == 20 && tool.type != TOOL_PROBE) { + throw "Error: T20 is reserved for Probe"; + } + + if (tool.number == 19) { + throw "Error: T19 is reserved for WCS verification tool"; + } + + writeln(""); var comment = "T" + toolFormat.format(tool.number) + " " + "D=" + xyzFormat.format(tool.diameter) + " " + localize("CR") + "=" + xyzFormat.format(tool.cornerRadius); @@ -1312,7 +1396,7 @@ function onOpen() { comment += " - " + getToolTypeName(tool.type); writeComment(tool.description); writeComment(comment); - if (staticProperties.measureToolsAtStart) { + if (getProperty("measureToolsAtStart")) { displayMedia("Net Share/Media/toolLoad" + tool.number + ".jpg"); writeBlock(mFormat.format(0), formatComment("Load Tool")); //Pause until operator loads tool writeToolMeasureBlock(tool, true); @@ -1321,8 +1405,8 @@ function onOpen() { } } } - writeBlock(mFormat.format(131)); writeln(""); + writeBlock(mFormat.format(131)); } if (staticProperties.useDWO) { @@ -2306,7 +2390,7 @@ function onSection() { if (operationNeedsSafeStart) { if (!retracted) { - skipBlock = true; + // skipBlock = true; writeRetract(Z); } } @@ -2389,7 +2473,7 @@ function onSection() { if (spindleSpeed > maximumSpindleRPM) { warning(subst(localize("Spindle speed '" + spindleSpeed + " RPM' exceeds maximum value of '%1 RPM."), maximumSpindleRPM)); } - skipBlock = !spindleChanged; + // skipBlock = !spindleChanged; writeBlock( sOutput.format(spindleSpeed), mFormat.format(tool.clockwise ? 3 : 4) ); @@ -2630,7 +2714,7 @@ function onSection() { var toolDistance = initialPosition.z - stockTopZ; // Prompt user to check stock-tool distance - displayMedia("Net Share/Media/checkDistance" + toolDistance.toPrecision(2) + ".jpg"); + displayMedia("Net Share/Media/checkDistance" + toolDistance.toPrecision(2).toString().replace(".", "_") + ".jpg"); writeBlock(mFormat.format(0), formatComment("Open door")); //displayMedia("Net Share/Media/checkPrompt.jpg"); writeWords(mFormat.format(131), formatComment("End Multimedia")); @@ -2639,14 +2723,16 @@ function onSection() { //var gotoRef = takeInput(("Is the tool " + toolDistance.toPrecision(3) + "in from the stock? [Y/N]"), ['N', 'Y']); // Create GOTO cases for Y/N selection, halt if N - //getTA("Net Share/Media/TAWarning.jpg", gotoRef['N'], onSecGotoRef); - //writeWords("N" + nFormat.format(gotoRef['Y']), mFormat.format(131), formatComment("End Multimedia")); - /*writeWords( + /* + getTA("Net Share/Media/TAWarning.jpg", gotoRef['N'], onSecGotoRef); + writeWords("N" + nFormat.format(gotoRef['Y']), mFormat.format(131), formatComment("End Multimedia")); + writeWords( conditional(!currentSection.isMultiAxis() || !tcpIsSupported, gFormat.format(43)), conditional(currentSection.isMultiAxis() && tcpIsSupported, gFormat.format(234)), zOutput.format(initialPosition.z), hFormat.format(lengthOffset) - );*/ + ); + */ writeComment("END VALIDATION SECTION"); // initialize spindle and engage coolant if heights are correct @@ -3948,7 +4034,7 @@ function getCoolantCodes(coolant) { } if (coolant == currentCoolantMode) { if (operationNeedsSafeStart && coolant != COOLANT_OFF && !isSpecialCoolantActive) { - isOptionalCoolant = true; + //isOptionalCoolant = true; } else if (!forceCoolant || coolant == COOLANT_OFF) { return undefined; // coolant is already active }