585,578 active members*
3,895 visitors online*
Register for free
Login
Results 1 to 9 of 9
  1. #1
    Join Date
    Aug 2007
    Posts
    96

    Sub Routines on VF3

    I enabled sub routines on my CAM programs post and the file was one but when I loaded it from the floppy into the haas memory it had the main program O4111 then 2 new ones O4112 (sub routine) and O4113 (sub routine) on the program list. Is this normal for how haas does subs? It caught me off guard since I thought it would have been in the same program with a sub call out. Here is the last bit of code in the program and how it was sent to the Haas via a floppy.
    N38993Z-.2F25.
    N38994M98P4113
    N38995M9
    N38996G91G28Z0.
    N38997G91G28Y0.M5
    N38998M30
    O4112
    ( SUB NUMBER: 4112 )
    N1G41X8.3755D6
    N2G3X8.5005Y3.43J.125
    N3G1Y4.5345F60.
    N4X5.2135
    N5Y1.2475
    N6X8.5005
    N7Y3.43
    N8G3X8.3755Y3.555I-.125
    N9G1X8.2755
    N10G40
    N11M99
    O4113
    ( SUB NUMBER: 4113 )
    N1G41X4.4115D6
    N2G3X4.5365Y3.0261J.125
    N3G1Y4.5345F60.
    N4X1.2495
    N5Y1.2475
    N6X4.5365
    N7Y3.0261
    N8G3X4.4115Y3.1511I-.125
    N9G1X4.3115
    N10G40
    N11M99
    %
    ( FILE LENGTH: 7278.94 FEET )

  2. #2
    Join Date
    Feb 2007
    Posts
    36
    looks to me like sub programs. when i do a sub routine i use M98P100L2(to call line n100 and run twice) i always put the subs after the main program between the m30 and % the "P" can be any n# line you want and i believe you can run it as many times as you want to.

  3. #3
    Join Date
    Mar 2003
    Posts
    4826
    Sub program = M98
    Sub routine = M97

    Don't use new program numbers to name the subroutines. All you need is to identify the line number where the sub routine begins:
    As in Drewmeister's example, except:
    M97 P100 L2
    First you get good, then you get fast. Then grouchiness sets in.

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)

  4. #4
    Join Date
    Aug 2007
    Posts
    96
    Thanks,
    I wonder why the program is one file , yet when i transfer it via the floppy to the control it created three different program numbers, like i stated above. I will check with the CAM dealer on changes to the post. Also if I would run it like I have , will it call up the sub programs out of memory and switch back to the main program O4111 ? On the Haas program directory it looks like:
    O4111 ??????????
    O4112 Sub Routine
    O4113 Sub Routine

  5. #5
    Join Date
    Feb 2007
    Posts
    36
    my bad, its been a while since i ran a sub routine

  6. #6
    Join Date
    Mar 2003
    Posts
    4826
    Rocko1,
    From what I can see, your program had 3 program numbers in it (that's what the big "O" signifies), so the Haas simply loaded what you sent

    When using subroutine numbering, I think it is necessary to be careful not to create ambiguous jumps caused by reusing the same set of line numbers over and over. While I've never tried it, I suppose the controller might give an error of some sort, or else it will only find the first instance of the line number you referenced, and keep executing the sub from there. The subsequent subs, if reusing existing line numbers could never be read.

    Line numbering is pretty much a nuisance and waste of time to upload anyways, but a line number at each tool change and at the beginning of each subroutine is enough to create a useful map for you and the control to know where to jump back and forth to.
    First you get good, then you get fast. Then grouchiness sets in.

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)

  7. #7
    Join Date
    Nov 2007
    Posts
    188
    Just remove the O when the control see the O it starts a new program and loads all the folling infofation in that program when it reads the next it creats another that why it split up your program in to 3 different ones

  8. #8
    Join Date
    Aug 2007
    Posts
    96
    Thanks to all, i will look at getting the post processor on the CAM changed.

  9. #9
    Join Date
    Mar 2005
    Posts
    1498
    071110-1507 EST USA

    Rocko1:

    I personally do not distinguish between subroutines and subprograms. They are both subroutines to me. But there are what I call internal subroutines and external ones.

    An internal subroutine is one contained within your main program and is called by an M97 command with a pointer to a line number within that subroutine. What do I mean by contained within your program may become clearer below.

    An external subroutine is a subroutine that is in and identified by a different O# program. The are two different calling instructions -- M98 and G65. The difference is that G65 provides a means to pass parameters to the called subroutine from parameters on the G65 instruction line. Unfortunately there is not an internal call equivalent to G65.

    A subroutine is a sequence of program instructions located at a known location and terminated with a special code, M99, to tell the computer instruction pointer to return to the next instruction after the instruction that called the subroutine. This allows the subroutine code to be used as many times as desired from many different source locations within some other program or subroutine. An internal subroutine does not have to preceed an M30.

    Forget subroutines for the moment. In HAAS the loading of one or more programs thru the serial port is initiated by a first % and terminate by the next %. When HAAS receives data after the first % it looks for an O# . Any valid data following this O# is loaded into HAAS memory under this O# until an error occurs, a % is detected, or another O# occurs. A new O# causes the data following it to be loaded into that O# and the previous O# is closed. This continues until any of the above ending conditions occurs. Once a second % is received you must reinitiate a receive with the RECV button.

    Your Mastercam postprocessor is what created the external subroutines, and it chose to put all these between a first and second %.

    This may not make the concept clear yet. If this does not provide clarification, then indicate your problem.

    .

Similar Threads

  1. Help Making Sub Routines
    By PROTOTRAKFAN in forum Parametric Programing
    Replies: 7
    Last Post: 07-15-2008, 12:09 AM
  2. sub routines
    By earl in forum Fanuc
    Replies: 2
    Last Post: 03-04-2007, 09:34 AM

Posting Permissions

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