Hello Guest it is March 28, 2024, 04:31:56 PM

Author Topic: Subroutine  (Read 2661 times)

0 Members and 1 Guest are viewing this topic.

Subroutine
« on: March 17, 2012, 11:38:50 PM »
Trying to get subroutine to work. If I create G code file with  Bob CAD nest and post using subroutine Mach runs file just fine. Problem is Bob CAD creates a corrupt contour ramp file in nest ( Been waiting 6 months for fix) What I want to do is swap the corrupt file with a known good file. Sometimes I need to call sub 150+ times so I want simple. I've read the manual and many  forum post still don't get it.

%
O100 (BOBCAD2.NC)
N01 (DATE - SAT. 03/17/2012 , TIME - 09:15PM)
N02 (POST -  MACH3 )

(T1 - 0.265 DIA. ENDMILL ROUGH)

N03 G00 G20 G90 G17 G40 G80 G49 G64 G94
N04 T1 M06 (0.265 ENDMILL ROUGH)
N05 G90 S706 M03
N06 G00 G54 X1.4173 Y1.9973
N07 G43 H1 Z0.25
N08 M98 P10 (SUBROUTINE CALL)
N09 X0.402 Y4.0492
N10 M98 P10 (SUBROUTINE CALL)
N11 G00 Z0.25
N12 X1.4173 Y6.1006
N13 M98 P10 (SUBROUTINE CALL)
N14 G00 Z0.25
N15 X3.708 Y1.9973
N16 M98 P10 (SUBROUTINE CALL)
N17 G00 Z0.25

N222 M05
N223 M09
N224 G91
N227 M30
%
(I WANT THE FOLLOWING TO BE THE SUB)
%
O10 (BGP2.NC)

N03 G00 G20 G90 G17 G40 G80 G49 G64 G94
N04 T1 M06 (0.265 ENDMILL ROUGH)
N05 G90 S24000 M03
N06 G00 G54 X0.9947 Y0.2553
N07 G43 H1 Z0.25
N08 G01 Z0. F210.
N09 G41 D1 Y0.0053 F160.
N10 G17 G02 X0.9947 Y0.0053 Z-0.5 I-1. J0. F210.
N11 X0.3628 Y0.9351 Z-0.905 I-1. J0.
N12 X0.9947 Y0.0053 I-0.3681 J-0.9298 F160.
N13 X0.3628 Y0.9351 I-1. J0.
N14 X0.9759 Y0.1979 Z.25 I-0.3681 J-0.9298
N15 G00 Z0.25
N18 G91
N21 M30
%

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Subroutine
« Reply #1 on: March 18, 2012, 12:00:55 AM »
OK here is your sub what exactly did you want to do with it?  Are you calling it from inside a Gcode program or is it to be a remote call? IT is an odd combination of SUB  but to each his own I guess. As long as it works for you.

O10 (BGP2.NC)
N03 G00 G20 G90 G17 G40 G80 G49 G64 G94
N04 T1 M06 (0.265 ENDMILL ROUGH)
N05 G90 S24000 M03
N06 G00 G54 X0.9947 Y0.2553
N07 G43 H1 Z0.25
N08 G01 Z0. F210.
N09 G41 D1 Y0.0053 F160.
N10 G17 G02 X0.9947 Y0.0053 Z-0.5 I-1. J0. F210.
N11 X0.3628 Y0.9351 Z-0.905 I-1. J0.
N12 X0.9947 Y0.0053 I-0.3681 J-0.9298 F160.
N13 X0.3628 Y0.9351 I-1. J0.
N14 X0.9759 Y0.1979 Z.25 I-0.3681 J-0.9298
N15 G00 Z0.25
N18 G91
N21 M99
%
« Last Edit: March 18, 2012, 12:02:36 AM by BR549 »

Offline rcaffin

*
  •  1,052 1,052
    • View Profile
Re: Subroutine
« Reply #2 on: March 18, 2012, 11:37:54 PM »
Quote
Trying to get subroutine to work.
N18 G91
N21 M30
%

The M30 command is ONLY for a main program. To return from a subroutine to the main program you MUST use M99.

Cheers