Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

Fanuc subprograms


dougm
 Share

Recommended Posts

I am trying to run a sub program Inside a main program

this is on a 16I control

I have searched the forums but am still confused.

any help is appreciated.

 

in the control this gives me "Program not found"

sample code

 

T1 M06 ( #1 CENTERDRILL)

(MAX - Z.1)

(MIN - Z-.04)

M08

G00 G17 G90 G54 X-.2461 Y.3346 S6500 M03

(STAGE NEXT TOOL )

M15 E1

Z.1

M98 P0001

G90 X.4939

M98 P0001

M09

M05

G91 G28 Z0.

G90

G53 X3. Y20.

G90

 

N0001

( #1 CENTERDRILL)

G91

G94

G98 G81 Z-.04 R-.1 F20.

Y-.6692

X.4922

Y.6692

G80

M99

 

Doug

Link to comment
Share on other sites

I am trying to run a sub program Inside a main program

this is on a 16I control

I have searched the forums but am still confused.

any help is appreciated.

 

in the control this gives me "Program not found"

sample code

 

T1 M06 ( #1 CENTERDRILL)

(MAX - Z.1)

(MIN - Z-.04)

M08

G00 G17 G90 G54 X-.2461 Y.3346 S6500 M03

(STAGE NEXT TOOL )

M15 E1

Z.1

M98 P0001

G90 X.4939

M98 P0001

M09

M05

G91 G28 Z0.

G90

G53 X3. Y20.

G90

 

N0001

( #1 CENTERDRILL)

G91

G94

G98 G81 Z-.04 R-.1 F20.

Y-.6692

X.4922

Y.6692

G80

M99

 

Doug

 

 

M98 calls an external sub.

 

M97 on a Haas calls an internal sub.

 

M99 is a return from a sub but it is also a call/jump to a sequence number.

 

Make the M98 P0001 a M99 P0001

 

Keep in mind that you'll need the M99 at the end of the drilling to also have a sequence number telling where to return to.

You'll have to figure out how to properly branch and return which will be impossible as Sequence Numbers are not required to be unique.

You can have an entire program with each block having the same sequence number so you need a unique sequence number call at the end of the drilling.

The only way to achieve this is with Macro B.

 

T1 M06 ( #1 CENTERDRILL)

(MAX - Z.1)

(MIN - Z-.04)

M08

G00 G17 G90 G54 X-.2461 Y.3346 S6500 M03

(STAGE NEXT TOOL )

M15 E1

Z.1

#1=[0]

M99 P100

N1

G90 X.4939

M99 P100

N2

M09

M05

G91 G28 Z0.

G90

G53 X3. Y20.

G90

 

N100

( #1 CENTERDRILL)

G91

G94

G98 G81 Z-.04 R-.1 F20.

Y-.6692

X.4922

Y.6692

G80

G90

#1=[#1+1]

M99 P[#1]

Link to comment
Share on other sites

What would be the advantage of doing this all in one program? I do sub programs all the time but they are always separate programs.

 

I like to use M97 on a Haas keeping everything in one program because it was easier to store and recall them, and when you pull the program up a year later, everything is there and ready to go within the one program you have re-loaded. There isn't as much organization needed to keep the sub-programs from getting lost or overwritten.

 

Other than that, it's really the same thing.

Link to comment
Share on other sites

What would be the advantage of doing this all in one program? I do sub programs all the time but they are always separate programs.

 

The old sh!te tip where I used to work was always a nightmare - main program would be saved but never the subs.

The haas idea is really good. Fanuc should swallow hard and admit someone else has a good idea and copy it.

Link to comment
Share on other sites

We program most of our parts here pretty much exclusively with internal subs and for the most part with good results. Although file size can be an issue.

 

Here's a sample of what is typical for our Robo using a 16i control.

 

%
O1000

G54 G0 G17 G40 G49 G80 G90 G94 G53
(  1/4 DRILL | TOOL - 1 | DIA. OFF. - 11 | TOOL DIA. - .25 )
N100 T1 M6
G0 G90 G54 X0. Y0. S10000 M3
G43 H1 Z.25
M98 P10001
G49 G53 M5 Z0.
M01
(  1/8 DRILL | TOOL - 2 | DIA. OFF. - 12 | TOOL DIA. - .125 )
N110 T2 M6
G0 G90 G54 X.4 Y-.3 S10000 M3
G43 H2 Z.25
M98 P10002
G49 G53 M5 Z0.
G53 X0. Y0.
M30

O0001
G98 G83 Z-1. R.1 Q.1 F76.
X.4 Y.2
X.8 Y.4
X1.2 Y.6
X1.6 Y.8
G80
M99

O0002
G98 G83 Z-1. R.1 Q.1 F76.
X.8 Y-.6
X1.2 Y-.9
X1.6 Y-1.2
G80
M99
%

 

The one thing I noticed in your code is your program is calling an M98 P with a program number.

Where as ours calls an M98 P1 with a program number.

Not sure if this is machine specific though.

 

Hope this helps.

Link to comment
Share on other sites

It is not P that tells the control how many times to repeat it but L, so M98 P1001 L3 would run program 1001 on 3 repeats.

 

Also, I do like the M97 call on the haas' but I do agree that is actually faster for the controller to jump to a separate program indtead of looking inside the one running.

 

Have you ever tried to restart a looong program in the middle on a haas control? It can literaly take some 30 seconds to read from the top down to the restart point.

 

Besides that, it is easier on Fanuc controllers to edit any subprograms when needed using the background editing while the machine keeps running, something I still can't figure out how to do on haas.

 

As far as organizing programs, fanuc controls will take all text at once as long as it doesnt find the % sign so a single file on your server can have a main program and 10 subs all with their own Oxxxx program number and a single % at top and a last % at the very bottom, after the last sub's M99.

 

HTH

Link to comment
Share on other sites
Guest CNC Apps Guy 1

It's on the Memory Card as one program, but as long as there is only a % at the top and bottom, it will create multiple programs in the control. In his sample, he had O1000 as his main and O1 and O2 were his subs. The control will read the whole file in and break them up at the "O"'s.

Link to comment
Share on other sites

He didnt mean it will be a single file on the control, his example will load 3 different programs (O1000 as main, and O0001 and O0002 as subs) but it will load them all at once as descibed on my previous post, see the % at beginning and bottom after O0002?

 

Oh well, all this is for the fanucs I've worked with on the past

Link to comment
Share on other sites
It's on the Memory Card as one program, but as long as there is only a % at the top and bottom, it will create multiple programs in the control. In his sample, he had O1000 as his main and O1 and O2 were his subs. The control will read the whole file in and break them up at the "O"'s.

 

He didnt mean it will be a single file on the control, his example will load 3 different programs (O1000 as main, and O0001 and O0002 as subs) but it will load them all at once as descibed on my previous post, see the % at beginning and bottom after O0002?

 

Dougm

This is correct, we load the complete file into the control as one. The control will break the main program from the subs.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

×
×
  • Create New...