586,051 active members*
3,686 visitors online*
Register for free
Login
IndustryArena Forum > Machine Controllers Software and Solutions > Fanuc > Fanuc Nesting Macro Call Question
Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2014
    Posts
    4

    Exclamation Fanuc Nesting Macro Call Question

    Hello everyone,

    I've created some programs to machine parts using Fanuc Macro sub-program calls and some Custom G-Code Calls to machine each part (with the ability to skip some ro allparts etc...)

    Here's a sample sub-program os a machining operation (the principle is that it repeats itself once for each part):

    Code:
    % O8050 (MACHINING OPERATION SUB-PROGRAM)
    
    
    N110
    G110 T#20 H#11 (Call to sub-program O9015)
    Z-#26
    G130
    GOTO#130
    N130
    
    
    M99%
    The G110 is a custom G-Code that will call a subprogram that handles tool calls, origines, etc.. and the G130 will set the next part to be machined and will either jump back to N110 to machine the next part or to N130 if it has machined all the parts.

    The question I have is if you guys know any way I can skip this entirely (as in jump to M99) if in the G110 it calculated that all parts are to be skipped.

    I know I can just add 2 more lines to make it work, for example (in green):

    Code:
    % O8050 (MACHINING OPERATION SUB-PROGRAM)
    
    N110
    G110 T#20 H#11 (Call to sub-program O9015)
    GOTO#110
    N110
    Z-#26
    G130
    GOTO#130
    
    N130
    
    
    M99%
    But this would defeat my idea of making this as simple as possible by adding 2 more lines.

    I was thinking about some fanuc option that would make me able to for example on the G110 (O9015) that could execute code on his parent program (O8050) that way I could just jump to the line I wanted from the G110 and could even remove the GOTO#130 and make it even more simple, or something that could make it able to end the program that was called before it, or some other option.

    If you guys can think of something please let me know.

    Thank you in advance for any help!
    Best Regards

  2. #2
    Join Date
    Nov 2014
    Posts
    4

    Re: Fanuc Nesting Macro Call Question

    I had a couple of ideas:


    1) I was thinking about doing something like a M97 call to a line like it was a sub-program, but that is on HAAS machines only.


    2) I saw a forum post about someone saying that M99 P_line_number ends a sub-program and returns to that "main" program line number, I was wondering if that actually works and if it could work on a sub-sub-program since it says "main" program. (Will only be at the machine on monday to test this)


    3) One idea just jumped into my mind, maybe using a M#110 to be either M99 (end program) or an M call that does nothing e.g. M400 and set #110 to either 99 or 400 on G110. Like this:


    Code:
    % O8050 (MACHINING OPERATION SUB-PROGRAM)
    
    
    
    
    N110
    G110 T#20 H#11 (Call to sub-program O9015)
    M#110
    Z-#26
    G130
    GOTO#130
    N130
    
    
    
    
    M99%



    At least that would make it one more line instead of two...




    Still open to any ideas.

  3. #3
    Join Date
    Feb 2011
    Posts
    353

    Re: Fanuc Nesting Macro Call Question

    depending on the model or age of the fanuc
    by changing parameter 6005 bit 0 to a 1 you can use m98Qxxxx to go to an Nxxxx just like haas m97
    you can also use it as M98pxxxxQxxxx to go to a program and line# with in that program
    not sure if this will help you with what you are trying to do

  4. #4
    Join Date
    Nov 2014
    Posts
    4

    Re: Fanuc Nesting Macro Call Question

    Thank you for your input rcs60!

    That is pretty cool to know, thank you! Someone told me on a different forum that M99 P__ does return to the previous program to line P__, so I'll be using that as it is perfect for what I intended.



    Another question I have since I changed all my programs counting on that M99 P__ working is that I now need to know what nested level I'm in, and I'm drawing a blank on how to do it, I thought of an idea:


    Some Fanuc variable that holds the previous program number (as in the program that called the current sub-program). AFAIK the var #4515 and #4115 holds the current program number, but how do I know what the previous one was without adding any code to that previous program?




    (Again I know I could easely do this by adding/checking a variable on each sub program but I want to keep the simplicity and do all the calculations in the same place)


    Thank you in advance for any help,
    Best Regards

  5. #5
    Join Date
    Nov 2014
    Posts
    4

    Re: Fanuc Nesting Macro Call Question

    For anyone wondering, I used M99 P_line_number_ (returns to previous program and to line Pxxx) to simplify my programs.

    I went from:

    Code:
    % O8050 (MACHINING OPERATION SUB-PROGRAM)
    
    
    N100
    G110 T#20 H#11
    GOTO#110
    N110
    Z-#26
    G130
    GOTO#130
    N130
    
    
    M99%
    To:

    Code:
    % O8050 (MACHINING OPERATION SUB-PROGRAM)
    
    
    N110
    G110 T#20 H#11
    Z-#26
    G130
    
    
    M99%

    By managing the lines to return to with G110 and G130, hope this might help someone some day!
    Best Regards

Similar Threads

  1. G65 macro call
    By ggborgen in forum Fanuc
    Replies: 19
    Last Post: 09-29-2014, 10:25 PM
  2. One touch macro call
    By vincent.pomerleau in forum Fanuc
    Replies: 7
    Last Post: 02-24-2014, 12:43 PM
  3. tip changing macro call
    By paulus 2 in forum Parametric Programing
    Replies: 2
    Last Post: 08-30-2013, 04:42 PM
  4. Can you do a macro call (M) and pass a string somehow?
    By alank2 in forum Mach Wizards, Macros, & Addons
    Replies: 3
    Last Post: 05-15-2012, 01:44 AM
  5. Fanuc custom Macro Question????
    By ixoxi999 in forum Fanuc
    Replies: 9
    Last Post: 12-08-2011, 11:31 AM

Tags for this Thread

Posting Permissions

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