Skip to content

Commit e2ad18f

Browse files
committed
improved coolant codes
1 parent 9b7c07c commit e2ad18f

File tree

1 file changed

+40
-11
lines changed

1 file changed

+40
-11
lines changed

OpenbuildsFusion360PostGrbl.cps

+40-11
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ Changelog
3535
05 Nov 2020 - V1.0.21 : poweron/off for plasma, coolant can be turned on for laser/plasma too
3636
04 Dec 2020 - V1.0.22 : Add Router11 and dial settings
3737
16 Jan 2021 - V1.0.23 : Remove end of file marker '%' from end of output, arcs smaller than toolRadius will be linearized
38+
25 Jan 2021 - V1.0.24 : Improve coolant codes
3839
*/
39-
obversion = 'V1.0.23';
40+
obversion = 'V1.0.24';
4041
description = "OpenBuilds CNC : GRBL/BlackBox"; // cannot have brackets in comments
4142
vendor = "OpenBuilds";
4243
vendorUrl = "https://openbuilds.com";
@@ -761,14 +762,6 @@ function onSection() {
761762
writeBlock(gFormat.format(53), gFormat.format(0), zOutput.format(toPreciseUnit(properties.machineHomeZ, MM)));
762763
}
763764

764-
// If the machine has coolant, write M8 or M9
765-
if (properties.hasCoolant) {
766-
if (tool.coolant || isLaser || isPlasma) {
767-
writeBlock(mFormat.format(8));
768-
} else {
769-
writeBlock(mFormat.format(9));
770-
}
771-
}
772765

773766
forceXYZ();
774767

@@ -788,6 +781,15 @@ function onSection() {
788781
else
789782
f = "";
790783
writeBlock(gAbsIncModal.format(90), gMotionModal.format(0), xOutput.format(initialPosition.x), yOutput.format(initialPosition.y), f);
784+
785+
// If the machine has coolant, write M8/M7 or M9
786+
if (properties.hasCoolant) {
787+
if (isLaser || isPlasma)
788+
setCoolant(1) // always turn it on since plasma tool has no coolant option in fusion
789+
else
790+
setCoolant(tool.coolant); // use tool setting
791+
}
792+
791793
if (isLaser && properties.UseZ)
792794
writeBlock(gMotionModal.format(0), zOutput.format(0));
793795
isNewfile = false;
@@ -965,7 +967,7 @@ function onClose() {
965967
}
966968
writeBlock(mFormat.format(5)); // Stop Spindle
967969
if (properties.hasCoolant) {
968-
writeBlock(mFormat.format(9)); // Stop Coolant
970+
setCoolant(0); // Stop Coolant
969971
}
970972
//onDwell(properties.spindleOnOffDelay); // Wait for spindle to stop
971973
gMotionModal.reset();
@@ -1050,4 +1052,31 @@ function round(num,digits) {
10501052
function toFixedNumber(num, digits, base) {
10511053
var pow = Math.pow(base||10, digits); // cleverness found on web
10521054
return Math.round(num*pow) / pow;
1053-
}
1055+
}
1056+
1057+
// set the coolant mode from the tool value
1058+
function setCoolant(coolval)
1059+
{
1060+
//writeComment("setCoolant " + coolval);
1061+
// 0 if off, 1 is flood, 2 is mist
1062+
switch(coolval) {
1063+
case 0:
1064+
writeBlock(mFormat.format(9)); // off
1065+
break;
1066+
case 1:
1067+
writeBlock(mFormat.format(8)); // flood
1068+
break;
1069+
case 2:
1070+
writeComment("Mist coolant on pin A3. special GRBL compile for this.");
1071+
writeBlock(mFormat.format(7)); // mist
1072+
break;
1073+
case 7: // flood and mist
1074+
writeBlock(mFormat.format(8)); // flood
1075+
writeBlock(mFormat.format(7)); // mist
1076+
break;
1077+
default:
1078+
writeComment("Coolant option not understood: " + coolval);
1079+
alert("Warning", "Coolant option not understood: " + coolval);
1080+
}
1081+
}
1082+

0 commit comments

Comments
 (0)