Skip to content

Commit

Permalink
Added Lathe Probe Mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
will1742 committed Aug 10, 2021
1 parent 3e6d58d commit 831e7b6
Show file tree
Hide file tree
Showing 3 changed files with 249 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Haas_Next_Generation/Bechtel VF2HP.cps
*.nc
.vscode/
*.dmp
*.dmp
*.failed
250 changes: 244 additions & 6 deletions Haas_Lathes_BIDC/haas st-20.cps
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ properties = {
description: "Output a tool list in the header of the code.",
group: 0,
type: "boolean",
value: false,
value: true,
scope: "post"
},
writeVersion: {
title: "Write version",
description: "Write the version number in the header of the code.",
group: 0,
type: "boolean",
value: false,
value: true,
scope: "post"
},
showSequenceNumbers: {
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -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: {
Expand All @@ -353,6 +353,10 @@ properties = {
}
};

staticProperties = {
postVersion: "VF4G8A21"
};

var permittedCommentChars = " ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,=_-";

var gFormat = createFormat({prefix:"G", decimals:0});
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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("");
}
}

Expand Down
6 changes: 3 additions & 3 deletions Haas_Mills_BIDC/Bechtel VF4.cps
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 831e7b6

Please sign in to comment.