-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathFANUC.GPP
616 lines (512 loc) · 12.2 KB
/
FANUC.GPP
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
; ; FANUC
; -----
;
@init_post
global string tool_diameter_f
global numeric flag1 flag2 m_feed_flag
global logical Pstart_flag
global string tstr
global string date_mark
global string time_mark
global string PID
global string used_tools<<100>>
global integer cur_tool cur_o_number
global integer tools_num
; Non GPPL variables
num_user_procs = 1
line_labels = FALSE ; Jump to N...
; Touchoff button position
;tob_posX = 111.111
;tob_posY = 222.222
;tob_posZ = 333.333
; GPPL variables
pre_processor = 'FANUC'
numeric_def_f = '5.3'
integer_def_f = '5.0(p)'
gcode_f = '2.0(p)'
mcode_f = '2.0(p)'
xpos_f = '5.3'
ypos_f = '5.3'
zpos_f = '5.3'
feed_f = '4.3(p)'
tool_diameter_f = '5.3/1'
blknum_f = '5.0(p)'
blknum_gen = false
blknum_exist = true
blknum = 1
blknum_delta = 1
blknum_max = 32000
;PID = 12345678901234
cur_tool = 1
tools_num = 0
; trace 'all':5
endp
;-------------------
@start_of_file
; before tools definition
;{'%'}
{'(', g_file_name, ')'}
{nl, '(',DATE ')'}
{nl}
{nl, '#12=1 (çàäàíèå êîë-âà ïîâòîðîâ ïî X)'}
{nl, '#13=0 (çàäàíèå ñìåùåíèÿ ïî X ìì)'}
{nl}
{nl, '#14=1 (çàäàíèå êîë-âà ïîâòîðîâ ïî Y)'}
{nl, '#15=0 (çàäàíèå ñìåùåíèÿ ïî Y ìì)'}
if rotate_used then
gcode = 69
{nb, 'G'gcode}
endif
if mirror_used then
{nb, 'G50.1 X0 Y0'}
endif
;rev{nb, '(SUBROUTINES: O'first_proc_number, ' .. O'last_proc_number, ')'}
{nl}
flag2 = 0
Pstart_flag = 1
cur_o_number = 105 ; cur number of procedure
endp
;-------------------
@start_program
; after tools definition
{nb, ' G21 G49 G0 ( ABS mm clr_Z_offset rapid_motion )' }
; call @home_number
endp
;-------------------
@end_program
{nl}
{nl, 'g0 x0 y0 (Â êîíöå ïðîãðàììû ïîâòîðà íà 0 êîîðäèíàò!)'}
{nl, 'g92 x-#13 (Ñäâèã ïî X)'}
;cur_o_number = cur_o_number + 1
{nl, 'o', cur_o_number, ' endrepeat'}
{nl, 'g92.1 (Îòìåíà îôñåòîâ ïî G92)'}
{nl, 'g90'}
{nl, 'g92 y-#15 (Ñäâèã ïî Y)'}
cur_o_number = cur_o_number + 1
{nl, 'o', cur_o_number, ' endrepeat'}
{nl, 'g92.1 (Îòìåíà îôñåòîâ ïî G92)'}
{nl, 'g90'}
;cur_o_number = cur_o_number + 1
;{nl, '#31 = ', PID}
;{nl, '#32 = 1'}
{nl, 'M30'}
endp
;-------------------
@end_of_file
;{nl, '%'}
{nl, '( =========================================== )'}
{nl, '( ÈÍÑÒÐÓÌÅÍÒÎÂ ', tools_num,' øò. )'}
cur_tool = 1
while cur_tool <= tools_num
{nl, '(', used_tools<<cur_tool>> };,')'}
cur_tool = cur_tool + 1
endw
{nl, '( =========================================== )'}
{nl}
{nl, '( Processed by postprocessor v.1.03 )'}
{nl, '( ©GSElabs, 2013 )'}
{nl, '( https://github.com/G-S-E )'}
endp
;-------------------
@relative_mode
gcode = 91
{nb, 'G'gcode, ' '}
skipline = FALSE
endp
;-------------------
@absolute_mode
gcode = 90
{nb, 'G'gcode, ' '}
skipline = FALSE
endp
;-------------------
@machine_plane
if machine_plane eq XY
gcode = 17
endif
if machine_plane eq YZ
gcode = 18
endif
if machine_plane eq ZX
gcode = 19
endif
;{nb, 'G'gcode}
endp
;-------------------
@call_proc
if active(parm1) then
gcode = 65
{nb, 'G'gcode, ' P'label}
{' A'parm1, [' B'parm2], [' C'parm3]}
else
{nb, 'M98 P'label}
endif
if proc_count gt 1 then
{' L'proc_count}
endif
{[' ('message, ')']}
endp
;-------------------
@proc
{nl, 'O'label}
endp
;-------------------
@end_proc
if dely eq 1
{' G64 '}
endif
{nb, 'M99'}
endp
;----------------
@loop
local integer var_num
var_num = loop_level + 20
{nb, '#', var_num, ' = 0'}
{nb, 'WHILE [#', var_num, ' LT ', loop_count, '] DO ', loop_level}
endp
;----------------
@end_loop
local integer var_num
var_num = loop_level + 20
{nb '#', var_num, ' = #', var_num, ' + 1'}
{nb 'G'home_number}
{nb 'END ', loop_level}
endp
;----------------
@def_tool
;;; {nb, '(G10 L12 P', (tool_number+50), ' R'tool_offset, ')'}
endp
;-------------------
@rapid_move
{nb}
gcode = 0
if change(gcode) then
{'G'gcode}
else
{' '}
endif
{[' X'xpos], [' Y'ypos], [' Z'zpos]}
; if flag1 eq 1
; {' S'spin:'5.0(p)',' M03'}
; {nb, 'M08'}
; endif
; flag1 = 0
endp
;-------------------
@line
{nb}
gcode = 1
if change(gcode) then
{'G'gcode}
else
{' '}
endif
{[' X'xpos], [' Y'ypos], [' Z'zpos]}
if m_feed_flag eq 1
m_feed_flag = 0
{ ' F'feed}
else
{ [' F'feed]}
endif
endp
;-------------------
@arc
{nb}
if arc_direction eq CCW then
gcode = 3
else ; CW
gcode = 2
endif
if change(gcode) then
{'G'gcode}
else
{' '}
endif
{[' X'xpos] [' Y'ypos] [' Z'zpos]}
if arc_size eq 360 then
if arc_plane eq XY then
{' I'xcenter_rel, ' J'ycenter_rel}
endif
if arc_plane eq YZ then
{' J'xcenter_rel, ' K'ycenter_rel}
endif
if arc_plane eq ZX then
{' K'xcenter_rel, ' I'ycenter_rel}
endif
else
if arc_size >= 180 then
radius = -radius
endif
{' R'radius}
endif
if m_feed_flag eq 1
m_feed_flag = 0
{ ' F'feed}
else
{ [' F'feed]}
endif
endp
;-------------------
@compensation
if side eq COMP_LEFT then
gcode = 41
endif
if side eq COMP_RIGHT then
gcode = 42
endif
if side eq COMP_OFF then
gcode = 40
endif
{nb, 'G'gcode, ' '}
skipline = FALSE
endp
;-------------------
@delay
gcode = 4
{nb 'G'gcode, ' P'delay_period:integer_def_f}
endp
;-------------------
@change_ref_point
; Given in absolute mode
gcode = 10
{nb, 'G'gcode, 'G91 L2 P'home_number ' X'xhome, ' Y'yhome, ' Z'zhome}
{nb,'G90'}
endp
;-------------------
@home_number
;gcode = 53 + home_number
;{nb, 'G'gcode}
flag2 = 1
endp
;-------------------
@rotate
; Not exist in FANUC 6M
if rotate_cancel then
gcode = 69
{nb, 'G'gcode}
else
gcode = 68
{nb, 'G'gcode, ' x0 y0 G91 R'angle}
{nb, 'G90'}
endif
endp
;-------------------
@fourth_axis
gcode = 0
{nb, 'G'gcode, ' A'angle}
endp
;-------------------
@change_tool
if Pstart_flag eq 1 ; on start iteration
;Pstart_flag = 0
else
{nl}
{nl, 'g0 x0 y0 (Â êîíöå ïðîãðàììû ïîâòîðà íà 0 êîîðäèíàò!)'}
{nl, 'g92 x-#13 (Ñäâèã ïî X)'}
;cur_o_number = cur_o_number + 1
{nl, 'o', cur_o_number, ' endrepeat'}
{nl, 'g92.1 (Îòìåíà îôñåòîâ ïî G92)'}
{nl, 'g90'}
{nl, 'g92 y-#15 (Ñäâèã ïî Y)'}
cur_o_number = cur_o_number + 1
{nl, 'o', cur_o_number, ' endrepeat'}
{nl, 'g92.1 (Îòìåíà îôñåòîâ ïî G92)'}
{nl, 'g90'}
cur_o_number = cur_o_number + 1
endif
tstr = '(MSG, Óñòàíîâè T' + tostr(tool_number)
if tool_type eq 0 then
tstr = tstr + ' - ÑÂÅÐËÎ D=' + tostr(tool_diameter) + 'MM )'
endif
if tool_type eq 1 then
tstr = tstr + ' ÐÀÄÈÓÑÍÀß ÔÐÅÇÀ D=' + tostr(tool_diameter) + 'MM, R=' + tostr(corner_radius) + ' MM)'
endif
if tool_type eq 2 then
tstr = tstr + ' ÔÐÅÇÀ D=' + tostr(tool_diameter) + 'MM, R=' + tostr(corner_radius) + ' MM)'
endif
if tool_type eq 3 then
tstr = tstr + ' ÒÈÏ 3 D=' + tostr(tool_diameter) + 'MM, R=' + tostr(corner_radius) + ' MM)'
endif
if tool_type eq 4 then
tstr = tstr + ' ÒÈÏ 4 D=' + tostr(tool_diameter) + 'MM, R=' + tostr(corner_radius) + ' MM)'
endif
if tool_type eq 5 then
tstr = tstr + ' ÒÈÏ 5 D=' + tostr(tool_diameter) + 'MM, R=' + tostr(corner_radius) + ' MM)'
endif
if tool_type eq 6 then
tstr = tstr + ' ÒÈÏ 6 D=' + tostr(tool_diameter) + 'MM, R=' + tostr(corner_radius) + ' MM)'
endif
if tool_type eq 7 then
tstr = tstr + ' ÒÈÏ 7 D=' + tostr(tool_diameter) + 'MM, R=' + tostr(corner_radius) + ' MM)'
endif
if tool_type eq 18 then
tstr = tstr + ' - ÑÂÅÐËÎ ÖÅÍÒÐÎÂÎ×ÍÎÅ D='+ tostr(tool_diameter) + ' MM R'+ tostr(corner_radius)+' MM)'
endif
if tool_type eq 15 then
tstr = tstr + ' - ÔÐÅÇÀ ÑÔÅÐÈ×ÅÑÊÀß D='+ tostr(tool_diameter) + ' MM R'+ tostr(corner_radius)+' MM)'
endif
{nl}
{nl, tstr}
used_tools<<tools_num+1>> = substr(tstr,15,strlen(tstr))
tools_num = tools_num + 1
; MIST coolant off
{nl, 'M9 (turn all coolant off)'}
if Pstart_flag eq 1 ; on start iteration
Pstart_flag = 0
{nl, 'o100 call (o100 - ïåðâûé çàìåð, o101 - ñëåäóþùèé çàìåð.)'}
;{nl, '(o101 call)'}
else
{nl, 'o101 call'}
endif
; turn-on MIST coolant if needed
if MIST eq 0
;NOP
else
{nl, 'M7 (turn mist coolant on)'}
endif
{nl}
cur_o_number = cur_o_number + 1
{nl, 'o', cur_o_number, ' repeat [#14] (Ïîâòîð ... ðàç ïî Y)'}
cur_o_number = cur_o_number - 1
{nl, 'o', cur_o_number, ' repeat [#12] (Ïîâòîð ... ðàç ïî X)'}
{nl}
tool_direction = CW
call @start_tool
{nl}
xpos = xnext
ypos = ynext
zpos = znext
skipline = FALSE
call @rapid_move
endp
;-------------------
@new_tool
{nb, '(', message, ')'}
endp
;-------------------
@message
{nb, '(', message, ')'}
endp
;-------------------
@drill
call @rapid_move
if drill_type eq drilling then
gcode = 81
endif
if drill_type eq f_drill then
gcode = 82
endif
if drill_type eq peck then
gcode = 83
endif
if drill_type eq tapping then
gcode = 84
endif
if drill_type eq boring then
gcode = 85
endif
if drill_type eq r_boring then
gcode = 86
endif
if drill_type eq f_boring then
gcode = 89
endif
if drill_type eq tapping then
{nb,'M29 S'spin:integer_def_f}
endif
{nb,'G98 G'gcode, ' Z'drill_lower_z, ' R'drill_upper_z}
if drill_type eq peck then
{' Q'down_step}
endif
if drill_type eq f_drill or drill_type eq tapping then
{' P'delay:integer_def_f}
endif
{' F'feed}
endp
;-------------------
@drill_point
if not first_drill then
{nb, ' ', [' X'xpos], [' Y'ypos], [' Z'zpos]}
endif
endp
;-------------------
@mirror
if mirror_type eq MIRROR_OFF then
{nb, 'G50.1 X0 Y0'}
else
{nb, 'G51.1 '}
if mirror_type eq MIRROR_X then
{'X1 Y0'}
endif
if mirror_type eq MIRROR_Y then
{'X0 Y1'}
endif
if mirror_type eq MIRROR_XY then
{'X1 Y1'}
endif
endif
endp
;-------------------
@end_drill
gcode = 80
{nb, 'G'gcode}
endp
;-------------------
@halt_program
{' M0'}
endp
;--------------------
@round_comp
; NOP
endp
;--------------------
@start_of_job
if dely eq 1
{nb, 'G61'}
endif
; flag1 = 1
endp
;--------------------
@end_of_job
; NOP
endp
;--------------------
@assign_axis
; TBD
endp
; =======================
; USER DEFINED PROCEDURES
; =======================
@call_simple_proc
active(message) = FALSE
active(parm1) = FALSE
active(parm2) = FALSE
active(parm3) = FALSE
proc_count = 1
call @call_proc
endp
;-------------------
@start_tool
if tool_direction eq CW then
mcode = 3
else ; CCW
mcode = 4
endif
{nl , 'S'spin:integer_def_f, ' M'mcode}
endp
;-------------------
@m_feed_spin
; if tool_direction eq CW then
; mcode = 4
; else ; CCW
; mcode = 3
; endif
; if change(spin)
; {nb,'S'spin:integer_def_f, ' M'mcode}
; endif
; m_feed_flag = 1
endp
;-------------------
@stop_tool
; {' M5'}
endp