Skip to content

Commit 6523a69

Browse files
committed
laser and plasma stuff
1 parent f177c6f commit 6523a69

File tree

2 files changed

+67
-27
lines changed

2 files changed

+67
-27
lines changed

OpenbuildsFusion360PostGrbl.cps

+62-27
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ Changelog
4242
24 Nov 2021 - V1.0.28 : Improved coolant selection, tweaked property groups, tweaked G53 generation, links for help in comments.
4343
21 Feb 2022 - V1.0.29 : Fix sideeffects of drill operation having rapids even when in noRapid mode by always resetting haveRapid in onSection
4444
10 May 2022 - V1.0.30 : Change naming convention for first file in multifile output (Sharmstr)
45+
xx Sep 2022 - V1.0.31 : better laser, with pierce option if cutting
4546
*/
46-
obversion = 'V1.0.30';
47+
obversion = 'V1.0.31';
4748
description = "OpenBuilds CNC : GRBL/BlackBox"; // cannot have brackets in comments
4849
longDescription = description + " : Post" + obversion; // adds description to post library dialog box
4950
vendor = "OpenBuilds";
@@ -81,10 +82,11 @@ properties =
8182
machineHomeX : -10, // always in millimeters
8283
machineHomeY : -10,
8384
gotoMCSatend : false, // true will do G53 G0 x{machinehomeX} y{machinehomeY}, false will do G0 x{machinehomeX} y{machinehomeY} at end of program
84-
PowerVaporise : 100, // cutting power in percent
85-
PowerThrough : 50,
86-
PowerEtch : 2,
85+
PowerVaporise : 5, // cutting power in percent, to vaporize plastic coatings
86+
PowerThrough : 100, // for through cutting
87+
PowerEtch : 10, // for etching the surface
8788
UseZ : false, // if true then Z will be moved to 0 at beginning and back to 'retract height' at end
89+
UsePierce : false, // if true && islaser && cutting use M3 and honor pierce delays, else use M4
8890
//plasma stuff
8991
plasma_usetouchoff : false, // use probe for touchoff if true
9092
plasma_touchoffOffset : 5.0, // offset from trigger point to real Z0, used in G10 line
@@ -201,10 +203,11 @@ propertyDefinitions = {
201203
type:"boolean",
202204
},
203205
204-
PowerVaporise: {title:"LASER: Power for Vaporizing", description:"Scary power VAPORIZE power setting, in percent.", group:"laserPlasma", type:"integer"},
206+
PowerVaporise: {title:"LASER: Power for Vaporizing", description:"Just enough Power to VAPORIZE plastic coating, in percent.", group:"laserPlasma", type:"integer"},
205207
PowerThrough: {title:"LASER: Power for Through Cutting", description:"Normal Through cutting power, in percent.", group:"laserPlasma", type:"integer"},
206208
PowerEtch: {title:"LASER: Power for Etching", description:"Just enough power to Etch the surface, in percent.", group:"laserPlasma", type:"integer"},
207209
UseZ: {title:"LASER: Use Z motions at start and end.", description:"Use True if you have a laser on a router with Z motion, or a PLASMA cutter.", group:"laserPlasma", type:"boolean"},
210+
UsePierce: {title:"LASER: Use pierce delays with M3 motion when cutting.", description:"True will use M3 commands and pierce delays, else use M4 with no delays.", group:"laserPlasma", type:"boolean"},
208211
plasma_usetouchoff: {title:"PLASMA: Use Z touchoff probe routine", description:"Set to true if have a touchoff probe for Plasma.", group:"laserPlasma", type:"boolean"},
209212
plasma_touchoffOffset:{title:"PLASMA: Plasma touch probe offset", description:"Offset in Z at which the probe triggers, always Millimeters, always positive.", group:"laserPlasma", type:"spatial"},
210213
@@ -284,6 +287,7 @@ var retractHeight = 1; // will be set by onParameter and used in onLinear to de
284287
var clearanceHeight = 10; // will be set by onParameter
285288
var topHeight = 1; // set by onParameter
286289
var leadinRate = 314; // set by onParameter: the lead-in feedrate,plasma
290+
var cuttingMode = 'none'; // set by onParameter for laser/plasma
287291
var linmove = 1; // linear move mode
288292
var toolRadius; // for arc linearization
289293
var plasma_pierceHeight = 1; // set by onParameter from Linking|PierceClearance
@@ -488,7 +492,10 @@ function writeHeader(secID)
488492
var unitstr = (unit == MM) ? 'mm' : 'inch';
489493
writeComment("Units = " + unitstr );
490494
if (isJet())
495+
{
491496
writeComment("Laser UseZ = " + properties.UseZ);
497+
writeComment("Laser UsePierce = " + properties.UsePierce);
498+
}
492499
493500
writeln("");
494501
if (hasGlobalParameter("document-path"))
@@ -804,8 +811,15 @@ function onSection()
804811
writeComment("Plasma pierce height " + plasma_pierceHeight);
805812
writeComment("Plasma topHeight " + topHeight);
806813
}
807-
808-
toolRadius = tool.diameter / 2.0;
814+
if (isLaser || isPlasma)
815+
{
816+
// fake the radius else the arcs are too small before being linearized
817+
toolRadius = tool.diameter * 4;
818+
}
819+
else
820+
{
821+
toolRadius = tool.diameter / 2.0;
822+
}
809823

810824
//TODO : plasma check that top height mode is from stock top and the value is positive
811825
//(onParameter =operation:topHeight mode= from stock top)
@@ -888,15 +902,19 @@ function onSection()
888902
return;
889903
}
890904
// figure cutmode, M3 or M4
891-
cutmode = 4; // always M4 mode
905+
if ((cuttingMode == 'etch') || (cuttingMode == 'vaporize'))
906+
cutmode = 4; // always M4 mode unless cutting
907+
else
908+
cutmode = 3;
892909
if (pwas != power)
893910
{
894911
sOutput.reset();
895912
//if (isFirstSection())
896913
if (cutmode == 3)
897-
writeBlock(mOutput.format(cutmode), sOutput.format(0)); // else you get a flash before the first g0 move
914+
writeBlock(mOutput.format(cutmode), sOutput.format(0), '; flash preventer'); // else you get a flash before the first g0 move
898915
else
899-
writeBlock(mOutput.format(cutmode), sOutput.format(power));
916+
if (cuttingMode != 'cut')
917+
writeBlock(mOutput.format(cutmode), sOutput.format(power), '; section power');
900918
}
901919
break;
902920
case TOOL_PLASMA_CUTTER:
@@ -998,7 +1016,7 @@ function onSection()
9981016

9991017
function onDwell(seconds)
10001018
{
1001-
if (seconds > 0.0)
1019+
if (seconds > 0.0)
10021020
writeBlock(gFormat.format(4), "P" + secFormat.format(seconds));
10031021
}
10041022

@@ -1104,21 +1122,19 @@ function onLinear(_x, _y, _z, feed)
11041122
// laser, plasma
11051123
if (x || y)
11061124
{
1125+
var z = properties.UseZ ? zOutput.format(_z) : "";
1126+
var s = sOutput.format(power);
11071127
if (haveRapid)
11081128
{
11091129
// this is the old process when we have rapids inserted by onRapid
1110-
var z = properties.UseZ ? zOutput.format(_z) : "";
1111-
var s = sOutput.format(power);
1112-
if (isPlasma && !powerOn) // plasma does some odd routing that should be rapid
1130+
if (!powerOn) // laser/plasma does some odd routing that should be rapid
11131131
writeBlock(gMotionModal.format(0), x, y, z, f, s);
11141132
else
11151133
writeBlock(gMotionModal.format(1), x, y, z, f, s);
11161134
}
11171135
else
11181136
{
11191137
// this is the new process when we dont have onRapid but GRBL requires G0 moves for noncutting laser moves
1120-
var z = properties.UseZ ? zOutput.format(0) : "";
1121-
var s = sOutput.format(power);
11221138
if (powerOn)
11231139
writeBlock(gMotionModal.format(1), x, y, z, f, s);
11241140
else
@@ -1152,8 +1168,9 @@ function onCircular(clockwise, cx, cy, cz, x, y, z, feed)
11521168
var rad = Math.sqrt(Math.pow(start.x - cx,2) + Math.pow(start.y - cy, 2));
11531169
if (properties.linearizeSmallArcs && (rad < toolRadius))
11541170
{
1155-
//writeComment("linearizing arc radius " + round(rad,4) + " toolRadius " + round(toolRadius,3));
1171+
if (debug) writeComment("linearizing arc radius " + round(rad,4) + " toolRadius " + round(toolRadius,3));
11561172
linearize(tolerance);
1173+
if (debug) writeComment("done");
11571174
return;
11581175
}
11591176
if (isFullCircle())
@@ -1164,8 +1181,12 @@ function onCircular(clockwise, cx, cy, cz, x, y, z, feed)
11641181
}
11651182
else
11661183
{
1167-
if (isPlasma && !powerOn)
1184+
if ((isLaser || isPlasma) && !powerOn)
1185+
{
1186+
if (debug) writeComment("arc linearize rapid");
11681187
linearize(tolerance * 4); // this is a rapid move so tolerance can be increased for faster motion and fewer lines of code
1188+
if (debug) writeComment("arc linearize rapid done");
1189+
}
11691190
else
11701191
switch (getCircularPlane())
11711192
{
@@ -1302,35 +1323,35 @@ function onCommand(command)
13021323
switch (command)
13031324
{
13041325
case COMMAND_STOP: // - Program stop (M00)
1305-
writeComment("Program stop (M00)");
1326+
writeComment("Program stop M00");
13061327
writeBlock(mFormat.format(0));
13071328
break;
13081329
case COMMAND_OPTIONAL_STOP: // - Optional program stop (M01)
1309-
writeComment("Optional program stop (M01)");
1330+
writeComment("Optional program stop M01");
13101331
writeBlock(mFormat.format(1));
13111332
break;
13121333
case COMMAND_END: // - Program end (M02)
1313-
writeComment("Program end (M02)");
1334+
writeComment("Program end M02");
13141335
writeBlock(mFormat.format(2));
13151336
break;
13161337
case COMMAND_POWER_OFF:
1317-
//writeComment("power off");
1338+
if (debug) writeComment("power off");
13181339
if (!haveRapid)
13191340
writeln("");
13201341
powerOn = false;
1321-
if (isPlasma)
1342+
if (isPlasma || (isLaser && (cuttingMode == 'cut')) )
13221343
writeBlock(mFormat.format(5));
13231344
break;
13241345
case COMMAND_POWER_ON:
1325-
//writeComment("power ON");
1346+
if (debug) writeComment("power ON");
13261347
if (!haveRapid)
13271348
writeln("");
13281349
powerOn = true;
1329-
if (isPlasma)
1350+
if (isPlasma || isLaser)
13301351
{
13311352
if (properties.UseZ)
13321353
{
1333-
if (properties.plasma_usetouchoff)
1354+
if (properties.plasma_usetouchoff && isPlasma)
13341355
{
13351356
writeln("");
13361357
writeBlock( "G38.2" , zOutput.format(toPreciseUnit(-plasma_probedistance,MM)), feedOutput.format(toPreciseUnit(plasma_proberate,MM)));
@@ -1344,16 +1365,20 @@ function onCommand(command)
13441365
else
13451366
writeBlock( gMotionModal.format(0), zOutput.format(plasma_pierceHeight));
13461367
}
1347-
writeBlock(mFormat.format(3), sOutput.format(power));
1368+
if (isPlasma || (cuttingMode == 'cut'))
1369+
writeBlock(mFormat.format(3), sOutput.format(power));
13481370
}
13491371
break;
1372+
default:
1373+
if (debug) writeComment("onCommand not handled " + command);
13501374
}
13511375
// for other commands see https://cam.autodesk.com/posts/reference/classPostProcessor.html#af3a71236d7fe350fd33bdc14b0c7a4c6
13521376
if (debug) writeComment("onCommand end");
13531377
}
13541378

13551379
function onParameter(name, value)
13561380
{
1381+
//onParameter('operation:keepToolDown', 0)
13571382
//if (debug) writeComment("onParameter =" + name + "= " + value); // (onParameter =operation:retractHeight value= :5)
13581383
name = name.replace(" ","_"); // dratted indexOF cannot have spaces in it!
13591384
if ( (name.indexOf("retractHeight_value") >= 0 ) ) // == "operation:retractHeight value")
@@ -1378,6 +1403,15 @@ function onParameter(name, value)
13781403
topHeight = value;
13791404
if (debug && isPlasma) writeComment("topHeight set " + topHeight);
13801405
}
1406+
if (name.indexOf('operation:cuttingMode') >= 0)
1407+
{
1408+
cuttingMode = value;
1409+
if (debug) writeComment("cuttingMode set " + cuttingMode);
1410+
if (cuttingMode.indexOf('cut') >= 0) // simplify later logic, auto/low/medium/high are all 'cut'
1411+
cuttingMode = 'cut';
1412+
if (cuttingMode.indexOf('auto') >= 0)
1413+
cuttingMode = 'cut';
1414+
}
13811415
// (onParameter =operation:pierceClearance= 1.5) for plasma
13821416
if (name == 'operation:pierceClearance')
13831417
plasma_pierceHeight = value;
@@ -1390,6 +1424,7 @@ function onParameter(name, value)
13901424
writeBlock( gMotionModal.format(1) , zOutput.format(topHeight) , feedOutput.format(leadinRate) );
13911425
gMotionModal.reset();
13921426
}
1427+
13931428
}
13941429
}
13951430

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
Creates .nc files optimized for GRBL based Openbuilds-style machines.
44
Supports router and laser operations.
55

6+
V1.0.31
7+
1. improved laser and plasma paths, esp when 'stay down' is selected
8+
1. laser pierce delay option when through cutting is selected
9+
1. Select 'LASER: use Z motions at start and end' to have full Z movement with laser and plasma cuts
10+
611
V1.0.25 supports plasma torch touchoff probing.
712
* Read the [instructions](https://github.com/OpenBuilds/OpenBuilds-Fusion360-Postprocessor/blob/master/README-plasma.md)
813

0 commit comments

Comments
 (0)