diff --git a/Haas_Lathes_BIDC/Bechtel ST-20.cps b/Haas_Lathes_BIDC/Bechtel ST-20.cps index 3ea940b..17b2596 100644 --- a/Haas_Lathes_BIDC/Bechtel ST-20.cps +++ b/Haas_Lathes_BIDC/Bechtel ST-20.cps @@ -10,7 +10,7 @@ FORKID {14D60AD3-4366-49dc-939C-4DB5EA48FF68} */ -description = "HAAS ST-20"; +description = "BIDC ST-20"; var gotYAxis = false; var yAxisMinimum = toPreciseUnit(gotYAxis ? -50.8 : 0, MM); // specifies the minimum range for the Y-axis @@ -354,7 +354,7 @@ properties = { }; staticProperties = { - postVersion: "VF4G8A21" + postVersion: "ST0G8A21" }; var permittedCommentChars = " ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,=_-"; @@ -425,7 +425,6 @@ var xOffset = createFormat({prefix:"X", decimals:(unit == MM ? 3 : 4), forceDeci var zOffset = createFormat({prefix:"Z", decimals:(unit == MM ? 3 : 4), forceDecimal:true}); // diameter mode & IS SCALING POLAR COORDINATES var rOffset = createFormat({prefix:"R", decimals:(unit == MM ? 3 : 4), forceDecimal:true}); // diameter mode & IS SCALING POLAR COORDINATES - // fixed settings var firstFeedParameter = 100; var usePolarCircular = false; @@ -1253,7 +1252,6 @@ function onOpen() { bOutput.disable(); } - if (highFeedrate <= 0) { error(localize("You must set 'highFeedrate' because axes are not synchronized for rapid traversal.")); return; @@ -1305,9 +1303,6 @@ function onOpen() { } } - - - // dump machine configuration var vendor = machineConfiguration.getVendor(); var model = machineConfiguration.getModel(); @@ -1341,28 +1336,12 @@ function onOpen() { zRanges[tool.number] = zRange; } } + writeln(""); } - var tools = getToolTable(); - // 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 comment = "T" + toolFormat.format(tool.number * 100 + compensationOffset % 100) + " " + - // (tool.diameter != 0 ? "D=" + spatialFormat.format(tool.diameter) + " " : "") + - // (tool.isTurningTool() ? localize("NR") + "=" + spatialFormat.format(tool.noseRadius) : localize("CR") + "=" + spatialFormat.format(tool.cornerRadius)) + - // (tool.taperAngle > 0 && (tool.taperAngle < Math.PI) ? " " + localize("TAPER") + "=" + taperFormat.format(tool.taperAngle) + localize("deg") : "") + - // (zRanges[tool.number] ? " - " + localize("ZMIN") + "=" + spatialFormat.format(zRanges[tool.number].getMinimum()) : "") + - // " - " + localize(getToolTypeName(tool.type)); - // writeComment(comment); - // } - // writeln(""); - // } - - writeln(""); - // will1742 | Gavin Williams | 8/10/21 // Auto probe tools + var tools = getToolTable(); if (tools.getNumberOfTools() > 0) { for (var i = 0; i < tools.getNumberOfTools(); ++i) { var tool = tools.getTool(i); diff --git a/Haas_Lathes_BIDC/haas st-20y.cps b/Haas_Lathes_BIDC/Bechtel ST-20Y.cps similarity index 94% rename from Haas_Lathes_BIDC/haas st-20y.cps rename to Haas_Lathes_BIDC/Bechtel ST-20Y.cps index 5b7ea3b..81d9ec0 100644 --- a/Haas_Lathes_BIDC/haas st-20y.cps +++ b/Haas_Lathes_BIDC/Bechtel ST-20Y.cps @@ -10,7 +10,7 @@ FORKID {14D60AD3-4366-49dc-939C-4DB5EA48FF68} */ -description = "HAAS ST-20Y"; +description = "BIDC ST-20Y"; var gotYAxis = true; var yAxisMinimum = toPreciseUnit(gotYAxis ? -50.8 : 0, MM); // specifies the minimum range for the Y-axis @@ -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: { @@ -92,7 +92,7 @@ properties = { description: "Use sequence numbers for each block of outputted code.", group: 1, type: "boolean", - value: false, + value: true, scope: "post" }, sequenceNumberStart: { @@ -108,7 +108,7 @@ properties = { description: "The amount by which the sequence number is incremented by in each block.", group: 1, type: "integer", - value: 1, + value: 5, scope: "post" }, optionalStop: { @@ -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: "STYG8A21" +}; + var permittedCommentChars = " ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,=_-"; var gFormat = createFormat({prefix:"G", decimals:0}); @@ -417,6 +421,10 @@ var cAxisBrakeModal = createModal({}, mFormat); var gExactStopModal = createModal({}, gFormat); // modal group for exact stop codes var tailStockModal = createModal({}, mFormat); +var xOffset = createFormat({prefix:"X", decimals:(unit == MM ? 3 : 4), forceDecimal:true}); // diameter mode & IS SCALING POLAR COORDINATES +var zOffset = createFormat({prefix:"Z", decimals:(unit == MM ? 3 : 4), forceDecimal:true}); // diameter mode & IS SCALING POLAR COORDINATES +var rOffset = createFormat({prefix:"R", decimals:(unit == MM ? 3 : 4), forceDecimal:true}); // diameter mode & IS SCALING POLAR COORDINATES + // fixed settings var firstFeedParameter = 100; var usePolarCircular = false; @@ -461,6 +469,175 @@ var machineState = { stockTransferIsActive: false }; +// will1742 | Gavin Williams | 8/20/21 +// Added constants and EQ's +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 PROBE_CENTERING_OFFSET = .375; // offet to center tool on probe + +const SOUTHWEST = { + num: 1, + name: "SOUTHWEST" +}; +const SOUTHEAST = { + num: 2, + name: "SOUTHEAST" +}; +const NORTHEAST = { + num: 3, + name: "NORTHEAST" +}; +const NORTHWEST = { + num: 4, + name: "NORTHWEST" +}; +const WEST = { + num: 5, + name: "WEST" +}; +const SOUTH = { + num: 6, + name: "SOUTH" +}; +const EAST = { + num: 7, + name: "EAST" +}; +const NORTH = { + num: 8, + name: "NORTH" +}; + +const WHOLD = { + name: "Wedge Holder", + x: -24.8094, + z: -13.2233, + 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"); + tool.threadPitch = toolSection.getParameter("operation:tool_threadPitch") + + if (holder == WHOLD) { + switch (tool.type) { + case TOOL_TURNING_GROOVING: + this.offsetType = "Grooving"; + this.probeX = function() { + return holder.x + (tool.holderOverallLength*2); + }; + this.probeZ = function() { + return holder.z + (tool.shankWidth*.5); + }; + + return; + default: + this.offsetType = "General Turning"; + this.probeX = function() { + return holder.x + (tool.holderOverallLength*2); + }; + if (tool.hand == 'L') { + this.probeZ = function() { + return holder.z - tool.cuttingWidth + (tool.shankWidth*.5); + }; + } else { + this.probeZ = function() { + return holder.z + tool.cuttingWidth - (tool.shankWidth*.5); + }; + } + } + } else { + switch (tool.type) { + case TOOL_DRILL: + case TOOL_DRILL_CENTER: + case TOOL_DRILL_SPOT: + case TOOL_COUNTER_BORE: + case TOOL_COUNTER_SINK: + case TOOL_MILLING_CHAMFER: + if (tool.numberOfFlutes != 1) { + this.offsetType = "General Drilling"; + this.probeX = function() { + return holder.x - PROBE_CENTERING_OFFSET; + }; + this.machineX = function() { + return holder.x; + } + this.probeZ = function() { + return holder.z + (tool.getBodyLength() + tool.getHolderLength()); + }; + return; + } + this.offsetType = "Indexible Drill"; + this.probeX = function() { + return holder.x + tool.diameter*.3 - PROBE_CENTERING_OFFSET; + }; + this.machineX = function() { + return holder.x; + }; + this.probeZ = function() { + return holder.z + (tool.getBodyLength() + tool.getHolderLength() + holder.sOffset); + }; + return; + + case TOOL_TURNING_THREADING: + this.offsetType = "Threading"; + this.probeX = function() { + return holder.x - (2*(tool.cuttingWidth) - tool.shankWidth); + }; + this.probeZ = function() { + return holder.z + tool.holderOverallLength + holder.sOffset; + }; + return; + + default: + this.offsetType = "General Turning" + this.probeX = function() { + return holder.x - (tool.cuttingWidth*2); + }; + this.probeZ = function() { + return holder.z + tool.holderOverallLength + holder.sOffset; + }; + } + } +} + /** G/M codes setup */ function getCode(code) { switch (code) { @@ -908,11 +1085,22 @@ function formatComment(text) { return "(" + String(text).replace(/[()]/g, "") + ")"; } + +// will1742 | Gavin Williams | 8/20/21 +// Added support for comments over max length /** Output a comment. */ function writeComment(text) { - writeln(formatComment(text)); + if (text.length > 80) { + var i = 0; + text = text.match(/.{1,80}/g); + while (text[i] != null) { + writeln(formatComment(text[i++])); + } + } else { + writeln(formatComment(text)); + } } function getB(abc, section) { @@ -926,6 +1114,112 @@ 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) { + switch (getHaasToolTypeBIDC(tool.type)) { + case BIDC_BORING_TURNING: + return SOUTHEAST; + case BIDC_GEN_TURNING: + if (tool.type == TOOL_TURNING_THREADING || tool.type == TOOL_TURNING_GROOVING) { + return internal ? SOUTHEAST : NORTHEAST; + } + return tool.hand =='R' ? NORTHEAST : NORTHWEST; + case HAAS_DRILL: + case HAAS_CENTER: + return EAST; + 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); + var compensationOffset = tool.isTurningTool() ? tool.compensationOffset : tool.lengthOffset; + if (compensationOffset > 99) { + error(localize("Compensation offset is out of range.")); + return; + } + + writeBlock(gFormat.format(10), "L10 P" + tool.number, xOffset.format(measureTool.probeX())); + writeBlock(gFormat.format(10), "L10 P" + tool.number, zOffset.format(measureTool.probeZ())); + if(tool.noseRadius != 0 || tool.cornerRadius != 0) { + writeBlock(gFormat.format(10), "L10 P" + tool.number, rOffset.format(tool.cornerRadius != 0 ? tool.cornerRadius : tool.noseRadius)); + } + + if (tool.type == TOOL_TURNING_THREADING) { + writeBlock(gFormat.format(10), "L10 P" + tool.number, rOffset.format(tool.threadPitch*2)); + } + + writeBlock("T" + toolFormat.format(tool.number * 100 + compensationOffset % 100)); + writeComment("PROBE: " + measureTool.offsetType + ", " + probeType.name); + writeBlock(mFormat.format(104)); + writeBlock(gFormat.format(212), "H" + probeType.num); + writeBlock(mFormat.format(105)); + if (tool.type == TOOL_TURNING_THREADING) { + writeBlock(gFormat.format(10), "L10 P" + tool.number, rOffset.format(0)); + } + if (measureTool.offsetType == "Indexible Drill") { + writeBlock(gFormat.format(10), "L10 P" + tool.number, xOffset.format(measureTool.machineX())); + } + writeln(""); +} + function onOpen() { if (getProperty("useRadius")) { maximumCircularSweep = toRad(90); // avoid potential center calculation errors for CNC @@ -996,12 +1290,20 @@ function onOpen() { return; } + // will1742 | Gavin Williams | 8/20/21 + 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()); } } @@ -1038,20 +1340,21 @@ function onOpen() { zRanges[tool.number] = zRange; } } + writeln(""); } + // will1742 | Gavin Williams | 8/20/21 + // Auto probe tools var tools = getToolTable(); 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 comment = "T" + toolFormat.format(tool.number * 100 + compensationOffset % 100) + " " + - (tool.diameter != 0 ? "D=" + spatialFormat.format(tool.diameter) + " " : "") + - (tool.isTurningTool() ? localize("NR") + "=" + spatialFormat.format(tool.noseRadius) : localize("CR") + "=" + spatialFormat.format(tool.cornerRadius)) + - (tool.taperAngle > 0 && (tool.taperAngle < Math.PI) ? " " + localize("TAPER") + "=" + taperFormat.format(tool.taperAngle) + localize("deg") : "") + - (zRanges[tool.number] ? " - " + localize("ZMIN") + "=" + spatialFormat.format(zRanges[tool.number].getMinimum()) : "") + - " - " + localize(getToolTypeName(tool.type)); - writeComment(comment); + var toolPosition = toolFormat.format(tool.number * 100 + compensationOffset % 100); + writeBlock("T" + toolFormat.format((tool.number - 3) >= 1 ? tool.number - 3 : tool.number + 9), mFormat.format(6)); + writeBlock(mFormat.format(0)); + writeComment("LOAD T" + tool.number + ": " + tool.description); + writeToolMeasureBlockBIDC(tool); } } }