-
Notifications
You must be signed in to change notification settings - Fork 1
/
plasmac.scpost
266 lines (248 loc) · 9.26 KB
/
plasmac.scpost
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
-- *****************************************************************************
-- * USER OPTIONS: change to suit *
-- * *
-- * cParms & pmx485 show custom PlasmaC parameters in the SheetCam tool file. *
-- * SheetCam does not use them but they are read by PlasmaCs materialverter *
-- * to import parameters into the PlasmaC material file from a SheetCam *
-- * toolset file. *
-- * *
-- * The PlasmaC GCode parser will remove line numbers so they don't show in *
-- * in the GUI but if enabled here they will appear in any GCode file saved *
-- * from SheetCam. *
-- *****************************************************************************
cParms = 0 -- set to 1 to show basic custom parameters
pmx485 = 0 -- set to 1 to show RS485 parameters
lineNumbers = 0 -- set to 1 to show linenumbers
noArcs = 0 -- set to 1 to convert arcs to line segments
-- *** DO NOT CHANGE ANYTHING BELOW THIS LINE **********************************
revNum = 'F'
revDate = 'May 15 2020'
assert(os.setlocale('C'))
if cParms == 1 then
post.DefineCustomToolParam('PlasmaTool', 'Puddle jump height', 'pjHeight', sc.unit1DECPLACE, 0, 0, 200)
post.DefineCustomToolParam('PlasmaTool', 'Puddle jump delay', 'pjDelay', sc.unit2DECPLACE, 0, 0, 9)
post.DefineCustomToolParam('PlasmaTool', 'THC enable', 'thcEnable', sc.unitBOOLEAN, 1, 0, 1)
post.DefineCustomToolParam('PlasmaTool', 'Cut voltage', 'cutVolts', sc.unit0DECPLACE, 99, 0, 200)
end
if pmx485 == 1 then
post.DefineCustomToolParam('PlasmaTool', 'Cut current', 'cutAmps', sc.unit0DECPLACE, 45, 10, 200)
post.DefineCustomToolParam('PlasmaTool', 'Gas pressure', 'gasPressure', sc.unit0DECPLACE, 0, 0, 150)
post.DefineCustomToolParam('PlasmaTool', 'Cut mode', 'cutMode', sc.unit0DECPLACE, 1, 1, 3)
end
function OnAbout(event)
ctrl = event:GetTextCtrl()
ctrl:AppendText('For a PlasmaC configuration on LinuxCNC\n\n')
ctrl:AppendText('Revision: ' .. revNum .. ' - ' .. revDate .. '\n')
end
function OnInit()
post.SetCommentChars ('()', '[]') --ensure ( ) characters do not appear in system text
post.Text ('; file name: ', fileName, '\n')
post.Text ('; date and time: ', os.date('%a') , ' ', os.date('%b') , ' ', os.date('%d') , ' ', os.date('%Y') , ' ', time, '\n')
post.Text ('; postprocessor: ', postName, ' rev: ', revNum, '\n')
post.Text (';\n')
post.Text (';begin pre-amble\n')
if scale == metric then
minimumMove = '0.000001'
post.Text (' G21 (units: metric)\n') --metric mode
units = 'mm'
precision = '0.000'
else
post.Text (' G20 (units: inches)\n') --inch mode
minimumMove = '0.00000004'
units = '"'
precision = '0.00000'
end
post.Text (' G40 (cutter compensation: off)\n')
post.Text (' G90 (distance mode: absolute)\n')
post.Text (' M52 P1 (adaptive feed: on)\n')
post.Text (' M65 P2 (enable THC)\n')
post.Text (' M65 P3 (enable torch)\n')
post.Text (' M68 E3 Q0 (velocity 100%)\n')
if scale == metric then
post.Text (' G64 P0.254 Q0.025 (tracking tolerances: 0.254mm)\n')
else
post.Text (' G64 P0.01 Q0.001 (tracking tolerances: 0.01")\n')
end
post.Text (' F#<_hal[plasmac.cut-feed-rate]>\n')
post.Text (';end pre-amble\n')
bigArcs = 1 --stitch arc segments together
minArcSize = 0.2 --arcs smaller than this are converted to moves
cut = 1
cutLength = 0
cutType = 'Cutting'
cutName = 'cut'
pierces = 0
spots = 0
scribes = 0
scribeLength = 0
oldTool = 0
drilling = 0
end
function OnNewLine()
if lineNumbers == 1 then
post.Text ('N')
post.Number (lineNumber, '00000')
post.Text (' ')
lineNumber = lineNumber + 10
end
end
function OnComment()
post.Text('(',commentText,')\n')
end
function OnToolChange()
post.Text (';\n;begin material setup\n')
if string.match (toolName, 'Air Scribe') or
string.match (toolName, 'Engraver') or
string.match(toolClass, 'MarkerTool') then
cutType = 'Scribing'
cutName = 'scribe'
spindleNum = 1
toolNum = 1
elseif string.match (toolName, 'Centre Spot') or
string.match (toolName, 'Center Spot') or
string.match(operationClass, 'DrillOperation') then
cutType = 'Spotting'
cutName = 'spot'
spindleNum = 2
toolNum = 0
else
cutType = 'Cutting'
cutName = 'cut'
spindleNum = 0
toolNum = 0
end
if toolNum ~= oldTool then
post.Text (' T', toolNum, ' M6 (select ', string.lower(cutType), ' tool)\n')
post.Text (' G43 H0 (apply tool offsets)\n')
oldTool = toolNum
end
post.Text (' M190 P' , tool,' (',string.lower(toolName), ' material)\n')
post.Text (' M66 P3 L3 Q2 (wait for valid change)\n')
post.Text (' F#<_hal[plasmac.cut-feed-rate]>\n')
post.Text (';end material setup\n')
end
function OnPenDown()
post.Text ('\n M3 $', spindleNum, ' S1 (', cutName, ' start)\n')
if cutType == 'Scribing' then
scribeLength = scribeLength + (entityLength * scale)
scribes = scribes + 1
elseif cutType == 'Spotting' then
post.Text (' G91 (relative distance mode)\n')
post.Text (' G1 X', minimumMove, ' (tiny move)\n')
post.Text (' G90 (absolute distance mode)\n')
spots = spots + 1
else
cutLength = cutLength + (entityLength * scale)
pierces = pierces + 1
end
entityLength = 0
end
function OnPenUp()
post.Text ('\n M5 $', spindleNum, '(', cutName, ' stop)\n')
if string.match (toolName, 'Air Scribe') then
post.Text (' G4 P1 (pause for scribe retract)\n')
end
post.Text (';end operation #', cut, ', ',string.lower(cutType), '\n')
cut = cut + 1
end
function OnRapid()
if math.hypot(endX - currentX, endY - currentY) < tonumber(minimumMove) then
return
end
if (entityLength and entityLength >= tonumber(minimumMove)) or drilling == 1 then
post.Text (';\n;begin operation #', cut, ', ',string.lower(cutType))
if cutType == 'Cutting' or cutType == 'Scribing' then
post.Text (', ')
post.Number (entityLength * scale, '0.00')
post.Text (units)
end
else
post.Text (';\n;park torch\n')
end
post.Text ('\n')
post.ModalText('')
post.ModalText (' G0')
post.NonModalNumber (' X', endX * scale, precision)
post.NonModalNumber (' Y', endY * scale, precision)
post.Text ('\n')
end
function OnMove()
if cutType == 'Cutting' or cutType == 'Scribing' then
if math.hypot(endX - currentX, endY - currentY) < tonumber(minimumMove) then
return
end
post.ModalText('')
post.ModalText (' G1')
post.NonModalNumber (' X', endX * scale, precision)
post.NonModalNumber (' Y', endY * scale, precision)
post.Text ('\n')
end
end
function OnArc()
if cutType == 'Cutting' or cutType == 'Scribing' then
if noArcs == 1 then
post.ArcAsMoves(0.25)
else
post.ModalText('')
if(arcAngle < 0) then
post.ModalText (' G3')
else
post.ModalText (' G2')
end
post.NonModalNumber (' X', endX * scale, precision)
post.NonModalNumber (' Y', endY * scale, precision)
post.Text (' I')
post.Number ((arcCentreX - currentX) * scale, precision)
post.Text (' J')
post.Number ((arcCentreY - currentY) * scale, precision)
post.Text ('\n')
end
end
end
function OnDrill()
if cutType == 'Spotting' then
drilling = 1
OnRapid()
OnPenDown()
OnPenUp()
drilling = 0
end
end
function OnFinish()
post.Text (';\n;begin post-amble\n')
if toolNum > 0 then
post.Text (' T0 M6 (select torch)\n')
post.Text (' G43 H0 (apply tool offsets)\n')
if cutType == 'Scribing' then
post.Text (' M65 P0\n')
end
end
post.Text (' G40 (cutter compensation: off)\n')
post.Text (' G90 (distance mode: absolute)\n')
post.Text (' M65 P2 (enable THC)\n')
post.Text (' M65 P3 (enable torch)\n')
post.Text (' M68 E3 Q0 (velocity 100%)\n')
post.Text (' M5 $-1 (backup stop)\n')
post.Text (';end post-amble\n')
post.Text (';\n')
post.Text (';begin statistics\n')
if spots > 0 then
post.Text('\n; Spots = ', spots, '\n')
end
if pierces > 0 then
post.Text('\n;Pierces = ', pierces, '\n')
end
if cutType == 'Cutting' then
post.Text('\n; Cuts = ', pierces , ', Length = ')
post.Number (cutLength, '0.00')
post.Text (units, '\n')
end
if scribes > 0 then
post.Text('\n;Scribes = ', scribes , ', Length = ')
post.Number (scribeLength, '0.00')
post.Text (units, '\n')
end
post.Text (';end statistics\n')
post.Text (';\n')
post.Text (' M30 (end program)\n')
end