Welcome! Log In Create A New Profile

Advanced

Yet another optimizer

Posted by Anonymous User 
Anonymous User
Yet another optimizer
May 10, 2011 04:01PM
I have written another optimizer... Jay's opti_qt works, but only on moves. Mine adds lots of path analysis and reorders and reverses cuts as needed. On the file that caused me to write my own, the raw file cut in 18 minutes. opti_qt cut about 3 minutes off that. Mine does it in under five minutes! It also works on dtill files.

I need some test files to torture it with... Anybody out there have some worthy examples? I would also like a couple of rather large ones to try it on. Execution timeston this sort of optimizer tend to go up order n squared. On a 2 Ghz box it optimizes a 6500 segment file in 0.2 seconds. On a 50,000 segment file it takes around 30 seconds.


(edited to fix a LOT of typos)



Edited 1 time(s). Last edit at 05/12/2011 09:48AM by texaspyro.
Anonymous User
Re: Yet another optimizer
May 11, 2011 06:08AM
Where is the download?
Anonymous User
Re: Yet another optimizer
May 11, 2011 08:12AM
Not yet ready for prime time...
Anonymous User
Re: Yet another optimizer
May 11, 2011 11:24AM
Ok, well as the co-developer of opti, I can help test it. You could also post before and after plots of the gcode. Did you start with Opti and add your own methods? Is that why you call it qt_opt? Also, Opti is extremely fast (sub second) but what really matters is the job time. You have my attention with your claim of 18 minutes to 3 minutes.

-Jay
Anonymous User
Re: Yet another optimizer
May 11, 2011 09:08PM
Well, the program is just call OPT. Written in plain C. Command line interface (or you can drop a file on it under Windows).

It was written from scratch. I did not look ar the OPTI (or any other) code (I thought that your program was called OPTI_QT or QT_OPTI).

I did some more testing of execution time versus program size. Goes up around N squared (double the size and it takes 4 times as long). A 60,000 cut file took 30 seconds to optimize on a 2 GHz. The improvement that my file saw was a reduction from 15 minutes to 5 minutes (a factor of 3 times, not down to 3 minutes). The program has no realistic limit on file size (other than hard coded for max 100,000 paths... easily changeable)

Attached are a pair of sample files. This one reduced the run time around 50%. It is a combined etch and mill file. Depending upon your Mach3, you may have some arc endpoint/radius errors. Runs fine on my laptop, croaks on a desktop running the exact same Mach3 config. Raw pcb-gcode output or optimized files both croak on the desktop. One option the program has is the ability to convert I,J,K arcs to Radius arcs that never have that problem. I need to fix the radius fixup code for arcs over 180 degrees.
Attachments:
open | download - mr16f.nc (29.5 KB)
open | download - mr16f_opt.nc (27.2 KB)
Anonymous User
Re: Yet another optimizer
May 12, 2011 01:21AM
I figured out my arc problems with Mach3. The mill profile on the desktop machine was from a different version of Mach3. It had the I,J,K values set for absolute mode and pcb-gcode uses relative mode. My mill is driven from the laptop. The desktop machine was used for writing the optimizer and has Mach3 on it for displaying test files. Also, I had a glitch in the part of my code that reverses the direction that arcs are cut. I had the code written so that it was (sort of) working around the IJK screw-up. When I fixed that, I had to make my arc code work the way it I originally thought it should have.
Anonymous User
Re: Yet another optimizer
May 13, 2011 06:20AM
Here is what I saw when I opened your files in NcPLot. I then ran the first one through Opti_qt. The original tool was command line only and called Opti. But by request I made it GUI using the QT library. If your's is better I'd like to use yours smiling smiley However, the GSuite I tried modified the paths too, and I didn't always get what I wanted so I went back to Opti which as you say just reordered the paths to reduce air moves.

As a better test, increase your isolations and decrease your tool size so there are multiple paths to optimize. For me this is more realistic.

-Jay
Attachments:
open | download - mr16f.png (12.8 KB)
open | download - mr16f_opt.png (9.4 KB)
open | download - mr16f_opt_qt.png (10.5 KB)
Anonymous User
Re: Yet another optimizer
May 14, 2011 11:50AM
That particular board was designed to be routed, milled, and drilled with a single 0.034" end mill, so one pass was used.

I have fixed the arc issues in the code...

I am currently modifying the program to be more generic... not just specific to pcb-gcode. It now has a pretty comprehensive gcode parser and handles lots more gcode features/word. It can also do things like convert the output to metric/inches, scale axes, handle relative/absolute movement. You can combine the etch/drill/mill for a side into one file if you want (if your etch/mill bits are different, make sure the mill file has its own tool number).
Anonymous User
Re: Yet another optimizer
May 14, 2011 01:26PM
BTW, when I was comparing the output text of the original/optimized path lengths between the two programs, I noticed that opti_qt does not include the length of the z-axis moves(tool raises) in the move distance. It only includes the x-y move distances. I break out the results into rapids/cuts/plunges.
Anonymous User
Re: Yet another optimizer
May 24, 2011 11:21AM
Hi i am new Here in this Forum
I'm From Germany
But i write most of the Simple G-code generators for EMC2 also involved in the cam of heekscad

Question why aren't you going to use the Tkinter Open GUI from Python this is most come to a lot of people
and it is used on all known platforms including Palm and Ipot so everyone can ad Lines to the final result !
?
if the sourcecode of your C or QT is open and puplic then it coudt also be rund under Linux mac and so on !
Anonymous User
Re: Yet another optimizer
May 25, 2011 10:44PM
The program that I have written/am still writing is written in straight C. It will compile and run on any system with a 32 bit C compiler. It has absolutely no need of a GUI. Also, I don't write in PYTHON, PERL, or any of the other 1,000,000,000,001 sucky languages that computer science students have foisted off on a naive world as a good idea.


The program has morphed into something rather more sophisto than a simple pcb-gcode optimizer. It now parses the full Mach3 and EMC languages. It reads in a file, unrolls all the subroutines, conditionals, and loops;. converts all coordinates to absolute (in metric or english), optimizes the paths in three dimensions (but the output probably only cuts properly for router type operations if you let it re-order the cuts), and outputs a "compiled" optimized cut file (pretty-formatted with comments, etc) . The output should be compatible with any CNC controller program since it converts many of the input language features to a very basic set of gcode operations.


I have also optimized the optimizer... it does a 100,000 cut file in under 30 seconds.
Anonymous User
Re: Yet another optimizer
June 02, 2011 01:02AM
and where is it ?
please do a HOWTO for people with no C Experience i'm on Ubuntu
Anonymous User
Re: Yet another optimizer
June 02, 2011 01:12AM
Thanks and understand that!
it rely reads as a perfect tool WHERE is ist ?
i need rely a good optimizer for bottem text milling got more air lines then milling. confused smiley
Attachments:
open | download - text_bottem_mill.png (204.1 KB)
Anonymous User
Re: Yet another optimizer
June 02, 2011 12:28PM
The program is not yet ready for prime time... It is now up to around 6000 lines of code and needs some finishing. I have added support for reading almost all of the EMC2 and Mach3 language features (not just pcb-gcode output).

The input language is converted to a small subset of gcode words that should be usable with either language. All moves and cuts are converted to absolute coordinates (in either metric or inches), offsets and scaling are applied during input and removed from the output, subroutines and loops are unrolled into inline code, etc

There is a lot of support for various 3D milling features of gcode, but it is probably not a good idea to let it reorder operations if the input is not for a flat router. Otherwise it might try to do cuts on the interior of the material before it has cut the exterior.

It works particularly well on drill and mill files, with over 35% reductions in machine time seen. The (rather atypical) file that got me started on the project is reduced by over 70%! (some of that is the ability to fix a bug in pcb-gcode output that cuts arcs at the plunge rate and not the cut rate).
Anonymous User
Re: Yet another optimizer
June 08, 2011 07:54PM
Well, the program is up to over 7500 lines long. It has basically turned into an optimizing gcode compiler that can handle pretty much the full Mach3 and EMC gcode dialects for input and spit out an optimized gcode file that is stripped of much of the gcode idiosyncrasies and idiocies.

It's still not ready for release, but if anybody has any gcode files (not just pcb-gcode output) that they would like to try, PM me...
Anonymous User
Re: Yet another optimizer
June 11, 2011 10:29PM
I have the program accepting pretty much all of the EMC gocde language including subroutines and conditional statements. It even handles recursion, local /global variables, etc properly.

It can compile the EMC flowsnake.ngc program and spit out code that Mach3 can handle. flowsnake is a rather small (40 line, 1Kb) but brutal program that generates a fractal like curve using recursive subroutine calls. The output is over 3000 lines/100Kb of gcode.

It does a very good job of ringing out any defects in your language parser or subroutine/conditional/variable implementation. If everyhing isn't working just right, you will know it.



Edited 1 time(s). Last edit at 06/11/2011 10:30PM by texaspyro.
Attachments:
open | download - snake.nc (1 KB)
open | download - snake_opt.nc (102.6 KB)
Anonymous User
Re: Yet another optimizer
June 14, 2011 06:47PM
Wel, it now can handle the Fanuc MacroB language... mostly. It does not specifically recognize what all the #xxxx parameters are used for. Seems like every single Fanuc controller is different.
Anonymous User
Re: Yet another optimizer
June 14, 2011 08:59PM
Since you have moved away from PCBGcode, might I suggest you open a thread on cnczone where you will get a lot more exposure and input.

Or you may like the quietness of this forum smiling smiley

-Jay
Anonymous User
Re: Yet another optimizer
June 16, 2011 07:38PM
At this stage, quiet is good... it was/is only intended as a pcb-gcode optimizer, but it has evolved a quite a bit beyond that (hint, if you want to learn about gcode/CNC programming, write a generic.universal gcode parser/optimizer and feed it anything and everything you can find... once you successfully do that, you will have a tough time finding anybody that can answer your remaining questions... also you head will REALLY ache and your noggin' will throb mecilessly).

It can handle pretty much anything you can throw at it, but if you are doing nasty 3D stuff, you might want to turn off the path optimizations. Also, I don't really handle the starting/ending/rapid Z axis coordinates well. I need to pay quite a bit more attention to that. Until then, best to leave it to pcb-gcode/router stuff.
Anonymous User
Re: Yet another optimizer
July 25, 2011 07:03AM
Hi,

i'm also interested in such an path optimizer because the exported paths from pcb-gcode are very unorganized.
So what is the status of your optimizer? smiling smiley

Ciao,
Rainer
Anonymous User
Re: Yet another optimizer
August 04, 2011 05:58AM
Sorry for the delay in responding... I have been distracted from the project by another project that pays real money... The optimizer is still being worked on. My pcb mill is STILL waiting for some parts and I have not been able to test any of the pcb-gcode stuff that most of the people here are interested in. Most of the current work has been adding support for handling the languages of various real CNC machines (Fanuc, Mazak, Haas, Fadal, Fagor, Mitsubishi, Okuma, etc) It turns out the the 2D router/pcb-gcode optimization code is a rather small part of the 17,000+ lines of code it is currently at.
Anonymous User
Re: Yet another optimizer
October 17, 2012 05:23PM
What happened to this project? Is the optimizer available to use?
Sorry, only registered users may post in this forum.

Click here to login