-
Notifications
You must be signed in to change notification settings - Fork 0
/
DDCSV11-Plasma.cps
690 lines (547 loc) · 24.9 KB
/
DDCSV11-Plasma.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
/*******************************************************************************
DeeEmm Plasma post processor for DDCSV1/2/3 and Next Wave Automation CNC Shark controllers
01.10.20 - Version 1.0.20100101
- Initial version based on https://www.brainright.com/Projects/CNCController
- Milling control changed for Plasma control
- Added pierce delay
- Added touch off routine
- Added user selectable cut + pierce height / pierce delay / Z offsets
05.10.20 - Version 1.0.20100501
- Tidied comments
- Removed incorrect M3 (spindle on) commands
- Removed redundant Z move
- Changed direction of Z probe action
- Modified onPower function for probe operation
- Tested in Fusion 360 and on DDSCSV
06.10.20 - Version 1.0.20100601
- Added manual probe offset
- Renamed existing probe offset function to probe distance
06.10.20 - Version 1.0.20100602
- Removed Z components from moves (relies on last set Z position)
- Enabled both M101 (probe down) and M103 (probe up) as both required to generate offset
- Set G90 before G92 in probe routine
- Added additional comments to generated code
09.10.20 - Version 1.0.20100901
- Added scratch start option (added torch type)
- Added Spot marking operation (using 'drilling' function)
- Tidied up the code removing unwanted / redundant stuff.
- Added better comments
11.10.20 - Version 1.0.20101102
- Added cut and feed in/out speeds
12.10.20 - Version 1.0.20101201
- Corrected millisecond abbreviation
13.08.21 - Version 1.0.21081301
- Commented out superfluous feed rate overrides (Issue #2)
15.08.21 - Version 1.0.21081501
- reverted previous change
- Added tool change handling to use with https://github.com/TimPaterson/Fusion360-Batch-Post
21.05.23 - Version 1.0.23052101
- Added option for 3D cutting. Boolean option to process Z axis moves.
27.07.23 - Version 1.0.23072701
- Changed code to pull pierce height / pierce delay and cut height directly from tool parameters
Usage
********************************************************************************
NOTE: Set WCS zero as 'stock box top' in setup. (top face of your object)
This way when z probe measures face and zeros the Z axis, torch offsets will be correct
- Copy this file to your Fusion360 'Post' folder on your local machine
- Select DDCSV Post processor in CAM setup within Fusion 360
- Adjust parameters in post processor parameters drop down to suit.
NOTE: If you are using the Spot Marking option you will need to create a separate drilling operation
for the holes. Choose a generic 3 axis machine for this. The tool is unimportant but it is very important
to make sure the WCS origin for all operations is set to the same location. Best practice is to use the
'Stock box point' at bottom left / top of stock
- After drilling operation has been generated change the operation type to 'cutting'
- Make sure that the parent folder ('Settings') is highlighted when you run the post processor to include all tool paths
- You will get a warning about multiple path and the WCS - this is normal (Refer note above)
- More info on the Github page - https://github.com/DeeEmm/DDCSV11-Plasma
- Guidelines for plasma settings
- NOTE: Piercing at a height 1.5 to 2 times the recommended cut height is recommended.
- NOTE: Amperage 10x material thickness (mm)
- NOTE: Pierce speed approximately 1/2 - 2/3 cut feed rate
Reference
********************************************************************************
DDCSV Probe function - http://bbs.ddcnc.com/forum.php?mod=viewthread&tid=150&extra=page%3D1
Autocad post processor reference - https://cam.autodesk.com/posts/reference/classPostProcessor.html
Original file - Copyright 2020 Jay McClellan - http://brainright.com/Projects/CNCController/
License
********************************************************************************
This code is provided under the BSD License. A copy of this license is provided below
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/
description = "DDCSV Plasma V1.0.20210801";
vendor = "DeeEmm";
vendorUrl = "https://github.com/DeeEmm/DDCSV11-Plasma";
legal="BSD License";
// TEST: added milling capability to try and 'spot' hole locations using drill function and plasma
capabilities = CAPABILITY_MILLING | CAPABILITY_JET;
certificationLevel = 2;
minimumRevision = 24000;
extension = "tap"; // DDCSV Compatible
setCodePage("ascii");
tolerance = spatial(0.0254, MM);
minimumChordLength = spatial(0.1, MM);
minimumCircularRadius = spatial(0.1, MM);
maximumCircularRadius = spatial(1000, MM);
minimumCircularSweep = toRad(0.01);
maximumCircularSweep = toRad(180);
allowHelicalMoves = false;
allowSpiralMoves = false;
allowedCircularPlanes = (1 << PLANE_XY); // allow only X-Y circular motion
var gFormat = createFormat({prefix:"G", decimals:1});
var mFormat = createFormat({prefix:"M", decimals:0});
var hFormat = createFormat({prefix:"H", decimals:0});
var dFormat = createFormat({prefix:"D", decimals:0});
var xyzFormat = createFormat({decimals:(3), forceDecimal:true, trim:false});
var feedFormat = createFormat({decimals:(unit == MM ? 0 : 1), forceDecimal:false});
var taperFormat = createFormat({decimals:1, scale:DEG});
var toolFormat = createFormat({decimals:0});
var xOutput = createVariable({prefix:"X", force:true}, xyzFormat);
var yOutput = createVariable({prefix:"Y", force:true}, xyzFormat);
var zOutput = createVariable({prefix:"Z", force:true}, xyzFormat);
var aOutput = createVariable({prefix:"A", force:true}, xyzFormat);
var iOutput = createReferenceVariable({prefix:"I", force:true}, xyzFormat);
var jOutput = createReferenceVariable({prefix:"J", force:true}, xyzFormat);
var feedOutput = createVariable({prefix:"F"}, feedFormat);
var safeRetractZ = 0; // safe Z coordinate for retraction
var showSectionTools = false; // true to show the tool name in each section
var currentCoolantMode = COOLANT_OFF;
var cutCount = 0;
var operationCount = 0;
var spotMarking = false;
/**********
* Post processor application dialog parameters
* User-defined properties
*
*******************/
properties = {
plasmaProbeDistance:50,
plasmaProbeOffset:-3.15,
plasmaProbeSpeed:300,
plasmaPierceSpeed:200,
// plasmaPierceHeight:3.8,
plasmaSpotHeight:1.5,
// plasmaPierceDelay:1250,
plasmaSpotMarkDuration:100,
// plasmaCutSpeed:325,
plasmaPositionSpeed:1800,
// plasmaCutHeight:1.5,
plasmaPostFlowDelay:1500,
plasmaSafeZ:10,
plasmaTorchType:"pilotArc",
plasma3Dcut: false
};
/**********
* user-defined property definitions
*
*******************/
propertyDefinitions = {
plasmaTorchType:{
title:"Plasma Torch Type",
description:"Select type of torch used. Scratch start will start arc when touching workpiece",
type: "enum",
values:[
{title:"Pilot Arc", id:"pilotArc"},
{title:"Scratch Start", id:"scratchStart"}
]
},
plasma3Dcut:{title:"3D cut", description:"Control torch in X,Y and Z", type: "boolean" },
plasmaProbeDistance: {title:"Probe Distance", description:"Z axis total travel for probe operation", group:0, type:"spatial"},
plasmaProbeOffset: {title:"Probe Offset", description:"Floating head activation distance", group:0, type:"spatial"},
plasmaProbeSpeed: {title:"Probe Speed", description:"Speed of probe operation", group:0, type:"number"},
plasmaPierceSpeed: {title:"Pierce Speed", description:"Speed of Pierce operation", group:0, type:"number"},
plasmaPierceHeight: {title:"Pierce Height", description:"Height for pierce operation", group:0, type:"number"},
plasmaPierceDelay: {title:"Pierce Delay (ms)", description:"Delay in milliseconds after torch on before moving to cut height", group:0, type:"number"},
plasmaSpotHeight: {title:"Spot Height", description:"Height for spot mark operation", group:0, type:"number"},
plasmaSpotMarkDuration: {title:"Spot mark duration (ms)", description:"Time in milliseconds torch is on for spot marking", group:0, type:"number"},
plasmaPostFlowDelay: {title:"Post Flow Delay (ms)", description:"Delay in milliseconds after torch off before moving", group:0, type:"number"},
plasmaPositionSpeed: {title:"Positioning Speed", description:"Feedrate for intermediate moves", group:0, type:"number"},
plasmaCutSpeed: {title:"Cut Speed", description:"Feedrate for cut moves", group:0, type:"number"},
plasmaCutHeight: {title:"Cut Height", description:"Height of torch whilst cutting", group:0, type:"spatial"},
plasmaSafeZ: {title:"Safe Height", description:"Safe distance of torch above workpiece", group:0, type:"spatial"}
};
/**********
* writeBlock
*
* Writes the specified block.
*
*******************/
function writeBlock() {
if (properties.showSequenceNumbers) {
writeWords2("N" + (sequenceNumber % 100000), arguments);
sequenceNumber += properties.sequenceNumberIncrement;
} else {
writeWords(arguments);
}
}
/**********
* writeOptionalBlock
*
* Writes the specified optional block.
*
*******************/
function writeOptionalBlock() {
if (properties.showSequenceNumbers) {
var words = formatWords(arguments);
if (words) {
writeWords("/", "N" + (sequenceNumber % 10000), words);
sequenceNumber += properties.sequenceNumberIncrement;
if (sequenceNumber >= 10000) {
sequenceNumber = properties.sequenceNumberStart;
}
}
} else {
writeWords2("/", arguments);
}
}
/**********
* formatBoundingBox
*
* Formats a bounding box as a readable string
*
*******************/
function formatBoundingBox(box) {
return xyzFormat.format(box.lower.x) + " <= X <= " + xyzFormat.format(box.upper.x) + " | " +
xyzFormat.format(box.lower.y) + " <= Y <= " + xyzFormat.format(box.upper.y) + " | " +
xyzFormat.format(box.lower.z) + " <= Z <= " + xyzFormat.format(box.upper.z);
}
/**********
* formatTool
*
* Formats a tool description as a readable string. This is also used to compare tools
* when warning about multiple tool types, so it will ignore minor tool differences if the
* main parameters are the same.
*
*******************/
function formatTool(tool) {
var str = "Tool: " + getToolTypeName(tool.type);
str += ", D=" + xyzFormat.format(tool.diameter) + " " +
localize("CR") + "=" + xyzFormat.format(tool.cornerRadius);
if ((tool.taperAngle > 0) && (tool.taperAngle < Math.PI)) {
str += " " + localize("TAPER") + "=" + taperFormat.format(tool.taperAngle) + localize("deg");
}
return str;
}
/**********
* onOpen
* Called when post processor is initially run
* This is where the file header is created
*
*******************/
function onOpen() {
writeComment("Created by DeeEmm DDCSV Plasma Post Processor");
writeComment("https://github.com/DeeEmm/DDCSV11-Plasma");
if (programName) {
writeComment("Program: " + programName);
}
if (programComment) {
writeComment(programComment);
}
var globalBounds; // Overall bounding box of tool travel throughout all sections
var toolsUsed = []; // Tools used (hopefully just one) in the order they are used
var toolpathNames = []; // Names of toolpaths, i.e. sections
var numberOfSections = getNumberOfSections();
for (var i = 0; i < numberOfSections; ++i) {
var section = getSection(i);
var boundingBox = section.getGlobalBoundingBox();
if (globalBounds) {
globalBounds.expandToBox(boundingBox);
} else {
globalBounds = boundingBox;
toolpathNames.push(section.getParameter("operation-comment"));
}
if (section.hasParameter('operation:clearanceHeight_value')) {
safeRetractZ = Math.max(safeRetractZ, section.getParameter('operation:clearanceHeight_value'));
if (section.getUnit() == MM && unit == IN) {
safeRetractZ /= 25.4;
} else if (section.getUnit() == IN && unit == MM) {
safeRetractZ *= 25.4;
}
}
}
writeComment("Workpiece: " + formatBoundingBox(getWorkpiece()));
writeComment("Tool travel: " + formatBoundingBox(globalBounds));
writeComment("Safe Z: " + xyzFormat.format(safeRetractZ));
var tool = section.getTool();
writeln("G90"); // absolute coordinates
writeln("M5"); // Make sure spindle is off
switch (unit) {
case IN:
writeComment("Units: inches");
writeln("G20"); // inches
writeln("G64 P0.001"); // precision in inches
break;
case MM:
writeComment("Units: millimeters");
writeln("G21"); // millimeters
writeln("G64 P0.0254"); // precision in mm
break;
}
}
/**********
* onCommand
* We're not using this at present but lets leave it here in case someone wants it to control air etc
*
*******************/
function onCommand(command) {
switch (command) {
case COMMAND_COOLANT_ON:
writeln("M08");
break;
case COMMAND_COOLANT_OFF:
writeln("M09");
break;
}
}
/**********
* writeComment
*
*******************/
function writeComment(text) {
text = text.replace(/\(/g," ").replace(/\)/g," ");
writeln("(--- " + text + " ---)");
}
/**********
* onComment
*
*******************/
function onComment(message) {
var comments = String(message).split(";");
for (comment in comments) {
writeComment(comments[comment]);
}
}
/**********
* setCoolant
*
*******************/
function setCoolant(coolant) {
if (coolant != currentCoolantMode) {
if (coolant == COOLANT_OFF) {
onCommand(COMMAND_COOLANT_OFF);
}
else {
onCommand(COMMAND_COOLANT_ON);
}
currentCoolantMode = coolant;
}
}
/**********
* onDwell
*
*******************/
function onDwell(seconds) {
if (seconds > 99999.999) {
warning(localize("Dwelling time is out of range."));
}
seconds = clamp(0.001, seconds, 99999.999);
writeBlock(gFormat.format(4), "P" + secFormat.format(seconds));
}
/**********
* onPower
*
* This function is invoked when the power mode changes (used for water jet, laser cutter, and plasma cutter)
* We are using it for our torch control. The 'power' variable passed to the function controls torch on / off
*******************/
function onPower(power) {
if (power) {
cutCount = cutCount + 1; // Increment the cut count
writeComment("[START] Probe Z Axis: " + (properties.plasmaProbeDistance) + "mm @ " + (properties.plasmaProbeSpeed) + "mm/s and add " + (properties.plasmaProbeOffset) + "mm floating head offset");
// probe down until the torch meets the workpiece
writeBlock(gFormat.format(4), 'P0'); // DND (Do Not Delete)
writeBlock(mFormat.format(101)); // Enable probe interrupt (skip function)
writeBlock(gFormat.format(91)); // switch to relative positioning
writeBlock(gFormat.format(91), 'Z-'+(properties.plasmaProbeDistance), 'F'+(properties.plasmaProbeSpeed)) ; // move downwards until interrupt triggers
writeBlock(mFormat.format(102)); // disable probe interrupt (skip function)
writeBlock(gFormat.format(4), 'P0'); // DND
// probe up until torch clears the workpiece
writeBlock(mFormat.format(103)); // Enable probe interrupt (skip function)
writeBlock(gFormat.format(91), 'Z'+(properties.plasmaProbeDistance), 'F'+(properties.plasmaProbeSpeed)) ; // move upwards until interrupt triggers
writeBlock(mFormat.format(102)); // disable probe interrupt (skip function)
writeBlock(gFormat.format(4), 'P0'); // DND
//set the z location for work surface
writeBlock(gFormat.format(90)); // switch to absolute positioning
writeBlock(gFormat.format(4), 'P0'); // DND
writeBlock(gFormat.format(92), 'Z'+(properties.plasmaProbeOffset)); // set z axis offset
writeBlock(gFormat.format(4), 'P0'); // DND
//writeComment("[END] Probe Z");
// Let's set up the torch
// If using scratch start torch - turn plasma on when torch is still touching the workpiece
if (properties.plasmaTorchType == 'scratchStart') {
writeComment("[SCRATCH START]");
writeBlock(gFormat.format(0), 'Z-1'); // move towards workpiece (this is just an arbitrary distance as torch moves away during probe routine and may not be touching the workpiece)
writeln("S500 M3"); // This is the correct DDCSV Format for spindle (torch) control. We need the speed declaration if parameter #220 is set to 'Gcode' (which is advisable else torch turns on as soon as job starts)
writeBlock(gFormat.format(4), 'P0'); // DND
}
// Are we cutting through or just spot marking?
if (spotMarking == true) {
// We're spotMarking - Lets do a Spot mark!!
writeComment("[START] Spot Mark - Operation #" + cutCount + " @ " + (properties.plasmaSpotHeight) + "mm Spot Height with " + (properties.plasmaSpotMarkDuration) + "ms Spot Mark Duration");
// turn on the torch (if its not already on)
writeln("S500 M3"); // correct DDCSV Format for spindle control.
writeBlock(gFormat.format(0), 'Z',(properties.plasmaCutHeight), 'F'+(properties.plasmaPierceSpeed)); // move up to cut height
writeBlock(gFormat.format(4), 'P'+(properties.plasmaSpotMarkDuration)); // wait for spot duration
writeBlock(mFormat.format(5)); // lets turn the torch off. just in case someone programmed some moves afterwards
} else {
// We're cutting through - Lets start a cut!!
// var tools = getToolTable();
// if (tools.getNumberOfTools() > 0) {
// var diaFormat = createFormat({decimals:4, trim:false});
// var twodecFormat = createFormat({decimals:2});
// for (var i = 0; i < tools.getNumberOfTools(); ++i) {
// var tool = tools.getTool(i);
// var comment = "T" + toolFormat.format(tool.number) + " - ";
// comment+= "PierceHeight: " + getParameter("operation:tool_pierceHeight") + " - ";
// writeln(comment);
// }
// }
// Get cut data directly from tool
if(hasParameter("operation:tool_pierceTime")) {
pDelay = getParameter("operation:tool_pierceTime");
writeComment("NOTE: pierceDelay value from tool");
} else {
pDelay = properties.plasmaPierceDelay
}
if(hasParameter("operation:tool_pierceHeight")) {
pHeight = getParameter("operation:tool_pierceHeight");
writeComment("NOTE: pierceHeight value from tool");
} else {
pHeight = properties.plasmaPierceHeight
}
if(hasParameter("operation:tool_cutHeight")) {
cHeight = getParameter("operation:tool_cutHeight");
writeComment("NOTE: cutHeight value from tool");
} else {
cHeight = properties.plasmaCutHeight
}
writeComment("[START] Cut Path - Operation #" + cutCount + " @ " + pHeight + "mm Pierce Height & " + cHeight + "mm Cut Height with " + pDelay + "ms Pierce Delay");
writeBlock(gFormat.format(0), 'Z'+pHeight, 'F'+(properties.plasmaPositionSpeed)); // move to pierce height
// turn on the torch (if its not already on)
writeln("S500 M3"); // correct DDCSV Format for spindle control.
writeBlock(gFormat.format(4), 'P'+pDelay); // wait for plasma delay
writeln('F'+(properties. plasmaPierceSpeed)); // Set the pierce feed rate
writeBlock(gFormat.format(0), 'Z',cHeight, 'F'+(properties.plasmaPierceSpeed)); // move down to cut height
// writeln('F'+(properties.plasmaCutSpeed)); // Set the cut feed rate
var f = 'F'+(hasParameter("operation:tool_feedEntry") ? getParameter("operation:tool_feedCutting") : toPreciseUnit(1000, MM));
if (f) {
writeln(f);
}
// We're now cutting!! WOOT!!
// the rest of the moves on the path are processed by the 'onLinear' and 'OnCircular' functions
}
} else { //no power so do torch off and lift head clear of workpiece
if (spotMarking == true) {
//writeComment("[END] Spot Mark - Operation #" + cutCount);
} else {
//writeComment("[END] Cut Path - Operation #" + cutCount);
}
spotMarking = false;
writeln('F'+(properties.plasmaPositionSpeed)); // Set the positioning feed rate
writeBlock(mFormat.format(5)), writeBlock(gFormat.format(0), 'Z',(properties.plasmaSafeZ));
writeBlock(gFormat.format(4), 'P',(properties.plasmaPostFlowDelay)); // wait for post flow delay
}
}
/**********
* onCyclePoint
* This is called for each drilling operation it includes the hole location
* We've hacked it to move to our spot mark locations and call the torch control function (onPower) instead.
* It's a complete bastardisation of its intended use. But it works.
*
*******************/
function onCyclePoint(x, y, z, r) {
// If we're in this function we are 'drilling' (spot marking) so let's set a var we can use later on.
spotMarking = true;
writeComment("Operation #" + ( cutCount + 1) + " Move to Spot Mark Location"); // tell the world
writeBlock(gFormat.format(0), 'X'+ x, 'Y'+ y); // move above the hole
onPower(1); // lets cheat and call the plasma function
onPower(0); // lets call the plasma function again with the 'power' set to '0'
}
/**********
* onRapid
*
*******************/
function onRapid(_x, _y, _z) {
var x = xOutput.format(_x);
var y = yOutput.format(_y);
var z = zOutput.format(_z);
if (x || y || z) {
writeln("G00 " + x + " " + y); // we control Z height via the plasma torch control routine (onPower)
}
}
/**********
* onLinear
*
*******************/
function onLinear(_x, _y, _z, feed) {
var x = xOutput.format(_x);
var y = yOutput.format(_y);
var z = zOutput.format(_z);
// var f = feedOutput.format(feed);
var f = 'F'+(hasParameter("operation:tool_feedEntry") ? getParameter("operation:tool_feedEntry") : toPreciseUnit(1000, MM));
if (x || y || z) {
if (properties.plasma3Dcut == true) {
writeln("G01 " + x + " " + y + " " + z + " " + f); // we include Z height for cutting non 2D surfaces (tubes etc)
} else {
writeln("G01 " + x + " " + y + " " + f); // we control Z height via the plasma torch control routine (onPower) + THC
}
}
}
/**********
* onCircular
*
*******************/
function onCircular(clockwise, cx, cy, cz, x, y, z, feed) {
var start = getCurrentPosition();
// var f = feedOutput.format(feed);
var f = 'F'+(hasParameter("operation:tool_feedEntry") ? getParameter("operation:tool_feedEntry") : toPreciseUnit(1000, MM));
if (f) {
writeln(f);
}
if (properties.plasma3Dcut == true) {
writeln((clockwise ? "G02 " : "G03 ") +
xOutput.format(x) + " " +
yOutput.format(y) + " " +
iOutput.format(cx - start.x, 0) + " " +
jOutput.format(cy - start.y, 0) + " " +
jOutput.format(cz - start.z, 0)); // we include Z height for cutting non 2D surfaces (tubes etc)
} else {
writeln((clockwise ? "G02 " : "G03 ") +
xOutput.format(x) + " " +
yOutput.format(y) + " " +
iOutput.format(cx - start.x, 0) + " " +
jOutput.format(cy - start.y, 0)); // we control Z height via the plasma torch control routine (onPower)
}
}
/**********
* onClose
*
*******************/
function onClose() {
setCoolant(COOLANT_OFF); // turn air off?
onImpliedCommand(COMMAND_STOP_SPINDLE);
//onImpliedCommand(COMMAND_END);
writeln("M5"); // turn plasma off
// Various end commands - uncomment whichever works with your setup
//writeln("G00 " + zOutput.format(safeRetractZ)); // retract to safe Z
//writeln("G28 " + zOutput.format(safeRetractZ)); // return to home
//writeln("M02");
writeln("M30"); // (used by Fusion360 'Post Process All' - https://github.com/TimPaterson/Fusion360-Batch-Post)
//writeln("M99");
writeComment("JOB FINISH");
}
/**********
* onSection
*
*******************/
function onSection() {
operationCount = operationCount + 1;
writeComment("Setup #" + operationCount);
var insertToolCall = isFirstSection() || (tool.number != getPreviousSection().getTool().number);
if (insertToolCall) {
//writeBlock("T" + toolFormat.format(tool.number), mFormat.format(6));
writeBlock("T" + toolFormat.format(tool.number)); // (used by Fusion360 'Post Process All' - https://github.com/TimPaterson/Fusion360-Batch-Post)
// Note, to prevent z change issues relating to different tool offsets, make sure you select same tool number on post processor tab for all tools
}
}