forked from martindb/mpcnc_posts_processor
-
Notifications
You must be signed in to change notification settings - Fork 29
/
DIYCNC_Grbl11.cps
147 lines (137 loc) · 5.72 KB
/
DIYCNC_Grbl11.cps
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/*
https://github.com/guffy1234/mpcnc_posts_processor
MPCNC posts processor for milling and laser/plasma cutting.
*/
include("DIYCNC_Common.js");
description = "DIYCNC Milling/Laser - Grbl 1.1";
// user-defined properties
mergeProperties(properties, {
cutterGrblMode: 4, // GRBL mode laser/plasma cutter
coolantAGrbl: 7, // GCode command to turn on Coolant channel A
coolantBGrbl: 8, // GCode command to turn on Coolant channel A
});
mergeProperties(propertyDefinitions, {
cutterGrblMode: {
title: "Laser: GRBL mode", description: "GRBL mode of the laser/plasma cutter", group: 4,
type: "integer", default_mm: 4, default_in: 4,
values: [
{ title: "M4 S{PWM}/M5 dynamic power", id: 4 },
{ title: "M3 S{PWM}/M5 static power", id: 3 },
]
},
coolantAGrbl: {
title: "Coolant: A code", description: "GRBL g-codes for control Coolant channel A", group: 6, type: "integer",
default_mm: 7, default_in: 7,
values: [
{ title: "M7 flood", id: 7 },
{ title: "M8 mist", id: 8 },
]
},
coolantBGrbl: {
title: "Coolant: B code", description: "GRBL g-codes for control Coolant channel B", group: 6, type: "integer",
default_mm: 8, default_in: 8,
values: [
{ title: "M7 flood", id: 7 },
{ title: "M8 mist", id: 8 },
]
},
});
function FirmwareGrbl() {
FirmwareBase.apply(this, arguments);
}
FirmwareGrbl.prototype = Object.create(FirmwareBase.prototype);
FirmwareGrbl.prototype.constructor = FirmwareGrbl;
FirmwareGrbl.prototype.init = function () {
gMotionModal = createModal({}, gFormat); // modal group 1 // G0-G3, ...
writeln("%");
}
FirmwareGrbl.prototype.start = function () {
writeBlock(gAbsIncModal.format(90)); // Set to Absolute Positioning
writeBlock(gFeedModeModal.format(94));
writeBlock(gPlaneModal.format(17));
writeBlock(gUnitModal.format(unit == IN ? 20 : 21));
}
FirmwareGrbl.prototype.end = function () {
writeBlock(mFormat.format(30));
}
FirmwareGrbl.prototype.close = function () {
writeln("%");
}
FirmwareGrbl.prototype.comment = function (text) {
writeln("(" + String(text).replace(/[\(\)]/g, "") + ")");
}
FirmwareGrbl.prototype.flushMotions = function () {
},
FirmwareGrbl.prototype.spindleOn = function (_spindleSpeed, _clockwise) {
writeActivityComment(" >>> Spindle Speed " + speedFormat.format(_spindleSpeed));
writeBlock(mFormat.format(_clockwise ? 3 : 4), sOutput.format(spindleSpeed));
}
FirmwareGrbl.prototype.spindleOff = function () {
writeBlock(mFormat.format(5));
}
FirmwareGrbl.prototype.laserOn = function (power) {
var laser_pwm = power / 100 * 255;
writeBlock(mFormat.format(properties.cutterGrblMode), sFormat.format(laser_pwm));
}
FirmwareGrbl.prototype.laserOff = function () {
writeBlock(mFormat.format(5));
}
FirmwareGrbl.prototype.coolantA = function (on) {
writeBlock(mFormat.format(on ? properties.coolantAGrbl : 9));
}
FirmwareGrbl.prototype.coolantB = function (on) {
writeBlock(mFormat.format(on ? properties.coolantBGrbl : 9));
}
FirmwareGrbl.prototype.dwell = function (seconds) {
seconds = clamp(0.001, seconds, 99999.999);
writeBlock(gFormat.format(4), "P" + secFormat.format(seconds));
}
FirmwareGrbl.prototype.display_text = function (txt) {
}
FirmwareGrbl.prototype.circular = function (clockwise, cx, cy, cz, x, y, z, feed) {
if (!properties.jobUseArcs) {
linearize(tolerance);
return;
}
var start = getCurrentPosition();
if (isFullCircle()) {
if (isHelical()) {
linearize(tolerance);
return;
}
switch (getCircularPlane()) {
case PLANE_XY:
writeBlock(gPlaneModal.format(17), gMotionModal.format(clockwise ? 2 : 3), xOutput.format(x), iOutput.format(cx - start.x, 0), jOutput.format(cy - start.y, 0), fOutput.format(feed));
break;
case PLANE_ZX:
writeBlock(gPlaneModal.format(18), gMotionModal.format(clockwise ? 2 : 3), zOutput.format(z), iOutput.format(cx - start.x, 0), kOutput.format(cz - start.z, 0), fOutput.format(feed));
break;
case PLANE_YZ:
writeBlock(gPlaneModal.format(19), gMotionModal.format(clockwise ? 2 : 3), yOutput.format(y), jOutput.format(cy - start.y, 0), kOutput.format(cz - start.z, 0), fOutput.format(feed));
break;
default:
linearize(tolerance);
}
} else {
switch (getCircularPlane()) {
case PLANE_XY:
writeBlock(gPlaneModal.format(17), gMotionModal.format(clockwise ? 2 : 3), xOutput.format(x), yOutput.format(y), zOutput.format(z), iOutput.format(cx - start.x, 0), jOutput.format(cy - start.y, 0), fOutput.format(feed));
break;
case PLANE_ZX:
writeBlock(gPlaneModal.format(18), gMotionModal.format(clockwise ? 2 : 3), xOutput.format(x), yOutput.format(y), zOutput.format(z), iOutput.format(cx - start.x, 0), kOutput.format(cz - start.z, 0), fOutput.format(feed));
break;
case PLANE_YZ:
writeBlock(gPlaneModal.format(19), gMotionModal.format(clockwise ? 2 : 3), xOutput.format(x), yOutput.format(y), zOutput.format(z), jOutput.format(cy - start.y, 0), kOutput.format(cz - start.z, 0), fOutput.format(feed));
break;
default:
linearize(tolerance);
}
}
}
FirmwareGrbl.prototype.toolChange = function () {
writeBlock(mFormat.format(6), tFormat.format(tool.number));
writeBlock(gFormat.format(54));
}
FirmwareGrbl.prototype.probeTool = function () {
}
currentFirmware = new FirmwareGrbl();