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


TheePres
 Share

Recommended Posts

Guest CNC Apps Guy 1

The problem with GOTO is it searches the entire program. If you use a DO/WHILE it goes much faster. Then you could have certain conditions so that if you want to have a section of code run a certain number of times, set a counter and say WHILE[#100LE#500]DO1 etc....

Like so;

 

#517=0

#122=3.

#123=120.

#112=15.

#113=-.75

#102=1.

#103=1.

IF[#122GT 1.]THEN#122=1.

IF[#112GT 15.]THEN#112= 15.

IF[#102GT 1.]THEN#102= 1.

 

#121=1

#124=#14004

WHILE[#121LE#122]DO1

 

#111=1

#114=#14002

WHILE[#111LE#112]DO2

 

#101=1

#104=#14001

WHILE[#101LE#102]DO3

 

#517=#517+1

#115=#14003

X#104Y#114B#124

 

#101=#101+1

#104=#104+#103

END3

 

#111=#111+1

#114=#114+#113

END2

 

#121=#121+1

#124=#124+#123

END1

Link to comment
Share on other sites

Do it every day on my 16m. M98 calls subprogram, M198 calls subprogram from data-server. I load programs into data-server, O1001, O1002, O1003 and so on. Have a control program in memory that just says

M198 P1001

M30

M198 P1002

....

Works the same in memory, just gotta have way smaller programs.

Link to comment
Share on other sites

M97 is the local subs the P word looks for the N number in your program. If you use this on a horizontal, like at the end of the program use a m98 to call another sub for the other pallet. You can run it to nesting problems if you do not use a m30 at the end. There is probably away around this, just havent took much time to find the answer.

Link to comment
Share on other sites

I have always considered a local sub program as residing in the main program. The subs are contained after the M30. So you can use subs all you want and you only load one program. As Tim explained its pretty easy to setup your post for this, doing just as he said.

 

ex.

%

O100;

;

;

T1M6(SPOT)

G0G90G54X0Y0M3S500

G43H1Z2.0

G99G81Z-2.5R.25F100.K0

M98H90(jumps to line N99)

G80(returns here after M99)

G0G91G28Z0

M1

;

;

T2M6(DRILL)

G0G90G54X0Y0M3S1000

G43H2Z2.0

G99G83Z-25.R.25F134.K0

M98H90(jumps to line N99)

G80(returns here after M99)

G0G91G28Z0

M30

;

;

N99(HOLE POSITION SUB)

X0Y0

X35.

Y20.

X50.Y50.

M99

;

;

%

Link to comment
Share on other sites

Been doing it for years. Sample from our horizontal;

quote:

%

O1000(MAIN-PROG.SUB.100 )

G0G17G40G80G90

G0G91G28Z0.

G0G91G28X0.Y0.

G90G53X0.Y0.Z0.

G91G30XYZ0.

M1

N1G0G90G54

M11

B0.

M10

M98P100

M1

N2G0G90G55

M11

B0.

M10

M98P100

etc...

etc...

etc...


Link to comment
Share on other sites

DC Gorn,

 

I just got my company to buy me this book.

 

Macro book

 

(Thanks to jmparis for posting that URL back in day)

 

I have read it, and been taking some notes, seems like a good starting point. However James and the other macro people we have here has to be aware, that the minute I can break into our horizontal, that I am going to have alot of questions for them. biggrin.gifbiggrin.gif

 

Lars

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

Here's a Simple Snippet.

 

G10

#148=1 (RESET OFFSET COUNTER)

#124=0 (RESET B COUNTER)

#526= 1. (NUMBER OF INDEX'S IN B)

#527= 120. (B INDEX AMOUNT)

#528= 1. (NUMBER OF PARTS IN X)

#529= 1. (X STEP AMOUNT)

#530= 15. (NUMBER OF PARTS IN Y)

#531= -.75 (Y STEP AMOUNT)

IF[#530GT 15.]THEN#530= 15.(Y STEP MAX SAFETY)

G11

 

N39

T1039M06 (T1039 - 1MM PROBE TIP - 1 FLUTES - )

#148=1

(CHECK CURRENT TOOL OFFSET)

#101=#[10000+#506]

IF[#101LE3.0]GOTO99999

T1001

#148=1

WHILE[#148LE#517]DO1

M11

B0.

G00G54.1P#148G90X0.Y0.S500

G43H99Z2.

M10

G54.1P#148

Z.5

(***** SET XY BORE ZERO *****)

G65P9800R-0.S.375W54.1V#148Z-.2I0.J0.

Z2.

M11

#148=#148+1

END1

G52 X0 Y0 Z0 B0M09

G28 G91 Z0 M219

G30 G91X0 Y0

G49

M01

 

This one will make as many parts as you need in X, Y, and/or as well as B. Each part has it's own offset. Pretty small footprint, and won't change in size if I want to add parts. One caveat, the parts need to be fixed spacing distances in X, Y, and B. I'm certainly not a MACRO guru but I do like them for their power, and I've incorporated them into several posts so I do not need to use and keep track of sub programs which can be a chore.

 

James teh Sub H8r

Link to comment
Share on other sites

Hmmm .... Half of us are "one page" and the other half is on another page of this book. biggrin.gifwink.gif

 

Theepres is looking to do internal subbing, NOT external (like M98 or M198).

 

The answer for FANUC (as some have mentioned here) is NO. There are some work arounds but not quite as effective. I use a lot of "While/Do"s like James mentioned. You can use "GOTO" but as he also mentioned, this causes the control to seek the file from the top. If the program is long and/or the control is slow, this will actually "pause" the machine until it finds it.

 

Another way is to use "M99P???" with a counter set in variable, but this has the same effect as a GOTO when its used in the "main body" of the program.

 

Haas has M97, Mazaks M98H?? .. Yep, Fanuc needs to add this to their stuff.

 

cheers.gif

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...