; ; FANUC ; ----- ; @init_post global string tool_diameter_f global numeric flag1 flag2 m_feed_flag global integer oword global integer owordnext global integer loop_num ; Non GPPL variables num_user_procs = 1 line_labels = FALSE ; Jump to N... ; 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 ; trace 'all':5 endp ;------------------- @start_of_file ; before tools definition {'%'} {nl, '(',g_file_name, ')'} {nl, '( MCV-OP )', ' (',DATE ')'} oword = 501 owordnext = 501 ; {nb, '(oword initialized to: ',oword,')'} ; {nb,'(xhome =',xhome,')'} ; {nb,'(yhome =',yhome,')'} ; {nb,'(zhome =',zhome,')'} if rotate_used then gcode = 69 {nb, 'G'gcode} endif if mirror_used then {nb, 'G50.1 X0 Y0'} endif {nb, '(SUBROUTINES: O'first_proc_number, ' .. O'last_proc_number, ')'} {nb, 'G92.1'} flag2 = 0 endp ;------------------- @start_program ; after tools definition {nb, 'G80 G49 G40'} ; call @home_number endp ;------------------- @end_program ; {nb, 'M98 P9010'} {nb, 'M30'} {nb, 'G92.1'} endp ;------------------- @end_of_file {nl, '%'} 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'} oword = owordnext ; {nb, '# = ', loop_level} ; {nb, '# = ', loop_count} ;if oword eq owordnext then {nb, 'O',oword,' WHILE [#', var_num, ' LT ', loop_count, ']'} oword = oword + 1 ;else ; {nb, 'O',owordnext,' WHILE [#', var_num, ' LT ', loop_count, ']'} ; oword = owordnext ;endif owordnext = owordnext +1 endp ;---------------- @end_loop local integer home_num local integer var_num var_num = loop_level + 20 ; {nb '(CODE TO END THE LOOP - START)'} {nb '#', var_num, ' = [#', var_num, ' + 1]'} loop_num = var_num home_num = 53 + home_number {nb 'G'home_num} oword = oword - 1 {nb 'O',oword,' ENDWHILE'} ; {nb,'(xhome =',xhome,')'} ; {nb,'(yhome =',yhome,')'} ; {nb,'(zhome =',zhome,')'} ; {nb 'G0 z25'} ; {nb 'G0 X0 Y0'} ; {nb,'(G92.1)'} ; {nb '(CODE TO END THE LOOP - ENDS)'} 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 local integer var_num var_num = loop_level + 20 ; {nb '(CODE TO CHANGE THE REF - START)'} {nb, 'G0 Z50'} {nb, 'G0 X0 Y0'} ; {nb, '(G92.1)'} ;if var_num eq 22 then ; {nb, 'G92 X[[#',var_num,'+1]*',xhome,']',' Y[#',(var_num-1),'*',yhome,']'} ;else ;if var_num eq 21 then ; {nb, 'G92 X[',xhome,']',' Y[#',var_num,'*',yhome,']'} ; else {nb, 'G92 X[-',xhome,']',' Y[-',yhome,']'} ; endif ;endif {nb, 'G90'} ; {nb '(CODE TO CHANGE THE REF - END)'} 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 {nb, 'G92.1'} {nb, 'G54'} {nb, 'G30'} if flag2 eq 0 call @home_number endif flag2 = 1 local logical save_blknum_gen ; {nb, 'M98 P9011'} {nb, 'G91 G28 Z0'} {nb, 'G90'} ; if tool_number gt 20 and tool_number lt 40 ; tool_number = (tool_number - 20) ; endif ; if tool_number gt 40 and tool_number lt 60 ; tool_number = (tool_number - 40) ; endif ; if tool_number gt 60 and tool_number lt 80 ; tool_number = (tool_number - 60) ; endif {nb, 'M01'} blknum_gen = true {nb, 'M6 T'tool_number} blknum_gen = FALSE if tool_type eq 0 then {nb, '( TOOL -'tool_number, '- DRILL DIA 'tool_diameter, ' MM )'} endif if tool_type eq 1 then {nb, '( TOOL -'tool_number, '- ROUGH DIA 'tool_diameter, ' MM )'} endif if tool_type eq 2 then {nb, '(TOOL -'tool_number, '- MILL DIA 'tool_diameter, ' R'corner_radius,' MM )'} endif ;{nb, 'G90 G00 G40 G'(53 + home_number)} label = first_user_proc save_blknum_gen = blknum_gen ;gcode = 43 ;{nb, 'G'gcode, ' H'tool_number, ' D'(tool_number+30), ' '} blknum_gen = save_blknum_gen xpos = xnext ypos = ynext zpos = znext skipline = FALSE call @rapid_move tool_direction = CCW call @start_tool if colent eq 0 {nb, 'M8'} endif if colent eq 17 {nb, 'M17'} endif if colent eq 18 {nb, 'M18'} endif 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 ;runs at the start of every machining operation 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 = 4 else ; CCW mcode = 3 endif {' 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