├── DIYCNC_Common.js ├── DIYCNC_Grbl11.cps ├── DIYCNC_Marlin20.cps ├── DIYCNC_RepRapFW.cps ├── LICENSE ├── README.md ├── Test ├── 1001_laser.gcode ├── 1001_m3m5.gcode ├── 1001_m3m5_coolant.gcode ├── 1001_manual.gcode └── cam_testpp.f3d └── screenshot.jpg /DIYCNC_Common.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | https://github.com/guffy1234/mpcnc_posts_processor 4 | 5 | MPCNC posts processor for milling and laser/plasma cutting. 6 | 7 | */ 8 | 9 | 10 | // user-defined properties 11 | properties = { 12 | jobTravelSpeedXY: 2500, // High speed for travel movements X & Y (mm/min) 13 | jobTravelSpeedZ: 300, // High speed for travel movements Z (mm/min) 14 | 15 | jobManualSpindlePowerControl: true, // Spindle motor is controlled by manual switch 16 | 17 | jobUseArcs: true, // Produce G2/G3 for arcs 18 | 19 | jobSetOriginOnStart: true, // Set origin when gcode start (G92) 20 | jobGoOriginOnFinish: true, // Go X0 Y0 Z0 at gcode end 21 | 22 | jobSequenceNumbers: false, // show sequence numbers 23 | jobSequenceNumberStart: 10, // first sequence number 24 | jobSequenceNumberIncrement: 1, // increment for sequence numbers 25 | jobSeparateWordsWithSpace: true, // specifies that the words should be separated with a white space 26 | 27 | toolChangeEnabled: true, // Enable tool change code (bultin tool change requires LCD display) 28 | toolChangeX: 0, // X position for builtin tool change 29 | toolChangeY: 0, // Y position for builtin tool change 30 | toolChangeZ: 40, // Z position for builtin tool change 31 | toolChangeZProbe: true, // Z probe after tool change 32 | toolChangeDisableZStepper: false, // disable Z stepper when change a tool 33 | 34 | probeOnStart: true, // Execute probe gcode to align tool 35 | probeThickness: 0.8, // plate thickness 36 | probeUseHomeZ: true, // use G28 or G38 for probing 37 | probeG38Target: -10, // probing up to pos 38 | probeG38Speed: 30, // probing with speed 39 | 40 | gcodeStartFile: "", // File with custom Gcode for header/start (in nc folder) 41 | gcodeStopFile: "", // File with custom Gcode for footer/end (in nc folder) 42 | gcodeToolFile: "", // File with custom Gcode for tool change (in nc folder) 43 | gcodeProbeFile: "", // File with custom Gcode for tool probe (in nc folder) 44 | 45 | cutterOnVaporize: 100, // Persent of power to turn on the laser/plasma cutter in vaporize mode 46 | cutterOnThrough: 80, // Persent of power to turn on the laser/plasma cutter in through mode 47 | cutterOnEtch: 40, // Persent of power to turn on the laser/plasma cutter in etch mode 48 | 49 | coolantA_Mode: 0, // Enable issuing g-codes for control Coolant channel A 50 | coolantB_Mode: 0, // Use issuing g-codes for control Coolant channel B 51 | 52 | commentWriteTools: true, 53 | commentActivities: true, 54 | commentSections: true, 55 | commentCommands: true, 56 | commentMovements: true, 57 | }; 58 | 59 | propertyDefinitions = { 60 | jobFirmware: { 61 | title: "Job: Firmware", description: "GCode output mode", group: 4, 62 | type: "integer", default_mm: 0, default_in: 0, 63 | values: [ 64 | { title: "Marlin 2.0/Repetier 1.0.3", id: 0 }, 65 | { title: "GRBL 1.1", id: 1 }, 66 | { title: "RepRap firmware (Duet)", id: 2 }, 67 | ] 68 | }, 69 | 70 | jobTravelSpeedXY: { 71 | title: "Job: Travel speed X/Y", description: "High speed for travel movements X & Y (mm/min; in/min)", group: 1, 72 | type: "spatial", default_mm: 2500, default_in: 100 73 | }, 74 | jobTravelSpeedZ: { 75 | title: "Job: Travel Speed Z", description: "High speed for travel movements z (mm/min; in/min)", group: 1, 76 | type: "spatial", default_mm: 300, default_in: 12 77 | }, 78 | 79 | jobManualSpindlePowerControl: { 80 | title: "Job: Manual Spindle On/Off", description: "Set Yes when your spindle motor is controlled by manual switch", group: 1, 81 | type: "boolean", default_mm: true, default_in: true 82 | }, 83 | jobUseArcs: { 84 | title: "Job: Use Arcs", description: "Use G2/G3 g-codes fo circular movements", group: 1, 85 | type: "boolean", default_mm: true, default_in: true 86 | }, 87 | 88 | jobMarlinEnforceFeedrate: { 89 | title: "Job: Marlin: Enforce Feedrate", description: "Add feedrate to each movement g-code", group: 1, 90 | type: "boolean", default_mm: false, default_in: false 91 | }, 92 | 93 | jobSetOriginOnStart: { 94 | title: "Job: Reset on start (G92)", description: "Set origin when gcode start (G92)", group: 1, 95 | type: "boolean", default_mm: true, default_in: true 96 | }, 97 | jobGoOriginOnFinish: { 98 | title: "Job: Goto 0 at end", description: "Go X0 Y0 at gcode end", group: 1, 99 | type: "boolean", default_mm: true, default_in: true 100 | }, 101 | 102 | jobSequenceNumbers: { 103 | title: "Job: Line numbers", description: "Show sequence numbers", group: 1, 104 | type: "boolean", default_mm: true, default_in: true 105 | }, 106 | jobSequenceNumberStart: { 107 | title: "Job: Line start", description: "First sequence number", group: 1, 108 | type: "integer", default_mm: 10, default_in: 10 109 | }, 110 | jobSequenceNumberIncrement: { 111 | title: "Job: Line increment", description: "Lncrement for sequence numbers", group: 1, 112 | type: "integer", default_mm: 1, default_in: 1 113 | }, 114 | jobSeparateWordsWithSpace: { 115 | title: "Job: Separate words", description: "Specifies that the words should be separated with a white space", group: 1, 116 | type: "boolean", default_mm: true, default_in: true 117 | }, 118 | jobDuetMillingMode: { 119 | title: "Job: Duet: Milling mode", description: "GCode command to setup Duet3d milling mode", group: 1, type: "string", 120 | default_mm: "M453 P2 I0 R30000 F200", default_in: "M453 P2 I0 R30000 F200" 121 | }, 122 | jobDuetLaserMode: { 123 | title: "Job: Duet: Laser mode", description: "GCode command to setup Duet3d laser mode", group: 1, type: "string", 124 | default_mm: "M452 P2 I0 R255 F200", default_in: "M452 P2 I0 R255 F200" 125 | }, 126 | 127 | toolChangeEnabled: { 128 | title: "Change: Enabled", description: "Enable tool change code (bultin tool change requires LCD display)", group: 2, 129 | type: "boolean", default_mm: true, default_in: true 130 | }, 131 | toolChangeX: { 132 | title: "Change: X", description: "X position for builtin tool change", group: 2, 133 | type: "spatial", default_mm: 0, default_in: 0 134 | }, 135 | toolChangeY: { 136 | title: "Change: Y", description: "Y position for builtin tool change", group: 2, 137 | type: "spatial", default_mm: 0, default_in: 0 138 | }, 139 | toolChangeZ: { 140 | title: "Change: Z ", description: "Z position for builtin tool change", group: 2, 141 | type: "spatial", default_mm: 40, default_in: 1.6 142 | }, 143 | toolChangeZProbe: { 144 | title: "Change: Make Z Probe", description: "Z probe after tool change", group: 2, 145 | type: "boolean", default_mm: true, default_in: true 146 | }, 147 | toolChangeDisableZStepper: { 148 | title: "Change: Disable Z stepper", description: "Disable Z stepper when change a tool", group: 2, 149 | type: "boolean", default_mm: false, default_in: false 150 | }, 151 | 152 | probeOnStart: { 153 | title: "Probe: On job start", description: "Execute probe gcode on job start", group: 3, 154 | type: "boolean", default_mm: true, default_in: true 155 | }, 156 | probeThickness: { 157 | title: "Probe: Plate thickness", description: "Plate thickness", group: 3, 158 | type: "spatial", default_mm: 0.8, default_in: 0.032 159 | }, 160 | probeUseHomeZ: { 161 | title: "Probe: Use Home Z", description: "Use G28 or G38 for probing", group: 3, 162 | type: "boolean", default_mm: true, default_in: true 163 | }, 164 | probeG38Target: { 165 | title: "Probe: G38 target", description: "Probing up to Z position", group: 3, 166 | type: "spatial", default_mm: -10, default_in: -0.5 167 | }, 168 | probeG38Speed: { 169 | title: "Probe: G38 speed", description: "Probing with speed (mm/min; in/min)", group: 3, 170 | type: "spatial", default_mm: 30, default_in: 1.2 171 | }, 172 | 173 | cutterOnVaporize: { 174 | title: "Laser: On - Vaporize", description: "Persent of power to turn on the laser/plasma cutter in vaporize mode", group: 4, 175 | type: "number", default_mm: 100, default_in: 100 176 | }, 177 | cutterOnThrough: { 178 | title: "Laser: On - Through", description: "Persent of power to turn on the laser/plasma cutter in through mode", group: 4, 179 | type: "number", default_mm: 80, default_in: 80 180 | }, 181 | cutterOnEtch: { 182 | title: "Laser: On - Etch", description: "Persent of power to on the laser/plasma cutter in etch mode", group: 4, 183 | type: "number", default_mm: 40, default_in: 40 184 | }, 185 | cutterMarlinMode: { 186 | title: "Laser: Marlin/Reprap mode", description: "Marlin/Reprar mode of the laser/plasma cutter", group: 4, 187 | type: "integer", default_mm: 106, default_in: 106, 188 | values: [ 189 | { title: "M106 S{PWM}/M107", id: 106 }, 190 | { title: "M3 O{PWM}/M5", id: 3 }, 191 | { title: "M42 P{pin} S{PWM}", id: 42 }, 192 | ] 193 | }, 194 | cutterMarlinPin: { 195 | title: "Laser: Marlin M42 pin", description: "Marlin custom pin number for the laser/plasma cutter", group: 4, 196 | type: "integer", default_mm: 4, default_in: 4 197 | }, 198 | cutterGrblMode: { 199 | title: "Laser: GRBL mode", description: "GRBL mode of the laser/plasma cutter", group: 4, 200 | type: "integer", default_mm: 4, default_in: 4, 201 | values: [ 202 | { title: "M4 S{PWM}/M5 dynamic power", id: 4 }, 203 | { title: "M3 S{PWM}/M5 static power", id: 3 }, 204 | ] 205 | }, 206 | 207 | gcodeStartFile: { 208 | title: "Extern: Start File", description: "File with custom Gcode for header/start (in nc folder)", group: 5, 209 | type: "file", default_mm: "", default_in: "" 210 | }, 211 | gcodeStopFile: { 212 | title: "Extern: Stop File", description: "File with custom Gcode for footer/end (in nc folder)", group: 5, 213 | type: "file", default_mm: "", default_in: "" 214 | }, 215 | gcodeToolFile: { 216 | title: "Extern: Tool File", description: "File with custom Gcode for tool change (in nc folder)", group: 5, 217 | type: "file", default_mm: "", default_in: "" 218 | }, 219 | gcodeProbeFile: { 220 | title: "Extern: Probe File", description: "File with custom Gcode for tool probe (in nc folder)", group: 5, 221 | type: "file", default_mm: "", default_in: "" 222 | }, 223 | 224 | coolantA_Mode: { 225 | title: "Coolant: A Mode", description: "Enable issuing g-codes for control Coolant channel A", group: 6, type: "integer", 226 | default_mm: 0, default_in: 0, 227 | values: [ 228 | { title: "off", id: 0 }, 229 | { title: "flood", id: 1 }, 230 | { title: "mist", id: 2 }, 231 | { title: "throughTool", id: 3 }, 232 | { title: "air", id: 4 }, 233 | { title: "airThroughTool", id: 5 }, 234 | { title: "suction", id: 6 }, 235 | { title: "floodMist", id: 7 }, 236 | { title: "floodThroughTool", id: 8 } 237 | ] 238 | }, 239 | coolantAMarlinOn: { title: "Coolant: A On command", description: "GCode command to turn on Coolant channel A", group: 6, type: "string", default_mm: "M42 P11 S255" }, 240 | coolantAMarlinOff: { 241 | title: "Coolant: A Off command", description: "Gcode command to turn off Coolant A", group: 6, type: "string", 242 | default_mm: "M42 P11 S0", default_in: "M42 P11 S0" 243 | }, 244 | 245 | coolantB_Mode: { 246 | title: "Coolant: B Mode", description: "Enable issuing g-codes for control Coolant channel B", group: 6, type: "integer", 247 | default_mm: 0, default_in: 0, 248 | values: [ 249 | { title: "off", id: 0 }, 250 | { title: "flood", id: 1 }, 251 | { title: "mist", id: 2 }, 252 | { title: "throughTool", id: 3 }, 253 | { title: "air", id: 4 }, 254 | { title: "airThroughTool", id: 5 }, 255 | { title: "suction", id: 6 }, 256 | { title: "floodMist", id: 7 }, 257 | { title: "floodThroughTool", id: 8 } 258 | ] 259 | }, 260 | coolantBMarlinOn: { 261 | title: "Coolant: B On command", description: "GCode command to turn on Coolant channel B", group: 6, type: "string", 262 | default_mm: "M42 P6 S255", default_in: "M42 P6 S255" 263 | }, 264 | coolantBMarlinOff: { 265 | title: "Coolant: B Off command", description: "Gcode command to turn off Coolant channel B", group: 6, type: "string", 266 | default_mm: "M42 P6 S0", default_in: "M42 P6 S0" 267 | }, 268 | 269 | commentWriteTools: { 270 | title: "Comment: Write Tools", description: "Write table of used tools in job header", group: 7, 271 | type: "boolean", default_mm: true, default_in: true 272 | }, 273 | commentActivities: { 274 | title: "Comment: Activities", description: "Write comments which somehow helps to understand current piece of g-code", group: 7, 275 | type: "boolean", default_mm: true, default_in: true 276 | }, 277 | commentSections: { 278 | title: "Comment: Sections", description: "Write header of every section", group: 7, 279 | type: "boolean", default_mm: true, default_in: true 280 | }, 281 | commentCommands: { 282 | title: "Comment: Trace Commands", description: "Write stringified commands called by CAM", group: 7, 283 | type: "boolean", default_mm: true, default_in: true 284 | }, 285 | commentMovements: { 286 | title: "Comment: Trace Movements", description: "Write stringified movements called by CAM", group: 7, 287 | type: "boolean", default_mm: true, default_in: true 288 | }, 289 | 290 | }; 291 | 292 | // Internal properties 293 | certificationLevel = 2; 294 | extension = "gcode"; 295 | setCodePage("ascii"); 296 | capabilities = CAPABILITY_MILLING | CAPABILITY_JET; 297 | 298 | // vendor of MPCNC 299 | vendor = "guffy1234"; 300 | vendorUrl = "https://github.com/guffy1234/mpcnc_posts_processor"; 301 | 302 | var sequenceNumber; 303 | var currentWorkOffset; 304 | 305 | // Formats 306 | var gFormat = createFormat({ prefix: "G", decimals: 1 }); 307 | var mFormat = createFormat({ prefix: "M", decimals: 0 }); 308 | 309 | var xyzFormat = createFormat({ decimals: (unit == MM ? 3 : 4) }); 310 | var xFormat = createFormat({ prefix: "X", decimals: (unit == MM ? 3 : 4) }); 311 | var yFormat = createFormat({ prefix: "Y", decimals: (unit == MM ? 3 : 4) }); 312 | var zFormat = createFormat({ prefix: "Z", decimals: (unit == MM ? 3 : 4) }); 313 | var iFormat = createFormat({ prefix: "I", decimals: (unit == MM ? 3 : 4) }); 314 | var jFormat = createFormat({ prefix: "J", decimals: (unit == MM ? 3 : 4) }); 315 | var kFormat = createFormat({ prefix: "K", decimals: (unit == MM ? 3 : 4) }); 316 | 317 | var speedFormat = createFormat({ decimals: 0 }); 318 | var sFormat = createFormat({ prefix: "S", decimals: 0 }); 319 | 320 | var pFormat = createFormat({ prefix: "P", decimals: 0 }); 321 | var oFormat = createFormat({ prefix: "O", decimals: 0 }); 322 | 323 | var feedFormat = createFormat({ decimals: (unit == MM ? 0 : 2) }); 324 | var fFormat = createFormat({ prefix: "F", decimals: (unit == MM ? 0 : 2) }); 325 | 326 | var toolFormat = createFormat({ decimals: 0 }); 327 | var tFormat = createFormat({ prefix: "T", decimals: 0 }); 328 | 329 | var taperFormat = createFormat({ decimals: 1, scale: DEG }); 330 | var secFormat = createFormat({ decimals: 3, forceDecimal: true }); // seconds - range 0.001-1000 331 | 332 | // Linear outputs 333 | var xOutput = createVariable({}, xFormat); 334 | var yOutput = createVariable({}, yFormat); 335 | var zOutput = createVariable({}, zFormat); 336 | var fOutput = createVariable({}, fFormat); 337 | var sOutput = createVariable({ force: true }, sFormat); 338 | 339 | // Circular outputs 340 | var iOutput = createReferenceVariable({}, iFormat); 341 | var jOutput = createReferenceVariable({}, jFormat); 342 | var kOutput = createReferenceVariable({}, kFormat); 343 | 344 | // Modals 345 | var gMotionModal = createModal({}, gFormat); // modal group 1 // G0-G3, ... 346 | var gPlaneModal = createModal({ onchange: function () { gMotionModal.reset(); } }, gFormat); // modal group 2 // G17-19 347 | var gAbsIncModal = createModal({}, gFormat); // modal group 3 // G90-91 348 | var gFeedModeModal = createModal({}, gFormat); // modal group 5 // G93-94 349 | var gUnitModal = createModal({}, gFormat); // modal group 6 // G20-21 350 | 351 | 352 | // Arc support variables 353 | minimumChordLength = spatial(0.01, MM); 354 | minimumCircularRadius = spatial(0.01, MM); 355 | maximumCircularRadius = spatial(1000, MM); 356 | minimumCircularSweep = toRad(0.01); 357 | maximumCircularSweep = toRad(180); 358 | allowHelicalMoves = false; 359 | allowedCircularPlanes = undefined; 360 | 361 | /** 362 | Writes the specified block. 363 | */ 364 | function writeBlock() { 365 | if (properties.jobSequenceNumbers) { 366 | writeWords2("N" + sequenceNumber, arguments); 367 | sequenceNumber += properties.jobSequenceNumberIncrement; 368 | } else { 369 | writeWords(arguments); 370 | } 371 | } 372 | 373 | function FirmwareBase() { 374 | this.machineMode = undefined; //TYPE_MILLING, TYPE_JET 375 | } 376 | 377 | FirmwareBase.prototype.section = function () { 378 | this.machineMode = currentSection.type; 379 | } 380 | 381 | var currentFirmware; 382 | 383 | // Called in every new gcode file 384 | function onOpen() { 385 | currentFirmware.init(); 386 | 387 | sequenceNumber = properties.jobSequenceNumberStart; 388 | if (!properties.jobSeparateWordsWithSpace) { 389 | setWordSeparator(""); 390 | } 391 | 392 | currentWorkOffset = undefined; 393 | // don't allow WCS 0 unless it is the only WCS used in the program 394 | if ((getNumberOfSections() > 0) && (getSection(0).workOffset == 0)) { 395 | for (var i = 0; i < getNumberOfSections(); ++i) { 396 | if (getSection(i).workOffset > 0) { 397 | error(localize("Using multiple work offsets is not possible if the initial work offset is 0.")); 398 | return; 399 | } 400 | } 401 | } 402 | 403 | } 404 | 405 | // Called at end of gcode file 406 | function onClose() { 407 | writeActivityComment(" *** STOP begin ***"); 408 | currentFirmware.flushMotions(); 409 | if (properties.gcodeStopFile == "") { 410 | onCommand(COMMAND_COOLANT_OFF); 411 | if (properties.jobGoOriginOnFinish) { 412 | rapidMovementsXY(0, 0); 413 | } 414 | onCommand(COMMAND_STOP_SPINDLE); 415 | currentFirmware.end(); 416 | writeActivityComment(" *** STOP end ***"); 417 | } else { 418 | loadFile(properties.gcodeStopFile); 419 | } 420 | currentFirmware.close(); 421 | } 422 | 423 | var cutterOnCurrentPower; 424 | 425 | function onSection() { 426 | 427 | // Write Start gcode of the documment (after the "onParameters" with the global info) 428 | if (isFirstSection()) { 429 | writeFirstSection(); 430 | } 431 | writeActivityComment(" *** SECTION begin ***"); 432 | 433 | // Tool change 434 | if (properties.toolChangeEnabled && !isFirstSection() && tool.number != getPreviousSection().getTool().number) { 435 | if (properties.gcodeToolFile == "") { 436 | // Builtin tool change gcode 437 | writeActivityComment(" --- CHANGE TOOL begin ---"); 438 | currentFirmware.toolChange(); 439 | writeActivityComment(" --- CHANGE TOOL end ---"); 440 | } else { 441 | // Custom tool change gcode 442 | loadFile(properties.gcodeToolFile); 443 | } 444 | } 445 | 446 | if (properties.commentSections) { 447 | // Machining type 448 | if (currentSection.type == TYPE_MILLING) { 449 | // Specific milling code 450 | writeComment(sectionComment + " - Milling - Tool: " + tool.number + " - " + tool.comment + " " + getToolTypeName(tool.type)); 451 | } 452 | 453 | if (currentSection.type == TYPE_JET) { 454 | // Cutter mode used for different cutting power in PWM laser 455 | switch (currentSection.jetMode) { 456 | case JET_MODE_THROUGH: 457 | cutterOnCurrentPower = properties.cutterOnThrough; 458 | break; 459 | case JET_MODE_ETCHING: 460 | cutterOnCurrentPower = properties.cutterOnEtch; 461 | break; 462 | case JET_MODE_VAPORIZE: 463 | cutterOnCurrentPower = properties.cutterOnVaporize; 464 | break; 465 | default: 466 | error("Cutting mode is not supported."); 467 | } 468 | writeComment(sectionComment + " - Laser/Plasma - Cutting mode: " + getParameter("operation:cuttingMode")); 469 | } 470 | 471 | // Print min/max boundaries for each section 472 | vectorX = new Vector(1, 0, 0); 473 | vectorY = new Vector(0, 1, 0); 474 | writeComment(" X Min: " + xyzFormat.format(currentSection.getGlobalRange(vectorX).getMinimum()) + " - X Max: " + xyzFormat.format(currentSection.getGlobalRange(vectorX).getMaximum())); 475 | writeComment(" Y Min: " + xyzFormat.format(currentSection.getGlobalRange(vectorY).getMinimum()) + " - Y Max: " + xyzFormat.format(currentSection.getGlobalRange(vectorY).getMaximum())); 476 | writeComment(" Z Min: " + xyzFormat.format(currentSection.getGlobalZRange().getMinimum()) + " - Z Max: " + xyzFormat.format(currentSection.getGlobalZRange().getMaximum())); 477 | } 478 | 479 | currentFirmware.section(); //adjust mode 480 | 481 | onCommand(COMMAND_START_SPINDLE); 482 | onCommand(COMMAND_COOLANT_ON); 483 | // Display section name in LCD 484 | currentFirmware.display_text(" " + sectionComment); 485 | 486 | // wcs 487 | var workOffset = currentSection.workOffset; 488 | if (workOffset == 0) { // change work offset of 0 to 1 489 | warningOnce(localize("Work offset has not been specified. Using G54 as WCS."), 0); 490 | workOffset = 1; 491 | } 492 | 493 | if (workOffset > 0) { 494 | if (workOffset > 6) { // handle work offsets greater than 6 495 | var code = workOffset - 6; 496 | if (code > 3) { 497 | error(localize("Work offset out of range.")); 498 | return; 499 | } 500 | if (workOffset != currentWorkOffset) { 501 | writeBlock(gFormat.format(59) + "." + code); // G59.n 502 | currentWorkOffset = workOffset; 503 | } 504 | } else { // handle work offsets 1-6 505 | if (workOffset != currentWorkOffset) { 506 | writeBlock(gFormat.format(53 + workOffset)); // G54->G59 507 | currentWorkOffset = workOffset; 508 | } 509 | } 510 | } 511 | } 512 | 513 | function resetAll() 514 | { 515 | xOutput.reset(); 516 | yOutput.reset(); 517 | zOutput.reset(); 518 | fOutput.reset(); 519 | } 520 | 521 | // Called in every section end 522 | function onSectionEnd() { 523 | resetAll(); 524 | writeActivityComment(" *** SECTION end ***"); 525 | writeln(""); 526 | } 527 | 528 | function onComment(message) { 529 | writeComment(message); 530 | } 531 | 532 | var pendingRadiusCompensation = RADIUS_COMPENSATION_OFF; 533 | 534 | function onRadiusCompensation() { 535 | pendingRadiusCompensation = radiusCompensation; 536 | } 537 | // Rapid movements 538 | function onRapid(x, y, z) { 539 | rapidMovements(x, y, z); 540 | } 541 | 542 | // Feed movements 543 | function onLinear(x, y, z, feed) { 544 | linearMovements(x, y, z, feed); 545 | } 546 | 547 | function onRapid5D(_x, _y, _z, _a, _b, _c) { 548 | error(localize("Multi-axis motion is not supported.")); 549 | } 550 | 551 | function onLinear5D(_x, _y, _z, _a, _b, _c, feed) { 552 | error(localize("Multi-axis motion is not supported.")); 553 | } 554 | 555 | function onCircular(clockwise, cx, cy, cz, x, y, z, feed) { 556 | if (pendingRadiusCompensation != RADIUS_COMPENSATION_OFF) { 557 | error(localize("Radius compensation cannot be activated/deactivated for a circular move.")); 558 | return; 559 | } 560 | currentFirmware.circular(clockwise, cx, cy, cz, x, y, z, feed) 561 | } 562 | 563 | // Called on waterjet/plasma/laser cuts 564 | var powerState = false; 565 | 566 | function onPower(power) { 567 | if (power != powerState) { 568 | if (power) { 569 | writeActivityComment(" >>> LASER Power ON"); 570 | currentFirmware.laserOn(cutterOnCurrentPower); 571 | } else { 572 | writeActivityComment(" >>> LASER Power OFF"); 573 | currentFirmware.laserOff(); 574 | } 575 | powerState = power; 576 | } 577 | } 578 | 579 | // Called on Dwell Manual NC invocation 580 | function onDwell(seconds) { 581 | if (seconds > 99999.999) { 582 | warning(localize("Dwelling time is out of range.")); 583 | } 584 | writeActivityComment(" >>> Dwell"); 585 | currentFirmware.dwell(seconds); 586 | } 587 | 588 | // Called with every parameter in the documment/section 589 | function onParameter(name, value) { 590 | 591 | // Write gcode initial info 592 | // Product version 593 | if (name == "generated-by") { 594 | writeComment(value); 595 | writeComment(" Posts processor: " + FileSystem.getFilename(getConfigurationPath())); 596 | } 597 | // Date 598 | if (name == "generated-at") writeComment(" Gcode generated: " + value + " GMT"); 599 | // Document 600 | if (name == "document-path") writeComment(" Document: " + value); 601 | // Setup 602 | if (name == "job-description") writeComment(" Setup: " + value); 603 | 604 | // Get section comment 605 | if (name == "operation-comment") sectionComment = value; 606 | } 607 | 608 | function onMovement(movement) { 609 | if (properties.commentMovements) { 610 | var jet = tool.isJetTool && tool.isJetTool(); 611 | var id; 612 | switch (movement) { 613 | case MOVEMENT_RAPID: 614 | id = "MOVEMENT_RAPID"; 615 | break; 616 | case MOVEMENT_LEAD_IN: 617 | id = "MOVEMENT_LEAD_IN"; 618 | break; 619 | case MOVEMENT_CUTTING: 620 | id = "MOVEMENT_CUTTING"; 621 | break; 622 | case MOVEMENT_LEAD_OUT: 623 | id = "MOVEMENT_LEAD_OUT"; 624 | break; 625 | case MOVEMENT_LINK_TRANSITION: 626 | id = jet ? "MOVEMENT_BRIDGING" : "MOVEMENT_LINK_TRANSITION"; 627 | break; 628 | case MOVEMENT_LINK_DIRECT: 629 | id = "MOVEMENT_LINK_DIRECT"; 630 | break; 631 | case MOVEMENT_RAMP_HELIX: 632 | id = jet ? "MOVEMENT_PIERCE_CIRCULAR" : "MOVEMENT_RAMP_HELIX"; 633 | break; 634 | case MOVEMENT_RAMP_PROFILE: 635 | id = jet ? "MOVEMENT_PIERCE_PROFILE" : "MOVEMENT_RAMP_PROFILE"; 636 | break; 637 | case MOVEMENT_RAMP_ZIG_ZAG: 638 | id = jet ? "MOVEMENT_PIERCE_LINEAR" : "MOVEMENT_RAMP_ZIG_ZAG"; 639 | break; 640 | case MOVEMENT_RAMP: 641 | id = "MOVEMENT_RAMP"; 642 | break; 643 | case MOVEMENT_PLUNGE: 644 | id = jet ? "MOVEMENT_PIERCE" : "MOVEMENT_PLUNGE"; 645 | break; 646 | case MOVEMENT_PREDRILL: 647 | id = "MOVEMENT_PREDRILL"; 648 | break; 649 | case MOVEMENT_EXTENDED: 650 | id = "MOVEMENT_EXTENDED"; 651 | break; 652 | case MOVEMENT_REDUCED: 653 | id = "MOVEMENT_REDUCED"; 654 | break; 655 | case MOVEMENT_HIGH_FEED: 656 | id = "MOVEMENT_HIGH_FEED"; 657 | break; 658 | case MOVEMENT_FINISH_CUTTING: 659 | id = "MOVEMENT_FINISH_CUTTING"; 660 | break; 661 | } 662 | if (id == undefined) { 663 | id = String(movement); 664 | } 665 | writeComment(" " + id); 666 | } 667 | } 668 | 669 | var currentSpindleSpeed = 0; 670 | 671 | function setSpindeSpeed(_spindleSpeed, _clockwise) { 672 | if (currentSpindleSpeed != _spindleSpeed) { 673 | if (_spindleSpeed > 0) { 674 | currentFirmware.spindleOn(_spindleSpeed, _clockwise); 675 | } else { 676 | currentFirmware.spindleOff(); 677 | } 678 | currentSpindleSpeed = _spindleSpeed; 679 | } 680 | } 681 | 682 | function onSpindleSpeed(spindleSpeed) { 683 | setSpindeSpeed(spindleSpeed, tool.clockwise); 684 | } 685 | 686 | function onCommand(command) { 687 | if (properties.commentActivities) { 688 | var stringId = getCommandStringId(command); 689 | writeComment(" " + stringId); 690 | } 691 | switch (command) { 692 | case COMMAND_START_SPINDLE: 693 | onCommand(tool.clockwise ? COMMAND_SPINDLE_CLOCKWISE : COMMAND_SPINDLE_COUNTERCLOCKWISE); 694 | return; 695 | case COMMAND_SPINDLE_CLOCKWISE: 696 | if (tool.jetTool) 697 | return; 698 | setSpindeSpeed(spindleSpeed, true); 699 | return; 700 | case COMMAND_SPINDLE_COUNTERCLOCKWISE: 701 | if (tool.jetTool) 702 | return; 703 | setSpindeSpeed(spindleSpeed, false); 704 | return; 705 | case COMMAND_STOP_SPINDLE: 706 | if (tool.jetTool) 707 | return; 708 | setSpindeSpeed(0, true); 709 | return; 710 | case COMMAND_COOLANT_ON: 711 | setCoolant(tool.coolant); 712 | return; 713 | case COMMAND_COOLANT_OFF: 714 | setCoolant(0); //COOLANT_DISABLED 715 | return; 716 | case COMMAND_LOCK_MULTI_AXIS: 717 | return; 718 | case COMMAND_UNLOCK_MULTI_AXIS: 719 | return; 720 | case COMMAND_BREAK_CONTROL: 721 | return; 722 | case COMMAND_TOOL_MEASURE: 723 | if (tool.jetTool) 724 | return; 725 | currentFirmware.probeTool(); 726 | return; 727 | case COMMAND_STOP: 728 | writeBlock(mFormat.format(0)); 729 | return; 730 | } 731 | } 732 | 733 | function writeFirstSection() { 734 | // dump tool information 735 | var toolZRanges = {}; 736 | var vectorX = new Vector(1, 0, 0); 737 | var vectorY = new Vector(0, 1, 0); 738 | var ranges = { 739 | x: { min: undefined, max: undefined }, 740 | y: { min: undefined, max: undefined }, 741 | z: { min: undefined, max: undefined }, 742 | }; 743 | var handleMinMax = function(pair, range) { 744 | var rmin = range.getMinimum(); 745 | var rmax = range.getMaximum(); 746 | if (pair.min == undefined || pair.min > rmin) { 747 | pair.min = rmin; 748 | } 749 | if (pair.max == undefined || pair.max < rmax) { 750 | pair.max = rmax; 751 | } 752 | } 753 | 754 | var numberOfSections = getNumberOfSections(); 755 | for (var i = 0; i < numberOfSections; ++i) { 756 | var section = getSection(i); 757 | var tool = section.getTool(); 758 | var zRange = section.getGlobalZRange(); 759 | var xRange = section.getGlobalRange(vectorX); 760 | var yRange = section.getGlobalRange(vectorY); 761 | handleMinMax(ranges.x, xRange); 762 | handleMinMax(ranges.y, yRange); 763 | handleMinMax(ranges.z, zRange); 764 | if (is3D() && properties.commentWriteTools) { 765 | if (toolZRanges[tool.number]) { 766 | toolZRanges[tool.number].expandToRange(zRange); 767 | } else { 768 | toolZRanges[tool.number] = zRange; 769 | } 770 | } 771 | } 772 | 773 | writeComment(" "); 774 | writeComment(" Ranges table:"); 775 | writeComment(" X: Min=" + xyzFormat.format(ranges.x.min) + " Max=" + xyzFormat.format(ranges.x.max) + " Size=" + xyzFormat.format(ranges.x.max - ranges.x.min)); 776 | writeComment(" Y: Min=" + xyzFormat.format(ranges.y.min) + " Max=" + xyzFormat.format(ranges.y.max) + " Size=" + xyzFormat.format(ranges.y.max - ranges.y.min)); 777 | writeComment(" Z: Min=" + xyzFormat.format(ranges.z.min) + " Max=" + xyzFormat.format(ranges.z.max) + " Size=" + xyzFormat.format(ranges.z.max - ranges.z.min)); 778 | 779 | if (properties.commentWriteTools) { 780 | writeComment(" "); 781 | writeComment(" Tools table:"); 782 | var tools = getToolTable(); 783 | if (tools.getNumberOfTools() > 0) { 784 | for (var i = 0; i < tools.getNumberOfTools(); ++i) { 785 | var tool = tools.getTool(i); 786 | var comment = " T" + toolFormat.format(tool.number) + " D=" + xyzFormat.format(tool.diameter) + " CR=" + xyzFormat.format(tool.cornerRadius); 787 | if ((tool.taperAngle > 0) && (tool.taperAngle < Math.PI)) { 788 | comment += " TAPER=" + taperFormat.format(tool.taperAngle) + "deg"; 789 | } 790 | if (toolZRanges[tool.number]) { 791 | comment += " - ZMIN=" + xyzFormat.format(toolZRanges[tool.number].getMinimum()); 792 | } 793 | comment += " - " + getToolTypeName(tool.type) + " " + tool.comment; 794 | writeComment(comment); 795 | } 796 | } 797 | } 798 | writeln(""); 799 | writeActivityComment(" *** START begin ***"); 800 | 801 | if (properties.gcodeStartFile == "") { 802 | currentFirmware.start(); 803 | } else { 804 | loadFile(properties.gcodeStartFile); 805 | } 806 | writeActivityComment(" *** START end ***"); 807 | writeln(""); 808 | } 809 | 810 | // Output a comment 811 | function writeComment(text) { 812 | currentFirmware.comment(text); 813 | } 814 | 815 | // Rapid movements with G1 and differentiated travel speeds for XY and Z 816 | function rapidMovementsXY(_x, _y) { 817 | var x = xOutput.format(_x); 818 | var y = yOutput.format(_y); 819 | if (x || y) { 820 | if (pendingRadiusCompensation != RADIUS_COMPENSATION_OFF) { 821 | error(localize("Radius compensation mode cannot be changed at rapid traversal.")); 822 | return; 823 | } 824 | f = fOutput.format(propertyMmToUnit(properties.jobTravelSpeedXY)); 825 | writeBlock(gMotionModal.format(0), x, y, f); 826 | } 827 | } 828 | function rapidMovementsZ(_z) { 829 | var z = zOutput.format(_z); 830 | if (z) { 831 | if (pendingRadiusCompensation != RADIUS_COMPENSATION_OFF) { 832 | error(localize("Radius compensation mode cannot be changed at rapid traversal.")); 833 | return; 834 | } 835 | f = fOutput.format(propertyMmToUnit(properties.jobTravelSpeedZ)); 836 | writeBlock(gMotionModal.format(0), z, f); 837 | } 838 | } 839 | 840 | function rapidMovements(_x, _y, _z) { 841 | rapidMovementsZ(_z); 842 | rapidMovementsXY(_x, _y); 843 | } 844 | 845 | // Linear movements 846 | function linearMovements(_x, _y, _z, _feed) { 847 | if (pendingRadiusCompensation != RADIUS_COMPENSATION_OFF) { 848 | // ensure that we end at desired position when compensation is turned off 849 | xOutput.reset(); 850 | yOutput.reset(); 851 | } 852 | var x = xOutput.format(_x); 853 | var y = yOutput.format(_y); 854 | var z = zOutput.format(_z); 855 | var f = fOutput.format(_feed); 856 | if (x || y || z) { 857 | if (pendingRadiusCompensation != RADIUS_COMPENSATION_OFF) { 858 | error(localize("Radius compensation mode is not supported.")); 859 | return; 860 | } else { 861 | writeBlock(gMotionModal.format(1), x, y, z, f); 862 | } 863 | } else if (f) { 864 | if (getNextRecord().isMotion()) { // try not to output feed without motion 865 | fOutput.reset(); // force feed on next line 866 | } else { 867 | writeBlock(gMotionModal.format(1), f); 868 | } 869 | } 870 | } 871 | 872 | // Test if file exist/can read and load it 873 | function loadFile(_file) { 874 | var folder = FileSystem.getFolderPath(getOutputPath()) + PATH_SEPARATOR; 875 | if (FileSystem.isFile(folder + _file)) { 876 | var txt = loadText(folder + _file, "utf-8"); 877 | if (txt.length > 0) { 878 | writeActivityComment(" --- Start custom gcode " + folder + _file); 879 | write(txt); 880 | writeActivityComment(" --- End custom gcode " + folder + _file); 881 | writeln(""); 882 | } 883 | } else { 884 | writeComment(" Can't open file " + folder + _file); 885 | error("Can't open file " + folder + _file); 886 | } 887 | } 888 | 889 | var currentCoolantMode = 0; 890 | 891 | // Manage coolant state 892 | function setCoolant(coolant) { 893 | if (currentCoolantMode == coolant) { 894 | return; 895 | } 896 | if (properties.coolantA_Mode != 0) { 897 | if (currentCoolantMode == properties.coolantA_Mode) { 898 | writeActivityComment(" >>> Coolant A OFF"); 899 | currentFirmware.coolantA(true); 900 | } else if (coolant == properties.coolantA_Mode) { 901 | writeActivityComment(" >>> Coolant A ON"); 902 | currentFirmware.coolantA(false); 903 | } 904 | } 905 | if (properties.coolantB_Mode != 0) { 906 | if (currentCoolantMode == properties.coolantB_Mode) { 907 | writeActivityComment(" >>> Coolant B OFF"); 908 | currentFirmware.coolantB(true); 909 | } else if (coolant == properties.coolantB_Mode) { 910 | writeActivityComment(" >>> Coolant B ON"); 911 | currentFirmware.coolantB(false); 912 | } 913 | } 914 | currentCoolantMode = coolant; 915 | } 916 | 917 | function propertyMmToUnit(_v) { 918 | return (_v / (unit == IN ? 25.4 : 1)); 919 | } 920 | 921 | function writeActivityComment(_comment) { 922 | if (properties.commentActivities) { 923 | writeComment(_comment); 924 | } 925 | } 926 | 927 | function mergeProperties(to, from) 928 | { 929 | for (var attrname in from) { 930 | to[attrname] = from[attrname]; 931 | } 932 | } 933 | 934 | function Firmware3dPrinterLike() { 935 | FirmwareBase.apply(this, arguments); 936 | this.spindleEnabled= false; 937 | } 938 | Firmware3dPrinterLike.prototype = Object.create(FirmwareBase.prototype); 939 | Firmware3dPrinterLike.prototype.constructor = Firmware3dPrinterLike; 940 | Firmware3dPrinterLike.prototype.init = function () { 941 | gMotionModal = createModal({ force: true }, gFormat); // modal group 1 // G0-G3, ... 942 | if (properties.jobMarlinEnforceFeedrate) { 943 | fOutput = createVariable({ force: true }, fFormat); 944 | } 945 | } 946 | Firmware3dPrinterLike.prototype.start = function () { 947 | writeBlock(gAbsIncModal.format(90)); // Set to Absolute Positioning 948 | writeBlock(gUnitModal.format(unit == IN ? 20 : 21)); 949 | writeBlock(mFormat.format(84), sFormat.format(0)); // Disable steppers timeout 950 | if (properties.jobSetOriginOnStart) { 951 | writeBlock(gFormat.format(92), xFormat.format(0), yFormat.format(0), zFormat.format(0)); // Set origin to initial position 952 | } 953 | if (properties.probeOnStart && tool.number != 0 && !tool.jetTool) { 954 | onCommand(COMMAND_TOOL_MEASURE); 955 | } 956 | } 957 | Firmware3dPrinterLike.prototype.end = function () { 958 | this.display_text("Job end"); 959 | } 960 | Firmware3dPrinterLike.prototype.close = function () { 961 | } 962 | Firmware3dPrinterLike.prototype.comment = function (text) { 963 | writeln(";" + String(text).replace(/[\(\)]/g, "")); 964 | } 965 | Firmware3dPrinterLike.prototype.flushMotions = function () { 966 | writeBlock(mFormat.format(400)); 967 | } 968 | Firmware3dPrinterLike.prototype.spindleOn = function (_spindleSpeed, _clockwise) { 969 | if (properties.jobManualSpindlePowerControl) { 970 | // for manual any positive input speed assumed as enabled. so it's just a flag 971 | if (!this.spindleEnabled) { 972 | this.askUser("Turn ON " + speedFormat.format(_spindleSpeed) + "RPM", "Spindle", false); 973 | } 974 | } else { 975 | writeActivityComment(" >>> Spindle Speed " + speedFormat.format(_spindleSpeed)); 976 | writeBlock(mFormat.format(_clockwise ? 3 : 4), sOutput.format(spindleSpeed)); 977 | } 978 | this.spindleEnabled = true; 979 | } 980 | Firmware3dPrinterLike.prototype.spindleOff = function () { 981 | if (properties.jobManualSpindlePowerControl) { 982 | writeBlock(mFormat.format(300), sFormat.format(300), pFormat.format(3000)); 983 | this.askUser("Turn OFF spindle", "Spindle", false); 984 | } else { 985 | writeBlock(mFormat.format(5)); 986 | } 987 | this.spindleEnabled = false; 988 | } 989 | Firmware3dPrinterLike.prototype.laserOn = function (power) { 990 | var laser_pwm = power / 100 * 255; 991 | switch (properties.cutterMarlinMode) { 992 | case 106: 993 | writeBlock(mFormat.format(106), sFormat.format(laser_pwm)); 994 | break; 995 | case 3: 996 | writeBlock(mFormat.format(3), oFormat.format(laser_pwm)); 997 | break; 998 | case 42: 999 | writeBlock(mFormat.format(42), pFormat.format(properties.cutterMarlinPin), sFormat.format(laser_pwm)); 1000 | break; 1001 | } 1002 | } 1003 | Firmware3dPrinterLike.prototype.laserOff = function () { 1004 | switch (properties.cutterMarlinMode) { 1005 | case 106: 1006 | writeBlock(mFormat.format(107)); 1007 | break; 1008 | case 3: 1009 | writeBlock(mFormat.format(5)); 1010 | break; 1011 | case 42: 1012 | writeBlock(mFormat.format(42), pFormat.format(properties.cutterMarlinPin), sFormat.format(0)); 1013 | break; 1014 | } 1015 | } 1016 | Firmware3dPrinterLike.prototype.coolantA = function (on) { 1017 | writeBlock(on ? properties.coolantAMarlinOn : properties.coolantAMarlinOff); 1018 | } 1019 | Firmware3dPrinterLike.prototype.coolantB = function (on) { 1020 | writeBlock(on ? properties.coolantBMarlinOn : roperties.coolantBMarlinOff); 1021 | } 1022 | Firmware3dPrinterLike.prototype.dwell = function (seconds) { 1023 | writeBlock(gFormat.format(4), "S" + secFormat.format(seconds)); 1024 | } 1025 | Firmware3dPrinterLike.prototype.display_text = function (txt) { 1026 | writeBlock(mFormat.format(117), (properties.jobSeparateWordsWithSpace ? "" : " ") + txt); 1027 | } 1028 | Firmware3dPrinterLike.prototype.circular = function (clockwise, cx, cy, cz, x, y, z, feed) { 1029 | if (!properties.jobUseArcs) { 1030 | linearize(tolerance); 1031 | return; 1032 | } 1033 | // Marlin supports arcs only on XY plane 1034 | var start = getCurrentPosition(); 1035 | if (isFullCircle()) { 1036 | if (isHelical()) { 1037 | linearize(tolerance); 1038 | return; 1039 | } 1040 | switch (getCircularPlane()) { 1041 | case PLANE_XY: 1042 | writeBlock(gMotionModal.format(clockwise ? 2 : 3), xOutput.format(x), iOutput.format(cx - start.x, 0), jOutput.format(cy - start.y, 0), fOutput.format(feed)); 1043 | break; 1044 | default: 1045 | linearize(tolerance); 1046 | } 1047 | } else { 1048 | switch (getCircularPlane()) { 1049 | case PLANE_XY: 1050 | writeBlock(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)); 1051 | break; 1052 | default: 1053 | linearize(tolerance); 1054 | } 1055 | } 1056 | } 1057 | 1058 | Firmware3dPrinterLike.prototype.askUser = function (text, title, allowJog) { 1059 | writeBlock(mFormat.format(0), (properties.jobSeparateWordsWithSpace ? "" : " ") + text); 1060 | } 1061 | 1062 | Firmware3dPrinterLike.prototype.toolChange = function () { 1063 | this.flushMotions(); 1064 | // Go to tool change position 1065 | onRapid(propertyMmToUnit(properties.toolChangeX), propertyMmToUnit(properties.toolChangeY), propertyMmToUnit(properties.toolChangeZ)); 1066 | currentFirmware.flushMotions(); 1067 | // turn off spindle and coolant 1068 | onCommand(COMMAND_COOLANT_OFF); 1069 | onCommand(COMMAND_STOP_SPINDLE); 1070 | if (!properties.jobManualSpindlePowerControl) { 1071 | // Beep 1072 | writeBlock(mFormat.format(300), sFormat.format(400), pFormat.format(2000)); 1073 | } 1074 | 1075 | // Disable Z stepper 1076 | if (properties.toolChangeDisableZStepper) { 1077 | this.askUser("Z Stepper will disabled. Wait for STOP!!", "Tool change", false); 1078 | writeBlock(mFormat.format(17), 'Z'); // Disable steppers timeout 1079 | } 1080 | // Ask tool change and wait user to touch lcd button 1081 | this.askUser("Tool " + tool.number + " " + tool.comment, "Tool change", true); 1082 | 1083 | // Run Z probe gcode 1084 | if (properties.toolChangeZProbe && tool.number != 0) { 1085 | onCommand(COMMAND_TOOL_MEASURE); 1086 | } 1087 | } 1088 | Firmware3dPrinterLike.prototype.probeTool = function () { 1089 | this.askUser("Attach ZProbe", "Probe", false); 1090 | // refer http://marlinfw.org/docs/gcode/G038.html 1091 | if (properties.probeUseHomeZ) { 1092 | writeBlock(gFormat.format(28), 'Z'); 1093 | } else { 1094 | writeBlock(gMotionModal.format(38.3), fFormat.format(propertyMmToUnit(properties.probeG38Speed)), zFormat.format(propertyMmToUnit(properties.probeG38Target))); 1095 | } 1096 | writeBlock(gFormat.format(92), zFormat.format(propertyMmToUnit(properties.probeThickness))); // Set origin to initial position 1097 | resetAll(); 1098 | if (properties.toolChangeZ != "") { // move up tool to safe height again after probing 1099 | rapidMovementsZ(propertyMmToUnit(properties.toolChangeZ)); 1100 | } 1101 | this.flushMotions(); 1102 | this.askUser("Detach ZProbe", "Probe", false); 1103 | } 1104 | 1105 | properties3dPrinter = { 1106 | jobMarlinEnforceFeedrate: false, // Add feedrate to each movement line 1107 | 1108 | cutterMarlinMode: 106, // Marlin mode laser/plasma cutter 1109 | cutterMarlinPin: 4, // Marlin laser/plasma cutter pin for M42 1110 | 1111 | coolantAMarlinOn: "M42 P11 S255", // GCode command to turn on Coolant channel A 1112 | coolantAMarlinOff: "M42 P11 S0", // Gcode command to turn off Coolant channel A 1113 | coolantBMarlinOn: "M42 P6 S255", // GCode command to turn on Coolant channel B 1114 | coolantBMarlinOff: "M42 P6 S0", // Gcode command to turn off Coolant channel B 1115 | }; 1116 | 1117 | propertyDefinitions3dPrinter = { 1118 | jobMarlinEnforceFeedrate: { 1119 | title: "Job: Enforce Feedrate", description: "Add feedrate to each movement g-code", group: 1, 1120 | type: "boolean", default_mm: false, default_in: false 1121 | }, 1122 | cutterMarlinMode: { 1123 | title: "Laser: Marlin/Reprap mode", description: "Marlin/Reprar mode of the laser/plasma cutter", group: 4, 1124 | type: "integer", default_mm: 106, default_in: 106, 1125 | values: [ 1126 | { title: "M106 S{PWM}/M107", id: 106 }, 1127 | { title: "M3 O{PWM}/M5", id: 3 }, 1128 | { title: "M42 P{pin} S{PWM}", id: 42 }, 1129 | ] 1130 | }, 1131 | cutterMarlinPin: { 1132 | title: "Laser: Marlin M42 pin", description: "Marlin custom pin number for the laser/plasma cutter", group: 4, 1133 | type: "integer", default_mm: 4, default_in: 4 1134 | }, 1135 | 1136 | coolantAMarlinOn: { title: "Coolant: A On command", description: "GCode command to turn on Coolant channel A", group: 6, type: "string", default_mm: "M42 P11 S255" }, 1137 | coolantAMarlinOff: { 1138 | title: "Coolant: A Off command", description: "Gcode command to turn off Coolant A", group: 6, type: "string", 1139 | default_mm: "M42 P11 S0", default_in: "M42 P11 S0" 1140 | }, 1141 | 1142 | coolantBMarlinOn: { 1143 | title: "Coolant: B On command", description: "GCode command to turn on Coolant channel B", group: 6, type: "string", 1144 | default_mm: "M42 P6 S255", default_in: "M42 P6 S255" 1145 | }, 1146 | coolantBMarlinOff: { 1147 | title: "Coolant: B Off command", description: "Gcode command to turn off Coolant channel B", group: 6, type: "string", 1148 | default_mm: "M42 P6 S0", default_in: "M42 P6 S0" 1149 | }, 1150 | }; 1151 | -------------------------------------------------------------------------------- /DIYCNC_Grbl11.cps: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | https://github.com/guffy1234/mpcnc_posts_processor 4 | 5 | MPCNC posts processor for milling and laser/plasma cutting. 6 | 7 | */ 8 | include("DIYCNC_Common.js"); 9 | 10 | description = "DIYCNC Milling/Laser - Grbl 1.1"; 11 | 12 | // user-defined properties 13 | mergeProperties(properties, { 14 | cutterGrblMode: 4, // GRBL mode laser/plasma cutter 15 | coolantAGrbl: 7, // GCode command to turn on Coolant channel A 16 | coolantBGrbl: 8, // GCode command to turn on Coolant channel A 17 | }); 18 | 19 | mergeProperties(propertyDefinitions, { 20 | cutterGrblMode: { 21 | title: "Laser: GRBL mode", description: "GRBL mode of the laser/plasma cutter", group: 4, 22 | type: "integer", default_mm: 4, default_in: 4, 23 | values: [ 24 | { title: "M4 S{PWM}/M5 dynamic power", id: 4 }, 25 | { title: "M3 S{PWM}/M5 static power", id: 3 }, 26 | ] 27 | }, 28 | coolantAGrbl: { 29 | title: "Coolant: A code", description: "GRBL g-codes for control Coolant channel A", group: 6, type: "integer", 30 | default_mm: 7, default_in: 7, 31 | values: [ 32 | { title: "M7 flood", id: 7 }, 33 | { title: "M8 mist", id: 8 }, 34 | ] 35 | }, 36 | coolantBGrbl: { 37 | title: "Coolant: B code", description: "GRBL g-codes for control Coolant channel B", group: 6, type: "integer", 38 | default_mm: 8, default_in: 8, 39 | values: [ 40 | { title: "M7 flood", id: 7 }, 41 | { title: "M8 mist", id: 8 }, 42 | ] 43 | }, 44 | }); 45 | 46 | function FirmwareGrbl() { 47 | FirmwareBase.apply(this, arguments); 48 | } 49 | 50 | FirmwareGrbl.prototype = Object.create(FirmwareBase.prototype); 51 | FirmwareGrbl.prototype.constructor = FirmwareGrbl; 52 | FirmwareGrbl.prototype.init = function () { 53 | gMotionModal = createModal({}, gFormat); // modal group 1 // G0-G3, ... 54 | writeln("%"); 55 | } 56 | FirmwareGrbl.prototype.start = function () { 57 | writeBlock(gAbsIncModal.format(90)); // Set to Absolute Positioning 58 | writeBlock(gFeedModeModal.format(94)); 59 | writeBlock(gPlaneModal.format(17)); 60 | writeBlock(gUnitModal.format(unit == IN ? 20 : 21)); 61 | } 62 | FirmwareGrbl.prototype.end = function () { 63 | writeBlock(mFormat.format(30)); 64 | } 65 | FirmwareGrbl.prototype.close = function () { 66 | writeln("%"); 67 | } 68 | FirmwareGrbl.prototype.comment = function (text) { 69 | writeln("(" + String(text).replace(/[\(\)]/g, "") + ")"); 70 | } 71 | FirmwareGrbl.prototype.flushMotions = function () { 72 | }, 73 | FirmwareGrbl.prototype.spindleOn = function (_spindleSpeed, _clockwise) { 74 | writeActivityComment(" >>> Spindle Speed " + speedFormat.format(_spindleSpeed)); 75 | writeBlock(mFormat.format(_clockwise ? 3 : 4), sOutput.format(spindleSpeed)); 76 | } 77 | FirmwareGrbl.prototype.spindleOff = function () { 78 | writeBlock(mFormat.format(5)); 79 | } 80 | FirmwareGrbl.prototype.laserOn = function (power) { 81 | var laser_pwm = power / 100 * 255; 82 | writeBlock(mFormat.format(properties.cutterGrblMode), sFormat.format(laser_pwm)); 83 | } 84 | FirmwareGrbl.prototype.laserOff = function () { 85 | writeBlock(mFormat.format(5)); 86 | } 87 | FirmwareGrbl.prototype.coolantA = function (on) { 88 | writeBlock(mFormat.format(on ? properties.coolantAGrbl : 9)); 89 | } 90 | FirmwareGrbl.prototype.coolantB = function (on) { 91 | writeBlock(mFormat.format(on ? properties.coolantBGrbl : 9)); 92 | } 93 | FirmwareGrbl.prototype.dwell = function (seconds) { 94 | seconds = clamp(0.001, seconds, 99999.999); 95 | writeBlock(gFormat.format(4), "P" + secFormat.format(seconds)); 96 | } 97 | FirmwareGrbl.prototype.display_text = function (txt) { 98 | } 99 | FirmwareGrbl.prototype.circular = function (clockwise, cx, cy, cz, x, y, z, feed) { 100 | if (!properties.jobUseArcs) { 101 | linearize(tolerance); 102 | return; 103 | } 104 | var start = getCurrentPosition(); 105 | 106 | if (isFullCircle()) { 107 | if (isHelical()) { 108 | linearize(tolerance); 109 | return; 110 | } 111 | switch (getCircularPlane()) { 112 | case PLANE_XY: 113 | 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)); 114 | break; 115 | case PLANE_ZX: 116 | 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)); 117 | break; 118 | case PLANE_YZ: 119 | 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)); 120 | break; 121 | default: 122 | linearize(tolerance); 123 | } 124 | } else { 125 | switch (getCircularPlane()) { 126 | case PLANE_XY: 127 | 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)); 128 | break; 129 | case PLANE_ZX: 130 | 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)); 131 | break; 132 | case PLANE_YZ: 133 | 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)); 134 | break; 135 | default: 136 | linearize(tolerance); 137 | } 138 | } 139 | } 140 | FirmwareGrbl.prototype.toolChange = function () { 141 | writeBlock(mFormat.format(6), tFormat.format(tool.number)); 142 | writeBlock(gFormat.format(54)); 143 | } 144 | FirmwareGrbl.prototype.probeTool = function () { 145 | } 146 | 147 | currentFirmware = new FirmwareGrbl(); -------------------------------------------------------------------------------- /DIYCNC_Marlin20.cps: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | https://github.com/guffy1234/mpcnc_posts_processor 4 | 5 | MPCNC posts processor for milling and laser/plasma cutting. 6 | 7 | */ 8 | include("DIYCNC_Common.js"); 9 | 10 | description = "DIYCNC Milling/Laser - Marlin 2.0"; 11 | 12 | mergeProperties(properties, properties3dPrinter); 13 | mergeProperties(propertyDefinitions, propertyDefinitions3dPrinter); 14 | 15 | function FirmwareMarlin20() { 16 | Firmware3dPrinterLike.apply(this, arguments); 17 | } 18 | FirmwareMarlin20.prototype = Object.create(Firmware3dPrinterLike.prototype); 19 | FirmwareMarlin20.prototype.constructor = FirmwareMarlin20; 20 | 21 | currentFirmware = new FirmwareMarlin20(); 22 | -------------------------------------------------------------------------------- /DIYCNC_RepRapFW.cps: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | https://github.com/guffy1234/mpcnc_posts_processor 4 | 5 | MPCNC posts processor for milling and laser/plasma cutting. 6 | 7 | */ 8 | include("DIYCNC_Common.js"); 9 | 10 | description = "DIYCNC Milling/Laser - RepRapFirmware"; 11 | 12 | // user-defined properties 13 | mergeProperties(properties, properties3dPrinter); 14 | mergeProperties(propertyDefinitions, propertyDefinitions3dPrinter); 15 | 16 | mergeProperties(properties, { 17 | jobDuetMillingMode: "M453 P2 I0 R30000 F200", // GCode command to setup Duet3d milling mode 18 | jobDuetLaserMode: "M452 P2 I0 R255 F200", // GCode command to setup Duet3d laser mode 19 | }); 20 | mergeProperties(propertyDefinitions, { 21 | jobDuetMillingMode: { 22 | title: "Job: Duet Milling mode", description: "GCode command to setup Duet3d milling mode", group: 1, type: "string", 23 | default_mm: "M453 P2 I0 R30000 F200", default_in: "M453 P2 I0 R30000 F200" 24 | }, 25 | jobDuetLaserMode: { 26 | title: "Job: Duet Laser mode", description: "GCode command to setup Duet3d laser mode", group: 1, type: "string", 27 | default_mm: "M452 P2 I0 R255 F200", default_in: "M452 P2 I0 R255 F200" 28 | }, 29 | }); 30 | 31 | 32 | function FirmwareRepRap() { 33 | Firmware3dPrinterLike.apply(this, arguments); 34 | } 35 | FirmwareRepRap.prototype = Object.create(Firmware3dPrinterLike.prototype); 36 | FirmwareRepRap.prototype.constructor = FirmwareRepRap; 37 | FirmwareRepRap.prototype.askUser = function (text, title, allowJog) { 38 | var v1 = " P\"" + text + "\" R\"" + title + "\" S3"; 39 | var v2 = allowJog ? " X1 Y1 Z1" : ""; 40 | writeBlock(mFormat.format(291), (properties.jobSeparateWordsWithSpace ? "" : " ") + v1 + v2); 41 | } 42 | FirmwareRepRap.prototype.section = function () { 43 | if (this.machineMode != currentSection.type) { 44 | switch (currentSection.type) { 45 | case TYPE_MILLING: 46 | writeBlock(properties.jobDuetMillingMode); 47 | break; 48 | case TYPE_JET: 49 | writeBlock(properties.jobDuetLaserMode); 50 | break; 51 | } 52 | } 53 | this.machineMode = currentSection.type; 54 | } 55 | FirmwareRepRap.prototype.laserOn = function (power) { 56 | switch (properties.cutterMarlinMode) { 57 | case 3: 58 | var laser_pwm = power / 100 * 255; 59 | writeBlock(mFormat.format(3), sFormat.format(laser_pwm)); 60 | return; 61 | } 62 | Firmware3dPrinterLike.prototype.laserOn.apply(this, arguments); 63 | } 64 | 65 | currentFirmware = new FirmwareRepRap(); -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 martindb 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | DIY CNC Fusion 360 CAM posts processor 3 | ==== 4 | 5 | This is modified fork of https://github.com/martindb/mpcnc_posts_processor 6 | 7 | CAM posts processor for use with Fusion 360 and [MPCNC](https://www.v1engineering.com/assembly/) with RAMPS or any 3-axis DIY CNC. 8 | Supported firmwares: 9 | - Marlin 2.0 10 | - Repetier firmware 1.0.3 (not tested. gcode is same as for Marlin) 11 | - GRBL 1.1 12 | - RepRap firmware (Duet3d) 13 | 14 | Some design points: 15 | - Setup operation types: Milling, Water/Laser/Plasma 16 | - Support MM and Inches units (**but all properties MUST be set in MM**) 17 | - XY and Z independent travel speeds. Rapids are done with G0. 18 | - Arcs support on XY plane (Marlin/Repetier/RepRap) or all panes (Grbl) 19 | - Tested with LCD display and SD card (built in tool change require printing from SD and LCD to restart) 20 | - Support for 3 different laser power using "cutting modes" (through, etch, vaporize) 21 | - Support 2 coolant channels. You may attach relays to control external devices - as example air jet valve. 22 | - Customizable level of verbosity of comments 23 | - Support line numbers 24 | - Support GRBL laser mode (**be noted that you probably to have enabled laser mode [$32=1](https://github.com/gnea/grbl/wiki/Grbl-v1.1-Laser-Mode)**) 25 | 26 | ![screenshot](/screenshot.jpg "screenshot") 27 | 28 | # User Properties 29 | 30 | ## Group 1: Job propertyes 31 | 32 | |Title|Description|Default| 33 | |---|---|---| 34 | Job: Firmware|Target firmware (marlin 2.0 or Repetir 1.0.3 / GRBL 1.1) / RepRap Firmware.|**Marlin**| 35 | Job: Travel Speed XY|High speed for travel movements X & Y (mm/min).|**2500 mm/min**| 36 | Job: Travel Speed Z|High speed for travel movements Z (mm/min).|**300 mm/min**| 37 | Job: Marlin: Manual Spindle On/Off|Set it to true when the motor of your spindle is controlled by manual switch. So the preprocessor will issue additional pauses for TURN ON/TURN OFF the motor.|**true**| 38 | Job: Marlin: Enforce feedrate|Add feedrate to each movement g-code.|**false**| 39 | Job: Use Arcs|Use G2/G3 g-codes fo circular movements.|**true**| 40 | Job: Reset on start (G92)|Set origin when gcode start (G92 X0 Y0 Z0). Only apply if not using gcodeStartFile.|**true**| 41 | Job: Goto 0 at end|Go X0 Y0 at gcode end. Useful to find if your machine loss steeps or have any other mechanic issue (like loose pulleys). Also useful for repetitive jobs. Only apply if not using gcodeStopFile.|**true**| 42 | Job: Use Arcs|Use G2/G3 g-codes fo circular movements.|**true**| 43 | Job: Line numbers|Show sequence numbers.|**false**| 44 | Job: Line start|First sequence number.|**10**| 45 | Job: Line increment|Increment for sequence numbers.|**1**| 46 | Job: Separate words|Specifies that the words should be separated with a white space.|**true**| 47 | Job: Duet: Milling Mode|GCode command to setup Duet3d milling mode.|**"M453 P2 I0 R30000 F200"**| 48 | Job: Duet: Laser Mode|GCode command to setup Duet3d laser mode.|**"M452 P2 I0 R255 F200"**| 49 | 50 | ## Group 2: Tool change 51 | 52 | |Title|Description|Default| 53 | |---|---|---| 54 | Change: Enabled|Enable tool change code (bultin tool change requires LCD display)|**true**| 55 | Change: X|X position for builtin tool change|**0**| 56 | Change: Y|Y position for builtin tool change|**0**| 57 | Change: Z|Z position for builtin tool change|**40**| 58 | Change: Make Z Probe|Z probe after tool change|**true**| 59 | Change: Disable Z stepper|Disable Z stepper when change a tool|**false**| 60 | 61 | ## Group 3: Z Probe 62 | 63 | |Title|Description|Default| 64 | |---|---|---| 65 | Probe: On job start|Execute probe gcode on job start|**true**| 66 | Probe: Plate thickness|Plate thickness|**0.8**| 67 | Probe: Use Home Z|Use G28 or G38 for probing|**true**| 68 | Probe: G38 target|Probing up to Z position|**-10**| 69 | Probe: G38 speed|Probing with speed|**30**| 70 | 71 | ## Group 4: Laser/Plasma related 72 | 73 | |Title|Description|Default|Values| 74 | |---|---|---|---| 75 | Laser: On - Vaporize|Persent of power to turn on the laser/plasma cutter in vaporize mode|**100**|| 76 | Laser: On - Through|Persent of power to turn on the laser/plasma cutter in through mode|**80**|| 77 | Laser: On - Etch|Persent of power to turn on the laser/plasma cutter in etch mode|**40**|| 78 | Laser: Marlin mode|Marlin mode of the laser/plasma cutter ()|**M106**|M106 S{PWM}/M107 = 0; M3 O{PWM}/M5 = 1; M42 P{pin} S{PWM} = 2;| 79 | Laser: Marlin pin|Marlin custom pin number for the laser/plasma cutter|**4**|| 80 | Laser: GRBL mode|GRBL mode of the laser/plasma cutter|**M4**|M4 S{PWM}/M5 dynamic power = 4; M3 S{PWM}/M5 static power = 3;| 81 | 82 | ## Group 5: Override behaviour by external files 83 | 84 | |Title|Description|Default| 85 | |---|---|---| 86 | Extern: Start File|File with custom Gcode for header/start (in nc folder)|| 87 | Extern: Stop File|File with custom Gcode for footer/end (in nc folder)|| 88 | Extern: Tool File|File with custom Gcode for tool change (in nc folder)|| 89 | Extern: Probe File|File with custom Gcode for tool probe (in nc folder)|| 90 | 91 | 92 | ## Group 6: Manage coolant control pins 93 | 94 | |Title|Description|Default|Values| 95 | |---|---|---|---| 96 | Coolant: A Mode|Enable issuing g-codes for control Coolant channel A|**0**|off=0; flood=1; mist=2; throughTool=3; air=4; airThroughTool=5; suction=6; floodMist=7; floodThroughTool=8| 97 | Coolant: A Marlin On command|GCode command to turn on Coolant channel A|**M42 P11 S255**|| 98 | Coolant: A Marlin Off command|Gcode command to turn off Coolant A|**M42 P11 S0**|| 99 | Coolant: A GRBL|GRBL g-codes for control Coolant channel A|**M7**|M7 flood = 7; M8 mist = 8| 100 | Coolant: B Mode|Enable issuing g-codes for control Coolant channel B|**0**|off=0; flood=1; mist=2; throughTool=3; air=4; airThroughTool=5; suction=6; floodMist=7; floodThroughTool=8| 101 | Coolant: B Marlin On command|GCode command to turn on Coolant channel B|**M42 P6 S255**|| 102 | Coolant: B Marlin Off command|Gcode command to turn off Coolant channel B|**M42 P6 S0**|| 103 | Coolant: B GRBL|GRBL g-codes for control Coolant channel B|**M8**|M7 flood = 7; M8 mist = 8| 104 | 105 | ## Group 7: Write comments into g-code 106 | 107 | |Title|Description|Default| 108 | |---|---|---| 109 | Comment: Write Tools|Write table of used tools in job header|true| 110 | Comment: Sections|Write header of every section|true| 111 | Comment: Activities|Write comments which somehow helps to understand current piece of g-code|true| 112 | Comment: Trace Commands|Write stringified commands called by CAM|true| 113 | Comment: Trace Movements|Write stringified movements called by CAM|true| 114 | 115 | 116 | # Sample of issued code blocks 117 | 118 | ## Gcode of milling with manually control spindel 119 | 120 | ```G-code 121 | ;Fusion 360 CAM 2.0.4860 122 | ; Posts processor: MPCNC_Mill_Laser.cps 123 | ; Gcode generated: Sunday, December 2, 2018 1:57:21 PM GMT 124 | ; Document: cam_testpp v5 125 | ; Setup: Setup1 126 | ; 127 | ; Ranges table: 128 | ; X: Min=2.588 Max=36 Size=33.412 129 | ; Y: Min=2.588 Max=36 Size=33.412 130 | ; Z: Min=-1 Max=15 Size=16 131 | ; 132 | ; Tools table: 133 | ; T1 D=3.175 CR=0 - ZMIN=-1 - flat end mill 134 | ; T2 D=1.5 CR=0 - ZMIN=-1 - flat end mill 135 | 136 | ; *** START begin *** 137 | G90 138 | G21 139 | M84 S0 140 | G92 X0 Y0 Z0 141 | ; COMMAND_TOOL_MEASURE 142 | ; --- PROBE TOOL begin --- 143 | M0 Attach ZProbe 144 | G28 Z 145 | G92 Z0.8 146 | G0 Z50 F300 147 | M0 Detach ZProbe 148 | ; --- PROBE TOOL end --- 149 | ; *** START end *** 150 | 151 | ; *** SECTION begin *** 152 | ;2D Contour1 - Milling - Tool: 1 - 1/8inch flat end mill 153 | ; X Min: 2.588 - X Max: 49.412 154 | ; Y Min: 2.588 - Y Max: 49.412 155 | ; Z Min: -1 - Z Max: 15 156 | M400 157 | ; COMMAND_START_SPINDLE 158 | ; COMMAND_SPINDLE_CLOCKWISE 159 | M0 Turn ON spindle 160 | ; COMMAND_COOLANT_ON 161 | M117 2D Contour1 162 | G0 Z15 163 | G0 X49.412 Y26 F2500 164 | G0 Z5 F300 165 | ; MOVEMENT_PLUNGE 166 | G1 Z1 F100 167 | G1 Z-1 168 | ; 14 169 | G1 Y49.412 F300 170 | G1 X2.588 171 | G1 Y2.588 172 | G1 X49.412 173 | G1 Y26 174 | ; MOVEMENT_RAPID 175 | G0 Z15 176 | ; *** SECTION end *** 177 | 178 | ; *** SECTION begin *** 179 | ;2D Contour2 - Milling - Tool: 1 - 1/8inch flat end mill 180 | ; X Min: 9.587 - X Max: 42.412 181 | ; Y Min: 9.587 - Y Max: 42.412 182 | ; Z Min: -1 - Z Max: 15 183 | M400 184 | ; COMMAND_START_SPINDLE 185 | ; COMMAND_SPINDLE_CLOCKWISE 186 | ; COMMAND_COOLANT_ON 187 | M117 2D Contour2 188 | G0 Z15 F300 189 | G0 X42.412 Y26 F2500 190 | G0 Z5 F300 191 | ; MOVEMENT_PLUNGE 192 | G1 Z1 F100 193 | G1 Z-1 194 | ; 14 195 | G1 Y42.412 F300 196 | G1 X9.587 197 | G1 Y9.587 198 | G1 X42.412 199 | G1 Y26 200 | ; MOVEMENT_RAPID 201 | G0 Z15 202 | ; *** SECTION end *** 203 | 204 | ; *** SECTION begin *** 205 | ; --- CHANGE TOOL begin --- 206 | ; COMMAND_COOLANT_OFF 207 | M400 208 | M300 S400 P2000 209 | G0 Z50 F300 210 | G0 X0 Y0 F2500 211 | ; COMMAND_STOP_SPINDLE 212 | M0 Turn OFF spindle 213 | M0 Put tool 2 - 1.5mm 214 | ; COMMAND_TOOL_MEASURE 215 | ; --- PROBE TOOL begin --- 216 | M0 Attach ZProbe 217 | G28 Z 218 | G92 Z0.8 219 | G0 Z50 F300 220 | M0 Detach ZProbe 221 | ; --- PROBE TOOL end --- 222 | ; --- CHANGE TOOL end --- 223 | ;Trace1 - Milling - Tool: 2 - 1.5mm flat end mill 224 | ; X Min: 16 - X Max: 36 225 | ; Y Min: 16 - Y Max: 36 226 | ; Z Min: -1 - Z Max: 15 227 | M400 228 | ; COMMAND_START_SPINDLE 229 | ; COMMAND_SPINDLE_CLOCKWISE 230 | M0 Turn ON spindle 231 | ; COMMAND_COOLANT_ON 232 | M117 Trace1 233 | G0 Z15 234 | G0 X36 Y36 F2500 235 | G0 Z4 F300 236 | ; MOVEMENT_LEAD_IN 237 | G1 Z-1 F300 238 | ; MOVEMENT_CUTTING 239 | G1 Y16 240 | G1 X16 241 | G1 Y36 242 | G1 X36 243 | ; MOVEMENT_LEAD_OUT 244 | G1 Z4 245 | ; MOVEMENT_RAPID 246 | G0 Z15 247 | ; *** SECTION end *** 248 | 249 | ; *** STOP begin *** 250 | M400 251 | ; COMMAND_COOLANT_OFF 252 | ; COMMAND_STOP_SPINDLE 253 | M0 Turn OFF spindle 254 | G0 X0 Y0 F2500 255 | M117 Job end 256 | ; *** STOP end *** 257 | ``` 258 | 259 | ## Gcode of milling with spindel controlled by M3/M4/M5 260 | 261 | ```G-code 262 | ;Fusion 360 CAM 2.0.4860 263 | ; Posts processor: MPCNC_Mill_Laser.cps 264 | ; Gcode generated: Sunday, December 2, 2018 1:56:26 PM GMT 265 | ; Document: cam_testpp v5 266 | ; Setup: Setup1 267 | ; 268 | ; Ranges table: 269 | ; X: Min=2.588 Max=36 Size=33.412 270 | ; Y: Min=2.588 Max=36 Size=33.412 271 | ; Z: Min=-1 Max=15 Size=16 272 | ; 273 | ; Tools table: 274 | ; T1 D=3.175 CR=0 - ZMIN=-1 - flat end mill 275 | ; T2 D=1.5 CR=0 - ZMIN=-1 - flat end mill 276 | 277 | ; *** START begin *** 278 | G90 279 | G21 280 | M84 S0 281 | G92 X0 Y0 Z0 282 | ; COMMAND_TOOL_MEASURE 283 | ; --- PROBE TOOL begin --- 284 | M0 Attach ZProbe 285 | G28 Z 286 | G92 Z0.8 287 | G0 Z50 F300 288 | M0 Detach ZProbe 289 | ; --- PROBE TOOL end --- 290 | ; *** START end *** 291 | 292 | ; *** SECTION begin *** 293 | ;2D Contour1 - Milling - Tool: 1 - 1/8inch flat end mill 294 | ; X Min: 2.588 - X Max: 49.412 295 | ; Y Min: 2.588 - Y Max: 49.412 296 | ; Z Min: -1 - Z Max: 15 297 | M400 298 | ; COMMAND_START_SPINDLE 299 | ; COMMAND_SPINDLE_CLOCKWISE 300 | ; >>> Spindle Speed 21000 301 | M3 S21000 302 | ; COMMAND_COOLANT_ON 303 | M117 2D Contour1 304 | G0 Z15 305 | G0 X49.412 Y26 F2500 306 | G0 Z5 F300 307 | ; MOVEMENT_PLUNGE 308 | G1 Z1 F100 309 | G1 Z-1 310 | ; 14 311 | G1 Y49.412 F300 312 | G1 X2.588 313 | G1 Y2.588 314 | G1 X49.412 315 | G1 Y26 316 | ; MOVEMENT_RAPID 317 | G0 Z15 318 | ; *** SECTION end *** 319 | 320 | ; *** SECTION begin *** 321 | ;2D Contour2 - Milling - Tool: 1 - 1/8inch flat end mill 322 | ; X Min: 9.587 - X Max: 42.412 323 | ; Y Min: 9.587 - Y Max: 42.412 324 | ; Z Min: -1 - Z Max: 15 325 | M400 326 | ; COMMAND_START_SPINDLE 327 | ; COMMAND_SPINDLE_CLOCKWISE 328 | ; >>> Spindle Speed 20000 329 | M3 S20000 330 | ; COMMAND_COOLANT_ON 331 | M117 2D Contour2 332 | G0 Z15 F300 333 | G0 X42.412 Y26 F2500 334 | G0 Z5 F300 335 | ; MOVEMENT_PLUNGE 336 | G1 Z1 F100 337 | G1 Z-1 338 | ; 14 339 | G1 Y42.412 F300 340 | G1 X9.587 341 | G1 Y9.587 342 | G1 X42.412 343 | G1 Y26 344 | ; MOVEMENT_RAPID 345 | G0 Z15 346 | ; *** SECTION end *** 347 | 348 | ; *** SECTION begin *** 349 | ; --- CHANGE TOOL begin --- 350 | ; COMMAND_COOLANT_OFF 351 | M400 352 | M300 S400 P2000 353 | G0 Z50 F300 354 | G0 X0 Y0 F2500 355 | ; COMMAND_STOP_SPINDLE 356 | M5 357 | M0 Put tool 2 - 1.5mm 358 | ; COMMAND_TOOL_MEASURE 359 | ; --- PROBE TOOL begin --- 360 | M0 Attach ZProbe 361 | G28 Z 362 | G92 Z0.8 363 | G0 Z50 F300 364 | M0 Detach ZProbe 365 | ; --- PROBE TOOL end --- 366 | ; --- CHANGE TOOL end --- 367 | ;Trace1 - Milling - Tool: 2 - 1.5mm flat end mill 368 | ; X Min: 16 - X Max: 36 369 | ; Y Min: 16 - Y Max: 36 370 | ; Z Min: -1 - Z Max: 15 371 | M400 372 | ; COMMAND_START_SPINDLE 373 | ; COMMAND_SPINDLE_CLOCKWISE 374 | ; >>> Spindle Speed 21000 375 | M3 S21000 376 | ; COMMAND_COOLANT_ON 377 | M117 Trace1 378 | G0 Z15 379 | G0 X36 Y36 F2500 380 | G0 Z4 F300 381 | ; MOVEMENT_LEAD_IN 382 | G1 Z-1 F300 383 | ; MOVEMENT_CUTTING 384 | G1 Y16 385 | G1 X16 386 | G1 Y36 387 | G1 X36 388 | ; MOVEMENT_LEAD_OUT 389 | G1 Z4 390 | ; MOVEMENT_RAPID 391 | G0 Z15 392 | ; *** SECTION end *** 393 | 394 | ; *** STOP begin *** 395 | M400 396 | ; COMMAND_COOLANT_OFF 397 | ; COMMAND_STOP_SPINDLE 398 | M5 399 | G0 X0 Y0 F2500 400 | M117 Job end 401 | ; *** STOP end *** 402 | ``` 403 | 404 | ## Gcode of milling with spindel controlled by M3/M4/M5 with using Coolants (both A and B channels) 405 | 406 | ```G-code 407 | ;Fusion 360 CAM 2.0.4860 408 | ; Posts processor: MPCNC_Mill_Laser.cps 409 | ; Gcode generated: Sunday, December 2, 2018 2:06:54 PM GMT 410 | ; Document: cam_testpp v5 411 | ; Setup: Setup1 412 | ; 413 | ; Ranges table: 414 | ; X: Min=2.588 Max=36 Size=33.412 415 | ; Y: Min=2.588 Max=36 Size=33.412 416 | ; Z: Min=-1 Max=15 Size=16 417 | ; 418 | ; Tools table: 419 | ; T1 D=3.175 CR=0 - ZMIN=-1 - flat end mill 420 | ; T2 D=1.5 CR=0 - ZMIN=-1 - flat end mill 421 | 422 | ; *** START begin *** 423 | G90 424 | G21 425 | M84 S0 426 | G92 X0 Y0 Z0 427 | ; COMMAND_TOOL_MEASURE 428 | ; --- PROBE TOOL begin --- 429 | M0 Attach ZProbe 430 | G28 Z 431 | G92 Z0.8 432 | G0 Z50 F300 433 | M0 Detach ZProbe 434 | ; --- PROBE TOOL end --- 435 | ; *** START end *** 436 | 437 | ; *** SECTION begin *** 438 | ;2D Contour1 - Milling - Tool: 1 - 1/8inch flat end mill 439 | ; X Min: 2.588 - X Max: 49.412 440 | ; Y Min: 2.588 - Y Max: 49.412 441 | ; Z Min: -1 - Z Max: 15 442 | M400 443 | ; COMMAND_START_SPINDLE 444 | ; COMMAND_SPINDLE_CLOCKWISE 445 | ; >>> Spindle Speed 21000 446 | M3 S21000 447 | ; COMMAND_COOLANT_ON 448 | ; >>> Coolant A ON 449 | M42 P11 S255 450 | M117 2D Contour1 451 | G0 Z15 452 | G0 X49.412 Y26 F2500 453 | G0 Z5 F300 454 | ; MOVEMENT_PLUNGE 455 | G1 Z1 F100 456 | G1 Z-1 457 | ; 14 458 | G1 Y49.412 F300 459 | G1 X2.588 460 | G1 Y2.588 461 | G1 X49.412 462 | G1 Y26 463 | ; MOVEMENT_RAPID 464 | G0 Z15 465 | ; *** SECTION end *** 466 | 467 | ; *** SECTION begin *** 468 | ;2D Contour2 - Milling - Tool: 1 - 1/8inch flat end mill 469 | ; X Min: 9.587 - X Max: 42.412 470 | ; Y Min: 9.587 - Y Max: 42.412 471 | ; Z Min: -1 - Z Max: 15 472 | M400 473 | ; COMMAND_START_SPINDLE 474 | ; COMMAND_SPINDLE_CLOCKWISE 475 | ; >>> Spindle Speed 20000 476 | M3 S20000 477 | ; COMMAND_COOLANT_ON 478 | ; >>> Coolant A OFF 479 | M42 P11 S0 480 | ; >>> Coolant B ON 481 | M42 P6 S255 482 | M117 2D Contour2 483 | G0 Z15 F300 484 | G0 X42.412 Y26 F2500 485 | G0 Z5 F300 486 | ; MOVEMENT_PLUNGE 487 | G1 Z1 F100 488 | G1 Z-1 489 | ; 14 490 | G1 Y42.412 F300 491 | G1 X9.587 492 | G1 Y9.587 493 | G1 X42.412 494 | G1 Y26 495 | ; MOVEMENT_RAPID 496 | G0 Z15 497 | ; *** SECTION end *** 498 | 499 | ; *** SECTION begin *** 500 | ; --- CHANGE TOOL begin --- 501 | M400 502 | G0 Z50 F300 503 | G0 X0 Y0 F2500 504 | ; COMMAND_COOLANT_OFF 505 | ; >>> Coolant B OFF 506 | M42 P6 S0 507 | ; COMMAND_STOP_SPINDLE 508 | M5 509 | M300 S400 P2000 510 | M0 Put tool 2 - 1.5mm 511 | ; COMMAND_TOOL_MEASURE 512 | ; --- PROBE TOOL begin --- 513 | M0 Attach ZProbe 514 | G28 Z 515 | G92 Z0.8 516 | G0 Z50 F300 517 | M0 Detach ZProbe 518 | ; --- PROBE TOOL end --- 519 | ; --- CHANGE TOOL end --- 520 | ;Trace1 - Milling - Tool: 2 - 1.5mm flat end mill 521 | ; X Min: 16 - X Max: 36 522 | ; Y Min: 16 - Y Max: 36 523 | ; Z Min: -1 - Z Max: 15 524 | M400 525 | ; COMMAND_START_SPINDLE 526 | ; COMMAND_SPINDLE_CLOCKWISE 527 | ; >>> Spindle Speed 21000 528 | M3 S21000 529 | ; COMMAND_COOLANT_ON 530 | M117 Trace1 531 | G0 Z15 532 | G0 X36 Y36 F2500 533 | G0 Z4 F300 534 | ; MOVEMENT_LEAD_IN 535 | G1 Z-1 F300 536 | ; MOVEMENT_CUTTING 537 | G1 Y16 538 | G1 X16 539 | G1 Y36 540 | G1 X36 541 | ; MOVEMENT_LEAD_OUT 542 | G1 Z4 543 | ; MOVEMENT_RAPID 544 | G0 Z15 545 | ; *** SECTION end *** 546 | 547 | ; *** STOP begin *** 548 | M400 549 | ; COMMAND_COOLANT_OFF 550 | ; COMMAND_STOP_SPINDLE 551 | M5 552 | G0 X0 Y0 F2500 553 | M117 Job end 554 | ; *** STOP end *** 555 | ``` 556 | 557 | ## Gcode of laser cutting 558 | 559 | ```G-code 560 | ;Fusion 360 CAM 2.0.4860 561 | ; Posts processor: MPCNC_Mill_Laser.cps 562 | ; Gcode generated: Sunday, December 2, 2018 2:07:32 PM GMT 563 | ; Document: cam_testpp v5 564 | ; Setup: Setup2 565 | ; 566 | ; Ranges table: 567 | ; X: Min=-25 Max=25 Size=50 568 | ; Y: Min=-25.5 Max=25 Size=50.5 569 | ; Z: Min=0 Max=15 Size=15 570 | ; 571 | ; Tools table: 572 | ; T1 D=0 CR=0 - ZMIN=0 - laser cutter 573 | 574 | ; *** START begin *** 575 | G90 576 | G21 577 | M84 S0 578 | G92 X0 Y0 Z0 579 | ; COMMAND_TOOL_MEASURE 580 | ; *** START end *** 581 | 582 | ; *** SECTION begin *** 583 | ;2D Profile1 - Laser/Plasma - Cutting mode: auto 584 | ; X Min: -25 - X Max: 25 585 | ; Y Min: -25.5 - Y Max: 25 586 | ; Z Min: 0 - Z Max: 15 587 | M400 588 | ; COMMAND_START_SPINDLE 589 | ; COMMAND_SPINDLE_COUNTERCLOCKWISE 590 | ; COMMAND_COOLANT_ON 591 | M117 2D Profile1 592 | G0 Z15 F300 593 | G0 X-9.94 Y-10.5 F2500 594 | G0 Z0 F300 595 | ; >>> LASER Power ON 596 | M106 S200 597 | ; COMMAND_POWER_ON 598 | ; MOVEMENT_LEAD_IN 599 | G1 Y-10 F1000 600 | G1 X-9.95 601 | ; MOVEMENT_CUTTING 602 | G1 X-10 603 | G1 Y10 604 | G1 X10 605 | G1 Y-10 606 | G1 X-9.95 607 | ; MOVEMENT_LEAD_OUT 608 | G1 X-9.96 609 | G1 Y-10.5 610 | ; >>> LASER Power OFF 611 | M107 612 | ; COMMAND_POWER_OFF 613 | ; MOVEMENT_RAPID 614 | G0 Z5 F300 615 | G0 X-9.99 Y-25.5 F2500 616 | G0 Z0 F300 617 | ; >>> LASER Power ON 618 | M106 S200 619 | ; COMMAND_POWER_ON 620 | ; MOVEMENT_LEAD_IN 621 | G1 Y-25 F1000 622 | G1 X-10 623 | ; MOVEMENT_CUTTING 624 | G1 X-25 625 | G1 Y25 626 | G1 X25 627 | G1 Y-25 628 | G1 X-10 629 | ; MOVEMENT_LEAD_OUT 630 | G1 X-10.01 631 | G1 Y-25.5 632 | ; >>> LASER Power OFF 633 | M107 634 | ; COMMAND_POWER_OFF 635 | ; MOVEMENT_RAPID 636 | G0 Z15 F300 637 | ; *** SECTION end *** 638 | 639 | ; *** STOP begin *** 640 | M400 641 | ; COMMAND_COOLANT_OFF 642 | ; COMMAND_STOP_SPINDLE 643 | G0 X0 Y0 F2500 644 | M117 Job end 645 | ; *** STOP end *** 646 | ``` 647 | 648 | # Resorces 649 | 650 | [Marlin G-codes](http://marlinfw.org/meta/gcode/) 651 | 652 | [PostProcessor Class Reference](https://cam.autodesk.com/posts/reference/classPostProcessor.html) 653 | 654 | [Post Processor Training Guide (PDF document)](https://cam.autodesk.com/posts/posts/guides/Post%20Processor%20Training%20Guide.pdf) 655 | 656 | [Enhancements to the post processor property definitions](https://forums.autodesk.com/t5/hsm-post-processor-forum/enhancements-to-the-post-processor-property-definitions/td-p/7325350) 657 | 658 | [Dumper PostProcessor](https://cam.autodesk.com/hsmposts?p=dump) 659 | 660 | [Library of exist post processors](https://cam.autodesk.com/hsmposts) 661 | 662 | [Post processors forum](https://forums.autodesk.com/t5/hsm-post-processor-forum/bd-p/218) 663 | 664 | [How to set up a 4/5 axis machine configuration](https://forums.autodesk.com/t5/hsm-post-processor-forum/how-to-set-up-a-4-5-axis-machine-configuration/td-p/6488176) 665 | 666 | [Beginners Guide to Editing Post Processors in Fusion 360! FF121 (Youtube video)](https://www.youtube.com/watch?v=5EodQIY25tU) 667 | -------------------------------------------------------------------------------- /Test/1001_laser.gcode: -------------------------------------------------------------------------------- 1 | ;Fusion 360 CAM 2.0.4860 2 | ; Posts processor: MPCNC_Mill_Laser.cps 3 | ; Gcode generated: Sunday, December 2, 2018 2:07:32 PM GMT 4 | ; Document: cam_testpp v5 5 | ; Setup: Setup2 6 | ; 7 | ; Ranges table: 8 | ; X: Min=-25 Max=25 Size=50 9 | ; Y: Min=-25.5 Max=25 Size=50.5 10 | ; Z: Min=0 Max=15 Size=15 11 | ; 12 | ; Tools table: 13 | ; T1 D=0 CR=0 - ZMIN=0 - laser cutter 14 | 15 | ; *** START begin *** 16 | G90 17 | G21 18 | M84 S0 19 | G92 X0 Y0 Z0 20 | ; COMMAND_TOOL_MEASURE 21 | ; *** START end *** 22 | 23 | ; *** SECTION begin *** 24 | ;2D Profile1 - Laser/Plasma - Cutting mode: auto 25 | ; X Min: -25 - X Max: 25 26 | ; Y Min: -25.5 - Y Max: 25 27 | ; Z Min: 0 - Z Max: 15 28 | M400 29 | ; COMMAND_START_SPINDLE 30 | ; COMMAND_SPINDLE_COUNTERCLOCKWISE 31 | ; COMMAND_COOLANT_ON 32 | M117 2D Profile1 33 | G0 Z15 F300 34 | G0 X-9.94 Y-10.5 F2500 35 | G0 Z0 F300 36 | ; >>> LASER Power ON 37 | M106 S200 38 | ; COMMAND_POWER_ON 39 | ; MOVEMENT_LEAD_IN 40 | G1 Y-10 F1000 41 | G1 X-9.95 42 | ; MOVEMENT_CUTTING 43 | G1 X-10 44 | G1 Y10 45 | G1 X10 46 | G1 Y-10 47 | G1 X-9.95 48 | ; MOVEMENT_LEAD_OUT 49 | G1 X-9.96 50 | G1 Y-10.5 51 | ; >>> LASER Power OFF 52 | M107 53 | ; COMMAND_POWER_OFF 54 | ; MOVEMENT_RAPID 55 | G0 Z5 F300 56 | G0 X-9.99 Y-25.5 F2500 57 | G0 Z0 F300 58 | ; >>> LASER Power ON 59 | M106 S200 60 | ; COMMAND_POWER_ON 61 | ; MOVEMENT_LEAD_IN 62 | G1 Y-25 F1000 63 | G1 X-10 64 | ; MOVEMENT_CUTTING 65 | G1 X-25 66 | G1 Y25 67 | G1 X25 68 | G1 Y-25 69 | G1 X-10 70 | ; MOVEMENT_LEAD_OUT 71 | G1 X-10.01 72 | G1 Y-25.5 73 | ; >>> LASER Power OFF 74 | M107 75 | ; COMMAND_POWER_OFF 76 | ; MOVEMENT_RAPID 77 | G0 Z15 F300 78 | ; *** SECTION end *** 79 | 80 | ; *** STOP begin *** 81 | M400 82 | ; COMMAND_COOLANT_OFF 83 | ; COMMAND_STOP_SPINDLE 84 | G0 X0 Y0 F2500 85 | M117 Job end 86 | ; *** STOP end *** 87 | -------------------------------------------------------------------------------- /Test/1001_m3m5.gcode: -------------------------------------------------------------------------------- 1 | ;Fusion 360 CAM 2.0.4860 2 | ; Posts processor: MPCNC_Mill_Laser.cps 3 | ; Gcode generated: Sunday, December 2, 2018 1:56:26 PM GMT 4 | ; Document: cam_testpp v5 5 | ; Setup: Setup1 6 | ; 7 | ; Ranges table: 8 | ; X: Min=2.588 Max=36 Size=33.412 9 | ; Y: Min=2.588 Max=36 Size=33.412 10 | ; Z: Min=-1 Max=15 Size=16 11 | ; 12 | ; Tools table: 13 | ; T1 D=3.175 CR=0 - ZMIN=-1 - flat end mill 14 | ; T2 D=1.5 CR=0 - ZMIN=-1 - flat end mill 15 | 16 | ; *** START begin *** 17 | G90 18 | G21 19 | M84 S0 20 | G92 X0 Y0 Z0 21 | ; COMMAND_TOOL_MEASURE 22 | ; --- PROBE TOOL begin --- 23 | M0 Attach ZProbe 24 | G28 Z 25 | G92 Z0.8 26 | G0 Z50 F300 27 | M0 Detach ZProbe 28 | ; --- PROBE TOOL end --- 29 | ; *** START end *** 30 | 31 | ; *** SECTION begin *** 32 | ;2D Contour1 - Milling - Tool: 1 - 1/8inch flat end mill 33 | ; X Min: 2.588 - X Max: 49.412 34 | ; Y Min: 2.588 - Y Max: 49.412 35 | ; Z Min: -1 - Z Max: 15 36 | M400 37 | ; COMMAND_START_SPINDLE 38 | ; COMMAND_SPINDLE_CLOCKWISE 39 | ; >>> Spindle Speed 21000 40 | M3 S21000 41 | ; COMMAND_COOLANT_ON 42 | M117 2D Contour1 43 | G0 Z15 44 | G0 X49.412 Y26 F2500 45 | G0 Z5 F300 46 | ; MOVEMENT_PLUNGE 47 | G1 Z1 F100 48 | G1 Z-1 49 | ; 14 50 | G1 Y49.412 F300 51 | G1 X2.588 52 | G1 Y2.588 53 | G1 X49.412 54 | G1 Y26 55 | ; MOVEMENT_RAPID 56 | G0 Z15 57 | ; *** SECTION end *** 58 | 59 | ; *** SECTION begin *** 60 | ;2D Contour2 - Milling - Tool: 1 - 1/8inch flat end mill 61 | ; X Min: 9.587 - X Max: 42.412 62 | ; Y Min: 9.587 - Y Max: 42.412 63 | ; Z Min: -1 - Z Max: 15 64 | M400 65 | ; COMMAND_START_SPINDLE 66 | ; COMMAND_SPINDLE_CLOCKWISE 67 | ; >>> Spindle Speed 20000 68 | M3 S20000 69 | ; COMMAND_COOLANT_ON 70 | M117 2D Contour2 71 | G0 Z15 F300 72 | G0 X42.412 Y26 F2500 73 | G0 Z5 F300 74 | ; MOVEMENT_PLUNGE 75 | G1 Z1 F100 76 | G1 Z-1 77 | ; 14 78 | G1 Y42.412 F300 79 | G1 X9.587 80 | G1 Y9.587 81 | G1 X42.412 82 | G1 Y26 83 | ; MOVEMENT_RAPID 84 | G0 Z15 85 | ; *** SECTION end *** 86 | 87 | ; *** SECTION begin *** 88 | ; --- CHANGE TOOL begin --- 89 | ; COMMAND_COOLANT_OFF 90 | M400 91 | M300 S400 P2000 92 | G0 Z50 F300 93 | G0 X0 Y0 F2500 94 | ; COMMAND_STOP_SPINDLE 95 | M5 96 | M0 Put tool 2 - 1.5mm 97 | ; COMMAND_TOOL_MEASURE 98 | ; --- PROBE TOOL begin --- 99 | M0 Attach ZProbe 100 | G28 Z 101 | G92 Z0.8 102 | G0 Z50 F300 103 | M0 Detach ZProbe 104 | ; --- PROBE TOOL end --- 105 | ; --- CHANGE TOOL end --- 106 | ;Trace1 - Milling - Tool: 2 - 1.5mm flat end mill 107 | ; X Min: 16 - X Max: 36 108 | ; Y Min: 16 - Y Max: 36 109 | ; Z Min: -1 - Z Max: 15 110 | M400 111 | ; COMMAND_START_SPINDLE 112 | ; COMMAND_SPINDLE_CLOCKWISE 113 | ; >>> Spindle Speed 21000 114 | M3 S21000 115 | ; COMMAND_COOLANT_ON 116 | M117 Trace1 117 | G0 Z15 118 | G0 X36 Y36 F2500 119 | G0 Z4 F300 120 | ; MOVEMENT_LEAD_IN 121 | G1 Z-1 F300 122 | ; MOVEMENT_CUTTING 123 | G1 Y16 124 | G1 X16 125 | G1 Y36 126 | G1 X36 127 | ; MOVEMENT_LEAD_OUT 128 | G1 Z4 129 | ; MOVEMENT_RAPID 130 | G0 Z15 131 | ; *** SECTION end *** 132 | 133 | ; *** STOP begin *** 134 | M400 135 | ; COMMAND_COOLANT_OFF 136 | ; COMMAND_STOP_SPINDLE 137 | M5 138 | G0 X0 Y0 F2500 139 | M117 Job end 140 | ; *** STOP end *** 141 | -------------------------------------------------------------------------------- /Test/1001_m3m5_coolant.gcode: -------------------------------------------------------------------------------- 1 | ;Fusion 360 CAM 2.0.4860 2 | ; Posts processor: MPCNC_Mill_Laser.cps 3 | ; Gcode generated: Sunday, December 2, 2018 2:06:54 PM GMT 4 | ; Document: cam_testpp v5 5 | ; Setup: Setup1 6 | ; 7 | ; Ranges table: 8 | ; X: Min=2.588 Max=36 Size=33.412 9 | ; Y: Min=2.588 Max=36 Size=33.412 10 | ; Z: Min=-1 Max=15 Size=16 11 | ; 12 | ; Tools table: 13 | ; T1 D=3.175 CR=0 - ZMIN=-1 - flat end mill 14 | ; T2 D=1.5 CR=0 - ZMIN=-1 - flat end mill 15 | 16 | ; *** START begin *** 17 | G90 18 | G21 19 | M84 S0 20 | G92 X0 Y0 Z0 21 | ; COMMAND_TOOL_MEASURE 22 | ; --- PROBE TOOL begin --- 23 | M0 Attach ZProbe 24 | G28 Z 25 | G92 Z0.8 26 | G0 Z50 F300 27 | M0 Detach ZProbe 28 | ; --- PROBE TOOL end --- 29 | ; *** START end *** 30 | 31 | ; *** SECTION begin *** 32 | ;2D Contour1 - Milling - Tool: 1 - 1/8inch flat end mill 33 | ; X Min: 2.588 - X Max: 49.412 34 | ; Y Min: 2.588 - Y Max: 49.412 35 | ; Z Min: -1 - Z Max: 15 36 | M400 37 | ; COMMAND_START_SPINDLE 38 | ; COMMAND_SPINDLE_CLOCKWISE 39 | ; >>> Spindle Speed 21000 40 | M3 S21000 41 | ; COMMAND_COOLANT_ON 42 | ; >>> Coolant A ON 43 | M42 P11 S255 44 | M117 2D Contour1 45 | G0 Z15 46 | G0 X49.412 Y26 F2500 47 | G0 Z5 F300 48 | ; MOVEMENT_PLUNGE 49 | G1 Z1 F100 50 | G1 Z-1 51 | ; 14 52 | G1 Y49.412 F300 53 | G1 X2.588 54 | G1 Y2.588 55 | G1 X49.412 56 | G1 Y26 57 | ; MOVEMENT_RAPID 58 | G0 Z15 59 | ; *** SECTION end *** 60 | 61 | ; *** SECTION begin *** 62 | ;2D Contour2 - Milling - Tool: 1 - 1/8inch flat end mill 63 | ; X Min: 9.587 - X Max: 42.412 64 | ; Y Min: 9.587 - Y Max: 42.412 65 | ; Z Min: -1 - Z Max: 15 66 | M400 67 | ; COMMAND_START_SPINDLE 68 | ; COMMAND_SPINDLE_CLOCKWISE 69 | ; >>> Spindle Speed 20000 70 | M3 S20000 71 | ; COMMAND_COOLANT_ON 72 | ; >>> Coolant A OFF 73 | M42 P11 S0 74 | ; >>> Coolant B ON 75 | M42 P6 S255 76 | M117 2D Contour2 77 | G0 Z15 F300 78 | G0 X42.412 Y26 F2500 79 | G0 Z5 F300 80 | ; MOVEMENT_PLUNGE 81 | G1 Z1 F100 82 | G1 Z-1 83 | ; 14 84 | G1 Y42.412 F300 85 | G1 X9.587 86 | G1 Y9.587 87 | G1 X42.412 88 | G1 Y26 89 | ; MOVEMENT_RAPID 90 | G0 Z15 91 | ; *** SECTION end *** 92 | 93 | ; *** SECTION begin *** 94 | ; --- CHANGE TOOL begin --- 95 | M400 96 | G0 Z50 F300 97 | G0 X0 Y0 F2500 98 | ; COMMAND_COOLANT_OFF 99 | ; >>> Coolant B OFF 100 | M42 P6 S0 101 | ; COMMAND_STOP_SPINDLE 102 | M5 103 | M300 S400 P2000 104 | M0 Put tool 2 - 1.5mm 105 | ; COMMAND_TOOL_MEASURE 106 | ; --- PROBE TOOL begin --- 107 | M0 Attach ZProbe 108 | G28 Z 109 | G92 Z0.8 110 | G0 Z50 F300 111 | M0 Detach ZProbe 112 | ; --- PROBE TOOL end --- 113 | ; --- CHANGE TOOL end --- 114 | ;Trace1 - Milling - Tool: 2 - 1.5mm flat end mill 115 | ; X Min: 16 - X Max: 36 116 | ; Y Min: 16 - Y Max: 36 117 | ; Z Min: -1 - Z Max: 15 118 | M400 119 | ; COMMAND_START_SPINDLE 120 | ; COMMAND_SPINDLE_CLOCKWISE 121 | ; >>> Spindle Speed 21000 122 | M3 S21000 123 | ; COMMAND_COOLANT_ON 124 | M117 Trace1 125 | G0 Z15 126 | G0 X36 Y36 F2500 127 | G0 Z4 F300 128 | ; MOVEMENT_LEAD_IN 129 | G1 Z-1 F300 130 | ; MOVEMENT_CUTTING 131 | G1 Y16 132 | G1 X16 133 | G1 Y36 134 | G1 X36 135 | ; MOVEMENT_LEAD_OUT 136 | G1 Z4 137 | ; MOVEMENT_RAPID 138 | G0 Z15 139 | ; *** SECTION end *** 140 | 141 | ; *** STOP begin *** 142 | M400 143 | ; COMMAND_COOLANT_OFF 144 | ; COMMAND_STOP_SPINDLE 145 | M5 146 | G0 X0 Y0 F2500 147 | M117 Job end 148 | ; *** STOP end *** 149 | -------------------------------------------------------------------------------- /Test/1001_manual.gcode: -------------------------------------------------------------------------------- 1 | ;Fusion 360 CAM 2.0.4860 2 | ; Posts processor: MPCNC_Mill_Laser.cps 3 | ; Gcode generated: Sunday, December 2, 2018 1:57:21 PM GMT 4 | ; Document: cam_testpp v5 5 | ; Setup: Setup1 6 | ; 7 | ; Ranges table: 8 | ; X: Min=2.588 Max=36 Size=33.412 9 | ; Y: Min=2.588 Max=36 Size=33.412 10 | ; Z: Min=-1 Max=15 Size=16 11 | ; 12 | ; Tools table: 13 | ; T1 D=3.175 CR=0 - ZMIN=-1 - flat end mill 14 | ; T2 D=1.5 CR=0 - ZMIN=-1 - flat end mill 15 | 16 | ; *** START begin *** 17 | G90 18 | G21 19 | M84 S0 20 | G92 X0 Y0 Z0 21 | ; COMMAND_TOOL_MEASURE 22 | ; --- PROBE TOOL begin --- 23 | M0 Attach ZProbe 24 | G28 Z 25 | G92 Z0.8 26 | G0 Z50 F300 27 | M0 Detach ZProbe 28 | ; --- PROBE TOOL end --- 29 | ; *** START end *** 30 | 31 | ; *** SECTION begin *** 32 | ;2D Contour1 - Milling - Tool: 1 - 1/8inch flat end mill 33 | ; X Min: 2.588 - X Max: 49.412 34 | ; Y Min: 2.588 - Y Max: 49.412 35 | ; Z Min: -1 - Z Max: 15 36 | M400 37 | ; COMMAND_START_SPINDLE 38 | ; COMMAND_SPINDLE_CLOCKWISE 39 | M0 Turn ON spindle 40 | ; COMMAND_COOLANT_ON 41 | M117 2D Contour1 42 | G0 Z15 43 | G0 X49.412 Y26 F2500 44 | G0 Z5 F300 45 | ; MOVEMENT_PLUNGE 46 | G1 Z1 F100 47 | G1 Z-1 48 | ; 14 49 | G1 Y49.412 F300 50 | G1 X2.588 51 | G1 Y2.588 52 | G1 X49.412 53 | G1 Y26 54 | ; MOVEMENT_RAPID 55 | G0 Z15 56 | ; *** SECTION end *** 57 | 58 | ; *** SECTION begin *** 59 | ;2D Contour2 - Milling - Tool: 1 - 1/8inch flat end mill 60 | ; X Min: 9.587 - X Max: 42.412 61 | ; Y Min: 9.587 - Y Max: 42.412 62 | ; Z Min: -1 - Z Max: 15 63 | M400 64 | ; COMMAND_START_SPINDLE 65 | ; COMMAND_SPINDLE_CLOCKWISE 66 | ; COMMAND_COOLANT_ON 67 | M117 2D Contour2 68 | G0 Z15 F300 69 | G0 X42.412 Y26 F2500 70 | G0 Z5 F300 71 | ; MOVEMENT_PLUNGE 72 | G1 Z1 F100 73 | G1 Z-1 74 | ; 14 75 | G1 Y42.412 F300 76 | G1 X9.587 77 | G1 Y9.587 78 | G1 X42.412 79 | G1 Y26 80 | ; MOVEMENT_RAPID 81 | G0 Z15 82 | ; *** SECTION end *** 83 | 84 | ; *** SECTION begin *** 85 | ; --- CHANGE TOOL begin --- 86 | ; COMMAND_COOLANT_OFF 87 | M400 88 | M300 S400 P2000 89 | G0 Z50 F300 90 | G0 X0 Y0 F2500 91 | ; COMMAND_STOP_SPINDLE 92 | M0 Turn OFF spindle 93 | M0 Put tool 2 - 1.5mm 94 | ; COMMAND_TOOL_MEASURE 95 | ; --- PROBE TOOL begin --- 96 | M0 Attach ZProbe 97 | G28 Z 98 | G92 Z0.8 99 | G0 Z50 F300 100 | M0 Detach ZProbe 101 | ; --- PROBE TOOL end --- 102 | ; --- CHANGE TOOL end --- 103 | ;Trace1 - Milling - Tool: 2 - 1.5mm flat end mill 104 | ; X Min: 16 - X Max: 36 105 | ; Y Min: 16 - Y Max: 36 106 | ; Z Min: -1 - Z Max: 15 107 | M400 108 | ; COMMAND_START_SPINDLE 109 | ; COMMAND_SPINDLE_CLOCKWISE 110 | M0 Turn ON spindle 111 | ; COMMAND_COOLANT_ON 112 | M117 Trace1 113 | G0 Z15 114 | G0 X36 Y36 F2500 115 | G0 Z4 F300 116 | ; MOVEMENT_LEAD_IN 117 | G1 Z-1 F300 118 | ; MOVEMENT_CUTTING 119 | G1 Y16 120 | G1 X16 121 | G1 Y36 122 | G1 X36 123 | ; MOVEMENT_LEAD_OUT 124 | G1 Z4 125 | ; MOVEMENT_RAPID 126 | G0 Z15 127 | ; *** SECTION end *** 128 | 129 | ; *** STOP begin *** 130 | M400 131 | ; COMMAND_COOLANT_OFF 132 | ; COMMAND_STOP_SPINDLE 133 | M0 Turn OFF spindle 134 | G0 X0 Y0 F2500 135 | M117 Job end 136 | ; *** STOP end *** 137 | -------------------------------------------------------------------------------- /Test/cam_testpp.f3d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martindb/mpcnc_posts_processor/88dbb91d9cc8ba493ece298b03f68c72c16cf679/Test/cam_testpp.f3d -------------------------------------------------------------------------------- /screenshot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martindb/mpcnc_posts_processor/88dbb91d9cc8ba493ece298b03f68c72c16cf679/screenshot.jpg --------------------------------------------------------------------------------