585,722 active members*
4,433 visitors online*
Register for free
Login
Results 1 to 12 of 12
  1. #1
    Join Date
    Sep 2003
    Posts
    29

    Question Fanuc 15m Subroutines

    Help.Anybody know the procedure for storing and calling subs in your main program instead of outside of it? For example Mazak uses (M98 H ) to call a sub stored within program and an N# to describe it.
    M98H1000
    .
    .
    .
    .
    .
    .
    N1000(SUB)

    Thanks in advance
    DB34

  2. #2
    Join Date
    Apr 2005
    Posts
    629
    I have not done that in MANY years, but if memory serves me it works something like

    M99 (either N or P) then the line number

    M99N1422

    or

    M99P1422

    This is not going to be a conditional jump (with IF-THEN) nor are you going to be able to use M99 as a typical "return".

    Like I said, it has been a very long time since doing that so I would suggest opening up that FANUC programming manual and look at the descriptions for both M98 and M99.

    Sorry, that's all I got.

    Chris

  3. #3
    Join Date
    Mar 2005
    Posts
    988
    Fanuc doesn't really have an internal sub routine ability like Mazatrol, Haas, Yasnac, etc. You can use the "M99 P... " like Chris mentioned but it has some drawbacks. It will act like a GOTO statement and not really a sub. And I'm not sure if the 15M can use the code like that so you'll have to try it and see.

    Other options are to use things like While/Do loops and such.
    It's just a part..... cutter still goes round and round....

  4. #4
    Join Date
    Feb 2006
    Posts
    24
    I know on the niigata with 15 you can call a sub program as a macro. Then after it's do it will return to the next line after the call.

    G65P8012

    but m98 jumps to a sub or macro
    m99 jumps out of a sub or macro

    but then i know that m99 also can be repeat program so ...
    I'll double check when i get to work tomarrow and repost

  5. #5
    Join Date
    Sep 2005
    Posts
    767
    Why not just call separate programs with M98Pxxxx. Each sub can return to the main program with an M99, and you can also nest subroutines by making M98 calls within subs.

    The only downside to keeping your subs separate is is that you have to upload and download multiple programs to the CNC for each job (one main plus many subs). On the 15M, though, this is easy to overcome. Here's how you can do it:

    Keep your program numbers together for each job. If you use, say, O1234 for the main program, and keep your subs called by that main program in sequence, like O1235, O1236, O1237, etc. You can then put the main program and all the subs in one FILE on your DNC system, like so:

    %
    O1234 (MAIN)
    N1
    N2
    (etc)
    M30
    O1235 (SUB1)
    N1
    N2
    (etc.)
    M99
    O1236 (SUB2)
    N1
    N2
    (etc.)
    M99
    O1237 (SUB3)
    N1
    N2
    (etc.)
    M99
    %

    (be sure that there are only percent signs at the begining and end, and NOT in between the programs.

    Then, when you download to the CNC, just queue up the file on your DNC system and press READ then ALL to download all the files together. When sending them back to your DNC system, press PUNCH then PROG#, then key in "1234", then press PROG# again and press the number of the last sub (1237) then press EXEC. That will send all the files within that RANGE to the DNC system for storage in one file. Just make sure your DNC system will not break down the data into 4 separate files by O-numbers. If your DNC system receives until a timeout occurs, you'll have no problem with uploads.

    Keeping your subs separate from the main has several advantages. You can call each sub multiple times, or you can call subs from other subs (nesting up to 5 layers deep).

  6. #6
    Join Date
    Mar 2005
    Posts
    988
    To finish my earlier reply, .....

    I'm with Dan here. Why not just use nested subs (M98 calls).
    It's just a part..... cutter still goes round and round....

  7. #7
    Join Date
    Nov 2005
    Posts
    274
    Quote Originally Posted by psychomill
    To finish my earlier reply, .....

    I'm with Dan here. Why not just use nested subs (M98 calls).

    DITTO Keep it simple, The biggest mistake I see a programer or an engineer (Such as myself) make is thinking just way to much. Just let go your mind and use the "FORCE" It always works for me :banana:

    Bluesman

  8. #8
    Join Date
    Sep 2003
    Posts
    29
    Thanks guys.The reason I like to do this is to keep the file transfering down to 1 file per program for the operators sake.
    DB34

  9. #9
    Join Date
    Feb 2006
    Posts
    338
    Well I prefer seperate files, but if you must....

    #100=500 (set to return N number)
    GOTO 1000
    N500
    ...

    N1000
    (sub)
    ...
    GOTO #100

  10. #10
    Join Date
    Sep 2003
    Posts
    29

    Question

    Thanks all but I need to loop these subs many times per program and although WHILE DO loops will work they are somewhat wordy for what I am trying to accomplish. Also, I like to keep these subs local because most are part specific. Any part families w/common features will have macros instead.
    Here is an example of 2 simple routines that need to be called repeatedly .It is for a 2.913 x .85 slot


    N80(.75 PLUNGE MILL)
    G65P6000T28A27
    G0G90G56X-5.375Y0.Z5.M3S2900M39M51
    Z1.
    G98G81R.1Z-2.1F26.
    M98 H1000 L13 (incremental plunge sub 13 x's)
    /
    N90(.75 HI POS)
    G65P6000T27A27
    G0G90G56X-5.5Y0.Z5.M3S3000M39M50
    Z1.
    G1Z0.Y.05F50.G41D27
    M98 H3000 L15(slot finish sub 15 x's)
    G90G3Y0R.025F30.
    G0Z5.G40
    .
    .
    .
    .
    .
    .M99
    .N1000(PLUNGE SUB)
    G91
    X.125
    M99
    N3000(FINISH SUB)
    G91
    G3Y-.1R.05Z-.063F20.
    G1X2.063Z-.063F40.
    G3Y.1R.05Z-.063F20.
    G1X-2.063Z-.063F40.
    M99
    %
    As you can see this saves much cutting an pasting of code
    While I realize these could be changed into macros, time is often not permitting and the quick and dirty way is needed.
    Please let me know if what I'm doing can be done a better way.
    As for storing subs in sequencial order; our numbering system won't allow this
    DB34

  11. #11
    Join Date
    Feb 2006
    Posts
    338
    Well other than breaking your subs out to seperate programs like Dan mentioned I don't see an easy way to do what you want on a Fanuc control. And really the only differance between that and what you just posted is how many programs show up on the control (just change the N1000 and N3000 to O100 and O3000). You can keep them together as a single file on the computer.

    If you only have 1 part program loaded to the control at a time you don't have to worry about program numbers interfearing. Just remove all programs before loading a new part.

    If that isn't good enough I suggest spending the time to make the macros for what you do most.

    Dale

  12. #12
    Join Date
    Jan 2005
    Posts
    304
    Try this. I can't prove it right now but it should do the trick for you.

    N80(.75 PLUNGE MILL)
    G65P6000T28A27
    G0G90G56X-5.375Y0.Z5.M3S2900M39M51
    Z1.
    G98G81R.1Z-2.1F26.
    M99P1000 (incremental plunge sub 13 x's)
    N1001
    /
    N90(.75 HI POS)
    G65P6000T27A27
    G0G90G56X-5.5Y0.Z5.M3S3000M39M50
    Z1.
    G1Z0.Y.05F50.G41D27
    M99P3000 (slot finish sub 15 x's)
    N3001
    G90G3Y0R.025F30.
    G0Z5.G40
    .
    .
    .
    .
    .
    .M99
    .N1000(PLUNGE SUB)
    #100=0
    WHILE[#100LE13]DO1
    G91
    X.125
    #100=#100+1
    END1
    M99P1001

    N3000(FINISH SUB)
    #101=0
    WHILE[#101LE15]DO1
    G91
    G3Y-.1R.05Z-.063F20.
    G1X2.063Z-.063F40.
    G3Y.1R.05Z-.063F20.
    G1X-2.063Z-.063F40.
    #101=#101+1
    END1
    M99P3001
    %

Posting Permissions

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