Page 1 of 2 12 LastLast
Results 1 to 20 of 21
  1. #1
    wrustle is offline Titanium
    Join Date
    Jun 2006
    Location
    Massachusetts
    Posts
    2,438

    Post

    Still fairly new to programming my machine, and can get by pretty well, but one thing I have not been able to do is sub programs. Once I program a part on my Haas VMC how do I make a sub program to machine for example the other parts in my vises? If my main program is for G54, how do I make that same program as a sub program to do G55, G56, and G57 for the other three pieces? So far I have been copying and pasting my programs which is not only time consuming, but also makes for a long program. Any advice or suggestions greatly appreciated.

    Best Regards,
    Russ

  2. #2
    izzoe46 is offline Cast Iron
    Join Date
    Jan 2006
    Location
    los angeles
    Posts
    408

    Post

    First you have to make a main program. Then from the main program you transfer to the sub. Here's a quick example:

    MILL 4 SQUARES 4X4 5 INCHES APART .25 DEEP

    O0001 MAIN PROGRAM
    G0 G90 G54 X0 Y0 S1000 M3.......(Go to position)
    G43 H1 Z.25.......(tool height)
    M98 P2.......(go to sub O0002)
    G0 G90 X5 Y0.....(Back to absolute move to position from G54)
    M98 P2........(Go to sub)
    G0 G90 X10 Y0.....(Back to absolute move to position)
    M98 P2.......(Go to sub)
    G0 G90 X15 Y0......(Absolute move to position
    M98 P2........(Go to O0002)
    G91 G28 Z0.....(Go z home)
    M30......(END OF PROGRAM)

    SUB PROGRAM
    O0002
    G91.....(Switch to incremental)
    G1 Z-.5 F25.....(Feed down .500)
    X4.....(feed x 4)
    Y-4.....(feed y -4)
    X-4......(feed x -4)
    Y4.......(feed y 4)
    G0 Z.5....(go z .500)
    M99.....(Back to main program)


    I like to program the subs in incremental because its less confusing. Just don't forget to go back to absolute when you're done.

  3. #3
    izzoe46 is offline Cast Iron
    Join Date
    Jan 2006
    Location
    los angeles
    Posts
    408

    Post

    You can also add a "Loop" to the line on the main program that has the M98== M98 P2 L5; and it will do it 5 times. Only difference is you have to move to the next position on your sub. after it moves the Z up. While still in incremental move on the X 10 inches ex:

    MILL 4 SQUARES 4X4 5 INCHES APART .25 DEEP

    O0001 MAIN PROGRAM
    G0 G90 G54 X0 Y0 S1000 M3.......(Go to position)
    G43 H1 Z.25.......(tool height)
    M98 P2 L4.......(go to sub O0002 Loop 4 times)
    G91 G28 Z0.....(Go z home)
    M30......(END OF PROGRAM)

    SUB PROGRAM
    O0002
    G91.....(Switch to incremental)
    G1 Z-.5 F25.....(Feed down .500)
    X4.....(feed x 4)
    Y-4.....(feed y -4)
    X-4......(feed x -4)
    Y4.......(feed y 4)
    G0 Z.5....(go z .500)
    X10.....(go x 10 inches to position for next square)
    M99.....(Back to main program)

    I havent done this in a while but i think it should work.

    Feel free to correct.

  4. #4
    SeymourDumore is online now Diamond
    Join Date
    Aug 2005
    Location
    CT
    Posts
    6,010

    Post

    If I may interject something else instead of sub programs.
    I absolutely abhor having multiple programs for the same parts, therefore always prefer local subs. Unlike Fanuc, HAAS uses them easy as pie.
    Also, in all cases I avoid using incremental programming.

    So, to make an easy example, here is a 1" square done 4 times using G54 - G57 workoffsets.

    %
    O00100
    (SAMPLE - SQUAREX4)
    (DATE - 08/06/07)
    (OPERATION - MILL SQUARE)
    (X0=PART CTR, Y0=PART CTR)
    (Z0=TOP)
    (CYCLE TIME: )
    (ROUGH 3/8 CARB)
    (SET DIA TO .385)
    G00 G53 Z0
    G90 G17 G54 G80 G94 G49 G40
    T1 M06
    G00 G43 H01 D01
    G00 X0. Y0 Z0.5
    S700 M03
    M08
    M97 P1000
    G55
    M97 P1000
    G56
    M97 P1000
    G57
    M97 P1000
    M09
    M05
    G00 G49 G53 Z0
    (FINISH - 3/8 CARB)
    T2 M06
    G00 G43 H02 D02
    G57
    G00 X0 Y0 Z.5
    S1400 M03
    M08
    M97 P1000
    G56
    M97 P1000
    G55
    M97 P1000
    G54
    M97 P1000
    M09
    M05
    G00 G49 G53 Y0 Z0
    T1 M06
    M30
    N1000 (MILL SQUARE SUB)
    G00 X0 Y0 Z.5
    G01 Z-.5 F200.
    G01 G41 X0 Y.5 F2.
    G01 X-.5 Y.5
    G01 X-.5 Y-.5
    G01 X.5 Y-.5
    G01 X.5 Y.5
    G01 X0 Y.5
    G01 G40 X0 Y0 Z.5 F200.
    M99
    %

    Note that this is a quick and dirty way of reducing the program size. The same sub is called for rough and finish for each part. The only caveat is that the roughing tool has a .01 oversize offset entered in the control, leaving you precisely .005 to finish all around.
    Also note that the finishing is called in reverse order, so the table is not whizzing back and forth between rough and finish.
    There is only one program and there is only one place to mess with to tweak.

  5. #5
    ARB's Avatar
    ARB
    ARB is offline Titanium
    Join Date
    Dec 2002
    Location
    Granville,NY,USA
    Posts
    3,568

    Post

    I concur with SD. This is how I like to leverage local subs too. [img]smile.gif[/img]
    1 thing I would do different is put the feedrate in the main program. That way I can finish faster than I rough.

    After a second look he is feeding in the z also.

    If you want to do this and still have main program control over your contour rate then just do the contour feed with a #500 variable.

    %
    O00100
    (SAMPLE - SQUAREX4)
    (DATE - 08/06/07)
    (OPERATION - MILL SQUARE)
    (X0=PART CTR, Y0=PART CTR)
    (Z0=TOP)
    (CYCLE TIME: )
    (ROUGH 3/8 CARB)
    (SET DIA TO .385)
    G00 G53 Z0
    G90 G17 G54 G80 G94 G49 G40
    T1 M06
    G00 G43 H01 D01
    G00 X0. Y0 Z0.5
    S700 M03
    M08
    #501=2.(rough feed rate)
    M97 P1000
    G55
    M97 P1000
    G56
    M97 P1000
    G57
    M97 P1000
    M09
    M05
    G00 G49 G53 Z0
    (FINISH - 3/8 CARB)
    T2 M06
    G00 G43 H02 D02
    G57
    G00 X0 Y0 Z.5
    S1400 M03
    M08
    #501=6.(finish feed rate)
    M97 P1000
    G56
    M97 P1000
    G55
    M97 P1000
    G54
    M97 P1000
    M09
    M05
    G00 G49 G53 Y0 Z0
    T1 M06
    M30
    N1000 (MILL SQUARE SUB)
    G00 X0 Y0 Z.5
    G01 Z-.5 F200.
    G01 G41 X0 Y.5 F#501
    G01 X-.5 Y.5
    G01 X-.5 Y-.5
    G01 X.5 Y-.5
    G01 X.5 Y.5
    G01 X0 Y.5
    G01 G40 X0 Y0 Z.5 F200.
    M99
    %

    About time we got back into some good old fashioned G code fun.

  6. #6
    wrustle is offline Titanium
    Join Date
    Jun 2006
    Location
    Massachusetts
    Posts
    2,438

    Post

    Izzo....thanks for the help, looks simple enough, I'll have to give it a try.

    Seymour....So if I understand this correctly, the sub program in the control would be "O1000" and is called for in the main program ("O0100")by "P1000" right? Why is it shown as "N1000" in the actual code for the sub program? Is that right? Not sure if I completely understand that part, since I thought the lines of the programs began with "N". It looks pretty simple though, and would be a heck of a lot easier when doing multiple pieces in the vises. Thank you.

    Best Regards,
    Russ

  7. #7
    wrustle is offline Titanium
    Join Date
    Jun 2006
    Location
    Massachusetts
    Posts
    2,438

    Post

    Thanks ARB....I've never heard of the feedrate numbers as you've shown, but it does make sense what you are saying. Is there any place to get some books or video's on Haas programming so I can learn more than just the basics?

    Best Regards,
    Russ

  8. #8
    chip_maker's Avatar
    chip_maker is offline Stainless
    Join Date
    Jan 2006
    Location
    ct.
    Posts
    1,024

    Post

    I run 3 6" kurt vises on my vf2 and do subs just like SD. I like it alot better that way. the whole program including the subs are saved as 1 program under the main program number.
    Now if haas built a heavy duty machine or fanuc's were more like the haas control, well that would be great.

  9. #9
    ARB's Avatar
    ARB
    ARB is offline Titanium
    Join Date
    Dec 2002
    Location
    Granville,NY,USA
    Posts
    3,568

    Post

    Wrustle,
    With the local sub call M97. The control looks within the program for that particular line number. It does not look in the program list for the program like M98 does. This is the nice part of M97 local sub call. Notice the M99 at the end of the sub. Also not that the sub comes after the M30. If you have the subs up in the main part of the program you will end up with an endless loop.

    I am not aware of any Haas books but if you do lots of looking back on this forum in the early days there was lots of G code discussion.


    That and ask away here. There are enough of us that like to show off a little that you should learn some creative methods.

    You might look at Mike Lynch's webside www.CNCcI.com he has some good basic information. Our own Heinz Putz has some good stuff as well. The codes may vary from fanuc but the concepts are the same.

  10. #10
    wrustle is offline Titanium
    Join Date
    Jun 2006
    Location
    Massachusetts
    Posts
    2,438

    Post

    Thanks ARB, it's all crystal clear now. Looking forward to trying it out thia afternoon.

    Best Regards,
    Russ

  11. #11
    SeymourDumore is online now Diamond
    Join Date
    Aug 2005
    Location
    CT
    Posts
    6,010

    Post

    Wrustle

    Just like ARB has described, M97 is used for local subs. The sub resides in the same program as the main. The difference or gotcha is the M99.
    All subprograms must end with M99, which in case of an M97 call will return the program pointer to the block right after the M97. In case however if the subprogram is encountered without a call, M99 will return to the top of the program, rewind/restart.
    That is why as ARB had pointed out you must put the M30 BEFORE any of the local subs, and put the % sign at the END AFTER all the local subs.
    Now for clearance of reading my programs, I only use N numbers whenever it's required. Haas does not need them on each block therefore any block I see with an N number is immediatey clear that it's either part of a subprogram or a canned cycle.

  12. #12
    mikey B is offline Aluminum
    Join Date
    Aug 2006
    Location
    ohio
    Posts
    61

    Post

    I prefer my subs be run like subroutines in a fadal.
    All subs reside at the top of the program with a goto command before them so at the start the machine skips them until they are called.

  13. #13
    SeymourDumore is online now Diamond
    Join Date
    Aug 2005
    Location
    CT
    Posts
    6,010

    Post

    Mikey
    It's the same as the HAAS, except they are at the end and the main body is on top. The GOTO serves the same purpose as the M30. If you have macros in the HAAS, you can have them on top as well, just use a GOTO to jump over the subs to the main body.

  14. #14
    michael is offline Cast Iron
    Join Date
    Oct 2004
    Location
    hangtown, california
    Posts
    456

    Post

    On Friday last I marked 37 years in the machining profession. I keep learning new things all the time and pass on knowledge when I can do so. Thanks to SeymourDumore, I just got the local sub trick. I like it. Makes program saving easier by being all bundled and keeps the sequence of subs orderly. The Haas is fairly new to me, but the OM doesn't always download the programs in sequential, numerical order, and I can be a bit anal about some things.
    Only a few sequence numbers to add to the program. I've only used them at tool changes before but I may modify my posts to use T# instead of N# to avoid any chance of confusion.

  15. #15
    gar
    gar is offline Stainless
    Join Date
    Feb 2005
    Location
    Ann Arbor, Michigan USA
    Posts
    1,336

    Post

    Unfortunately HAAS does not provide the capability to pass paramters to local subroutines. See G65 for external subroutines.

    Thus, you have to load individual variables to accomplish this result.

    Having local subroutines that are unique to a program within that program is a great advantage.

    .


    .

  16. #16
    Zdravko Dren is offline Plastic
    Join Date
    Jul 2005
    Location
    Croatia
    Posts
    45

    Post

    Are local subs possible on Fanuc, I'm using main program with external subs?

  17. #17
    Gary E is online now Diamond
    Join Date
    Jan 2006
    Location
    Houston, TX
    Posts
    5,712

    Post

    Reading the above brings back old memories...

    Question...
    You break a tool in the middle of part number 2

    Can you stop and change the tool and then go right to Part number 2 and resume ??

    Keep in mind that these may not be little parts in a vice,
    they may be 3 ft x 8 ft parts on the table.

  18. #18
    HuFlungDung is offline Diamond
    Join Date
    Jan 2005
    Location
    Canada
    Posts
    6,412

    Post

    Gary,

    I think it is possible to get as close as the beginning of a process using the current tool, at the correct work offset.

    On Haas, I insert the tool change command lines at the beginning of every sub, not within the main program. On Haas, this does not pose a great difficulty because it can be set to skip over those tool change lines without unneccessary machine motions.

    Keep in mind that the new tool will most likely require a re-reading of the tool length offset register to ensure that the new tool is being recognised. Running with the tool change within the sub permits a re-read of the length offset.

    So, in restarting the program, I would cursor down within the main program to the sub call wherein the old tool failed. The machine will necessarily have to cut air until it finds metal again.

  19. #19
    SeymourDumore is online now Diamond
    Join Date
    Aug 2005
    Location
    CT
    Posts
    6,010

    Post

    Hu.

    With the "Program Restart" parameter turned on you don't even need to do that. It just runs the entire program in memory at full proc. speed until it reaches your restart point. It then turns on spindle, coolant, offsets and all just like if it was ran normally, retracts to machine Z0, plunges to the Z0 clearance for that operation and then feeds into the location where you restarted.
    IOW no need to put the toolchange into the sub. You can do that but no need to.

  20. #20
    HuFlungDung is offline Diamond
    Join Date
    Jan 2005
    Location
    Canada
    Posts
    6,412

    Post

    Seymour,

    That is true, but some day, I hope to grow my kahunas to such a size that I turn that option off Sometimes, it takes 10 minutes to get running again, and that time would be better spent letting the machine cut air within the sub, which it is going to have to do anyways.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

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