587,401 active members*
3,561 visitors online*
Register for free
Login
Page 1 of 2 12
Results 1 to 20 of 26
  1. #1
    Join Date
    May 2009
    Posts
    17

    fanuc subprogramming

    i would like to know what is the subprogramming sequence for a part program that has 4 slots at 10mm deep and 15mm wide (from start to M30):drowning:

  2. #2
    Join Date
    Mar 2005
    Posts
    988
    M98


    ..... you're leaving out way too many details here ....
    It's just a part..... cutter still goes round and round....

  3. #3
    Join Date
    May 2009
    Posts
    3
    need more info. , size of blank (material thickness x width x length)
    (with and length of the slots and distance center to
    center of the slot, also the offset from the edge of the
    stock.)

  4. #4
    Join Date
    May 2009
    Posts
    17

    part detail

    Sorry guys 4 not giving more detail.I'm new to subprogramming.Hope this is what you need.part size(300x300).material thickness(70mm).slot offset from edge(30mm).slot depth(10mm),width(15mm).distance center to
    center of the slot(25mm)

  5. #5
    Join Date
    Feb 2006
    Posts
    338
    A rough outline of the code (not using your real location/sizes)

    Code:
    G90
    G0 X10.0 Y5.0 (position for first pocket)
    M98 P101 (call sub program)
    G0 X20.0 Y5.0
    M98 P101
    G0 X30.0 Y5.0
    M98 P101
    G0 X40.0 Y5.0
    M98 P101
    Code:
    O0101 (Sub to cut pocket in incremental)
    G91
    G1 X5.0 Z-1.0 F3.0
    (... pocket)
    G90
    M99
    If you have code that does (or can) repeat, cut it out into a separate program and call it as a sub. Make sure to keep track of modal commands going into and out of the subs. Like G1/G0 and G90/G91 ect. in this sample.


    How and why you do this with your code is based on what your doing and why. Although usually space is a main reason. Another is reduced complexity when reading the main program. IE. 50 lines for the pocket replaced by a sub call and a comment if your nice.

  6. #6
    Join Date
    May 2005
    Posts
    66
    I'm trying to write some G code macros that will run on as many different controllers as possible, so here's some more questions regarding Fanuc subroutine calls.

    Is there a limit in the range of subroutine numbers that can be called, ie:
    O1234 (Does this number have to be in a subrange?)

    On Fanucs, is the method to call a "local" subroutine (ie in the same file) the same as the method to call a subroutine located in a separate file?

    Is there a convention for how you name the files containing subroutines?

    Thanks,

    Paul T.

  7. #7
    Join Date
    May 2007
    Posts
    1003
    Quote Originally Posted by titchener View Post
    I'm trying to write some G code macros that will run on as many different controllers as possible, so here's some more questions regarding Fanuc subroutine calls.

    Is there a limit in the range of subroutine numbers that can be called, ie:
    O1234 (Does this number have to be in a subrange?)


    Far as I know subprograms on a Fanuc can have any program number from 1 to 9999.


    Quote Originally Posted by titchener View Post
    On Fanucs, is the method to call a "local" subroutine (ie in the same file) the same as the method to call a subroutine located in a separate file?


    As far as I know (I hate speaking in absolutes. I could be wrong!), it is impossible to have 2 programs in the same file. Doesn't matter whether they are subs or not. Each program has its own program number, and thus is a SEPARATE file.


    Quote Originally Posted by titchener View Post
    Is there a convention for how you name the files containing subroutines?

    Thanks,

    Paul T.


    No. You decide how to arrange them. There are parameters that allow you to run subprograms with a G, an M or a T call. I don't use the T-call for obvious reasons. Each parameter is associated with a SPECIFIC program number. These are all 9000 series protected programs (9000-9029). You may want to take advantage of these calls, but it is your choice what type of subprograms you want associated with each series of program numbers.

    As an example Hardinge uses Safe Index Subprograms O1, O2 (front spindle), and O3, O4 (subspindle). I put them in O9001, O9002, O9003 and O9004 to keep them from being modified or accidentally deleted. Turns out these programs can be called with an M. So now I use M91, M92, M93 and M94 instead of M98P9001, M98P9002, etc. to call them.

    Hardinge has a couple deep drilling subroutines that come with their lathes. The older version is O9135, the newer version O9136 so when I wrote my own macro drill program I called it O9134.

  8. #8
    Join Date
    Jun 2008
    Posts
    1511
    Quote Originally Posted by titchener View Post
    On Fanucs, is the method to call a "local" subroutine (ie in the same file) the same as the method to call a subroutine located in a separate file?
    Paul,
    With Fanuc you cannot call a subroutine and have that same subroutine located in your calling program. If you are running program O1234 and you want to call a subroutine O9000 this can be done via M98P9000 or G65P9000. However this 9000 program has to be a separate program. You might be thinking of Haas because they have the ability of calling a subroutine in the same program. If you use a M97P9000 you can have program 9000 and 1234 combined. The M97P9000 will search within program 1234 for 9000. If you use M98P9000 it will search externally for program 9000.

    Dale,
    You were correct. Sometimes we know more then we think. Or is it we think we know more then we really do. I like the first one better .

    Stevo

  9. #9
    Join Date
    Feb 2006
    Posts
    338
    A bit off topic I think, but if space is a reason for calling subs, another way to "extend" your memory is to use the PCMCIA card as added storage. You have to change you I/O channel to the card and there are limits to what can be in the g-code on the card.

    Your main program is in normal memory, and uses a special call to pull the subs from the card. What I have done in the past is make the bulk of a single tool (movement type code only) a sub program.

    Ah, just looked it up again. "DNC by PCMCIA" for fanuc 16i, 18i ans 20i M198
    The main restriction is that the card program can not call any other subs in any way. We use subs for M6 and a few other things, so that is why I split the movement code as the subs on the card.

  10. #10
    Join Date
    Jan 2005
    Posts
    304

    Possible but different

    I think I understand where you are coming from.
    I run many machines with mitsubishi controls and they have the ability to keep sub routines within the main program. This allows for a part program to contain everything i needs.
    exam: M98H# wil hop to a place within the program that contains the N# that the H# refers to, when done M99 sends you back to the line following the "M98" line to continue with the program.
    That exact format does not work in a Fanuc BUT you can create a program that will give you that result, as long as you have Macro option.
    On the Fanuc you will have to use "M99P#" to make the program hop to "N#" like the M98H# did above. The return is where the biggest change will be. Using "M99" will NOT return you to the line following the "M99P#", it will return you to the start of the program. You will need to use a "GOTO#" statement and have a line following the "M99P#" with a "N#" to match the "#" on the GOTO# line. Here is an example.
    "
    "
    "
    M99P123 (GOT TO N123)
    N321
    "
    "
    "
    N123(sub-routine)
    "
    "
    "
    GOTO321 (GO TO N321)

    This works I use it all the time. If you do NOT have the Macro option it will not understand the "GOTO" statements

  11. #11
    Join Date
    Jun 2008
    Posts
    1511
    Quote Originally Posted by dpuch View Post
    Ah, just looked it up again. "DNC by PCMCIA" for fanuc 16i, 18i ans 20i M198
    The main restriction is that the card program can not call any other subs in any way. We use subs for M6 and a few other things, so that is why I split the movement code as the subs on the card.
    Yes that can be a big restriction. The other thing is not all controls are equipped with a PCMCIA card. So it would depend on the control model that Warren is using.

    Quote Originally Posted by cogsman1 View Post
    On the Fanuc you will have to use "M99P#" to make the program hop to "N#" like the M98H# did above. The return is where the biggest change will be. Using "M99" will NOT return you to the line following the "M99P#", it will return you to the start of the program. You will need to use a "GOTO#" statement and have a line following the "M99P#" with a "N#" to match the "#" on the GOTO# line. Here is an example.

    This works I use it all the time. If you do NOT have the Macro option it will not understand the "GOTO" statements
    Cogsman,
    Why the M99P123? If you are going to stay in the same program why not just use your GOTO’s to achieve this? I am just curious as to the reasoning.

    GOTO123
    N321

    N123

    GOTO321

    Stevo

  12. #12
    Join Date
    Feb 2008
    Posts
    586
    Stevo1,

    I think he meant it was easier to use the M99P## if you don't have Macro B. IIIRC, the Macro A format was G65H(something)P## for a GOTO statement. It's been a very long time since I used or even seen in a manual the Macro A format.

    Also, I think a negative P (M99P-123) will look backwards for the line number and save a tiny bit of time.

  13. #13
    Join Date
    Jun 2008
    Posts
    1511
    Beege,
    That makes sense. I never thought of the macroA scenario. I didn’t think anyone used that anymore. I use the M99P() in only one of my macros to jump once the F&S are set for the current tool in the spindle matching the modal “N” after the tool change. It actually works pretty slick having a speed and feed program so you don't have to program it in every macro line it all runs off the tool number and is set at every tool change. Other then that I have no use for that function. That doesn’t mean I won’t in the future.

    Stevo

  14. #14
    Join Date
    Feb 2006
    Posts
    338
    Regarding "sub programs" in a single fanuc program.

    A bit more detail to make it fully functional. This allows it to be reused inside the same program (not a fixed return point).

    Code:
    X10.0 Y15.0
    #100=121 (Set return address)
    GOTO 5000
    N0121
    ... 
    X10.0 Y20.0
    #100=122 (Set return address)
    GOTO 5000
    N0122
    ...
    (rest of program)
    M30
    
    
    (Sub) 
    N5000
    ... (sub code)
    
    GOTO #100

  15. #15
    Join Date
    May 2007
    Posts
    781
    Quote Originally Posted by dpuch View Post
    Regarding "sub programs" in a single fanuc program.

    A bit more detail to make it fully functional. This allows it to be reused inside the same program (not a fixed return point).
    And to get even more complicated.
    You can set asside a small block of variables for use as a stack, you can then push the return address on the stack just before calling the sub.
    Then at the end of the sub you can pop the return address and GOTO it.
    This will allow multiple levels of sub calls deeper then G65 calls can do, but you have to remember you are not getting a new set of local variables at each call.

    If you have ever done any assembly level programming you know all about it.

  16. #16
    Join Date
    May 2009
    Posts
    10
    Quote Originally Posted by titchener View Post
    I'm trying to write some G code macros that will run on as many different controllers as possible, so here's some more questions regarding Fanuc subroutine calls.

    Is there a limit in the range of subroutine numbers that can be called, ie:
    O1234 (Does this number have to be in a subrange?)

    On Fanucs, is the method to call a "local" subroutine (ie in the same file) the same as the method to call a subroutine located in a separate file?

    Is there a convention for how you name the files containing subroutines?

    Thanks,

    Paul T.
    Many FANUCs and other controls which use the Oxxxx program naming convention allow eight or more digits for a program number. Often as options on FANUCs but standard on others.

  17. #17
    Join Date
    Jun 2007
    Posts
    73
    Just found out about the lack of M97 subroutines in fanucs. Missing my Haas already and im just away from it for a day or two.

    Anyway... Im new to macros, and i really want to try the GOTO command, but im not sure if it will work. Does the controller determine capability or does the machine / added software? Currently running a Kitamura w 16i-T.

    Thanks!

  18. #18
    Join Date
    May 2007
    Posts
    1003
    Quote Originally Posted by Smrtman5 View Post
    Just found out about the lack of M97 subroutines in fanucs. Missing my Haas already and im just away from it for a day or two.

    Anyway... Im new to macros, and i really want to try the GOTO command, but im not sure if it will work. Does the controller determine capability or does the machine / added software? Currently running a Kitamura w 16i-T.

    Thanks!
    Don't know a thing about Haas lathes. What are M97 subprograms? Fanuc uses M98P???? to call up subroutines. Is this what an M97 on a Haas does?

    GOTO will work fine on a Fanuc as long as you have Macro B. GOTO14 makes the control jump to block N14. Does it work differently on a Haas?

    Thanks.

  19. #19
    Join Date
    Sep 2010
    Posts
    1230
    Quote Originally Posted by Smrtman5 View Post
    Just found out about the lack of M97 subroutines in fanucs. Missing my Haas already and im just away from it for a day or two.

    Anyway... Im new to macros, and i really want to try the GOTO command, but im not sure if it will work. Does the controller determine capability or does the machine / added software? Currently running a Kitamura w 16i-T.

    Thanks!
    Fanuc controls do have Sub Programs; they're called with M98.

    To check if your machine has the User Macro option, press the Offset button and from the page that appearts you will be able to navigate to the Macro Registry page. If you are able to do that then you control has the Macro option. Another method is to include a Macro Statement in a program, and see if the control will exercise it.

    The GOTO statement is used to branch to another part of the program and is frequently used in conjunction with a Conditional Statement, but it can be used on its own. Try it in a program as shown following, then single block through the program to see if the GOTO command is accepted by the control and exercised.

    Program start code goes here
    -----------
    -----------
    GOTO 10
    -----------
    -----------
    -----------
    -----------
    N10-------
    ----------
    ----------

    In the above program, when the GOTO 10 block is read, the program will advance to the N10 block and bypass all code between it and the N10 block. It the control does that then your control has the Macro option.

    User Macro programming is a quite a powrful tool and its use it limited only by your imagination. The above example is not a very comprehensive use of the GOTO statement, only a suggested method to check if your control has the option.

    The above branch can also be achieved whether the control has User Macro or not by using M99


    M99 P10
    ------------
    ------------
    ------------
    ------------
    ------------
    N10--------
    ------------
    ------------

    Regards,

    Bill

  20. #20
    Join Date
    Jun 2008
    Posts
    1511
    Dale,

    The Haas will use macroB option like the fanuc does if the control has it. I am not very familiar with Haas either but what I was told M97 is used like Fanuc’s M98 except the subprogram can be in the main program.

    So as an example the 2 programs below are all in program O0001
    O0001

    M97P9000
    M30
    O9000

    M99
    The program will run and jump past the M30 when the M97 is commanded and then return when M99 is read. The syntax may not be correct but this is what I remember.

    Smrtman5,

    The easiest way to determine if your control has macroB option is to do as Bill stated. Do a simple MDI program like #1=1 and if the machine accepts it and #1 gets set to 1 then your machine has the ability of macroB.

    Stevo

Page 1 of 2 12

Similar Threads

  1. GE Fanuc & FANUC proprietary posts
    By cncadmin in forum Fanuc
    Replies: 76
    Last Post: 01-12-2022, 07:33 PM
  2. Fanuc & GE Fanuc Repairs
    By RRL in forum News Announcements
    Replies: 0
    Last Post: 10-01-2008, 06:42 PM
  3. Subprogramming
    By hitachi in forum Uncategorised CAM Discussion
    Replies: 3
    Last Post: 06-17-2006, 03:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •