586,116 active members*
3,421 visitors online*
Register for free
Login

Thread: M98 Looping

Page 1 of 2 12
Results 1 to 20 of 21
  1. #1
    Join Date
    Nov 2005
    Posts
    244

    M98 Looping

    I was wondering if there is a way to add a statement to have the flexibilty of having the G91 C30. start at another location if wanted in the loop?

    Ex. Start a C90 position instead of from the beginning. I have a example below.

    I am trying to work around my Cam system and post not being able to post a G66 which is my machining info and a M98 which is my positon info.

    %
    O1000
    N10 G54 X0 Y0 Z5.0
    N20 (TOOL-2-.125-FINISH-ENDMILL)
    N30 T2
    N40 M6
    N50 M8
    N60 G90 G17 G0 X2.0878 Y.2118 C0. S3820 M3
    N70 G43 Z5. H2
    N80 M98 P5 L5
    N90 M9
    N100 G91 G28 Z0
    N110 M30
    N120

    O5
    N10 ( SUB NUMBER: 5 )
    N20 ( OPERATION 6: CONTOUR )
    N30 G91 C30.
    N40 G90 G0 X2.0878 Y.2118
    N50 Z1.228
    N60 G1 Z1.063 F10.
    N70 G41 X2.0035 Y.2656 D52
    N80 X1.9439 Y.3037
    N90 X1.9369 Y.3021 F20.
    N100 X1.9298 Y.3004
    N110 X1.9227 Y.2973
    N120 X1.9086 Y.2875
    N130 X1.9026 Y.2826
    N140 X1.8985 Y.2755
    N150 X1.8943 Y.2684
    N160 X1.8921 Y.2613
    N170 X1.8895 Y.2331
    N180 X1.8899 Y.226
    N190 X1.904 Y.0069
    N200 X1.9042 Y-.0002
    N210 X1.9039 Y-.0072
    N220 X1.8899 Y-.2264
    N230 X1.8895 Y-.2334
    N240 X1.8921 Y-.2617
    N250 X1.8945 Y-.2686
    N260 X1.9028 Y-.2829
    N270 X1.9086 Y-.2875
    N280 X1.9227 Y-.2973
    N290 X1.9298 Y-.3004
    N300 X1.9369 Y-.3021
    N310 X1.9439 Y-.3037
    N320 X2.0036 Y-.2657
    N330 G40 X2.0879 Y-.2119
    N340 G0 Z5.
    N350 M99
    %

  2. #2
    Join Date
    Feb 2008
    Posts
    267
    Instead of C30. you could say C#100 and set #100 to whatever you would like.
    Control the process, not the product!
    Machining is more science than art, master the science and the artistry will be evident.

  3. #3
    Join Date
    Nov 2005
    Posts
    244
    This is what I came up with so far. I am reading and trying things as I go. I was wondering if there is a way to clearout the angle offset after it is used once? I am not sure of the format I would need.

    Thank You

    %
    O0001 ( TEST )
    N10 ( DATE - 23-06-11 TIME - 13:34 )
    N20 G20
    N30 G0 G17 G40 G80 G90 G94 G98
    N40 G0 G28 G91 Z0.
    N50 G0 G28 X0. Y0.
    ( ENDMILL-.750 )
    N70 T3
    N80 M6
    N90 G0 G54 G90 X2.3232 Y.1768 C0. B0. S203 M3
    N100 G43 H3 Z.25 M8
    N110 Z.2
    ( F=ANGLE-OFFSET-TO-RESTART-WHERE-NEEDED-0.0-IS-DEFAULT )
    N120 G65 P1001 L4 A15.0 F0.0
    N200 M9
    N210 M5
    N220 G0 G28 G91 Z0.
    N230 G0 G28 X0. Y0.
    N240 G28
    N250 M30
    ( SUBPROGRAM-MILL-4-HOLES )
    O1001
    N090 #102=#7
    N100 #101=#1
    N110 G91 C#101+#102
    N115 G90
    N120 G1 Z-1.5 F6.
    N130 G3 X2.25 Y0. I.1768 J-.1768 F.81
    N140 X2.5 Y-.25 I.25
    N150 X2.75 Y0. J.25
    N160 X2.5 Y.25 I-.25
    N170 X2.3232 Y.1768 J-.25
    N180 G1 Z-1.3 F100.
    N190 G0 Z.25
    M99
    %

  4. #4
    Join Date
    Feb 2008
    Posts
    267
    Quote Originally Posted by camtd View Post
    This is what I came up with so far. I am reading and trying things as I go. I was wondering if there is a way to clearout the angle offset after it is used once? I am not sure of the format I would need.

    Thank You

    %
    O0001 ( TEST )
    N10 ( DATE - 23-06-11 TIME - 13:34 )
    N20 G20
    N30 G0 G17 G40 G80 G90 G94 G98
    N40 G0 G28 G91 Z0.
    N50 G0 G28 X0. Y0.
    ( ENDMILL-.750 )
    N70 T3
    N80 M6
    N90 G0 G54 G90 X2.3232 Y.1768 C0. B0. S203 M3
    N100 G43 H3 Z.25 M8
    N110 Z.2
    ( F=ANGLE-OFFSET-TO-RESTART-WHERE-NEEDED-0.0-IS-DEFAULT )
    N120 G65 P1001 L4 A15.0 F0.0
    N200 M9
    N210 M5
    N220 G0 G28 G91 Z0.
    N230 G0 G28 X0. Y0.
    N240 G28
    N250 M30
    ( SUBPROGRAM-MILL-4-HOLES )
    O1001
    N090 #102=#7
    N100 #101=#1
    N110 G91 C#101+#102
    N115 G90
    N120 G1 Z-1.5 F6.
    N130 G3 X2.25 Y0. I.1768 J-.1768 F.81
    N140 X2.5 Y-.25 I.25
    N150 X2.75 Y0. J.25
    N160 X2.5 Y.25 I-.25
    N170 X2.3232 Y.1768 J-.25
    N180 G1 Z-1.3 F100.
    N190 G0 Z.25

    #7=0(SET OFFSET TO 0 FOR SUBSEQUENT ITERATIONS)

    M99
    %
    See the red text above, this would set it to 0 at the end of the first loop.
    To clear a variable i.e make it's value empty you would set it to #0.
    HTH
    Good luck
    Control the process, not the product!
    Machining is more science than art, master the science and the artistry will be evident.

  5. #5
    Join Date
    Dec 2004
    Posts
    150
    Quote Originally Posted by camtd View Post
    This is what I came up with so far. I am reading and trying things as I go. I was wondering if there is a way to clearout the angle offset after it is used once? I am not sure of the format I would need.

    Thank You

    %
    O0001 ( TEST )
    N10 ( DATE - 23-06-11 TIME - 13:34 )
    N20 G20
    N30 G0 G17 G40 G80 G90 G94 G98
    N40 G0 G28 G91 Z0.
    N50 G0 G28 X0. Y0.
    ( ENDMILL-.750 )
    N70 T3
    N80 M6
    N90 G0 G54 G90 X2.3232 Y.1768 C0. B0. S203 M3
    N100 G43 H3 Z.25 M8
    N110 Z.2
    ( F=ANGLE-OFFSET-TO-RESTART-WHERE-NEEDED-0.0-IS-DEFAULT )
    N120 G65 P1001 L4 A15.0 F0.0
    N200 M9
    N210 M5
    N220 G0 G28 G91 Z0.
    N230 G0 G28 X0. Y0.
    N240 G28
    N250 M30
    ( SUBPROGRAM-MILL-4-HOLES )
    O1001
    N090 #102=#7
    N100 #101=#1
    N110 G91 C#101+#102
    N115 G90
    N120 G1 Z-1.5 F6.
    N130 G3 X2.25 Y0. I.1768 J-.1768 F.81
    N140 X2.5 Y-.25 I.25
    N150 X2.75 Y0. J.25
    N160 X2.5 Y.25 I-.25
    N170 X2.3232 Y.1768 J-.25
    N180 G1 Z-1.3 F100.
    N190 G0 Z.25
    M99
    %
    Hi Camtd,
    Or you could still use M98 (i think like this )

    %
    O0001 ( TEST )
    N10 ( DATE - 23-06-11 TIME - 13:34 )
    N20 G20
    N30 G0 G17 G40 G80 G90 G94 G98
    N40 G0 G28 G91 Z0.
    N50 G0 G28 X0. Y0.
    ( ENDMILL-.750 )
    N70 T3
    N80 M6
    N90 G0 G54 G90 X2.3232 Y.1768 C0. B0. S203 M3
    N100 G43 H3 Z.25 M8
    N110 Z.2

    #500=0( START ANGLE-OFFSET-TO-RESTART-WHERE-NEEDED-0.0-IS-EFAULT)
    #501=20.0( PITCH)
    #502=4( REPEATS )

    N120 M98 P1001 L#502

    N200 M9
    N210 M5
    N220 G0 G28 G91 Z0.
    N230 G0 G28 X0. Y0.
    N240 G28
    N250 M30



    ( SUBPROGRAM-MILL-4-HOLES )
    O1001
    N110 G91 C#501
    N115 G90
    N120 G1 Z-1.5 F6.
    N130 G3 X2.25 Y0. I.1768 J-.1768 F.81
    N140 X2.5 Y-.25 I.25
    N150 X2.75 Y0. J.25
    N160 X2.5 Y.25 I-.25
    N170 X2.3232 Y.1768 J-.25
    N180 G1 Z-1.3 F100.
    N190 G0 Z.25
    M99
    %

    Just edit the values in green.
    Good luck,
    Keith.

  6. #6
    Join Date
    Nov 2005
    Posts
    244

    Both options are great

    I did not expect to learn so much.

    I seems when I read the books my eyes get a glaze over them and I just get more confused.

    How would a statement look if I wanted to say
    If #500 in not equal to #501/360 then print a error on the screen "starting angle not dividable by 360 degrees"

    Thank You

  7. #7
    Join Date
    Feb 2008
    Posts
    267
    Quote Originally Posted by camtd View Post
    I did not expect to learn so much.

    I seems when I read the books my eyes get a glaze over them and I just get more confused.

    How would a statement look if I wanted to say
    If #500 in not equal to #501/360 then print a error on the screen "starting angle not dividable by 360 degrees"

    Thank You
    Explain a little more about what you want.
    What do you not want #501 to be?
    I am assuming that you do not want fractional angle such as #501=32.423
    But you know what "they" say about assuming.
    Control the process, not the product!
    Machining is more science than art, master the science and the artistry will be evident.

  8. #8
    Join Date
    Nov 2005
    Posts
    244
    I would like #501 to be 15 degrees

  9. #9
    Join Date
    Nov 2005
    Posts
    244
    I added what I think is all but the one thing which is to make sure the distance is divisible by 15 in the correct way.

    Thank You

    %
    O0001 ( TEST )
    N10 ( DATE - 23-06-11 TIME - 13:34 )
    N20 G20
    N30 G0 G17 G40 G80 G90 G94 G98
    N40 G0 G28 G91 Z0.
    N50 G0 G28 X0. Y0.
    ( ENDMILL-.750 )
    N70 T3
    N80 M6
    N90 G0 G54 G90 X2.3232 Y.1768 C0. B0. S203 M3
    N100 G43 H3 Z.25 M8
    N110 Z.2

    #500=0( START ANGLE-OFFSET-TO-RESTART-WHERE-NEEDED-0.0-IS-DEFAULT)
    N120 M98 P1001 L#502

    N200 M9
    N210 M5
    N220 G0 G28 G91 Z0.
    N230 G0 G28 X0. Y0.
    N240 G28
    N250 M30



    ( SUBPROGRAM-MILL-4-HOLES )
    O1001

    #501=20.0( PITCH)
    #502=4( REPEATS )
    #503=15/360 (NOT SURE WHAT LOGIC TO PUT HERE
    IF[#500NE#503] GOTO N777
    N777
    M5
    #3000= (MODIFED POSTION IS NOT CORRECT)


    N110 G91 C#501
    N115 G90
    N120 G1 Z-1.5 F6.
    N130 G3 X2.25 Y0. I.1768 J-.1768 F.81
    N140 X2.5 Y-.25 I.25
    N150 X2.75 Y0. J.25
    N160 X2.5 Y.25 I-.25
    N170 X2.3232 Y.1768 J-.25
    N180 G1 Z-1.3 F100.
    N190 G0 Z.25
    M99
    %

  10. #10
    Join Date
    Feb 2008
    Posts
    267
    A few things,
    You've moved this...

    Code:
    #501=20.0( PITCH)
    #502=4( REPEATS )
    #503=15/360      (NOT SURE WHAT LOGIC TO PUT HERE
    into the sub program but it needs to be in the main program ahead of the M98 call.
    Otherwise the number of repeats will not be read on your first time through the loop because #502 is not set untill you're in the sub program.
    Too the logoic will be fired on every iteration of the loop, which is usually not necessary or desired.

    Now onto the error trapping...
    Do you want the offset angle to be limited to 15° or divisibile by 15°.
    Control the process, not the product!
    Machining is more science than art, master the science and the artistry will be evident.

  11. #11
    Join Date
    Nov 2005
    Posts
    244
    I would like it divisible by 15.

    Thanks

  12. #12
    Join Date
    Feb 2008
    Posts
    267
    Quote Originally Posted by camtd View Post
    I would like it divisible by 15.

    Thanks

    Code:
    #503=#500 MOD 15
    IF[#500EQ0]GOTO777(I ASSUME 0 IS OK TO USE)
    IF[#503EQ0]GOTO777(NO REMAINDER/DIVISIBLE BY 15)
    #3000=1(#500 IS NOT 0 OR DIVISIBLE BY 15)
    N77730
    I did not test this on a machine but it should be good
    Control the process, not the product!
    Machining is more science than art, master the science and the artistry will be evident.

  13. #13
    Join Date
    Nov 2005
    Posts
    244
    Wow

    I feel like I worked a full day already. What a great help to understanding more about the macro functions. I will look up in Peter Smid book about the definition of "Mod"

    I moved the G91 C15 at the bottom so I could start machining a X0. I did run this through NcPlot and it worked good.

    Thank You Very Much

    %
    O0001 ( TEST )
    N10 ( DATE - 23-06-11 TIME - 13:34 )
    N20 G20
    N30 G0 G17 G40 G80 G90 G94 G98
    N40 G0 G28 G91 Z0.
    N50 G0 G28 X0. Y0.
    ( ENDMILL-.750 )
    N70 T3
    N80 M6
    N90 G0 G54 G90 X2.3232 Y.1768 C0. B0. S203 M3
    N100 G43 H3 Z.25 M8
    N110 Z.2


    ( ******************* )

    ( START ANGLE-OFFSET -TO-RESTART-WHERE-NEEDED-0.0-IS-DEFAULT)
    #500=0

    ( *******************)
    #501=15.0( PITCH)
    #502=4( REPEATS )
    #503=#500 MOD 15
    IF[#500EQ0] GOTO 777
    IF[#503EQ0] GOTO 777
    #3000=1 (#500 IS NOT 0 OR DIVISIBLE BY 15)
    N777
    ( ********************* )
    N120 M98 P1001 L#502
    N200 M9
    N210 M5
    N220 G0 G28 G91 Z0.
    N230 G0 G28 X0. Y0.
    N240 G28
    N250 M30

    ( SUBPROGRAM-MILL-4-HOLES )
    O1001
    N115 G90
    N120 G1 Z-1.5 F6.
    N130 G3 X2.25 Y0. I.1768 J-.1768 F.81
    N140 X2.5 Y-.25 I.25
    N150 X2.75 Y0. J.25
    N160 X2.5 Y.25 I-.25
    N170 X2.3232 Y.1768 J-.25
    N180 G1 Z-1.3 F100.
    N190 G0 Z.25
    N110 G91 C#501
    M99
    %

  14. #14
    Join Date
    Feb 2008
    Posts
    267
    You could look here too.

    but basically mod is the remainder of one number divided by another.
    so...

    45/15=3 with no remainder
    45 MOD 15 = 0
    45/17=2.64705...
    45 MOD 17 = 11 or (11/17= .64705...)
    Said another way 11 units out of 17 is what is left over.
    Said still another way...
    45-(2*17) {2 full divisions}
    45-34=11
    HTH
    Happy Macroing!
    Control the process, not the product!
    Machining is more science than art, master the science and the artistry will be evident.

  15. #15
    Join Date
    May 2007
    Posts
    1003
    Quote Originally Posted by ProProcess View Post
    Code:
    #503=#500 MOD 15
    IF[#500EQ0]GOTO777(I ASSUME 0 IS OK TO USE)
    IF[#503EQ0]GOTO777(NO REMAINDER/DIVISIBLE BY 15)
    #3000=1(#500 IS NOT 0 OR DIVISIBLE BY 15)
    N77730
    I did not test this on a machine but it should be good



    I've only ever programmed lathes, but am going to be getting the chance to work with a couple mills. Therefore I am looking to expand my macro knowledge. I have a few questions if it is alright to ask here.

    First, I am only familiar with some Fanuc controls. F=#9 not #7 on them. (As in N090 #102=#7). What control are you guys talking about?

    Second, I don't recall seeing MOD in a Fanuc operating manual. What does it mean/do? Oops. Hadn't read page 2. Still don't recall seeing it in a Fanuc manual or Peter Smid's Macro book. Will try to remember to check in Smid's book when I go back to work Tuesday. Also the Fanuc manuals I look at are for lathes, so I'll have to check one of the mill manuals.

    Third, in N77730 shouldn't 30 have an address? If not, what does the control take it to mean?

    Fourth, OP wanted number divisible by 15, yet I saw 15/360. The latest revised program makes more sense to me.

    Fifth, how is C being incremented? When I increment C on a lathe I have to add something to the current value.

    One thing for sure that I'll need to look up is how G90 and G91 get used on a mill.

    Appreciate any help you can provide in helping me gain further understanding. Thanks.

  16. #16
    Join Date
    Feb 2008
    Posts
    267
    Quote Originally Posted by g-codeguy View Post
    First, I am only familiar with some Fanuc controls. F=#9 not #7 on them. (As in N090 #102=#7). What control are you guys talking about?
    I think this is true univerally, I did not scrutinize each bit of code, maybe it was a typo along the way.

    Quote Originally Posted by g-codeguy View Post
    Third, in N77730 shouldn't 30 have an address? If not, what does the control take it to mean?
    Should just be N777, N77730 was a typo


    Quote Originally Posted by g-codeguy View Post
    Fifth, how is C being incremented? When I increment C on a lathe I have to add something to the current value.

    One thing for sure that I'll need to look up is how G90 and G91 get used on a mill.
    G90/G91 Absolute/Incremental address
    Control the process, not the product!
    Machining is more science than art, master the science and the artistry will be evident.

  17. #17
    Join Date
    Nov 2005
    Posts
    244
    Correct, the F=#9 I was so involved in figuring out the other stuff I over looked that.

    In the example #501 = the angle C will index I set it to incremental so I could apply a loop.

    If I did not do that from what I have experience so far I would have to use a G66 with absolute and bounce back between the indexing and cutting.

    The controls I am referring to are Fanuc style B.

    Do you have a example to put up on what you would like to do?
    I had a great learning experience in doing that last week.

  18. #18
    Join Date
    May 2007
    Posts
    1003
    camtd, I assume you are asking me. No I don't have an example yet. Set up my first mill job tonight. Last operation. C-drill, drill, ream. Tools were in but not touched off. Had to mount and tram fixture. (Is tram the correct terminology for indicating the fixture before locking it down?) Set 6 work shifts. Didn't get to run it because I had a couple lathe programs to write since I'm on vacation the rest of the week.

  19. #19
    Join Date
    Dec 2004
    Posts
    150
    Quote Originally Posted by g-codeguy View Post

    Fifth, how is C being incremented? When I increment C on a lathe I have to add something to the current value.

    One thing for sure that I'll need to look up is how G90 and G91 get used on a mill.

    Appreciate any help you can provide in helping me gain further understanding. Thanks.
    Hi, on a mill G90=absolute positioning and G91=incremental positioning
    therefore to move C axis 10 degrees you could put G91G0C10 , this would not move to 10 but would move 10 from where it is currently positioned. How are you incrementing on lathe are you using U an W?. Only thing with this is dont forget to have a G90 following when you switch back to absolut positions.
    Keith.

  20. #20
    Join Date
    Feb 2008
    Posts
    267
    Quote Originally Posted by TURNER View Post
    ... How are you incrementing on lathe are you using U an W?.
    On Lathes, usually the incremental designation for C is H.


    Code:
    G0 C70. (GO TO C 70 DEGREES)
    GO H12. (INCREMENT C 12 DEGREES C POSITION IS NOW 82 DEGREES)
    Control the process, not the product!
    Machining is more science than art, master the science and the artistry will be evident.

Page 1 of 2 12

Similar Threads

  1. Parametric Looping problem
    By gtrrpa in forum Parametric Programing
    Replies: 12
    Last Post: 11-16-2010, 12:03 AM
  2. Looping command?
    By rigo430 in forum Haas Lathes
    Replies: 1
    Last Post: 04-11-2010, 11:35 PM
  3. LOOPING? with Camsoft??
    By nelZ in forum CamSoft Products
    Replies: 15
    Last Post: 10-15-2008, 09:56 PM
  4. Program Looping
    By Bohemund in forum CamSoft Products
    Replies: 7
    Last Post: 05-26-2007, 05:08 PM
  5. Sub Looping
    By murphyspost in forum Daewoo/Doosan
    Replies: 8
    Last Post: 12-27-2006, 05:28 PM

Posting Permissions

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