implement better coasting. add device layer forced retractions

This commit is contained in:
Stewart Allen 2019-04-02 19:08:19 -07:00
commit 7813bb9c63
4 changed files with 44 additions and 22 deletions

View file

@ -574,6 +574,10 @@ var gs_kiri_fdm = exports;
append("; --- layer " + layer + " (" + consts.height + " @ " + consts.z + ") ---"); append("; --- layer " + layer + " (" + consts.height + " @ " + consts.z + ") ---");
} }
if (layer > 0 && device.layerRetract) {
retract();
}
// second layer transitions // second layer transitions
if (layer === 1) { if (layer === 1) {
// second layer fan on // second layer fan on

View file

@ -254,7 +254,7 @@ var gs_kiri_print = exports;
switch (mode) { switch (mode) {
case 'CAM': case 'CAM':
case 'FDM': case 'FDM':
scope.renderMoves(true, 0x777777); scope.renderMoves(true, 0xdddddd);
break; break;
case 'LASER': case 'LASER':
scope.renderMoves(false, 0x0088aa); scope.renderMoves(false, 0x0088aa);
@ -337,7 +337,9 @@ var gs_kiri_print = exports;
}); });
view = KIRI.newLayer(scope.group); view = KIRI.newLayer(scope.group);
scope.layerView.push(view); scope.layerView.push(view);
if (showMoves) view.lines(move, moveColor); if (showMoves) {
view.lines(move, moveColor);
}
for (var speed in print) { for (var speed in print) {
var sint = Math.min(6000, parseInt(speed)); var sint = Math.min(6000, parseInt(speed));
var rgb = hsv2rgb({h:sint/6000, s:1, v:0.6}); var rgb = hsv2rgb({h:sint/6000, s:1, v:0.6});
@ -431,30 +433,35 @@ var gs_kiri_print = exports;
moveSpeed = process.outputSeekrate, moveSpeed = process.outputSeekrate,
closest = poly.findClosestPointTo(startPoint), closest = poly.findClosestPointTo(startPoint),
perimeter = poly.perimeter(), perimeter = poly.perimeter(),
isShort = perimeter < process.outputShortPoly,
first = true, first = true,
last = startPoint; last = startPoint,
wipeDist = options.wipe || 0,
coastDist = options.coast || 0;
if (isShort) { // if short, use calculated print speed based on sliding scale
shortSpeed = shortSpeed + (printSpeed - shortSpeed) * (perimeter / process.outputShortPoly); if (perimeter < process.outputShortPoly) {
printSpeed = shortSpeed + (printSpeed - shortSpeed) * (perimeter / process.outputShortPoly);
} }
poly.forEachPoint(function(point, pos, points, count) { poly.forEachPoint(function(point, pos, points, count) {
if (first) { if (first) {
if (options.onfirst) options.onfirst(point); if (options.onfirst) {
options.onfirst(point);
}
// move from startPoint to point // move from startPoint to point
addOutput(output, point, 0, moveSpeed); addOutput(output, point, 0, moveSpeed);
first = false; first = false;
} else { } else {
var dist = last.distTo2D(point); var seglen = last.distTo2D(point);
if (options.shorten && dist > options.shorten && count === points.length) { if (coastDist && shellMult && perimeter - seglen <= coastDist) {
point = last.offsetPointFrom(point, options.shorten); var delta = perimeter - coastDist;
} var offset = seglen - delta;
if (isShort) { var offPoint = last.offsetPointFrom(point, offset)
addOutput(output, point, shellMult, shortSpeed); addOutput(output, offPoint, shellMult, printSpeed);
} else { shellMult = 0;
addOutput(output, point, shellMult, printSpeed);
} }
perimeter -= seglen;
addOutput(output, point, shellMult, printSpeed);
} }
last = point; last = point;
}, true, closest.index); }, true, closest.index);
@ -487,7 +494,7 @@ var gs_kiri_print = exports;
fillMult = opt.mult || process.outputFillMult, fillMult = opt.mult || process.outputFillMult,
shellMult = opt.mult || process.outputShellMult || (process.laserSliceHeight >= 0 ? 1 : 0), shellMult = opt.mult || process.outputShellMult || (process.laserSliceHeight >= 0 ? 1 : 0),
sparseMult = process.outputSparseMult, sparseMult = process.outputSparseMult,
finishFactor = process.outputFinishFactor || 0, coastDist = process.outputCoastDist || 0,
finishSpeed = opt.speed || process.outputFinishrate, finishSpeed = opt.speed || process.outputFinishrate,
firstShellSpeed = process.firstLayerRate, firstShellSpeed = process.firstLayerRate,
firstFillSpeed = process.firstLayerFillRate, firstFillSpeed = process.firstLayerFillRate,
@ -535,7 +542,8 @@ var gs_kiri_print = exports;
startPoint = scope.polyPrintPath(poly, startPoint, preout, { startPoint = scope.polyPrintPath(poly, startPoint, preout, {
rate: finishShell ? finishSpeed : printSpeed, rate: finishShell ? finishSpeed : printSpeed,
accel: finishShell, accel: finishShell,
shorten: finishShell && !firstLayer ? nozzle * finishFactor : 0, wipe: process.outputWipeDistance || 0,
coast: firstLayer ? 0 : coastDist,
extrude: shellMult, extrude: shellMult,
onfirst: function(firstPoint) { onfirst: function(firstPoint) {
if (startPoint.distTo2D(firstPoint) > retractDist) { if (startPoint.distTo2D(firstPoint) > retractDist) {

View file

@ -41,6 +41,7 @@ self.kiri.license = exports.LICENSE;
extrudeAbs: 1, extrudeAbs: 1,
filamentSize: 1, filamentSize: 1,
nozzleSize: 1, nozzleSize: 1,
layerRetract: 1,
gcodePre: 1, gcodePre: 1,
gcodePost: 1, gcodePost: 1,
gcodeProc: 1, gcodeProc: 1,
@ -98,7 +99,8 @@ self.kiri.license = exports.LICENSE;
outputBrimOffset: 1, outputBrimOffset: 1,
outputShortPoly: 1, outputShortPoly: 1,
outputShortFactor: 1, outputShortFactor: 1,
outputFinishFactor: 1, outputCoastDist: 1,
outputWipeDistance: 1,
sliceMinHeight: 1, sliceMinHeight: 1,
outputCooling: 1, outputCooling: 1,
// detectThinWalls: 1, // detectThinWalls: 1,
@ -244,6 +246,7 @@ self.kiri.license = exports.LICENSE;
maxHeight: 150, // FDM maxHeight: 150, // FDM
filamentSize: 1.75, // FDM filamentSize: 1.75, // FDM
nozzleSize: 0.4, // FDM nozzleSize: 0.4, // FDM
layerRetract: false,// FDM
spindleMax: 0, // CAM spindleMax: 0, // CAM
gcodePre: [], // FDM/CAM header script gcodePre: [], // FDM/CAM header script
gcodePost: [], // FDM/CAM footer script gcodePost: [], // FDM/CAM footer script
@ -314,7 +317,8 @@ self.kiri.license = exports.LICENSE;
outputBrimOffset: 2, outputBrimOffset: 2,
outputShortPoly: 30.0, outputShortPoly: 30.0,
outputShortFactor: 0.2, outputShortFactor: 0.2,
outputFinishFactor: 0, outputCoastDist: 0,
outputWipeDistance: 0,
sliceMinHeight: 0, sliceMinHeight: 0,
detectThinWalls: false, detectThinWalls: false,
antiBacklash: 1, antiBacklash: 1,
@ -2298,9 +2302,10 @@ self.kiri.license = exports.LICENSE;
setDeviceDepth: UC.newInput("bed depth", {title:"millimeters", convert:UC.toInt}), setDeviceDepth: UC.newInput("bed depth", {title:"millimeters", convert:UC.toInt}),
setDeviceHeight: UC.newInput("max height", {title:"max build height\nin millimeters", convert:UC.toInt, modes:FDM}), setDeviceHeight: UC.newInput("max height", {title:"max build height\nin millimeters", convert:UC.toInt, modes:FDM}),
setDeviceMaxSpindle: UC.newInput("max spindle rpm", {title:"max spindle speed\n0 to disable", convert:UC.toInt, modes:CAM}), setDeviceMaxSpindle: UC.newInput("max spindle rpm", {title:"max spindle speed\n0 to disable", convert:UC.toInt, modes:CAM}),
setDeviceExtrusion: UC.newBoolean("extrusion absolute", onBooleanClick, {title:"extrusion moves absolute"}), setDeviceExtrusion: UC.newBoolean("extrude absolute", onBooleanClick, {title:"extrusion moves absolute"}),
setDeviceOrigin: UC.newBoolean("origin center", onBooleanClick, {title:"bed origin center"}), setDeviceOrigin: UC.newBoolean("origin center", onBooleanClick, {title:"bed origin center"}),
setDeviceOriginTop: UC.newBoolean("origin top", onBooleanClick, {title:"part z origin top", modes:CAM}), setDeviceOriginTop: UC.newBoolean("origin top", onBooleanClick, {title:"part z origin top", modes:CAM}),
setDeviceLayerRetract: UC.newBoolean("layer retract", onBooleanClick, {title:"retract between layers"}),
setDevice: UC.newGroup("gcode", $('device')), setDevice: UC.newGroup("gcode", $('device')),
setDeviceFan: UC.newInput("fan power", {title:"set cooling fan power", modes:FDM, size:15}), setDeviceFan: UC.newInput("fan power", {title:"set cooling fan power", modes:FDM, size:15}),
@ -2584,7 +2589,8 @@ self.kiri.license = exports.LICENSE;
outputRetractDwell: UC.newInput("engage dwell", {title:"time between re-engaging\nfilament and movement\nin milliseconds", convert:UC.toInt, modes:FDM}), outputRetractDwell: UC.newInput("engage dwell", {title:"time between re-engaging\nfilament and movement\nin milliseconds", convert:UC.toInt, modes:FDM}),
outputShortPoly: UC.newInput("short outline", {title:"poly perimeter length\ntriggers short slowdown\nin millimeters", bound:UC.bound(0,200), convert:UC.toFloat, modes:FDM}), outputShortPoly: UC.newInput("short outline", {title:"poly perimeter length\ntriggers short slowdown\nin millimeters", bound:UC.bound(0,200), convert:UC.toFloat, modes:FDM}),
outputShortFactor: UC.newInput("short factor", {title:"max speed reduction factor\nfor short segments\nas % of print speed", bound:UC.bound(0.05,1), convert:UC.toFloat, modes:FDM}), outputShortFactor: UC.newInput("short factor", {title:"max speed reduction factor\nfor short segments\nas % of print speed", bound:UC.bound(0.05,1), convert:UC.toFloat, modes:FDM}),
outputFinishFactor: UC.newInput("short end", {title:"% of nozzle diameter to\nshorten finish path by\nvalues of 0-1", bound:UC.bound(0.0,1), convert:UC.toFloat, modes:FDM}), outputCoastDist: UC.newInput("coast", {title:"non-printing end\nof perimeter shells\nin millimeters", bound:UC.bound(0.0,10), convert:UC.toFloat, modes:FDM}),
// outputWipeDistance: UC.newInput("wipe", {title:"non-printing move at\close of polygon\nin millimeters", bound:UC.bound(0.0,10), convert:UC.toFloat, modes:FDM}),
sliceMinHeight: UC.newInput("min layer", {title: "enables adaptive slicing with\nthis as the min layer height\nin millimeters\n0 to disable", bound:UC.bound(0,3.0), convert:UC.toFloat, modes:FDM}), sliceMinHeight: UC.newInput("min layer", {title: "enables adaptive slicing with\nthis as the min layer height\nin millimeters\n0 to disable", bound:UC.bound(0,3.0), convert:UC.toFloat, modes:FDM}),
zHopDistance: UC.newInput("z hop dist", {title: "amount to raise z\non retraction moves\nin millimeters\n0 to disable", bound:UC.bound(0,3.0), convert:UC.toFloat, modes:FDM}), zHopDistance: UC.newInput("z hop dist", {title: "amount to raise z\non retraction moves\nin millimeters\n0 to disable", bound:UC.bound(0,3.0), convert:UC.toFloat, modes:FDM}),
antiBacklash: UC.newInput("anti-backlash", {title: "use micro-movements to cancel\nbacklash during fills\nin millimeters", bound:UC.bound(0,3), convert:UC.toInt, modes:FDM}), antiBacklash: UC.newInput("anti-backlash", {title: "use micro-movements to cancel\nbacklash during fills\nin millimeters", bound:UC.bound(0,3), convert:UC.toInt, modes:FDM}),
@ -3011,6 +3017,7 @@ self.kiri.license = exports.LICENSE;
origin_center: UI.setDeviceOrigin.checked, origin_center: UI.setDeviceOrigin.checked,
origin_top: UI.setDeviceOriginTop.checked, origin_top: UI.setDeviceOriginTop.checked,
extrude_abs: UI.setDeviceExtrusion.checked, extrude_abs: UI.setDeviceExtrusion.checked,
layer_retract: UI.setDeviceLayerRetract.checked,
spindle_max: parseInt(UI.setDeviceMaxSpindle.value) || 0 spindle_max: parseInt(UI.setDeviceMaxSpindle.value) || 0
}, },
cmd: { cmd: {
@ -3052,6 +3059,7 @@ self.kiri.license = exports.LICENSE;
bedDepth: valueOf(set.bed_depth, 175), bedDepth: valueOf(set.bed_depth, 175),
maxHeight: valueOf(set.build_height, 150), maxHeight: valueOf(set.build_height, 150),
nozzleSize: valueOf(set.nozzle_size, 0.4), nozzleSize: valueOf(set.nozzle_size, 0.4),
layerRetract: valueOf(set.layer_retract, false),
filamentSize: valueOf(set.filament_diameter, 1.75), filamentSize: valueOf(set.filament_diameter, 1.75),
extrudeAbs: valueOf(set.extrude_abs, false), extrudeAbs: valueOf(set.extrude_abs, false),
spindleMax: valueOf(set.spindle_max, 0), spindleMax: valueOf(set.spindle_max, 0),
@ -3092,6 +3100,7 @@ self.kiri.license = exports.LICENSE;
UI.setDeviceLayer.value = dev.gcodeLayer.join('\n'); UI.setDeviceLayer.value = dev.gcodeLayer.join('\n');
UI.setDeviceFilament.value = dev.filamentSize; UI.setDeviceFilament.value = dev.filamentSize;
UI.setDeviceNozzle.value = dev.nozzleSize; UI.setDeviceNozzle.value = dev.nozzleSize;
UI.setDeviceLayerRetract.checked = dev.layerRetract;
// CAM // CAM
UI.setDeviceMaxSpindle.value = dev.spindleMax; UI.setDeviceMaxSpindle.value = dev.spindleMax;
UI.setDeviceSpindle.value = dev.gcodeSpindle.join('\n'); UI.setDeviceSpindle.value = dev.gcodeSpindle.join('\n');
@ -3111,6 +3120,7 @@ self.kiri.license = exports.LICENSE;
UI.setDeviceWidth, UI.setDeviceWidth,
UI.setDeviceHeight, UI.setDeviceHeight,
UI.setDeviceExtrusion, UI.setDeviceExtrusion,
UI.setDeviceLayerRetract,
UI.setDeviceOrigin, UI.setDeviceOrigin,
UI.setDeviceOriginTop, UI.setDeviceOriginTop,
UI.setDeviceFan, UI.setDeviceFan,

View file

@ -1,7 +1,7 @@
var exports = { var exports = {
COPYRIGHT:"Copyright (C) 2014-2019 Stewart Allen <sa@grid.space> - All Rights Reserved", COPYRIGHT:"Copyright (C) 2014-2019 Stewart Allen <sa@grid.space> - All Rights Reserved",
LICENSE:"See the license.md file included with the source distribution", LICENSE:"See the license.md file included with the source distribution",
VERSION:"1.3.0" VERSION:"1.3.1"
}; };
if (!module) var module = {}; if (!module) var module = {};
module.exports = exports; module.exports = exports;