From 831e7b6967932dc7027a5fe287b1a17919a725bf Mon Sep 17 00:00:00 2001 From: "Williams, Gavin J" Date: Tue, 10 Aug 2021 15:45:38 -0400 Subject: [PATCH] Added Lathe Probe Mappings --- .gitignore | 3 +- Haas_Lathes_BIDC/haas st-20.cps | 250 +++++++++++++++++++++++++++++++- Haas_Mills_BIDC/Bechtel VF4.cps | 6 +- 3 files changed, 249 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 6bf6f62..7ac6952 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ Haas_Next_Generation/Bechtel VF2HP.cps *.nc .vscode/ -*.dmp \ No newline at end of file +*.dmp +*.failed \ No newline at end of file diff --git a/Haas_Lathes_BIDC/haas st-20.cps b/Haas_Lathes_BIDC/haas st-20.cps index cbf7c2e..0f35c43 100644 --- a/Haas_Lathes_BIDC/haas st-20.cps +++ b/Haas_Lathes_BIDC/haas st-20.cps @@ -76,7 +76,7 @@ properties = { description: "Output a tool list in the header of the code.", group: 0, type: "boolean", - value: false, + value: true, scope: "post" }, writeVersion: { @@ -84,7 +84,7 @@ properties = { description: "Write the version number in the header of the code.", group: 0, type: "boolean", - value: false, + value: true, scope: "post" }, showSequenceNumbers: { @@ -157,7 +157,7 @@ properties = { title: "Show notes", description: "Writes operation notes as comments in the outputted code.", type: "boolean", - value: false, + value: true, scope: "post" }, useCycles: { @@ -334,7 +334,7 @@ properties = { title: "Safe start all operations", description: "Write optional blocks at the beginning of all operations that include all commands to start program.", type: "boolean", - value: false, + value: true, scope: "post" }, useYAxisForDrilling: { @@ -353,6 +353,10 @@ properties = { } }; +staticProperties = { + postVersion: "VF4G8A21" +}; + var permittedCommentChars = " ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,=_-"; var gFormat = createFormat({prefix:"G", decimals:0}); @@ -461,6 +465,129 @@ var machineState = { stockTransferIsActive: false }; +const HAAS_DRILL = 1; +const HAAS_TAP = 2; +const HAAS_SHELL = 3; +const HAAS_END_MILL = 4; +const HAAS_CENTER = 5; +const HAAS_BALL_NOSE = 6; +const HAAS_PROBE = 7; +const BIDC_GEN_TURNING = 8; +const BIDC_BORING_TURNING = 9; +const BIDC_CUST_TURNING = 10; + +const SOUTHWEST = 1; +const SOUTHEAST = 2; +const NORTHEAST = 3; +const NORTHWEST = 4; +const WEST = 5; +const SOUTH = 6 +const EAST = 7; +const NORTH = 8; + +const WHOLD = { + name: "Wedge Holder", + x: -24.8257, + z: -13.7333, + sOffset: 0.0 +}; + +const SRBLOCK = { + name: "Small Round Block", + x: -15.5690, + z: -12.4896, + sOffset: 0.5 +} + +const LRBLOCK = { + name: "Large Round Block", + x: -15.5690, + z: -12.4896, + sOffset: 0.74 +} + +function getCompleteTool(holder, tool) { + var toolSection; + for (i = 0; i < getNumberOfSections(); i++) { + toolSection = getSection(i); + if (toolSection.getTool().number == tool.number) { + break; + } + } + this.holder = holder; + this.tool = tool; + this.inner = toolSection.getParameter("operation:turningMode") == "inner"; + this.axial = toolSection.getWorkPlane().getElement(0, 0) == 0; + + tool.shankWidth = toolSection.getParameter("operation:tool_shankWidth"); + tool.cuttingWidth = toolSection.getParameter("operation:tool_cuttingWidth"); + tool.holderOverallLength = toolSection.getParameter("operation:tool_holderOverallLength"); + + if (holder == WHOLD) { + switch (tool.type) { + case TOOL_TURNING_GROOVING: + this.offsetType = "Grooving"; + this.x = function() { + return holder.x + tool.holderOverallLength*2; + }; + this.z = function() { + return holder.z + tool.shankWidth; + }; + break; + + default: + this.offsetType = "General Turning"; + this.x = function() { + return holder.x + tool.holderOverallLength*2; + }; + this.z = function() { + return holder.z + (tool.cuttingWidth + tool.shankWidth)*.5; + }; + } + } else { + switch (tool.type) { + case HAAS_DRILL: + if (tool.numberOfFlutes != 1) { + this.offsetType = "General Drilling"; + this.x = function() { + return holder.x; + }; + this.z = function() { + return holder.z + (tool.getBodyLength() + tool.getHolderLength()); + }; + break; + } + this.offsetType = "Indexible Drilling"; + this.x = function() { + return holder.x + tool.diameter*.15; + }; + this.z = function() { + return holder.z + (tool.getBodyLength() + tool.getHolderLength()); + }; + break; + + case TOOL_TURNING_THREADING: + this.offsetType = "Threading"; + this.x = function() { + return holder.x + (tool.cuttingWidth - tool.shankWidth*.5); + }; + this.z = function() { + return holder.z + (tool.holderOverallLength + holder.sOffset); + }; + break; + + default: + this.offsetType = "General Turning" + this.x = function() { + return holder.x + tool.cuttingWidth*2; + }; + this.z = function() { + return holder.z + (tool.holderOverallLength + holder.sOffset); + }; + } + } +} + /** G/M codes setup */ function getCode(code) { switch (code) { @@ -926,6 +1053,93 @@ function getB(abc, section) { var machineConfigurationMainSpindle; var machineConfigurationSubSpindle; +function getHaasToolTypeBIDC(toolType) { + switch (toolType) { + case TOOL_DRILL: + return HAAS_DRILL; // drill + case TOOL_MILLING_END_FLAT: + case TOOL_MILLING_END_BULLNOSE: + case TOOL_MILLING_TAPERED: + return HAAS_END_MILL; // end mill + case TOOL_DRILL_SPOT: + case TOOL_MILLING_CHAMFER: + case TOOL_DRILL_CENTER: + case TOOL_COUNTER_SINK: + case TOOL_COUNTER_BORE: + return HAAS_CENTER; // center drill + case TOOL_MILLING_END_BALL: + return HAAS_BALL_NOSE; // ball nose + case TOOL_PROBE: + return HAAS_PROBE; // probe + case TOOL_TURNING_GENERAL: + case TOOL_TURNING_THREADING: + case TOOL_TURNING_GROOVING: + return BIDC_GEN_TURNING; + case TOOL_TURNING_BORING: + return BIDC_BORING_TURNING; + case TOOL_TURNING_CUSTOM: + return BIDC_CUST_TURNING; + default: + error(localize("Invalid HAAS tool type.")); + return -1; + } +} + +function getToolHolderBIDCST20(toolNum) { + switch (toolNum) { + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + return WHOLD; + case 9: + case 12: + return SRBLOCK; + case 10: + case 11: + return LRBLOCK; + default: + throw "INVALID ST20 TOOL NUMBER. RANGE 1-12" + } +} + +function getHaasProbingTypeBIDC(tool, internal, axial) { + switch (getHaasToolTypeBIDC(tool.type)) { + case BIDC_BORING_TURNING: + case BIDC_GEN_TURNING: + if (internal) { + return SOUTHEAST; + } + return tool.hand =='R' ? NORTHEAST : NORTHWEST; + case HAAS_DRILL: + case HAAS_END_MILL: + return axial ? EAST : NORTH; + default: + throw "INVALID PROBING DIRECTION"; + } +} + +function writeToolMeasureBlockBIDC(tool) { + var holder = getToolHolderBIDCST20(tool.number); + + + let measureTool = new getCompleteTool(holder, tool); + var probeType = getHaasProbingTypeBIDC(tool, measureTool.inner, measureTool.axial); + + writeln("DESC: " + tool.description); + writeln("HOLDER: " + holder.name); + writeln("OFFSET: " + measureTool.offsetType); + writeln("TOOL TYPE: " + getToolTypeName(tool.type)); + writeln("Probe Type: " + probeType); + writeln("X:" + measureTool.x()); + writeln("Z:" + measureTool.z()); + writeln(""); +} + function onOpen() { if (getProperty("useRadius")) { maximumCircularSweep = toRad(90); // avoid potential center calculation errors for CNC @@ -961,6 +1175,7 @@ function onOpen() { bOutput.disable(); } + if (highFeedrate <= 0) { error(localize("You must set 'highFeedrate' because axes are not synchronized for rapid traversal.")); return; @@ -996,15 +1211,25 @@ function onOpen() { return; } + writeComment("Career Account Username: " + getGlobalParameter("username")); + writeComment("Filename: " + getGlobalParameter("document-path")); + writeComment("Date: " + getGlobalParameter("generated-at")); + writeComment("Post Version: " + staticProperties.postVersion); + + // will1742 + // TODO: Alter versions and headers if (getProperty("writeVersion")) { if ((typeof getHeaderVersion == "function") && getHeaderVersion()) { - writeComment(localize("post version") + ": " + getHeaderVersion()); + writeComment(localize("Post Version") + ": " + getHeaderVersion()); } if ((typeof getHeaderDate == "function") && getHeaderDate()) { - writeComment(localize("post modified") + ": " + getHeaderDate()); + writeComment(localize("Post Modified") + ": " + getHeaderDate()); } } + + + // dump machine configuration var vendor = machineConfiguration.getVendor(); var model = machineConfiguration.getModel(); @@ -1053,6 +1278,19 @@ function onOpen() { " - " + localize(getToolTypeName(tool.type)); writeComment(comment); } + writeln(""); + } + + // will1742 | Gavin Williams | 8/10/21 + // Auto probe tools + if (tools.getNumberOfTools() > 0) { + for (var i = 0; i < tools.getNumberOfTools(); ++i) { + var tool = tools.getTool(i); + var compensationOffset = tool.isTurningTool() ? tool.compensationOffset : tool.lengthOffset; + var toolPosition = toolFormat.format(tool.number * 100 + compensationOffset % 100); + writeToolMeasureBlockBIDC(tool); + } + writeln(""); } } diff --git a/Haas_Mills_BIDC/Bechtel VF4.cps b/Haas_Mills_BIDC/Bechtel VF4.cps index e041d89..20f8f61 100644 --- a/Haas_Mills_BIDC/Bechtel VF4.cps +++ b/Haas_Mills_BIDC/Bechtel VF4.cps @@ -2408,9 +2408,9 @@ function onSection() { writeln(""); } - // if (hasParameter("notes") && getParameter("notes").toUpperCase().indexOf("APPROVED") <= -1) { - // throw "Operation \"" + getParameter("operation-comment") + "\" not approved. See a Peer Mentor." - // } + if (hasParameter("notes") && getParameter("notes").toUpperCase().indexOf("APPROVED") <= -1) { + throw "Operation \"" + getParameter("operation-comment") + "\" not approved. See a Peer Mentor." + } if (staticProperties.showNotes) { var notes = getParameter("notes");