Skip to content

002 improved probing #6

Merged
merged 11 commits into from
Jul 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Haas_Next_Generation/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Changelog
06/14/21 Added media and QA
06/15/21 Check tool distance from stock, finalized QA
06/21/21 Tool probing required, tool probing now uses P9995
06/28/21 Tool specific probing added, with cases for type of probing and k factor

Function List:

Expand All @@ -25,10 +26,15 @@ takeInput(prompt, options)

any number of options can be input, sequenceNumbers will be adjusted to compensate

setMacro(macro, value, comment)
sets specified macro, adds inline comment


General notes:

- staticProperties is a dictionary containing all properties previously allowed to be altered by the user.
Any property which should be alterable by users should be uncommented from the properties dictionary and removed from staticProperties.

- Some optional portions were commented out, specifically those associated with safe start.

- Macro references can be found on page 189 of the milling manual
233 changes: 224 additions & 9 deletions Haas_Next_Generation/haas vf2.cps
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
$Date: 2021-06-01 08:35:38 $

FORKID {DBD402DA-DE90-4634-A6A3-0AE5CC97DEC7}

Modified by BIDC of Purdue University
Authors: Gavin Williams (will1742@purdue.edu)
*/

// >>>>> INCLUDED FROM ../../../haas next generation.cps
Expand Down Expand Up @@ -411,7 +414,7 @@ staticProperties = {
useDWO: true,
safeStartAllOperations: true,
preloadTool: true,
chipTransport: true,
chipTransport: false,
optionalStop: true,
separateWordsWithSpace: true,
useRadius: false,
Expand All @@ -438,9 +441,26 @@ staticProperties = {
useM130PartImages: false,
useM130ToolImages: false,
coolantPressure: "",
singleResultsFile: true
singleResultsFile: true,
pencilWCSVerif: 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 @@ -631,6 +651,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 @@ -667,8 +689,47 @@ function getHaasToolType(toolType) {
}
}

// 06/24/21 | Gavin Williams | will1742
// 002 Improved Probing
// Added case for shell mills
// Added improved 9023 compatibility
/*
function getHaasProbingType(tool, use9023) {
var probeType;
switch (getHaasToolType(tool.type)) {
case 3:
probeType = ((tool.taperAngle > 0) ? 1 : 3);
break;
case 4:
probeType = 1; // rotate
break;
case 1:
case 2:
case 5:
case 6:
case 7:
probeType = 2; // non rotate
break;
case 0:
probeType = 3; // rotate length and dia
break;
default:
error(localize("Invalid HAAS tool type."));
return -1;
}

if (use9023) {
if (probeType == 2 || probeType == 3){
return probeType + 10;
}
return 23;
}

return probeType;
};*/

function getHaasProbingType(toolType, use9023) {
switch (getHaasToolType(toolType)) {
switch (getHaasToolType(toolType.type)) {
case 3:
case 4:
return (use9023 ? 23 : 1); // rotate
Expand All @@ -686,6 +747,111 @@ function getHaasProbingType(toolType, use9023) {
}
}

function getHaasToolTypeBIDC(toolType) {
switch (toolType) {
case TOOL_DRILL:
case TOOL_REAMER:
return HAAS_DRILL; // drill
case TOOL_TAP_RIGHT_HAND:
case TOOL_TAP_LEFT_HAND:
return HAAS_TAP; // tap
case TOOL_MILLING_FACE:
case TOOL_MILLING_SLOT:
case TOOL_BORING_BAR:
return HAAS_SHELL; // shell mill
case TOOL_MILLING_END_FLAT:
case TOOL_MILLING_END_BULLNOSE:
case TOOL_MILLING_TAPERED:
case TOOL_MILLING_DOVETAIL:
case TOOL_MILLING_THREAD:
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_FORM:
return HAAS_CENTER; // center drill
case TOOL_MILLING_END_BALL:
case TOOL_MILLING_LOLLIPOP:
case TOOL_MILLING_RADIUS:
return HAAS_BALL_NOSE; // ball nose
case TOOL_PROBE:
return HAAS_PROBE; // probe
default:
error(localize("Invalid HAAS tool type."));
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_FORM) {
return formatCNumber(NO_PROBING, use9023);
}
return 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:
if (tool.type == TOOL_BORING_BAR || tool.type == TOOL_MILLING_END_FLAT) {
return DEFAULT_HAAS_K_FACTOR;
}
if (tool.type == TOOL_MILLING_FACE && tool.taperAngle != 0) {
return NULL_HAAS_K_FACTOR;
}
if (tool.type == TOOL_MILLING_THREAD) {
return DEFAULT_HAAS_K_FACTOR + tool.getThreadPitch();
}
return DEFAULT_HAAS_K_FACTOR + tool.cornerRadius;
case HAAS_BALL_NOSE:
if (tool.type == TOOL_MILLING_RADIUS) {
return NULL_HAAS_K_FACTOR;
}
return DEFAULT_HAAS_K_FACTOR + (tool.diameter/2);
case HAAS_CENTER:
case HAAS_PROBE:
case HAAS_DRILL:
case HAAS_TAP:

return NULL_HAAS_K_FACTOR;
default:
return -1;
}
}

function writeToolCycleBlock(tool) {
writeOptionalBlock("T" + toolFormat.format(tool.number), mFormat.format(6)); // get tool
writeOptionalBlock(mFormat.format(0)); // wait for operator
Expand All @@ -710,7 +876,6 @@ function writeToolMeasureBlock(tool, preMeasure) {
// var writeFunction = measureTool ? writeBlock : writeOptionalBlock;
var writeFunction = writeBlock;
var comment = measureTool ? formatComment("MEASURE TOOL") : "";
if (!preMeasure) {
prepareForToolCheck();
}
Expand All @@ -727,23 +892,32 @@ function writeToolMeasureBlock(tool, preMeasure) {
);
} else { // use Macro P9995 to measure tools
// writeFunction("T" + toolFormat.format(tool.number), mFormat.format(6)); // get tool
// TODO: fix tool type
setMacro(1600 + tool.number, tool.numberOfFlutes, "Number of Flutes");
writeFunction(
gFormat.format(65),
"P9995",
"A0.",
"B" + getHaasToolType(tool.type) + ".",
"C" + getHaasProbingType(tool.type, 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
}
measureTool = false;
}

// 6/28/21 | Gavin Williams | will1742
// 002 Improved Probing
// sets specified macro number with value
function setMacro(macro, value, comment) {
writeWords("#" + macro + "=" + value, "(" + comment + ")");
}

function defineMachineModel() {
var useTCPC = staticProperties.useTCPC;
switch (staticProperties.machineModel) {
Expand Down Expand Up @@ -1146,10 +1320,12 @@ function onOpen() {
}
comment += " - " + getToolTypeName(tool.type);
writeComment(comment);
writeComment(tool.description);
if (staticProperties.measureToolsAtStart) {
writeBlock("T" + toolFormat.format(tool.number), mFormat.format(6)); //Changes Tool
writeBlock(mFormat.format(0), formatComment("Load Tool")); //Pause until operator loads tool
writeToolMeasureBlock(tool, true);
// TODO WHATISBOOL
} else {
writeToolCycleBlock(tool);
}
Expand Down Expand Up @@ -1699,6 +1875,10 @@ function onManualNC(command, value) {

var probeOutputWorkOffset = 1;
var stockTopZ = -1;
var stockUpperX;
var stockLowerX;
var stockUpperY;
var stockLowerY;

function onParameter(name, value) {
if (name == "probe-output-work-offset") {
Expand All @@ -1710,6 +1890,18 @@ function onParameter(name, value) {
if (name == "stock-upper-z") {
stockTopZ = value;
}
if (name == "stock-upper-x") {
stockUpperX = value;
}
if (name == "stock-lower-x") {
stockLowerX = value;
}
if (name == "stock-upper-y") {
stockUpperY = value;
}
if (name == "stock-lower-y") {
stockLowerY = value;
}
}

var seenPatternIds = {};
Expand Down Expand Up @@ -1998,6 +2190,27 @@ function setAbsoluteMode(xyz, abc) {
}

function onSection() {
if (isFirstSection() && staticProperties.pencilWCSVerif) {
var stockMidX = (stockUpperX + stockLowerX)/2;
var stockMidY = (stockUpperY + stockLowerY)/2;
writeln("");
writeComment("Verify WCS");
writeBlock("T" + toolFormat.format(19), mFormat.format(6)); //Changes Tool
writeBlock(gFormat.format(0), xOutput.format(stockMidX), yOutput.format(stockMidY));
displayMedia("Net Share/Media/xyWCSCheck.png");
writeBlock(mFormat.format(0), formatComment("Open door"));
displayMedia("Net Share/Media/arrowDown.png");
var gotoRef = takeInput("Is the graphite probing device in the middle of the stock?", ['Y']);
writeWords("N" + nFormat.format(gotoRef['Y']), mFormat.format(131), formatComment("End Multimedia"));
writeBlock(gFormat.format(55), gFormat.format(43), hFormat.format(19), zOutput.format(stockTopZ));
displayMedia("Net Share/Media/zWCSCheck.png");
writeBlock(mFormat.format(0), formatComment("Open door"));
displayMedia("Net Share/Media/arrowDown.png");
gotoRef = takeInput("Is the graphite probing device touching the stock?", ['Y']);
writeWords("N" + nFormat.format(gotoRef['Y']), mFormat.format(131), formatComment("End Multimedia"));
}


var forceToolAndRetract = optionalSection && !currentSection.isOptional();
optionalSection = currentSection.isOptional();

Expand Down Expand Up @@ -2431,8 +2644,10 @@ function onSection() {
writeComment("END VALIDATION SECTION");

// initialize spindle and engage coolant if heights are correct
writeBlock(mFormat.format((tool.clockwise ? 3 : 4)), formatComment("Restart spindle"));
setCoolant(tool.coolant);
if (tool.type != TOOL_PROBE) {
writeBlock(mFormat.format((tool.clockwise ? 3 : 4)), formatComment("Restart spindle"));
setCoolant(tool.coolant);
}

// define subprogram
subprogramDefine(initialPosition, abc, retracted, zIsOutput);
Expand Down