586,414 active members*
2,962 visitors online*
Register for free
Login
Results 1 to 13 of 13
  1. #1
    Join Date
    Dec 2008
    Posts
    13

    limit on subroutines,only six?

    I have a fanuc control on a router. I have a set of 9 profiles that are the same I thought I could enter the g code for one and then set that as a subroutine and jest move the start points for each. When the program runs it will run the first six and then move to each location for the last three but only briefly stops at each location and then moves to the next, finaly ending the list for calls for the subs it will finish the rest of the program and stop. why wont it cut the last three parts?

  2. #2
    Join Date
    Sep 2010
    Posts
    1230
    Quote Originally Posted by oreos40 View Post
    I have a fanuc control on a router. I have a set of 9 profiles that are the same I thought I could enter the g code for one and then set that as a subroutine and jest move the start points for each. When the program runs it will run the first six and then move to each location for the last three but only briefly stops at each location and then moves to the next, finaly ending the list for calls for the subs it will finish the rest of the program and stop. why wont it cut the last three parts?
    Post your code so we can see how you've structured your program. Practically speaking, there's no limit to the number of times a sub can be called, only a limit to the number of levels of nesting of sub programs.

    Regards,

    Bill

  3. #3
    Join Date
    Dec 2008
    Posts
    13
    This is a program to cut some small wooden men. I have 9 to a set they are numbered 1-9 I have not tackled the engraving yet I will get back to that when the rest of this runs. My thoughts are to number the programs 0901-0909 for the engraving and to use the sub of 0900 for cutting them out. I will engrave the same number on each one in a set of 9 because it is easy to toss them into corresponding buckets rather than sorting the numbers afterward for individual sets
    as I have mentioned things go great untill it reaches the seventh rep on the sub and then it skips through to the end and shuts down.
    O0901
    MO6
    S 5000 M3
    G90 G0 X-11. Y-22. Z-8.
    M98 P0900
    G90 G0 X-11. Y-19.688
    M98 P0900
    G90 G0 X-11. Y-17.376
    M98 P0900
    G90 G0 X-11. Y-15.064
    M98 P0900
    G90 G0 X-11. Y-12.752
    M98 P0900
    G90 GO X-11. Y-10.44
    M98 P0900
    G90 G0 X-11. Y-8.128
    M98 P0900
    G90 G0 X-11. Y-5.816
    M98 P0900
    G90 G0 X-11. Y-3.504
    G54 G40 G49 G28 X0Y0Z0 M15
    M30






    O0900
    G91 G01
    Z-0.75 X0.3125
    Y-0.3107
    G03 X0.25 Y-0.25 I0.25 J0.
    G01 X0.2777
    G03 X0.25 Y0.25 I0. J0.25
    X-0.1661 Y0.2355 I-0.25 J0.
    G01 X-0.0624 Y0.0222
    X0.0173 Y0.1629
    G03 X0.0014 Y0.0264 I-0.2486 J0.0264
    X-0.0837 Y0.1866 I-0.25 J0.
    G01 X-0.2148 Y.1914
    X0.2759 Y0.089
    G03 X0.1797 Y0.2399 I-0.0703 J0.2399
    X-0.25 Y0.25 I-0.25 J0.
    G01 X-0.3841
    X0.0624 Y0.0222
    G03 X0.1661 Y0.2355 I-0.0839 J0.2355
    X-0.0694 Y0.1728 I-0.25 J0.
    X-0.2667 Y0.2247 I-1.1742 J-1.1234
    X-0.2792 Y0. I-0.1396 J-0.2074
    X-0.2667 Y-0.2247 I0.9075 J-1.348
    X-0.0694 Y-0.1728 I0.1806 J-0.1728
    X0.1661 Y-0.2355 IO.25 J0.
    G01 X0.0624 Y-0.0222
    X-0.3841
    GO3 X-0.25 Y-0.25 I0. J-0.25
    X0.1797 Y-0.2339 I0.25 J0.
    G01 X0.2759 Y-0.0809
    X-0.2148 Y-0.1914
    GO3 X-0.0837 Y-0.1866 I0.1663 J-0.1866
    X0.0014 Y-0.0264 I0.25 J0.
    G01 X0.0173 Y-0.1629
    X-0.0624 Y-0.0222
    G03 X-0.1661 Y-0.2355 I0.0839 J-0.2355
    X0.25 Y-0.25 I0.25 J0.
    X0.2777
    G03 X0.25 Y0.25 I0. J0.25
    G01 Y0.3107
    G01 X0.3125
    G00 Z0.75
    M99

  4. #4
    Join Date
    Sep 2010
    Posts
    1230
    Quote Originally Posted by oreos40 View Post
    O0901
    MO6
    S 5000 M3
    G90 G0 X-11. Y-22. Z-8.
    M98 P0900
    G90 G0 X-11. Y-19.688
    M98 P0900
    G90 G0 X-11. Y-17.376
    M98 P0900
    G90 G0 X-11. Y-15.064
    M98 P0900
    G90 G0 X-11. Y-12.752
    M98 P0900
    G90 GO X-11. Y-10.44
    M98 P0900
    G90 G0 X-11. Y-8.128
    M98 P0900
    G90 G0 X-11. Y-5.816
    M98 P0900
    G90 G0 X-11. Y-3.504
    G54 G40 G49 G28 X0Y0Z0 M15
    M30
    Is the program in your Post a Cut and Paste from your actual program? If so, there is an “O” character instead of a Zero as shown in red. Otherwise, I can’t see any problem with your code that should make it fall over. Repeatedly calling the sub program in the manner that you have is an accepted method, and I can’t see any reason why your program would fall through after completing 6 calls.

    I haven’t waded through your incremental sub program, but if the tool ended where it started in X and Y, you could add at the end of the sub program the Y pitch of the parts, and call the sub from the main program in the following way to have the sub repeat 9 times, but there would be an extra Y 2.312 move at the end of machining the 9 parts. If your control has the User Macro option, you could achieve your desired result more eloquently using a Macro statement.

    Give calling the sub program and have it repeat 9 times a go to see if that works.

    O0901
    MO6
    S 5000 M3
    G90 G0 X-11. Y-22. Z-8.
    M98 P0900 L9
    G54 G40 G49 G28 X0Y0Z0 M15
    M30



    X-0.0624 Y-0.0222
    G03 X-0.1661 Y-0.2355 I0.0839 J-0.2355
    X0.25 Y-0.25 I0.25 J0.
    X0.2777
    G03 X0.25 Y0.25 I0. J0.25
    G01 Y0.3107
    G01 X0.3125
    G00 Z0.75
    Y 2.312 (Y shift for next part)
    M99

    Regards,

    Bill

  5. #5
    Join Date
    Dec 2008
    Posts
    13
    that was a typo on my part it is not in the program on the control. I will try your suggestion with the L9 and the offset in Y at the end of the sub

  6. #6
    Join Date
    Feb 2006
    Posts
    1792
    I have seen a similar problem on an emulated Fanuc control.
    Do you have original or emulated Fanuc?

  7. #7
    Join Date
    Mar 2003
    Posts
    4826
    It sounds like a controller bug where it thinks these are nested subs for some reason. Maybe you need more lines between each sub call in the main program? For example, you could write in the main:
    M98 P....
    G90
    G00 Z-8.0 (this is your apparent clearance plane)
    G00 X Y
    M98 P....
    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
    Dec 2008
    Posts
    13
    it is a fanuc control not an emulator why would it do six calls and not the remaining three then. I wont have a chance to try this till the fourth of january.

  9. #9
    Join Date
    Jun 2008
    Posts
    1511
    I see a lot of O (ohs) instead of zeros. Can you maybe cut and paste the “actual” program that is not working? It’s a small point but possible that it is mistyped.

    I would also do something like Hu suggested. I would try putting an M1 after each sub and then turn your optional stop on (if you have one). Then once it stops put the machine in single block to see where the program is jumping to and what it is actually buffering and running. It may not be making it to the sub or it might be. By adding spaces or EOB they may help you see things that you would not normally see. It could be an issue with look ahead. It does not seem like it is or you would have this problem earlier however if for some reason it is seeing all 9 M98P900 at one time it could be thinking it is nesting them. IIRC you would typically get an alarm if you tried nesting to many programs but who knows at this point.

    Don’t know but am very curious to the solution.

    Stevo

  10. #10
    Join Date
    Dec 2008
    Posts
    13
    I have not way to output the actual program at this point. again why would it do the first six and skip the rest. I have single blocked the routine through when it reaches the sub for the seventh it moves to the start point for number seven and waits when I hit the cycle start it moves to the start point for number eight when I hit the cycle start it moves to the start for number 9 one mor cycle start and it goes to x0y0z0 and the spidle shuts off. I'll try the suggestions when I get back to the shop.

  11. #11
    Join Date
    Feb 2006
    Posts
    1792
    Nesting should not be an issue. If you nest more than allowed, it would alarm out. It is not that the control would ignore extra subs.

    Which control version you have?

  12. #12
    Join Date
    Mar 2003
    Posts
    2932
    What model Fanuc is this?

  13. #13
    Join Date
    Mar 2003
    Posts
    4826
    Quote Originally Posted by oreos40 View Post
    I have not way to output the actual program at this point. again why would it do the first six and skip the rest. I have single blocked the routine through when it reaches the sub for the seventh it moves to the start point for number seven and waits when I hit the cycle start it moves to the start point for number eight when I hit the cycle start it moves to the start for number 9 one mor cycle start and it goes to x0y0z0 and the spidle shuts off. I'll try the suggestions when I get back to the shop.
    Bugs don't follow normal logic, and unless you can get a firmware update for the controller to fix problems that you discover, you need to learn how to avoid the bugs.

    You may have other options other than sub program calls to make repetitive parts. Subprograms are good when you really need to save memory space, but your program is not overly lengthy. For example, you might be able to run your subprogram in absolute mode, and change the workshift in your main program. I don't know how many workshifts you have available.

    G54
    M98 P
    G55
    M98 P
    G56
    M98P
    etc

    I see you have called the workshift at the end of your program, which to me, is not the proper place to have a 'safety line'. It should be at the beginning of the program. You might need to increase your understanding of gcode a little bit more, but it will be worth it.

    The workshifts contain the XY values of the start datum for each running of the program, instead of including repositioning moves inside your sub.
    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)

Similar Threads

  1. Edgecam Subroutines
    By John Holmes in forum EdgeCam
    Replies: 16
    Last Post: 02-05-2013, 05:45 PM
  2. with subroutines
    By Thad Swarfburn in forum G-Code Programing
    Replies: 0
    Last Post: 06-25-2009, 02:37 AM
  3. Arguments for Subroutines (G65)
    By theragust in forum Milltronics
    Replies: 5
    Last Post: 10-17-2007, 04:04 PM
  4. EMC and Subroutines?
    By watchman in forum LinuxCNC (formerly EMC2)
    Replies: 9
    Last Post: 06-17-2007, 08:30 PM
  5. Oi subroutines help
    By mishikwest in forum Fanuc
    Replies: 1
    Last Post: 08-01-2006, 11:17 PM

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
  •