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 + ") ---");
}
if (layer > 0 && device.layerRetract) {
retract();
}
// second layer transitions
if (layer === 1) {
// second layer fan on

View file

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

View file

@ -41,6 +41,7 @@ self.kiri.license = exports.LICENSE;
extrudeAbs: 1,
filamentSize: 1,
nozzleSize: 1,
layerRetract: 1,
gcodePre: 1,
gcodePost: 1,
gcodeProc: 1,
@ -98,7 +99,8 @@ self.kiri.license = exports.LICENSE;
outputBrimOffset: 1,
outputShortPoly: 1,
outputShortFactor: 1,
outputFinishFactor: 1,
outputCoastDist: 1,
outputWipeDistance: 1,
sliceMinHeight: 1,
outputCooling: 1,
// detectThinWalls: 1,
@ -244,6 +246,7 @@ self.kiri.license = exports.LICENSE;
maxHeight: 150, // FDM
filamentSize: 1.75, // FDM
nozzleSize: 0.4, // FDM
layerRetract: false,// FDM
spindleMax: 0, // CAM
gcodePre: [], // FDM/CAM header script
gcodePost: [], // FDM/CAM footer script
@ -314,7 +317,8 @@ self.kiri.license = exports.LICENSE;
outputBrimOffset: 2,
outputShortPoly: 30.0,
outputShortFactor: 0.2,
outputFinishFactor: 0,
outputCoastDist: 0,
outputWipeDistance: 0,
sliceMinHeight: 0,
detectThinWalls: false,
antiBacklash: 1,
@ -2298,9 +2302,10 @@ self.kiri.license = exports.LICENSE;
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}),
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"}),
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')),
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}),
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}),
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}),
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}),
@ -3011,6 +3017,7 @@ self.kiri.license = exports.LICENSE;
origin_center: UI.setDeviceOrigin.checked,
origin_top: UI.setDeviceOriginTop.checked,
extrude_abs: UI.setDeviceExtrusion.checked,
layer_retract: UI.setDeviceLayerRetract.checked,
spindle_max: parseInt(UI.setDeviceMaxSpindle.value) || 0
},
cmd: {
@ -3052,6 +3059,7 @@ self.kiri.license = exports.LICENSE;
bedDepth: valueOf(set.bed_depth, 175),
maxHeight: valueOf(set.build_height, 150),
nozzleSize: valueOf(set.nozzle_size, 0.4),
layerRetract: valueOf(set.layer_retract, false),
filamentSize: valueOf(set.filament_diameter, 1.75),
extrudeAbs: valueOf(set.extrude_abs, false),
spindleMax: valueOf(set.spindle_max, 0),
@ -3092,6 +3100,7 @@ self.kiri.license = exports.LICENSE;
UI.setDeviceLayer.value = dev.gcodeLayer.join('\n');
UI.setDeviceFilament.value = dev.filamentSize;
UI.setDeviceNozzle.value = dev.nozzleSize;
UI.setDeviceLayerRetract.checked = dev.layerRetract;
// CAM
UI.setDeviceMaxSpindle.value = dev.spindleMax;
UI.setDeviceSpindle.value = dev.gcodeSpindle.join('\n');
@ -3111,6 +3120,7 @@ self.kiri.license = exports.LICENSE;
UI.setDeviceWidth,
UI.setDeviceHeight,
UI.setDeviceExtrusion,
UI.setDeviceLayerRetract,
UI.setDeviceOrigin,
UI.setDeviceOriginTop,
UI.setDeviceFan,

View file

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