## G-Code optimization

This forum is for requests and queries about machine tool support for Vectric Products
Bertho
Vectric Apprentice
Posts: 54
Joined: Tue Jan 27, 2009 1:19 am

### G-Code optimization

Now that I got the text editing learning curve behind me I am wondering if there are any options to generate more efficient G-Code.
The most obvious issue is happening when multiple passes are done in a pocket.
As the simplest example I am milling a hole through a workpiece.
The resultant code generated:

Move to x/y & safe height
plunge to pass-1 depth
cut a circle for the hole and return to start x/y
go to safe height
plunge to previous depth plus additional pass depth
cut a circle for the hole and return to start x/y
go to safe height
plunge to previous depth plus additional pass depth
cut a circle for the hole and return to start x/y
go to safe height
plunge to previous depth plus additional pass depth
and so on until finally through the material

The "go to safe height & plunge to previous depth" takes a very long time with slow feed on delicate mills

I manually hunt for the Go to safe height and remove them but it is time-consuming and can be a disaster if I remove the wrong Go to safe Height command.

Is there any option or trick to do this automatically?

I even considered writing a little programs that would hunt though the code to optimize it.
TIA Bertho

gravirozo
Vectric Wizard
Posts: 1978
Joined: Sat Jan 10, 2009 12:38 am

### Re: G-Code optimization

hello berto

the safe height will reamain, as the startpoint not always equal with the endpoint in pocketing... in most case it is different... and in a fragmanted pocket can occur the rapid movement damage the areas where don't need to pocketing...

the solution is simple... in your postprocessor you need to place one line
"G0Z0.1"
the 0.1 value is example.... you find out a safe height.....

+---------------------------------------------------
+ Commands output for rapid moves
+---------------------------------------------------

begin RAPID_MOVE

"G0[X][Y][Z]"
"G0Z0.1" <<<<<<<< here's the right place

+---------------------------------------------------
+ Commands output for the first feed rate move
+---------------------------------------------------

begin FIRST_FEED_MOVE

"G1[X][Y][Z][F]"

for the first rapid movement place an elevation value as you like, and the machine after movement to the startpoint of pocketing with rapid movement will go downward to the plane you define...

this will reduce the time, need for machining, but i think no way to eliminate to raise the tool between passes...
try to imagine an " #8 " shaped pocket.... it might start in one side and ending up in other side, so if tool is not raised but moved with rapidmovement, it will cut trough the material between two side of shape...

if you make a larger series, you need to reverse toolpath and copy after each other, and already you can work without raising tool between passes...

i hope it helps you...
viktor

Bertho
Vectric Apprentice
Posts: 54
Joined: Tue Jan 27, 2009 1:19 am

### Re: G-Code optimization

I think it is actually much simpler than that:

If there is no X-Y movement between the "go to safe height" and the next plunge command
Then remove remove the go to safe height command
Else proceed as normal.

That is what I do manually now.
Bertho

gravirozo
Vectric Wizard
Posts: 1978
Joined: Sat Jan 10, 2009 12:38 am

### Re: G-Code optimization

hello berto...

for all case, the simplest to place a line in the PP....

for series, with DIFFERENT start endpoint the fastest result to reverse each second pass... but it only worth if you have hundred of part...

with SAME start-endpoint your case is working... but since a pocket a countable area, and tool won't goes back on already cleared area, so 99.99 percent the chance for DIFFERENT start-endpoint...

for all invidual situaion.... i think very hard to find working solution...(one for all)

thank you
viktor