Gcode optimisation

Stuck with a problem in your code? Seek help here.

Gcode optimisation

Postby Mjolinor » January 25th, 2016, 8:54 am

So I have a router for making PCBs. All works well but everything I have tried that makes Gcode makes cuts that are not necessary.

Attached is an example file showing the cuts in blue. There are eight paths in this file and I have written a C programme to make eight files, one for each path.

It is a simple file, a 2 pin header on the right and a 4 pin header on the left, two of the four pins are connected together, one of the 4 pin goes to the two pin and there is a ground connection on each header.

Of the eight paths the long straight one is totally unnecessary and the "C" shaped one on the left would be unnecessary if a small cut were placed between pins two and three of the four pin header.

As well as that on the thermal relief it is not necessary to cut the shape,as this is a router removing copper it is only necessary to pass once with an L shape instead or closing the cut with a loop.

So, human brain V computer. I can easily see from the picture what can be done to remove what is not needed but no way can I work out how to search the coordinate lists in the gcode to give the same effect.

Any pointers?
Attachments
1.jpg
Mjolinor
 
Posts: 228
Joined: July 30th, 2013, 10:05 am
Location: Burnley, UK

Re: Gcode optimisation

Postby bandersnatch » January 28th, 2016, 3:12 pm

Hi,

I hope you in Burnley have not been too heavily affected by the flooding in Northen England.

How about a picture of your router/setup?
I am also keen to use this method for quick PCB prototyping & would be interested in your experience/advice.

Your optimisation problems/ideas are a major research topic for many large companies and effective tools/algorithms are
correspondingly expensive/hard to find/jealously protected (!)

The basic problem is how to map a simple list of points into the more abstract (and deceptively complex) concept of
the "best path". This is related to the famous "travelling salesman" problem & is usually solved in a heuristic manner
rather than using a fixed algorithm. This approach can yield useful results but one cannot guarantee that the best
possible result has been found.

This field of research is huge and can lead you into a mind-boggling world of abstract algebra. Intellectually interesting
if you like playing with Rubik's cube (more relevant than you might think) but not really immediately useful to you.

I suggest you take the Engineering approach (near-enough is good enough)
rather than the Scientific approach (find the absolute truth) and make a compromise between
manual optimisation and wear on your milling bits...

One simple approach is to write a program that does the following:
1/ Parse the Gcode text file and visualize the path followed by the router as a line graphic on the screen, +
with large dots/labels displayed at each Gcode point in the original file
2/ Use the awesome abstract analysis capabilities of the human brain to identify & improve inefficient paths
- Being able to rearrange the sequence using drag&drop would be really kool feature...
3/ Create a new Gcode text file & go to step 1
Do this until you get bored or things are good enough...

I wouldn't use C for this but rather a good high-level IDE environment.
I build systems in many different languages/operating systems depending on the requirements.
Unix is dear to my heart (since 1980..oh brother...so long ago!!)
but I always try to use the best tool for the job, regardless of the origins/politics of the evil empire responsible..
At the risk of getting flamed I gotta say that Visual Basic/Visual C# is awesomely useful for
rapid prototyping of applications that have non-trivial IDEs.
You can quickly & brainlessly build what you need without wasting time on the details.
You also have a HUGE base of existing code for every conceivable task, which saves you enormous amounts of time
Yeah, yeah no real object-orientation, Windows-based blah, blah... & if you are undisciplined then
the result can quickly become a horrible mess but who cares?
The aim is to play with/develop an idea not build "the next big thing" for the masses..
Over the last 5 years I have built a successful commercial system with 22000 lines of Java code using Eclipse & WindowBuilder
but still use VB/Visual Studio for fast prototyping/playing with ideas..

I hope this gives you a few ideas
STFB
bandersnatch
 
Posts: 148
Joined: September 17th, 2014, 12:06 pm


Return to Help Me! Software

Who is online

Users browsing this forum: No registered users and 2 guests