Welcome! Log In Create A New Profile

Advanced

Opti - PCB-Gcode Optimizer available here

Posted by Anonymous User 
Anonymous User
Opti - PCB-Gcode Optimizer available here
July 27, 2008 11:29AM
Posting this link to JayC's optimizer:

Quote:
JayC

Use this link [www.mediafire.com]
to open a shared folder of all the files. This way I don't have to
update file links when I add/remove things smiling smiley




Edited 1 time(s). Last edit at 07/31/2008 03:43PM by pcbgcode.
Anonymous User
Update
July 27, 2008 02:34PM
Update: (I know I just can't stop working on this thing) ... there is now a single file (about 3.3MB versus the 5MB beforehand) that no longer requires the DLLs. Ok, now I want some feedback from you guys winking smiley

Jay



Edited 1 time(s). Last edit at 08/01/2008 05:47PM by JayC.
Re: Jay Couture's optimizer is available for download
July 27, 2008 04:55PM
Hello Jay,

feedback for opti_7_27_08_1122:

Old Length : 4266.97 New Length :626.554 saved 85.3162%
Optimizations took: 0.06 seconds.
Done! Please review the generated gcode before proceeding to use the output.

Work fine thumbs up

Francis
Anonymous User
Re: Jay Couture's optimizer is available for download
July 30, 2008 03:29PM
JayC,

could you please put up a dummy statement expalining the foermat of NC file Your optimiser expects.

I am not having any joy with the optimiser and suspect it is due to the differences in NC file format.
Anonymous User
Re: Issues with opti
July 30, 2008 04:38PM
Are you using PCB-Gcode ULP? If so, confirm that your gcode-defaults.h (in the eagle ulp directory) look like this.. If that fails, feel free to attach a copy of your file and I'll have a look.

//
// G codes
//
string RAPID = "G00 ";
string FEED = "G01 ";
string ARC_CW = "G02 ";
string ARC_CCW = "G03 ";
string DWELL = "G04 " + PARAM + "%f" + EOL;


( This gcode generated by F:/Program Files/EAGLE-4.16r2/ulp/pcb-gcode.ulp )
( Copyright 2005 by John Johnson. See readme.txt for licensing terms. )

( This file generated from the board F:/Program Files/EAGLE-4.16r2/projects/Robots/Arm/arm1.brd )
( This file generated  7/29/2008 10:46:25p )

( Settings from pcb-machine.h )
( tool size = 0.0050 )
( z high = 0.2000	z up = 0.0200	z down = -0.0550 )
( drill depth = -0.0700 )
( spindle on time = 0.1000 )
( milling depth = -0.0100 )
( tool change at X1.0000, Y1.0000, Z5.6000 )
( feed rate = 16.0000	feed rate z = 5.0000 )

( Settings from pcb-defaults.h )
( Default isolate = 0.0001 )
( isolate max = 0.0001 )
( isolate step = 0.0060 )
( Generated: top outlines, top drill, bottom outlines,  )
( Unit of measure: inch )


G20

G90
G00 Z0.2000 
G00 X0 Y0
M03
G04 P0.100000
G00 Z0.0200 
G00 X0.5618 Y0.3546 
G01 Z-0.0550 F5.00  
G01 F16.00 
G01 X0.5618 Y0.3546 
G01 X0.5382 Y0.3546 
G01 X0.5214 Y0.3378 
G01 X0.5214 Y0.2622 
G01 X0.5382 Y0.2454 
G01 X0.5618 Y0.2454 
G01 X0.5786 Y0.2622 
G01 X0.5786 Y0.3378 
G01 X0.5618 Y0.3546 
G00 Z0.0200 
G00 X0.6618 Y0.3546 
G01 Z-0.0550 F5.00  
G01 F16.00 
G01 X0.6618 Y0.3546 
G01 X0.6382 Y0.3546 
G01 X0.6214 Y0.3378 
G01 X0.6214 Y0.2622 
G01 X0.6382 Y0.2454 
G01 X0.6618 Y0.2454 
G01 X0.6786 Y0.2622 
G01 X0.6786 Y0.3378 
G01 X0.6618 Y0.3546 
G00 Z0.0200 
G00 X0.5382 Y0.6546 
G01 Z-0.0550 F5.00  
G01 F16.00 
G01 X0.5382 Y0.6546 
G01 X0.5214 Y0.6378 
G01 X0.5214 Y0.5622 
G01 X0.5382 Y0.5454 
G01 X0.5618 Y0.5454 
G01 X0.5786 Y0.5622 
G01 X0.5786 Y0.6378 
G01 X0.5657 Y0.6507 
G01 X0.6544 Y0.7394 
G01 X0.6606 Y0.7456 
G01 X0.6606 Y0.7874 
G01 X0.6635 Y0.7874 
G01 X0.6826 Y0.8065 
G01 X0.6826 Y0.8935 
G01 X0.6635 Y0.9126 
G01 X0.6365 Y0.9126 
G01 X0.6174 Y0.8935 
G01 X0.6174 Y0.8065 
G01 X0.6365 Y0.7874 
G01 X0.6394 Y0.7874 
G01 X0.6394 Y0.7544 
G01 X0.5396 Y0.6546 
G01 X0.5382 Y0.6546 
G00 Z0.0200 
G00 X0.7618 Y0.3546

Jay



Edited 1 time(s). Last edit at 08/01/2008 05:48PM by JayC.
Anonymous User
Note
July 30, 2008 04:39PM
BTW guys, do NOT try the optimizer on the drill files ... I ran a simulation last night and it was not good smiling smiley They are already more or less optimized. It would take some more code to accommodate them special.

Jay



Edited 2 time(s). Last edit at 08/01/2008 05:49PM by JayC.
Anonymous User
Re: Jay Couture's optimizer is available for download
July 31, 2008 08:21AM
Here's the modified code to read in drill files, I got 78% off a board I did

You only need to change where it reads the file, thanks to OO programming the rest of it work unmodified after that smiling smiley

It strips out everything apart from the drill coordinates, so it doesn't keep any separate drill sizes and once it's done you need to look at the output and copy the Z, F, R and P variables to the top line for it to work.

Shouldn't be too hard to add to the GUI program, have a separate area to process drill files

Enjoy.

    vector <path>boardPaths;
    ifstream myfile (drillfile);
    if (myfile.is_open())
    {
        while (! myfile.eof() )
        {
            string TempString;
            point tempPoint;
            path tempPath;
            getline (myfile,TempString);  //get line

            if (TempString.find("G82"winking smiley != string::npos)
            {
                tempPoint = getCoord(TempString); //get coord from string
                tempPath.coord = tempPoint; //save coord
                tempPath.pathList.push_back(TempString); //save string
                boardPaths.push_back(tempPath);
            }

        }
    }
    myfile.close();
Anonymous User
Re: new code for drilling
July 31, 2008 02:07PM
Good deal. I'll get to work adding this code. Thanks Daniel!

Jay



Edited 1 time(s). Last edit at 08/01/2008 05:49PM by JayC.
Anonymous User
Re: Jay Couture's optimizer is available for download
July 31, 2008 02:09PM
John, any way to change the title of this thread. It's not my optimizer ... it's Daniel's. I'm only a contributor. Maybe just call it "Opti - PCB-Gcode Optimizer available here"
Anonymous User
Re: Jay Couture's optimizer is available for download
July 31, 2008 04:08PM
Jay,

I am not using Eagle path to G code.
I am generating G code from gerber .
Here is a sample g code file which works on EMC2 machine but is not being recognised as valid gcode file by the optimiser.


G00 Z3
G00X238.13650Y94.12000
G01Z-0.035F50
F90G01X238.13650Y205.88000
G02X239.20000Y206.94350I1.06350J0.00000
G01X340.80000Y206.94350
G02X341.86350Y205.88000I0.00000J-1.06350
G01X341.86350Y94.12000
G02X340.80000Y93.05650I-1.06350J0.00000
G01X239.20000Y93.05650
G02X238.13650Y94.12000I0.00000J1.06350
G00 Z3
G00X239.20000Y93.05650
M30



This is the kind of code I am working with. Please comment on compatibility with your algorithm.


Typically the files tend to be anywhere from a few lines such as this example to tens of thousands of lines.

How does your software handle stack issues and swap memory?
Anonymous User
Re: Non PCB-gcode differences
August 01, 2008 06:45AM
Well, I can make a modification to my code, or you can modify your code ... take your pick smiling smiley

All you need to do is add spaces between the different parts of the command G00 X.... Y.....
(note: all you need to change are the G00X...Y... lines)
or

I can add a condition to look for no space. I can do the latter no problem, it'll have to wait for tonight after work though. I'll also add in Daniels drill optimization code.

Jay



Edited 3 time(s). Last edit at 08/01/2008 05:50PM by JayC.
Anonymous User
Re: Opti - PCB-Gcode Optimizer available here
August 01, 2008 05:57PM
Miller,

What the algorithm is doing in the program is it is searching for all the G01 commands, which is the shape that is to be milled in between those that are not, which are expected to be fast moves to the next 'shape', so with the list of G01's that define the shape and the co-ordinates of the starting point of the shape, it can then reorder them. So your while still valid commands there that aren't G01, are going to confuse the reading of the code. This program really was only written for pcb-gcode code as we know what format the code will come out in as there are thousands of possible ways to write the same thing we can't check for and deal with them all. So if you want to run the optimiser, you're bet to generate your files with pcb-gcode, I use it with EMC2 myself and it works pretty well.

The memory management in the software relies on C++ STL containers for the data structure, so there should be no memory leaks or anything as we don't make any call to 'new' at all (well I can only speak for my code here, JayC's GUI might do something bad but I doubt that either). It probably isn't the most efficient code but I'm only a engineering student who's done a few programming classes here. smiling smiley
Anonymous User
Update 8/1/2008
August 01, 2008 08:39PM
Added code to allow for input files with no spacing between G code and coordinate pair.

Not sure how I want to approach the drill files yet so that is not included in this release.

Jay
Anonymous User
Re: Opti - PCB-Gcode Optimizer available here
August 02, 2008 09:57PM
dakiller Wrote:
-------------------------------------------------------
> Miller,
>
> What the algorithm is doing in the program is it
> is searching for all the G01 commands, which is

Not any more. The program looks for G00 X... Y... (and now G00X...Y... without spaces) lines as the signal that a path is beginning and ending. Anything in between is included as part of the current path. Additionally, it no longer relies on the (File Footer) to sense the last path.

> the shape that is to be milled in between those
> that are not, which are expected to be fast moves
> to the next 'shape', so with the list of G01's
> that define the shape and the co-ordinates of the
> starting point of the shape, it can then reorder
> them. So your while still valid commands there
> that aren't G01, are going to confuse the reading
> of the code. This program really was only written
> for pcb-gcode code as we know what format the code

Originally the code you provided was tied tightly almost exclusively to the output from PCB-Gcode ... but this is no longer the case.

> will come out in as there are thousands of
> possible ways to write the same thing we can't
> check for and deal with them all. So if you want
> to run the optimiser, you're bet to generate your
> files with pcb-gcode, I use it with EMC2 myself
> and it works pretty well.
>
> The memory management in the software relies on
> C++ STL containers for the data structure, so
> there should be no memory leaks or anything as we
> don't make any call to 'new' at all (well I can

I always wondered why re-initializing the temp variables in the while loop was better/faster than using "global" variables declared in main? Can you explain. I did try it the other way and it was a lot slower.

> only speak for my code here, JayC's GUI might do
> something bad but I doubt that either). It
> probably isn't the most efficient code but I'm
> only a engineering student who's done a few
> programming classes here. smiling smiley

I can't see any way to make it more efficient. You read in the paths, then start at one point and find it's nearest neighbor, then fine it's nearest ... and so on.

Jay
Anonymous User
Re: Opti - PCB-Gcode Optimizer available here
August 03, 2008 03:34AM
Quote:
JayC

I always wondered why re-initializing the temp variables in the while loop was better/faster than using "global" variables declared in main? Can you explain. I did try it the other way and it was a lot slower.

I don't really know here either, probably something the compiler is doing to it. I just initialise variables only when needed.

Quote:
JayC

I can't see any way to make it more efficient. You read in the paths, then start at one point and find it's nearest neighbor, then fine it's nearest... and so on.

I wasn't speaking to the general searching algorithm but the specific code, like one thing that comes to mind is that when you copy from the old boardPaths to the new one it has to copy all the strings over in the process. Using pointers, it could probably be done more efficiently. I put no thought at all into making efficient code here as in this day and age of processing speed it's all relativity quick, I wouldn't mind if it took minutes even, when the optimised path cuts hours off the milling time for me.

I've actually looked around at travelling sales man algorithms to maybe get an even better algorithm but the maths always looks way beyond what I can follow
Anonymous User
Re: Opti - PCB-Gcode Optimizer available here
August 03, 2008 08:22AM
Like you said, todays processing is too fast to bother. I added a timer to the command line version. we are talking milliseconds for a 2000 line gcode file.

F:\Engineering\projects\CNC\gcode_opti>opti top1.nc
Optimizer for PCB Gcode. By Daniel Purvis and Jay Couture
Version: 1.1 Releases 8/1/2008

Input: top1.nc
Output: top1_OPT.nc

Old Length : 32.0576 New Length :5.66018 saved 82.3437%
Optimizations took: 0.062 seconds.
Done! Please review the generated gcode before proceeding to use the output.

Keep in mind this is an Athlon X2 2.1GHz system.

Jay



Edited 1 time(s). Last edit at 08/03/2008 08:23AM by JayC.
Anonymous User
Re: Opti - PCB-Gcode Optimizer available here
August 03, 2008 07:12PM
Jay,

Thanks for the effort..

Over the weekend I had also started to look at my code requirements nd have started to write ( in Euphoria) a parsing and sorting algorithm.

Hope to have it finished soon.

I too am looking for G00 lines as starting point for the next block of instructions to do machining.

I look at lines containing "G00" token and then parse the line for other possible tokens, identify their location along the line and extract content in between tokens. This way the parser can be expanded at a later date to include more complex G code statements vis-a-vis sorting code for clockwise and anti clockwise machining.

There was a member of the group who was interested in LINUX COMPATIBLE sorting software. Euphoria ( in general ) is OS portable so may be for those runing EMC2 this may be of interest.

More soon.
Anonymous User
Re: Opti - PCB-Gcode Optimizer available here
August 08, 2008 01:58PM
Just following up. Did the changes I made work for you, or did you decide to roll your own?

Jay
Anonymous User
Re: Opti - PCB-Gcode Optimizer available here
August 08, 2008 11:48PM
Jay,

The changes are working.
I am getting good outcomes so far about 30% reduction in high speed traverse path length
Will keep an eye on rate of optimisation.

I am working on a version of own.


Thanks again.
Anonymous User
Re: Opti - PCB-Gcode Optimizer available here
August 13, 2008 07:35PM
Hi
I am greatly interested in the optimization project. However, as output exists now from the latest available exe from JayC, opti-qt exe, it has a problem for me.
My NC output for a pcb board in Eagle from the pcb-gcode program seems correct as viewed with notepad.exe and it displays, I think correctly, with ncplot.exe. The optimized code alone also looks good in ncplot.exe as text -- but now there no display to visually check optimization paths. Surprisingly, Notepad.exe shows a continuous file with no line end for NC code, ?are there no line feeds and returns - ? My cnc, a closed loop MaxNC also will not read the optimized code.
I write a little code in C to help with NC programing, and my quick look with C at the file optimized NC code from opti-qt leads me to ask if line terminations are C, or .txt , compatible and if not, why not? How can I proceed to use the project?
I would like to find a way to use/participate in this great idea.

Best regards, odubob
Anonymous User
Re: Opti - PCB-Gcode Optimizer available here
August 14, 2008 07:45AM
// For each path in our footer vector of paths
for (int i=0; i < tempPathF.pathList.size(); i++)	
{
 {
  out<<tempPathF.pathList.at(i)<<"\n";
 }
}
  	optimizedFile.close();
As you can see in the code it is appending a "\n" for each line read in. However, when I view the HEX output what should be a 0D 0a (13 10 for carriage return then linefeed) shows up as 0A 0A ... interesting. I will research this can provide updated code when I find the root cause. In the meantime, I have not seen this issue with the DOS version of the code so you can use that in the short term. Note: I have not seen an issue in Mach3 either so you may try to view your file in that if you use it.

Jay



Edited 3 time(s). Last edit at 08/15/2008 05:43AM by JayC.
Anonymous User
Re: Opti - PCB-Gcode Optimizer available here
August 14, 2008 08:31AM
Update: I can only assume that the code did not append the 0D before the 0A was due to the cross-compiler nature of the Qt library. I would have though MingW would have done that seeing how I was compiling for a x86 Windows platform. Nevertheless I have added the "\r" (carriage return) to the output code and all is well now. Unfortunately, it means you need to download the 3.2MB file again to see the changes.

I have uploaded the new file and placed the old ones in the "older" folder.

Jay
Anonymous User
Re: Opti - PCB-Gcode Optimizer available here
August 14, 2008 05:19PM
Hi,
and thank you for the effort. I read your first msg and was about to reply: ' I use "..\r\n" in my C code' and then I found your second msg - indicating we agree. I hope this revision will make the code more transportable and I can believe it will, and will be fine.
oduBob
Anonymous User
Re: Opti - PCB-Gcode Optimizer available here
August 15, 2008 05:45AM
Bob, this is the first time I can remember ever having to add the \r to a \n in my C programs. But thinking back most of my output was to the screen and if I needed to redirect it to a file I would do that on the command line.

Jay
Anonymous User
Re: Opti - PCB-Gcode Optimizer available here
August 15, 2008 08:28PM
Why don't you use endl instead of '/n' ? I never had any problems when using endl in the original code
Anonymous User
Re: Opti - PCB-Gcode Optimizer available here
August 16, 2008 08:05AM
Tried it ... did the same as "\n" on the windows code.
Anonymous User
Re: Opti - PCB-Gcode Optimizer available here
August 16, 2008 06:33PM
Hi, just a report and a question for someone regarding pcb-gcode.ulp
First, yep, the result: The code addition of "..\r\n" resulted in making a fine pcb board on the first try with the optimized code.

Secondly, this question shows my ignorance of recent time. I used for years the Dos version of Eagle, and until yesterday, the (first?) windows version 3.55. Both worked fine and I really don't need more. But using windows version 3.55, I could not get pcb-gcode to run (from the errors, I think they updated the script code format). I downloaded the free 5.11 to test out milling a small board (..but Group move will not work on the light version, ..sigh ...).

Is there an alternative for milling using my perfectly fine version 3.55? Or, ..sigh.., now do I purchasing an update just for milling a prototype?
oduBob
Anonymous User
Re: Opti - PCB-Gcode Optimizer available here
August 26, 2008 08:21PM
Hi oduBob,

AFAIK, Light has everything Pro does. It is just limited by size and number of layers.
The way commands work on groups has changed due to there being a right-click menu now. See the online help in Eagle for details.
Anonymous User
Re: Opti - PCB-Gcode Optimizer available here
September 24, 2008 12:13AM
Hi,
Just tried to use Optimizer gui version 1.2 but I can't drop any .nc file into the gui window.
My cursor displays a circle with a line through it and doesn't allow the drop.
This happens when dragging with right mouse button as well as left.
I tried version 1.1 as well, but the same thing.
Any ideas?

Kenny.
Anonymous User
Re: Opti - PCB-Gcode Optimizer available here
September 24, 2008 06:50PM
nekmech Wrote:
-------------------------------------------------------
> Hi,
> Just tried to use Optimizer gui version 1.2 but I

Now you have me confused. The file isn't versioned yet (IIRC) I have only provided the dates of compile/release. So do you mean the August 1 release as 1.2?

*** EDIT: Well, there's egg on my face. Looks like I did enter the "version" in the file notes on Mediafire. Sorry for the confusion ***

> can't drop any .nc file into the gui window.
> My cursor displays a circle with a line through it

it will for the bottom window ... what about the top. Don't use the right-mouse click use a left-click and drag.

> and doesn't allow the drop.

Are you dropping where is says "<drop content>"? Seethe attached image. I highlighted in red where you should drop your file. The bottom window is display only.



Edited 2 time(s). Last edit at 09/24/2008 07:03PM by JayC.
Attachments:
open | download - opti_show.jpg (18 KB)
Sorry, only registered users may post in this forum.

Click here to login