diff --git a/Haas_Lathes_BIDC/haas st-20.cps b/Haas_Lathes_BIDC/haas st-20.cps index 0f35c43..3245b92 100644 --- a/Haas_Lathes_BIDC/haas st-20.cps +++ b/Haas_Lathes_BIDC/haas st-20.cps @@ -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: true, + value: false, scope: "post" }, useCycles: { @@ -421,6 +421,11 @@ 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; @@ -476,14 +481,38 @@ 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 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", @@ -559,10 +588,10 @@ function getCompleteTool(holder, tool) { } this.offsetType = "Indexible Drilling"; this.x = function() { - return holder.x + tool.diameter*.15; + return holder.x + tool.diameter*.3; }; this.z = function() { - return holder.z + (tool.getBodyLength() + tool.getHolderLength()); + return holder.z + (tool.getBodyLength() + tool.getHolderLength() + holder.sOffset); }; break; @@ -579,7 +608,7 @@ function getCompleteTool(holder, tool) { default: this.offsetType = "General Turning" this.x = function() { - return holder.x + tool.cuttingWidth*2; + return holder.x - tool.cuttingWidth*2; }; this.z = function() { return holder.z + (tool.holderOverallLength + holder.sOffset); @@ -1126,17 +1155,25 @@ function getHaasProbingTypeBIDC(tool, internal, axial) { function writeToolMeasureBlockBIDC(tool) { var holder = getToolHolderBIDCST20(tool.number); - let measureTool = new getCompleteTool(holder, tool); var probeType = getHaasProbingTypeBIDC(tool, measureTool.inner, measureTool.axial); + 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.x())); + writeBlock(gFormat.format(10), "L10 P" + tool.number, zOffset.format(measureTool.z())); + if(tool.noseRadius != 0 || tool.cornerRadius != 0) { + writeBlock(gFormat.format(10), "L10 P" + tool.number, rOffset.format(tool.cornerRadius != 0 ? tool.cornerRadius : tool.noseRadius)); + } - 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()); + 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)); writeln(""); } @@ -1266,20 +1303,22 @@ function onOpen() { } 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(""); - } + // 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 @@ -1288,9 +1327,12 @@ function onOpen() { var tool = tools.getTool(i); var compensationOffset = tool.isTurningTool() ? tool.compensationOffset : tool.lengthOffset; var toolPosition = toolFormat.format(tool.number * 100 + compensationOffset % 100); + writeComment(tool.description); + writeBlock("T" + toolFormat.format((tool.number - 3) >= 1 ? tool.number - 3 : tool.number + 9), mFormat.format(6)); + writeBlock(mFormat.format(0)); + writeComment("LOAD TOOL " + tool.number); writeToolMeasureBlockBIDC(tool); } - writeln(""); } }