Skip to content

Commit

Permalink
Added new ProbingType function
Browse files Browse the repository at this point in the history
  • Loading branch information
will1742 committed Jun 25, 2021
1 parent 65bfee7 commit 16e88e9
Showing 1 changed file with 92 additions and 14 deletions.
106 changes: 92 additions & 14 deletions Haas_Next_Generation/haas vf2.cps
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,22 @@ staticProperties = {
singleResultsFile: true
};

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 NO_PROBING = 0;
const LEN_ROT = 1;
const LEN_NON_ROT = 2;
const LEN_DIA_ROT = 3;

const DEFAULT_HAAS_K_FACTOR = 0.05;
const NULL_HAAS_K_FACTOR = 0;

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}
Expand Down Expand Up @@ -634,6 +650,8 @@ function writeComment(text) {
/**
Returns the matching HAAS tool type for the tool.
*/

// TODO FIX TOOL TYPE
function getHaasToolType(toolType) {
switch (toolType) {
case TOOL_DRILL:
Expand Down Expand Up @@ -710,7 +728,7 @@ function getHaasProbingType(tool, use9023) {
};*/

function getHaasProbingType(toolType, use9023) {
switch (getHaasToolType(toolType)) {
switch (getHaasToolType(toolType.type)) {
case 3:
case 4:
return (use9023 ? 23 : 1); // rotate
Expand All @@ -732,42 +750,102 @@ function getHaasToolTypeBIDC(toolType) {
switch (toolType) {
case TOOL_DRILL:
case TOOL_REAMER:
return 1; // drill
return HAAS_DRILL; // drill
case TOOL_TAP_RIGHT_HAND:
case TOOL_TAP_LEFT_HAND:
return 2; // tap
return HAAS_TAP; // tap
case TOOL_MILLING_FACE:
case TOOL_MILLING_SLOT:
case TOOL_BORING_BAR:
return 3; // shell mill
return HAAS_SHELL; // shell mill
case TOOL_MILLING_END_FLAT:
case TOOL_MILLING_END_BULLNOSE:
case TOOL_MILLING_TAPERED:
case TOOL_MILLING_DOVETAIL:
return 4; // end mill
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:
case TOOL_MILLING_THREAD:
case TOOL_MILLING_FORM:
return 5; // center drill
return HAAS_CENTER; // center drill
case TOOL_MILLING_END_BALL:
case TOOL_MILLING_LOLLIPOP:
case TOOL_MILLING_RADIUS:
return 6; // ball nose
return HAAS_BALL_NOSE; // ball nose
case TOOL_PROBE:
return 7; // probe
return HAAS_PROBE; // probe
default:
error(localize("Invalid HAAS tool type."));
return -1;
}
}

function getHaasProbingTypeBIDC(toolType) {
//TODO
return -1;
// 06/25/21 | Gavin Williams | will1742
// 002 Probing
function formatCNumber(probeType, use9023){
if (use9023) {
if (probeType == LEN_NON_ROT || probeType == LEN_DIA_ROT){
return probeType + 10;
}
return 23;
}
return probeType;
}

function getHaasProbingTypeBIDC(tool, use9023) {
switch (getHaasToolTypeBIDC(tool.type)) {
case HAAS_PROBE:
return formatCNumber(NO_PROBING, use9023);
case HAAS_TAP:
case HAAS_DRILL:
return formatCNumber(LEN_NON_ROT, use9023);
case HAAS_CENTER:
if (tool.type == TOOL_MILLING_THREAD) {
return formatCNumber(LEN_DIA_ROT, use9023);
}
if (tool.type == TOOL_MILLING_FORM) {
return formatCNumber(NO_PROBING, use9023);
}
formatCNumber(LEN_NON_ROT, use9023);
case HAAS_END_MILL:
return formatCNumber((tool.type == TOOL_MILLING_TAPERED ? LEN_ROT : LEN_DIA_ROT), use9023);
case HAAS_BALL_NOSE:
return formatCNumber((tool.type == TOOL_MILLING_RADIUS ? LEN_ROT : LEN_DIA_ROT), use9023);
case HAAS_SHELL:
if ((tool.type == TOOL_MILLING_FACE) && (tool.taperAngle !=0)) {
return formatCNumber(LEN_ROT, use9023);
}
return formatCNumber(LEN_DIA_ROT, use9023);
default:
return -1;
}
}

function getHaasKFactorBIDC(tool) {
switch (getHaasToolTypeBIDC(tool.type)) {
case HAAS_SHELL:
case HAAS_END_MILL:
// TODO: Add cases
return DEFAULT_HAAS_K_FACTOR;
case HAAS_BALL_NOSE:
if (tool.type == TOOL_MILLING_RADIUS) {
return NULL_HAAS_K_FACTOR;
}
return tool.diameter + DEFAULT_HAAS_K_FACTOR;
case HAAS_CENTER:
case HAAS_PROBE:
case HAAS_DRILL:
case HAAS_TAP:
if (tool.type == TOOL_MILLING_THREAD) {
return tool.getThreadPitch() + DEFAULT_HAAS_K_FACTOR;
}
return NULL_HAAS_K_FACTOR;
default:
return -1;
}
}

function writeToolCycleBlock(tool) {
Expand Down Expand Up @@ -815,12 +893,12 @@ function writeToolMeasureBlock(tool, preMeasure) {
gFormat.format(65),
"P9995",
"A0.",
"B" + getHaasToolType(tool.type) + ".",
"C" + getHaasProbingType(tool, false) + ".",
"B" + getHaasToolTypeBIDC(tool.type) + ".",
"C" + getHaasProbingTypeBIDC(tool, false) + ".",
"T" + toolFormat.format(tool.number),
"E" + xyzFormat.format(tool.bodyLength + tool.holderLength),
"D" + xyzFormat.format(tool.diameter),
"K" + xyzFormat.format(0.1),
"K" + xyzFormat.format(getHaasKFactorBIDC(tool)),
"I0.",
comment
); // probe tool
Expand Down

0 comments on commit 16e88e9

Please sign in to comment.