Hello Guest it is April 19, 2024, 05:39:53 AM

Author Topic: M98 subroutine won't execute  (Read 2506 times)

0 Members and 1 Guest are viewing this topic.

M98 subroutine won't execute
« on: March 26, 2012, 01:13:35 AM »
Ok, this is embarassing.  I've read that some of you are using the M98 syntax for a subroutine call.  So the function must be working in Mach3.  The trouble is that I can't get it to work.  I really need this to work and here is a very simple test file that I wrote:

;( CNC File       :- Injector Hole Test ver A3 )
;( Produced       :- March 25, 2012 )
;( Post Processor :- M_Mach 3_inc 02_02_12 )
;( Part Number ID :- Injector complete pocket )
;( Tools Used )
;( T01  9.53mm End Mill)
;( T02  6.35mm End Mill)
;( T03  5.56 Twist Drill / Center Drill)
;
%
N5  O0001
N10 G00 G21 G17 G90 G40 G49
N20 G52  X30.0  y0.0  ;start with first offset
N30 M98  P0002 L1  ;call the machining routine
N40 G52 X60  Y0.0  ;use a different offset to run it again
N30 M98  P0002 L1  ;call the machining routine
N50 G28
N60 M30
;
;Injector pocket routine is here
N70 O0002  ;injector pocket routine
N80 M05
N90 X0.      Y0.
N100 M06 T03
N110 M03
N120 G43 H3
N130 S2000
N140 G04 P2.0
N150 G00 x20  Y-20  Z50
N155 M99
N160 G98 G83 X20  Y-20  Z-7.0 Q1.0   R3.0  F100.0
N170 G80
N180 G00 Z80.
;
N190 M05
N200 M06 T01  ;tool change to 9.53mm  end mill
N210 M03
N220 G43 H1
N230 S2500
N240 G04 P2.0
N250 X20    Y-20    F1000
N260 Z3
;
;Mill out the full depth of the 24mm body first.  Use 2mm go-round cuts
;make the 24mm body pocket in 2 steps, first to 15mm depth
N270 G01 Z-7.0  F30  ;plunge to 15mm depth
N280 G01 X22  F15  ;OD cut #1, of 5
N290 G03 X22  I-2.0  J0  ;go-round
N300 G01 X24       ;OD cut #1, of 5
N310 G03 X24  I-4.0  J0  ;go-round
N320 G01 X26    ;OD cut #2, of 5
N330 G03 X26  I-6.0  J0  ;go-round
N340 G01 X27.2    ;OD cut #3, of 5
N350 G03 X27.2  I-7.2  J0  ;go-round
N360 G03 X27.2  I-7.2  J0  F40 ;go-round for cleanup
N370 G01 X26  F500  ;back away from the wall
N380 G01 Z-3.8  ;Move up to the upper O-ring step
N390 G01 X28.2 F15
N400 G03 X28.2  I-8.2  J0  ;go-round
N410 G03 X28.2  I-8.2  J0  F50 ;go-round for cleanup
N420 G01 X20  F500  ;back to center
N430 G00 Z50.
N440 M99  ;end of routine
%

Lines N5 through N60 execute without doing anything.  Nothing at all.  The toolpath window of Mach3 shows nothing.  Why???  What's wrong here.  The code itself works fine.  Here is the same code with very minor differences that I've run on metal:

;( CNC File       :- Injector Hole Test ver A3 )
;( Produced       :- March 25, 2012 )
;( Post Processor :- M_Mach 3_inc 02_02_12 )
;( Part Number ID :- Injector complete pocket )
;( Tools Used )
;( T01  9.53mm End Mill)
;( T02  6.35mm End Mill)
;( T03  5.56 Twist Drill / Center Drill)
;
%
N10 G00 G21 G17 G90 G40 G49
N20 M05
N20 G52 X90 Y0  ;use this offset to find an open spot in the practice material
N30 X0.      Y0.
N40 M06 T03  ;Change to 5.56mm drill bit
N50 M03
N60 G43 H3
N70 S2000
N80 G04 P2.0
N90 G00 x20  Y-20  Z50
N110 G98 G83 X20  Y-20  Z-7.0 Q1.0   R3.0  F100.0  ;Peck drill with rapid in-feed
N120 G80
N130 G00 Z80.
;
N140 M05
N150 M06 T01  ;tool change to 9.53mm  end mill
N160 M03
N170 G43 H1  ;use the offset for this tool
N180 S2000
N190 G04 P2.0
N200 X20    Y-20    F1000
N210 Z3
;
;Mill out the full depth of the 24mm body first.  Use 2mm go-round cuts
N220 G01 Z-7.0  F30  ;plunge to 7mm depth
N230 G01 X22  F20  ;OD cut #1, of 5
N240 G03 X22  I-2.0  J0  ;go-round
N250 G01 X24       ;OD cut #1, of 5
N260 G03 X24  I-4.0  J0  ;go-round
N270 G01 X26    ;OD cut #2, of 5
N280 G03 X26  I-6.0  J0  ;go-round
N290 G01 X27.2    ;OD cut #3, of 5
N300 G03 X27.2  I-7.2  J0  ;go-round
N310 G03 X27.2  I-7.2  J0  F100 ;go-round for cleanup
N320 G01 X26  F500  ;back away from the wall
N330 G01 Z-3.8  ;Move up to the upper O-ring step
N340 G01 X28.3 F40
N350 G03 X28.3  I-8.3  J0  ;go-round
N360 G03 X28.3  I-8.3  J0  F100 ;go-round for cleanup
N370 G01 X20  F500  ;back to center
N380 G00 Z50.
;
N390 G28
N392 G52 X0 Y0
N400 M30
%

The code without the subroutine call works fine.  The subroutine call does not.  I've spent days on this.  What's going on???  BTW, it would be VERY VERY helpful to have a working example of the M98/M99 syntax in the manual. 

Thank you,
Steve

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: M98 subroutine won't execute
« Reply #1 on: March 26, 2012, 01:43:05 AM »
OK first you cannot use line numbers on lines that contain the Oword. Mach cannot see the Oword if you do.

You first SUB it NOT a sub that is the main program it cannot have the Oword at teh beginning.

In sub # 2 you have a M99 at line 155 which stops the rest of the code from runnning is the following code part of the sub OR main program. IF main program it is in the wrong place. IF sub then remove the M99 so the rest can run. It is ODD to have a tool change in the middle of a sub BUT if it works(;-)


;( CNC File       :- Injector Hole Test ver A3 )
;( Produced       :- March 25, 2012 )
;( Post Processor :- M_Mach 3_inc 02_02_12 )
;( Part Number ID :- Injector complete pocket )
;( Tools Used )
;( T01  9.53mm End Mill)
;( T02  6.35mm End Mill)
;( T03  5.56 Twist Drill / Center Drill)
;
%
(main Program)
N10 G00 G21 G17 G90 G40 G49
N20 G52  X30.0  y0.0  ;start with first offset
N30 M98  P0002 L1  ;call the machining routine
N40 G52 X60  Y0.0  ;use a different offset to run it again
N30 M98  P0002 L1  ;call the machining routine
N50 G28
N60 M30
;
;Injector pocket routine is here
N70 O0002  ;injector pocket routine
N80 M05
N90 X0.      Y0.
N100 M06 T03
N110 M03
N120 G43 H3
N130 S2000
N140 G04 P2.0
N150 G00 x20  Y-20  Z50

N160 G98 G83 X20  Y-20  Z-7.0 Q1.0   R3.0  F100.0
N170 G80
N180 G00 Z80.
;
N190 M05
N200 M06 T01  ;tool change to 9.53mm  end mill
N210 M03
N220 G43 H1
N230 S2500
N240 G04 P2.0
N250 X20    Y-20    F1000
N260 Z3
;
;Mill out the full depth of the 24mm body first.  Use 2mm go-round cuts
;make the 24mm body pocket in 2 steps, first to 15mm depth
N270 G01 Z-7.0  F30  ;plunge to 15mm depth
N280 G01 X22  F15  ;OD cut #1, of 5
N290 G03 X22  I-2.0  J0  ;go-round
N300 G01 X24       ;OD cut #1, of 5
N310 G03 X24  I-4.0  J0  ;go-round
N320 G01 X26    ;OD cut #2, of 5
N330 G03 X26  I-6.0  J0  ;go-round
N340 G01 X27.2    ;OD cut #3, of 5
N350 G03 X27.2  I-7.2  J0  ;go-round
N360 G03 X27.2  I-7.2  J0  F40 ;go-round for cleanup
N370 G01 X26  F500  ;back away from the wall
N380 G01 Z-3.8  ;Move up to the upper O-ring step
N390 G01 X28.2 F15
N400 G03 X28.2  I-8.2  J0  ;go-round
N410 G03 X28.2  I-8.2  J0  F50 ;go-round for cleanup
N420 G01 X20  F500  ;back to center
N430 G00 Z50.
N440 M99  ;end of routine
%