PDA

View Full Version : Tile / Repeat G-Code?



Tenson
23-01-2013, 12:11 PM
Hi,

I have made some G-Code and tested it and tuned it all as I want. Now I'd like to produce it numerous times across a large sheet of material. Is there a way to 'tile' the G-Code so I don't have to program it all again many times over?

I guess there must be a way to copy the G-code with all the co-ordinates off-set by a fixed amount?

I hope so!

motoxy
23-01-2013, 12:53 PM
I would think that that would involve a loop to change an offset. Check out this link it may help

G-Code Tutorial: Conditions and Looping (http://www.cnccookbook.com/CCCNCGCodeIFGOTOWHEN.htm)

Bruce

Jonathan
23-01-2013, 01:18 PM
If you use mach 3 I think one of the built-in wizards does what you need.

Tenson
23-01-2013, 01:24 PM
Thanks Jonathan. Any help on which wizard it is? I've never used any wizards before.

Swarfing
23-01-2013, 10:35 PM
Check out nesting

John S
24-01-2013, 12:23 AM
Do it properly and use G54 work off sets.

read this.

Cnc Programming Handbook: A Comprehensive Guide to Practical Cnc Programming - Peter Smid - Google Books (http://books.google.co.uk/books?id=JNnQ8r5merMC&pg=PA124&lpg=PA124&dq=g54+0ffset&source=bl&ots=PYRIRT0PvL&sig=vGyWpYsWly8mDyp-1eWZtGO740s&hl=en&sa=X&ei=SXAAUfmbNtLK0AXgr4CYDQ&ved=0CFEQ6AEwAw#v=onepage&q=g54%200ffset&f=false)

Tenson
24-01-2013, 12:41 AM
Wow, the whole book is online for free? :topsy_turvy:

D.C.
24-01-2013, 02:23 AM
Wow, the whole book is online for free? :topsy_turvy:

Nope that is just a preview.

JAZZCNC
24-01-2013, 02:51 AM
Do it properly and use G54 work off sets.

read this.

Cnc Programming Handbook: A Comprehensive Guide to Practical Cnc Programming - Peter Smid - Google Books (http://books.google.co.uk/books?id=JNnQ8r5merMC&pg=PA124&lpg=PA124&dq=g54+0ffset&source=bl&ots=PYRIRT0PvL&sig=vGyWpYsWly8mDyp-1eWZtGO740s&hl=en&sa=X&ei=SXAAUfmbNtLK0AXgr4CYDQ&ved=0CFEQ6AEwAw#v=onepage&q=g54%200ffset&f=false)

Work offsets will still need the G-Code repeating but with the relevant work offset added. Workoff sets are ok if just few parts needed but not ideal if for instance you wanted say the Word "Jazz" cutting 100 times. There are better ways.

One better way to do it if just a few is to put your main code in a subroutine then call the subroutine using M98 p#. You can then either use incremental moves for the offset and recall the subroutine or like John says use Workoff sets in the main program and then call the subroutine like this. (also see attached file for G91 incremental move way which will draw 8 squares 50mm apart using same code)

G21 (metric units)
G54 (Default work offset)
G0 z10 (move to position)
x0y0
(Main program will write whats in subroutine at each Work offset location)
M98 p1000 (Call subroutine)
G55 (Work offset 1 )
M98 p1000 (Call subroutine)
G56 (Work offset 2 )
M98 p1000 (Call subroutine)

M30 ( End and rewind)

o1000 (Sub routine)
Pretend this is G-code and writes
G1 "John S is an Old Twat . .LMAO"
M99 (End sub)

Even better way is to put the G-code you want cut in a Macro file and using parameters for the start location which you then feed from the main program. This is getting a bit more involved so won't go into it but just search parameteric G-code amd macro.
Look here G-Code Tutorial: Parameterized Programming

(http://www.cnccookbook.com/CCCNCGCodeParameterized.htm)
(http://www.cnccookbook.com/CCCNCGCodeParameterized.htm)

JAZZCNC
24-01-2013, 10:33 AM
Here the same G-code for the Squares but using parametric G-code.

Notice how it's much cleaner code and even thou theres twice has many squares there's less lines of code.
This is made possible by the fact the subroutine is called 4 times with the (L) parameter and the use of a variable we define has #1 at the top which we then use at the end of the SUB (G91 x#1) to offset the next square on the X axis. We actually didn't need the variable and could just used a G91 150 incremental move but you'll see why we did below.

Now here's the beauty of Parametric g-code. If you look carefully you'll see that the first row is offset in X direction by 10mm but the proceeding rows are not.?
This is because at line n50 we moved x10 but when we return from the sub and reposition to start of next row with line n70 it used the value in #2 variable which is 0. So each time we return from the proceeding subs we return to X0 and it repeats.
We don't want this and if this was normal code it would say X0 on every line it now says X#2 and we'd have to edit every line. Using variables we don't need to and can just edit #2 variable and hey presto every line gets changed. .:yahoo:

Now going back to the Sub you should see why we used the variable.? . . .Yep by just changing the #1 variable we can instantly change the offset for all squares.:thumsup:
Also by just repeating 2 lines (m98 p1000 L4) & ( g0 x#2 ) we can add 4 more squares in another row.!

Tenson
24-01-2013, 04:25 PM
Blimey that got my head twisted Jazz! I'll have to read the links first I think. Thanks though, I'm sure it will be helpful when I understand it.

I don't suppose anyone knows if there is a simple button to do this in Dolphin? :)

JAZZCNC
24-01-2013, 07:06 PM
I don't suppose anyone knows if there is a simple button to do this in Dolphin? :)

What exactly are you wanting to do.?

Like someone mentioned nesting may be your easiest answer if you want simple.? Thou often nesting comes has an extra option along requiring more Cash.!!

If for instance you just want 4 or 6 parts out of one sheet then do like John suggested and use work offsets. It's very easy to do just set your workoff sets in Mach then either copy code 4 times replacing G54 in each with a new offset. Or better still just put the code in subroutine then after each return put the new work offset.
Something like this but you'll after set the work offsets in Mach's offset list first.

G21 G40 G49 G54 G80 G90 G91.1

m98 p1000
g55
m98 p1000
g56
m98 p1000
g57
m98 p1000
m30

o1000 (subroutine)
Your G-code
m99

John S
24-01-2013, 07:43 PM
o1000 (Sub routine)
Pretend this is G-code and writes
G1 "John S is an Old Twat . .LMAO"
M99 (End sub)





I was going to say, less of the old, but I am old, I can't say less of the twat so I'll just have to chalk this one up to experience..............

JAZZCNC
24-01-2013, 08:51 PM
I was going to say, less of the old, but I am old, I can't say less of the twat so I'll just have to chalk this one up to experience..............

You know your my Hero Old Man and taking the Piss out of the ultimate piss taker is meant with great respect. .:applause:

John S
25-01-2013, 12:00 AM
I don't suppose anyone knows if there is a simple button to do this in Dolphin? :)

Yup.

http://www.stevenson-engineers.co.uk/files/dolphin%20repeat.jpg

Use the repeat command, 5th up from the bottom on the left, three diamonds, looks like a Renault badge but unlike a Renault it works.

Tenson
25-01-2013, 12:38 PM
Brilliant John, thank you!

I realise it's still worth learning about G54 offsets and stuff though.

JAZZCNC
25-01-2013, 01:30 PM
Never used Dolphin but Isn't that just to repeat multiple parts in a grid pattern not actually nest one part into piece of material many times.?
Could just use Copy & paste and rotate to do that.!!

Tenson
25-01-2013, 01:52 PM
If I did copy and paste, it would just cut the part in the same place, wouldn't it? Anyway the part is rectangle so I've no problem with cutting on a grid.

JAZZCNC
25-01-2013, 02:37 PM
If I did copy and paste, it would just cut the part in the same place, wouldn't it? Anyway the part is rectangle so I've no problem with cutting on a grid.

No it would cut were ever you paste it down. Most CAD/CAM programs give you as way to copy and layout multiple copies of the same part or bits of it. Bobcad calls it translate others will be different names.!
True nesting you can select multiple parts tell it how many of each and the separation required then the nesting function will either lay them out in a grid or if odd shaped rotate to make best use of the material.
This is great for instance when cutting say different Letters or numbers out of one sheet has each letter will be different shape a grid pattern would be very wasteful. The nesting function will twist and place them to extract the most out the sheet and will even place smaller items inside the waste of another part IE: e from the centre of O.!!
Also very handy if your unsure how many parts you'll get out of sheet of material because it will tell you exactly.!! This is why often nesting is an upgrade or only in the Pro version.

How many do you want to cut.? Out of what size material.?

Has an exercise if you don't mind posting the G-code I'll see if I can make parametric code so you enter required number of pieces and material size along with part separation and the code does the rest.?

HankMcSpank
25-01-2013, 03:54 PM
I'm way too lazy to learn g-code in any great detail, so to do multiple parts, I use cambam's nesting feature which makes it piece of p15s to do multiple copies (& saves many a tool change too)

Tenson
08-02-2013, 09:52 PM
Would someone help me, please! (Mr. Hobnob?) I'm trying to use the repeat command in Dolphin CAM and it doesn't seem to do anything.

In the help file it says it needs a start command and an end command. I assume end is a stop command. How do I do a start command? M6? Will it show the repeated parts in the CAM window or will it just issue a repeat G-Code command or something? I have uploaded the Dolphin file I wanted repeated in a 2x2 grid (4 parts) here - File Here (http://www.audiosmile.com/upload-bits/8mm-2-toberepeat.cnc)

Help appreciated, thanks!

JAZZCNC
10-02-2013, 05:08 PM
Would someone help me, please! (Mr. Hobnob?) I'm trying to use the repeat command in Dolphin CAM and it doesn't seem to do anything.

In the help file it says it needs a start command and an end command. I assume end is a stop command. How do I do a start command? M6? Will it show the repeated parts in the CAM window or will it just issue a repeat G-Code command or something? I have uploaded the Dolphin file I wanted repeated in a 2x2 grid (4 parts) here - File Here (http://www.audiosmile.com/upload-bits/8mm-2-toberepeat.cnc)

Help appreciated, thanks!

That files corrupted.!! (Edit: Sorry see it's Dolphin file not G-code. . Doh)

M6 is tool change command. Won't work.!!

What exactly are you wanting to do repeat the Entire G-code program in the same place or at different locations on the bed.?

There isn't a dedicated G or M code to repeat entire program but there is way to do it using Sub programs M98/M99. This could be what Dolphin is referring to has M98 calls the sub program and M99 Ends it.

It's common for a good Cam package to use Sub calls for repetitive procedures like holes etc has it cuts down on the number of lines and file size. This same Sub program technique can be used to call the entire bulk of the program but still leave the initialisation code. Chances are this is what Dolphin does with the repeat option.?

Creating a Sub-Program is easy to do by simple putting a label NUMBER starting with O (not zero) IE: O200 before the code you want repeating then at the end of the code has the very last command put M99 to define it's end point.

This creates your Sub program which is now no longer part of the MAIN program but is completely separate set of code which we can call either 1 time or 9999 times using the L address option thats parameter of the M98 call. It can also be placed at any point in the code and doesn't have to be in sequence.

To use we include the M98 command in our MAIN program followed by the label number for the Sub program using P parameter IE: P200 then we tell it how many times we want it repeated using the parameter L IE: L4.

So the entire thing would look like this M98 P200 L4 . . . .This will repeat the code in Sub-program O200 4 x times before returning to the next line after the M98 call where it then continues on thru the remaining MAIN code.

The entire program to repeat same code 4 times would look something like this.

N01 G21 G17 G40 G80 (Initialization)
N02 G90 G0 G54 X10 Y10 S10000 M03 T01 ( Absolute coords and start location & 10K RPM, Start spindle, tool 1)
N03 M6 (Tool change)
N04 M98 P200 L4 (Call Sub Program O200 4 times)
N05 G28 Z M5 ( Z Home & spindle stop)
N06 G28 X Y ( X & Y Home)
N07 M30 ( End program & rewind code)

O200 (Sub program with code to repeat)
N100 (Code)
N110 (Code)
N120 (Code)
N120 M99 (End of Sub program return to N05)

If you wanted to repeat the same code but at different places then it would be easy to do using Work offsets and call the Sub program after each offset is applied IE

N01 G21 G17 G40 G80 (Initialization)
N02 G90 G0 G54 X10 Y10 S10000 M03 T01 ( Absolute coords and start location & 10K RPM, Start spindle, tool 1)
N03 M6 (Tool change)
N04 G55 M98 P200 ( applied Work offset 55 call Sub x1 no L value defaults to 1 call)
N05 G56 M98 P200 ( applied Work offset 56 )
N06 G57 M98 P200 ( applied Work offset 57 )
N07 G28 Z M5 ( Z Home & spindle stop)
N08 G28 X Y ( X & Y Home)
N09 M30 ( End program & rewind code)

O200 (Sub program with code to repeat)
N100 (Code)
N110 (Code)
N120 (Code)
N120 M99 (End of Sub program return to N05)

Hope this helps.

Tenson
11-02-2013, 11:43 PM
Thanks Jazz, to be honest I can't follow that very easily on a Monday night after a few beers. I'm sure it will help others when they search though so thanks for taking the time.

I did manage to get the Dolphin PartMaster repeat option to work just now though! For those who might need to know, you start the sequence with the repeat menu option and the radio button set to 'start sequence and enter your offsets. Then you need to go to the end point of what you want to repeat and do the exact same repeat menu option but this time switch the radio button to 'end sequence'. Ignore the other settings this time since it is the end of the sequence the offsets don't need to be set. This probably seems really obvious having done it, but for some reason I wasn't getting it, I think mostly because I didn't expect to use the same menu button to mark the start and one to mark the end.

http://i608.photobucket.com/albums/tt169/tenson_uk/Dolphin-Repeat.jpg

JAZZCNC
12-02-2013, 12:12 AM
Ok but thats not really repeat G-code it's cutting 4 Identical parts in the same Gcode program. It's Repeat tool-paths really.!
All your actually doing is copying the same tool paths in 4 different locations but in the same Work Offset (G54). Creating one large G-code program with the same tool paths calculated at different locations.

Don't really matter in this day n age of modern controls and large PC memory but this would create a massive file size compared to repeating g-code like I mentioned. . . BUT. . It's doing what you want and that's all that really matters..:yahoo:

John S
12-02-2013, 01:54 AM
Would someone help me, please! (Mr. Hobnob?) I'm trying to use the repeat command in Dolphin CAM and it doesn't seem to do anything.

In the help file it says it needs a start command and an end command. I assume end is a stop command. How do I do a start command? M6? Will it show the repeated parts in the CAM window or will it just issue a repeat G-Code command or something? I have uploaded the Dolphin file I wanted repeated in a 2x2 grid (4 parts) here - File Here (http://www.audiosmile.com/upload-bits/8mm-2-toberepeat.cnc)

Help appreciated, thanks!

Just use the code you have and bracket it between the repeat commands.
File attached, change the .zip to .cnc don't unzip it just rename it.

8202

On the first line you see the repeat and the start radio box is ticked 2 x 2 selected and x is 120mm so it sits to the right and Y is -20 so it sits underneath.

The end repeat just needs to have the end radio box selected, doesn't matter about filling the boxes in as it's just an end command.

John S
13-02-2013, 02:29 AM
Bump
Tensing did you miss this ?

Ulsterman
23-09-2013, 04:29 AM
Learn to use Do /while on Fanuc controls
This will help a lot with repeat cycles

O1000(Drill Holes 2mm deep 5 mm apart*10)
#501=10 (number of holes )
Goo G90 G54 p1 Xo Yo Z50 Mo3 S1000 G43 H1
G00 Z2.0
()
While [#501 GT 0]Do 1
Go1 G91 Z-4.0 F100.0
Goo z4.0
G00 x-5.0
#501=[#501-1]
END 1


Commands to Home

JAZZCNC
23-09-2013, 09:17 PM
Learn to use Do /while on Fanuc controls
This will help a lot with repeat cycles

O1000(Drill Holes 2mm deep 5 mm apart*10)
#501=10 (number of holes )
Goo G90 G54 p1 Xo Yo Z50 Mo3 S1000 G43 H1
G00 Z2.0
()
While [#501 GT 0]Do 1
Go1 G91 Z-4.0 F100.0
Goo z4.0
G00 x-5.0
#501=[#501-1]
END 1


Commands to Home

Bit late this Ulster man but anyway think Tenson use's Mach3 control which doesn't support conditional code like Do/while in the main G-code file so needs to be done thru macro's. And think he was meaning more for the CAD/CAM software to post process it in main G-code file has most folks on here don't get into running macro's and sub routines etc.