587,089 active members*
3,151 visitors online*
Register for free
Login
IndustryArena Forum > MetalWorking Machines > Haas Machines > Haas Mills > Can you use the graph feature to display sub program moves?
Results 1 to 16 of 16
  1. #1
    Join Date
    Jun 2006
    Posts
    440

    Can you use the graph feature to display sub program moves?

    I wrote a program that has a couple of sub program calls in it. I loaded the programs, set up offsets & went to the graph function to run the program. It runs through the first moves but when it comes to the subs it just skips over them like they aren't there. Basically I'm just trying to learn how to write sub programs and this part we make is ideal. Code monkey's long hand version not elegant to paraphrase.

    I ran the program in air for a few minutes and everything is ok up to the point I ran it, after the first call first repeat, but without graphing it I have to watch it cut for a long time to proof it and I'm worried about the g91 X-1.875 move and the call in that sub for another sub with repeats. I've got the sub programs loaded into the controller @ o9001 and o9002. The code is below if that helps.

    %
    O0050 (CTRC HAMMER OP01)
    (T01 - D1.5IN SINGLE PT CCW ROT)
    (MAT-S7 TOOL STEEL ANNEALED)
    N0010 G20 G40 G49 G90
    N0020 M6 T01
    N0030 G43 H01
    N0040 G0 G54 X-3.125 Y-3.25
    N0050 S670 M04
    N0060 Z.25 M08
    N0070 M98 P9001 K15
    N0080 M98 P9002 K11
    N0090 M09
    N0100 M05
    N0110 G91 G28 Z0.0
    N0120 M30
    %

    %
    O9001 (CTRC HAMMER SUB1)
    N0140 G91 G1 Y.05 F10.0
    N0150 Z-2.75 F2.7
    N0160 Y-.05 F10.0
    N0170 G0 Z2.75
    N0180 G1 Y.05 F10.
    N0190 M99
    %

    %
    O9002 (CTRC HAMMER SUB2)
    N0210 G91 X-1.875 Y-.75
    N0220 M98 P9001 K15
    N0230 M99
    %
    Suppose you were an idiot and suppose you were a member of Congress. But I repeat myself.
    Mark Twain

  2. #2
    Join Date
    Mar 2003
    Posts
    4826
    You can run the program in single step, even in graphics mode. Press F4 to see the code at the bottom of the graphics window. You should be able to see what line is executing, so that you can check your program jumps.

    I'm not sure about calling repeats with a "K" address? Shouldn't that be "L"?

    If I am intending to switch to incremental mode, I always make a point of writing G91 on a line by itself. When I switch back, I write G90 on a line by itself, before the M99. If you intend to begin your subprogram in incremental, it is usually best to start with a G91 and end with a G90 before it jumps back to the main program, providing that the main program is all absolute. You can then call G91 in the next subprogram and end that one with a G90.
    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)

  3. #3
    Join Date
    Jul 2005
    Posts
    12177
    Change your subprogram number to something different than 9nnnn.

    Haas uses 9nnnn for some of the options such as engraving and there are settings which turn off the Graphics display for 9nnnn programs. You can go into the Settings and turn them on if you really want to keep the 9nnnn numbering.

    EDIT: Noticed Hu's comment about K and L...he is correct, L is the one for multiple sub calls.
    An open mind is a virtue...so long as all the common sense has not leaked out.

  4. #4
    Join Date
    Jun 2006
    Posts
    440
    Hu,
    I was using the F4 and F1 which is how I saw it seeming to skip over. I'll change that K with an L tomoorow and check that. I should have checked that in the fine manual. Might have been the lathe in school that used the K address. I'll remember that about the absolute and incremental. Harder to make a mistake that way.

    Geof,
    Why would you not want to use the 9nnn numbers? I could use another series like the 7nnn but aren't the 9nnn the only ones that can be locked? I had planned to log the sub-programs and load them on both machines but wanted to be able to lock those programs from editing in the future.
    Suppose you were an idiot and suppose you were a member of Congress. But I repeat myself.
    Mark Twain

  5. #5
    Join Date
    Jul 2005
    Posts
    12177
    Quote Originally Posted by Shotout View Post
    Geof,
    Why would you not want to use the 9nnn numbers? I could use another series like the 7nnn but aren't the 9nnn the only ones that can be locked? I had planned to log the sub-programs and load them on both machines but wanted to be able to lock those programs from editing in the future.
    Yes if you want to lock only group of programs you need to use the 9nnnn. I was just pointing out that if you use 9nnnn then you may not see them in graphics depending on what your settings are.

    I also have an aversion to using the same number group as the canned programs just in case I screw up and overwrite something.
    An open mind is a virtue...so long as all the common sense has not leaked out.

  6. #6
    Join Date
    Jun 2006
    Posts
    440
    Quote Originally Posted by Geof View Post
    Yes if you want to lock only group of programs you need to use the 9nnnn. I was just pointing out that if you use 9nnnn then you may not see them in graphics depending on what your settings are.

    I also have an aversion to using the same number group as the canned programs just in case I screw up and overwrite something.
    I see your point. We have no macros etc on the machines so all the 9nnnn numbers are empty. I'll have to decide how important it is to lock the programs I guess and make a decision. Probably would be wise to defer to experiance is my thought for now, chances are pretty good that it won't be really necessary to lock those programs, just so long as I'm consistent which is my main concern.

    Hu's and your pointer on the address value fixed the problem, looking at the machine position it was returning to Y-3.25 after returning to g54 Z.25 after the last repeat so it seems to be moving like I want.

    Now I just need to rewrite with the seperate g90, g91 lines as suggested by Hu as that sounds like a good habit to have, add the stock allowance for surface grinding after heat treating and probably a g41 move changing my Y values to match. This should work until I can figure out a better way to machine the part with our equipment if there is one.

    Thanks
    Scott
    Suppose you were an idiot and suppose you were a member of Congress. But I repeat myself.
    Mark Twain

  7. #7
    Join Date
    Mar 2003
    Posts
    4826
    Scott,
    Are you familiar with the M97 local sub call? If your subroutines are unique to each main program, it is probably more convenient to just load the subs in after the main program's M30. That way, there is no worrying about having program numbers available, because the subroutines exist within one program.

    The calling of a subroutine is basically the same except that you use an M97 in place of the M98. The P address called is simply a line number at the start of the sub. I do not otherwise use line numbers in my programs for anything except subroutine addresses, so this allows me to use a simple addresses like N100, N200 etc, without using an editor to discover what the literal line number might be, or worrying if the line number has changed after an edit. But you can use whatever you like.

    The subroutines are not named with a Ooooo program number.
    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)

  8. #8
    Join Date
    Jun 2006
    Posts
    440
    I have read about them in some of the reference books I have and have used them in my cad software for multiple pockets but never hand coded them. It would eliminate one concern such as deleting a sub program, or worse overwritting it with something inappropriate to this program. I have to stage the part, haven't wrote the portion from M00(xxx) on to allow moving it down on the fixture so it could end up being a nice little 3/4 printed page program. I think the long hand version is about 4pgs printed on legal paper.

    The block no. idea is a really good one. I like line numbers normally since it allows me to restart long programs the next morning if I have a part on the machine at the end of the day, but since that wouldn't be the case in this instance, and it is a short program to boot it would work well for this.

    On the same vein how do you do a restart in a program like this skipping to say the fourth repeat on the second sub? Would you just edit the program x,y start and decrease the repeats, or is there a better way?

    Quote Originally Posted by HuFlungDung View Post
    Scott,
    Are you familiar with the M97 local sub call? If your subroutines are unique to each main program, it is probably more convenient to just load the subs in after the main program's M30. That way, there is no worrying about having program numbers available, because the subroutines exist within one program.

    The calling of a subroutine is basically the same except that you use an M97 in place of the M98. The P address called is simply a line number at the start of the sub. I do not otherwise use line numbers in my programs for anything except subroutine addresses, so this allows me to use a simple addresses like N100, N200 etc, without using an editor to discover what the literal line number might be, or worrying if the line number has changed after an edit. But you can use whatever you like.

    The subroutines are not named with a Ooooo program number.
    Suppose you were an idiot and suppose you were a member of Congress. But I repeat myself.
    Mark Twain

  9. #9
    Join Date
    Mar 2003
    Posts
    4826
    I don't know of a surefire method to get to the middle of a repeat easily with minimal programming. If you think it will be a frequent occurance, then I suppose you should expand the number of fully written out calls to the sub within the main program, either eliminating the repeats altogether, or at least allowing you to get closer to where you want to be, with less air cutting time.
    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)

  10. #10
    Join Date
    Jun 2006
    Posts
    440
    Quote Originally Posted by HuFlungDung View Post
    I don't know of a surefire method to get to the middle of a repeat easily with minimal programming. If you think it will be a frequent occurance, then I suppose you should expand the number of fully written out calls to the sub within the main program, either eliminating the repeats altogether, or at least allowing you to get closer to where you want to be, with less air cutting time.
    I've made about 5 of these in the last year so I could just go on a case by case basis. Most of the hours in making this part and the two slotted bars that goes with it is actually blanking the material to the dimensions anyway.

    Thanks Hu
    Suppose you were an idiot and suppose you were a member of Congress. But I repeat myself.
    Mark Twain

  11. #11
    Join Date
    Jul 2005
    Posts
    12177
    Quote Originally Posted by Shotout View Post
    ....On the same vein how do you do a restart in a program like this skipping to say the fourth repeat on the second sub? Would you just edit the program x,y start and decrease the repeats, or is there a better way?
    Practically every program I write has subroutines because I put every tool in its own subroutine; most of my programs work on multiple parts and this way I can edit a program onto a different machine with a different number of vises.

    The subroutine calls are all near the top of what I designate the main part of the program and all it does is set the work zero and then call the sub so the structure is like this for three work zeroes and three tools:

    Name
    (Part description)
    Bunch of stuff
    G54 M97 P1000
    /G55 M97 P1000
    /G56 M97 P1000
    --------
    G54 M97 P2000
    /G55 M97 P2000
    /G56 M97 P2000
    ---------
    G54 M97 P3000
    /G55 M97 P3000
    /G56 M97 P3000
    ---------
    Bunch of stuff
    M30
    ---------
    N1000
    T1M06
    Tool 1 operations
    M99
    ----
    N2000
    T2M06
    Tool 2 operations
    M99
    ----
    N2000
    T3M06
    Tool 3 operations
    M99
    ----

    Restart can be done anywhere, at any line within a subroutine or at the M97 command. If the restart is done in the subroutine the control uses the first subroutine call as the reference. In other words if I put in the restart on tool 2 right on the T2M06 line it would do the G54 location and continue from there. If I want to start in one of the other work zeroes the restart has to be done at the M97 line so a restart for tool 3 in G56 would start at G56 M97 P3000.

    The block deletes are to shut out the second and third work zeroes during setup so all the wear settings can be adjusted before doing multiple parts.

    I find this system convenient because line numbers match the tool number and it is easy to jump down to any part of the program. For instance the spindle on command is always the second or third line in the sub. Additional subroutine calls within the main subroutines use P1100, P1200 etc.

    You comment on a 3/4 page program. I have some that are about 600 lines just for the work zero designation and subroutine calls working with 11 tools at 32 different work zeroes with some work zeroes used at different angular positions on a rotating fixture. These were fun to write but one took a 45 minute part using three separate programs and fixtures down to just under 8 minutes and I have recouped the fifteen hours I spent combining the three existing programs many times over. Also recouped the ten days it took to build the fixture.
    An open mind is a virtue...so long as all the common sense has not leaked out.

  12. #12
    Join Date
    Jun 2006
    Posts
    440
    Quote Originally Posted by Geof View Post
    Practically every program I write has subroutines because I put every tool
    Geof,
    I see the benefit of using ea. as a sub so you can use run multiple parts at once plus any edit for one part is translated into the others by default, plus it keeps one tooling op going at once for ea. part so you don't waste a lot of time on tool changes. Could be pretty easy to edit some of my existing programs using multiple offsets to make them more effecient. It took things in a direction that hadn't occured to me yet. Working by myself in my situation leaves me feeling like I'm reinventing the wheel at times.

    Your comment on increased effiecency on the mutlisetups hits home. One thing I'm always worried about it cumilative tolerance errors with multiple setups. As I learn more this format will become more practical for me. Right now I'm settled on a pretty simple setup and program much like Hu suggested, but your example puts me in mind of an example I read. 100,000,000 holes in a grid pattern. A simple program with 6 lines and two subs (one per tool) of 11 and 10 lines each. Long hand it would take approximately 19yrs uninterupted to write.

    Hu,
    I think this is going to work well as you suggested I changed them to all subroutines using the haas manual to check my formating. It graphs well and checks against my print. Just couldn't make myself take that g90 out of the saftey line or seperate that g91 g28 z0.0 just looks wrong and bothers me. did seperate the other g91s as you suggested though.

    Thanks
    scott
    %
    O5000 (CTRC CUTTER BAR CAVITIES)
    (T01- D1.5IN SINGLE PT CUTTER CCW ROTATION)
    (MATERIAL- S7 TOOL STEEL)
    G20 G40 G49 G90
    M6 T01 G43 H01
    G0 G54 X-3.125 Y-3.25 M04 S670
    G0 Z.25 M08
    M97 P0100 L10
    M97 P0200 L11
    M09
    M05
    G91 G28 Z0.00
    M00 (INDEX STOCK DOWN ON FIXTURE)
    G90
    G0 X-3.125 Y-3.25
    M04 S670
    G0 Z.25 M08
    M97 P0100 L10
    M97 P0200 L10
    M09
    M05
    G91 G28 Z0.0
    M30

    N0100(CTRC CUTTER BAR SUB01)
    G91
    G1 Y0.076 F10.0
    Z-2.75 F2.7
    Y-.076 F10.0
    G0 Z2.75
    Y0.076
    M99

    N0200(CTRC CUTTER BAR SUB02)
    G91
    G0 X-1.875 Y-.76
    M98 P7001 L10
    M99
    %
    Suppose you were an idiot and suppose you were a member of Congress. But I repeat myself.
    Mark Twain

  13. #13
    Join Date
    Mar 2003
    Posts
    4826
    Yes, by all means leave the G90 in the safety line for the main program and the G91 goes hand in hand with the G28. I wouldn't call G90 in the safety line a precaution, I think of it more as an essential piece of information about the program.

    What I was trying to clarify was changing modes in the subs, should be done in a systematic and clear fashion so that you always know what mode you are in, for sure. I prefer to make it a rule that the main program is running in absolute mode, and take the necessary steps that the returns from any subs would not be ambiguous about what the current mode is when working within the main program.
    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)

  14. #14
    Join Date
    Jun 2006
    Posts
    440
    Quote Originally Posted by HuFlungDung View Post
    Yes, by all means leave the G90 in the safety line for the main program and the G91 goes hand in hand with the G28. I wouldn't call G90 in the safety line a precaution, I think of it more as an essential piece of information about the program.

    What I was trying to clarify was changing modes in the subs, should be done in a systematic and clear fashion so that you always know what mode you are in, for sure. I prefer to make it a rule that the main program is running in absolute mode, and take the necessary steps that the returns from any subs would not be ambiguous about what the current mode is when working within the main program.
    Got ya. I appreciate your's and Geof's help. I've got my setup sheet etc written so I can update the file folder. Now I just need to build the fixture, basically an angle plate with some studs, tapped holes and jack bolts with thru holes for t-nuts. Better than suspending it between vises like I have been doing with jack bolts along the length. Easier to index the part too since I won't have to indicate in on half a hole.
    Suppose you were an idiot and suppose you were a member of Congress. But I repeat myself.
    Mark Twain

  15. #15
    Join Date
    Jul 2005
    Posts
    12177
    Related to the G91/G90 issue I will make some suggestions for you to consider.

    Lose the G91 that is associated with the G28 and lose the G28. Do your home move using G53. That way you do not have the G91 state active at the end of a program. Also when you use G53 it is easy to put in the coordinates that position the table convenient for reloading the vises.

    In subs which use G91 put this at the top of the sub, as you are doing, so you have a reminder when you are editing that the sub is working in incremental...but...put a G90 at the bottom with the M99 so you have reverted back to absolute going back to the main program. I know this is a belts and braces approach but it can prevent problems.

    Also look into using G52 to define a local work coordinate for the subs. This way you can avoid switching back and forth between absolute and incremental because everything is done in absolute.
    An open mind is a virtue...so long as all the common sense has not leaked out.

  16. #16
    Join Date
    Jun 2006
    Posts
    440
    G53 work set corrd is a good idea, always just edited my post to something like (in absolute) g0 z5.0 y2.0 for vice reloading. I could just use a g0 g53 command just as easy.

    I see your point about the g90 at the next to last line of the sub, I was reading after my last post (lunch) that I should be doing that likely for exactly the same good reasons.

    I've largely ignored the local coord system in the past mainly because I was always using cad software, but I find myself editing programs more and more lately to get what I want out of them so I need to look at it. I'm probably just being knit picky but I'm getting a more and more jobs in that are time critical as of late so... Maybe I'm just getting off this learning curve plateau I've been on. One can hope :-)

    Quote Originally Posted by Geof View Post
    Related to the G91/G90 issue I will make some suggestions for you to consider.

    Lose the G91 that is associated with the G28 and lose the G28. Do your home move using G53. That way you do not have the G91 state active at the end of a program. Also when you use G53 it is easy to put in the coordinates that position the table convenient for reloading the vises.

    In subs which use G91 put this at the top of the sub, as you are doing, so you have a reminder when you are editing that the sub is working in incremental...but...put a G90 at the bottom with the M99 so you have reverted back to absolute going back to the main program. I know this is a belts and braces approach but it can prevent problems.

    Also look into using G52 to define a local work coordinate for the subs. This way you can avoid switching back and forth between absolute and incremental because everything is done in absolute.
    Suppose you were an idiot and suppose you were a member of Congress. But I repeat myself.
    Mark Twain

Similar Threads

  1. Help tring to cut hex using c x moves
    By DryRun in forum G-Code Programing
    Replies: 7
    Last Post: 09-30-2007, 11:15 AM
  2. Graph problem
    By afterburn25 in forum Haas Mills
    Replies: 2
    Last Post: 04-12-2007, 02:38 PM
  3. Rapid moves G00
    By dicksonhof in forum Mach Software (ArtSoft software)
    Replies: 9
    Last Post: 11-07-2006, 04:21 PM
  4. Z position moves up during run
    By henryj1951 in forum Gecko Drives
    Replies: 3
    Last Post: 03-28-2006, 12:16 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
  •