Machsupport Forum

G-Code, CAD, and CAM => G-Code, CAD, and CAM discussions => Topic started by: subzero on April 04, 2008, 11:31:13 AM

Title: Simple G-Code Loop Question
Post by: subzero on April 04, 2008, 11:31:13 AM
With Mach3, i have a problem with looping. here it's :

G00 X20
M98 P1
L 10
G00   Z-2.5
G00   Y29
G00   X8
G00   Z-5
G00   Y0
G00   Z0
G00   X0
M99
M30

It gaves loop errors, and it loops forever...

In fact all i want is to proceed with 10 loops for the following basic g-code :

G00   X20
---- loop starts here ----
G00   Z-2.5
G00   Y29
G00   X8
G00   Z-5
G00   Y0
G00   Z0
G00   X0
---- loop ends here ----

Thanks for any help...
Title: Re: Simple G-Code Loop Question
Post by: Graham Waterworth on April 04, 2008, 12:10:38 PM
You could do it like this :-

O0001
G00   X20
M98 P2 L10 (call sub 10 times)
M30

O0002
G00   Z-2.5
G00   Y29
G00   X8
G00   Z-5
G00   Y0
G00   Z0
G00   X0
M99

Graham.
Title: Re: Simple G-Code Loop Question
Post by: subzero on April 21, 2008, 09:57:43 AM
Thanks Graham,

It worked, in fact i found similar gcode from forum then both are successfull, the thing now i'm looking for is a "counter" for processing part number.

Regards
Title: Re: Simple G-Code Loop Question
Post by: vmax549 on April 21, 2008, 02:01:36 PM
IF you are looking for a loop counter then MACH has one there is a hidden DRO that reports the number of loops processed. I will try to find the DRO number for you, then you can place the dro on the screen and have a counter.

NOTE:  The DRO# is 222     It is basically a nest counter. It sees the total loop number then subtracts one each pass.  You may have to add a G04p0 to the last line of the sub before the g99 call to keep the dro current to the loop.

(;-) TP