586,102 active members*
3,149 visitors online*
Register for free
Login
Results 1 to 15 of 15
  1. #1
    Join Date
    Sep 2007
    Posts
    181

    whole G-Code REPEAT command ??

    seems simple but have been searching everywhere to no avail...

    is the a g-code command that simply restarts proccessing at the beginning of the code?

    or just repeat the code ?

  2. #2
    Join Date
    Jul 2005
    Posts
    12177
    I think what you can use depends on your controller.

    Sometimes if you end a program with M99 the controller will go back and start at the top, and do this endlessly; some controllers will give an alarm telling you it is an endless loop.

    The best way in my opinion is just put the code to be repeated in a subroutine and then use an L count in the subroutine call;

    etc
    etc
    M97 P1000 L5
    etc
    etc
    M30
    N1000 Code being repeated
    etc
    etc
    M99

    You can simply repeat the section of code. I program on Haas and it is so easy to duplicate blocks of code I will do this when I am feeling too lazy to set up the subroutine format. But if you simply repeat the block of code many times then want to edit it you have many places to edit; with the subroutine approach you edit at one place.
    An open mind is a virtue...so long as all the common sense has not leaked out.

  3. #3
    Join Date
    Feb 2008
    Posts
    586
    Since G codes don't have anything to do with "tape function", probably you would need an M code, like M99. You might be able to use a WHILE/DO loop, or an IF/GOTO or a straight GOTO statement. The M98 subprogram call would work for L times, but it wouldn't be an endless loop. The only G code might be a G65 macro call that would refer to a program that had M99P10 at the end (where 10 is the line number just before that macro call). Then you'd also be stuck in a loop. Of course it does depend on which control you are using.

  4. #4
    Join Date
    Jul 2007
    Posts
    195
    M30 is rewind back to start of program. But you have to hit the big green button again to start the program again.
    Be carefull what you wish for, you might get it.

  5. #5
    Join Date
    Sep 2007
    Posts
    181
    Thx for the info....Beege the M98 sounds simple since I dont actually need it to be endless. so it would just be (M98 #) where # = numer of repeats?

    btw, the controller is a xylotex and yes Geof its pulling an alarm with M99

  6. #6
    Join Date
    Oct 2005
    Posts
    672
    Typically, the M98 calls the subprogram/subroutine.

    On my Mitsubishi controls, the format is:

    M98 Pppp Hhhh Ll

    ppp=external subprogram number (omit if subroutine is at end of current program)
    hhh= line number of the subroutine
    l= number of times to repeat

    The subroutine would start at line hhh and the signal to finish and return the original block is M99.

    Some machines have proprietary loop/repeat codes.

  7. #7
    Join Date
    Oct 2005
    Posts
    672
    Xylotex only refers to the motors/drives apparently? What software is controlling all this on the PC?

  8. #8
    Join Date
    Sep 2007
    Posts
    181
    Capris, using Mach3

  9. #9
    Join Date
    Oct 2005
    Posts
    672
    According to the Mach3 website, Geof's code above is close except he has M97 instead of M98 and instead of using "N1000" it should be O1000. Note that O1000 starts with the letter "O", not the numeral zero.

    Plagarizing Geof:

    etc
    etc
    M98 P1000 L5
    etc
    etc
    M30
    O1000 Code being repeated
    etc
    etc
    M99


    According to the Mach3 website, line O1000 cannot contain anything other than a comment (sub 1000, for example).

    I get all that from http://www.machsupport.com/docs/Mach3Mill_1.84.pdf looking at page 138 of 157 of the PDF file (10-34 in Mach3 pages).

  10. #10
    Join Date
    Jul 2005
    Posts
    12177
    Quote Originally Posted by Caprirs View Post
    ....Plagarizing Geof:...
    Imitation; the most sincere form of flattery. Thank you.

    The M97/M98 thing is why I have learnt to put the comment about it depending on your controller.

    I program on Haas and use M97 which is an internal subroutine call, M98 jumps you out to a different program. Does Mach use M98 as an internal call requiring the M99 return?
    An open mind is a virtue...so long as all the common sense has not leaked out.

  11. #11
    Join Date
    Oct 2005
    Posts
    672
    Quote Originally Posted by Geof View Post
    Imitation; the most sincere form of flattery. Thank you.

    The M97/M98 thing is why I have learnt to put the comment about it depending on your controller.

    I program on Haas and use M97 which is an internal subroutine call, M98 jumps you out to a different program. Does Mach use M98 as an internal call requiring the M99 return?
    Is stealing really the same as imitation?

    On my Mitsubishi machines, there is no M97. M98 is the only available command.

    M98 P H L I J

    P = external program number. If no P is specified, the control searches within the current program.

    H = line number. I don't know why Mits uses H instead of N. If going to an external program P, no H is required.

    L = repeat. Number of times to repeat the sub. If no L specified, the sub is executed once.

    I, J = allow for rotation of the sub as it is repeated. For example, making a gear involves the code for single tooth that is repeated enough times to rotate the 360 degrees.

  12. #12
    Join Date
    Jul 2005
    Posts
    12177
    Quote Originally Posted by Caprirs View Post
    Is stealing really the same as imitation? .....
    Go on, cut me some slack

    That rotation feature looks handy. Haas does it a different way.
    An open mind is a virtue...so long as all the common sense has not leaked out.

  13. #13
    Join Date
    Jun 2007
    Posts
    3757

    Question Repeats in Mach3.

    I do similar to post#9 and in the sub program I quite often incremnt some variable, like this:

    G52 X0 Y0 Z0 (forget any I might have done before)
    #666=0 (START POINT)
    #667=-20 (INCREMENT TO NEXT PATTERN)
    M98 P1000 L5
    G52 X0 (FORGET THE OFFSET)
    etc
    (I WANT TO MANUALLY START PROGRAM HERE and use #666)
    (#666 should be -75 after run from here)
    (Second process using #666)
    etc
    M30
    (--- end of program)
    (subroutines)
    O
    1000 Code being repeated
    N333 G52 X#666 (NEW X offset for this pattern)
    etc (the pattern starting at X0 first time, then X-15 ... X-60)
    etc
    #666=#666+#667 (NEXT X OFFSET)
    M99

    This all works and runs to the end correctly.
    The problem I have is that if I wish to run part of the program
    from N333, by moving down through the code window to the start line N333, Hit set line, then run from here, while the program does it's dummy runs it does not loop through the subroutine 5 times, so when the program is ready to start at N333 the value in #666 is only #667. The rapid stepping after hitting run from here does not honor the L5.
    If I know I am going to want to do some intermediate starts, I make a hole heap of inline code with cut and paste.

    Does anybody know how to make this work properly?
    Can you put conditional coding in line in Mach3?
    Super X3. 3600rpm. Sheridan 6"x24" Lathe + more. Three ways to fix things: The right way, the other way, and maybe your way, which is possibly a faster wrong way.

  14. #14
    Join Date
    Aug 2009
    Posts
    146
    Ok, guys, here is a problem to resolve. When I use M98 to execute a pattern L5 times, it executes the first one with no problem, when it returns to the top to execute the second thru 5th iteration, it slows down to a crawl contrary to the speed settings that I so carefully set. Would anyone have any ideas why this is happening?
    Larry
    W4LML 20mtrs

  15. #15
    Join Date
    Feb 2008
    Posts
    586
    Perhaps you've used an "inches/mm per minute" code near the end of the repeated section, and forgotten to re-instate "inches/mm per revolution" at the beginning of the code. .005 inches per minute is darn slow.

Similar Threads

  1. g code for repeat the previous move
    By woffler in forum G-Code Programing
    Replies: 6
    Last Post: 03-27-2008, 04:07 AM
  2. How Do I Repeat?
    By TZ250 in forum Dolphin CAD/CAM
    Replies: 2
    Last Post: 03-04-2008, 12:11 PM
  3. Repeat command on TL-1?
    By Haeusser in forum Haas Lathes
    Replies: 4
    Last Post: 07-31-2007, 11:31 PM
  4. Need help on G75.1 pattern repeat
    By wayne mitchell in forum G-Code Programing
    Replies: 1
    Last Post: 03-16-2005, 09:49 PM
  5. Repeat g-code with y offset
    By tpaulson in forum G-Code Programing
    Replies: 19
    Last Post: 11-29-2004, 08:36 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
  •