586,103 active members*
3,594 visitors online*
Register for free
Login
IndustryArena Forum > Other Machines > PCB milling > Optimizer for PCB-Gcode
Page 1 of 2 12
Results 1 to 20 of 27
  1. #1
    Join Date
    Dec 2004
    Posts
    1137

    Optimizer for PCB-Gcode

    I have posted a similar thread on this subject on www.millpcbs.com. I have taken some publicly available code posted on the PCB-Gcode Yahoo forum for optimizing the output from the Eagle CAD ulp PCB-Gcode and improved it. It is a DOS application and now I'm making plans to update it with a Windows GUI.

    Long story short, I'd appreciate feedback on the UI. I'm only initially coding for PCB-gcode output, but if I see opportunities to modify it to be more generic I'll give them consideration. For now, if you have a current program that you like the UI on that would match the functionality of what you would like in a GUI for "Optimizer for PCB-Gcode" please post them here or on the www.millpcbs.com thread.

    Jay

  2. #2
    Join Date
    Dec 2004
    Posts
    1137

    Updated Code: 7/10/2008

    I have updated the code to be more universal in how it treats the paths in the input files. It now looks for the first G00 X... Y... line to start the path, and the next G00 X... Y... line to end the path.

    Using the code posted by Dan above here are the results:
    Input: c:\temp\suice.nc
    Output: c:\temp\suice_OPT.nc

    Old Length : 60869.8 New Length :5376.26 saved 91.1676%
    Optimizations took: 1.36 seconds.
    Done! Please review the generated gcode before proceeding to use the output.

    Yep that's 60 thousand units of travel reduced to 5 thousand!

    Jay

  3. #3
    Join Date
    Dec 2004
    Posts
    1137
    Before and after of the file I spoke about above:

    http://picasaweb.google.com/jay.couture/CNC02

  4. #4
    Join Date
    Dec 2004
    Posts
    1137
    800+ views and no feedback Anyone using this?

  5. #5
    Join Date
    Jun 2007
    Posts
    10
    Hi,

    I guess I'll be the first one to respond.
    I'm observing the progress of your program almost from the beginning. It started at the pcb-gcode mailing list (which is btw not working at the moment), then at millpcbs.com forum and now on cnczone.
    Personally I tried to optimize a few gcode files which I generated with pcb-gcode and all of them look just fine. Unfortunately I haven't had the chance to try them out in practice. Hhopefully I'll be milling a few PCBs next weekend - on my cheap DIY CNC .
    I also have to say that I'm really glad that someone finally made a public and a working version of an optimizer because that "random" path selector from pcb-gcode generator really annoyed me, especially as my CNC doesn't have fast feedrates (25 cm/min or 9.8 inch/min) so any unnecessary movements add quite a lot to the final work time.

    So, keep up the good work and keep us uposted with the progress of the GUI.

    BTW, which IDE do you use with QT - Visual Studio, Eclipse or perhaps something else? I'm also starting to experiment with it but I have some difficulties with the Eclipse plugin for QT because g++ doesn't seem to find main.cpp

  6. #6
    Join Date
    Dec 2004
    Posts
    1137
    Quote Originally Posted by Tester View Post
    Hi,

    I guess I'll be the first one to respond.
    ...
    So, keep up the good work and keep us posted with the progress of the GUI.

    BTW, which IDE do you use with QT - Visual Studio, Eclipse or perhaps something else? I'm also starting to experiment with it but I have some difficulties with the Eclipse plugin for QT because g++ doesn't seem to find main.cpp
    I'm using the MingW C++ compiler. When I installed Qt, it sets up a link to a command line that sets all of the environment variables. To compile, you first do a qmake -project, then qmake which generates the make file. Finally, run make to compile and link which places the output into a new directory called release. I downloaded and have been reading the Qt book. I have my GUI planned out, just need some time to code it now

    Jay

  7. #7
    Join Date
    Jun 2007
    Posts
    10
    Today I tried to mill a smal PCB and found an error in optimized gcode.
    When first path is milled CNC continues to the next path without raising the spindle thus braking one connection on its way. All other paths are milled without a problem.
    I attached the original and optimized gcode files so you can analyze them. *The problematic line in optimized file is line number 34 (spindle should be raised to Z 0.5000 but instead it stays at Z -0.2000).

    I hope I provided enough information so you can locate the cause of the problem.

    EDIT:
    I'm not sure if line 34 is "the problematic one", but the path of the traveling spindle at the wrong height can be clearly seen in Mach3.
    Attached Files Attached Files

  8. #8
    Join Date
    Dec 2004
    Posts
    1137
    The issue is that the Z up movement occurs after the (File Footer) tag and thus is not included in this path. HMMM, the best solution I can think of (which would also remove the need for the (File Footer) tag is to make the last path always the footer path (my terminology for the last path in the source file).

    I will work on a solution and post an update. In the mean time, you can just add G00 Z0.5000 before the (File Footer) tag as a work around.

    Jay

  9. #9
    Join Date
    Jun 2007
    Posts
    10
    Yes, this seems to be the problem. Thanks for the temporary solution .

  10. #10
    Join Date
    Dec 2004
    Posts
    1137
    Updated 7/21/2008

    Modified the code to remove the (File Footer) tag requirement. This should make it pretty universal now. Still working on GUI development, but got sidetracked playing with my mill this weekend

    Here

    Jay

  11. #11
    Join Date
    Aug 2007
    Posts
    6
    Hmm, your source code looks familiar nice to know it's going to good use.

    I see you've put a bit more care into how it reads in the files, you've done a nice job with it. I'm surprised someone didn't make an optimiser for it sooner, it's such a crude algorithm but it works so well here.

    Please feel free to make whatever you want with it, just as long as I get some credit

  12. #12
    Join Date
    Dec 2004
    Posts
    1137

    Cool

    Yes the code you posted is the kernel of the optimizer. At the top of the source file is:
    Code:
    /*
    *   PCB-Gcode Optimiser
    *   Original code: Daniel
    *   Updated Code: Jay C
    *
    *   Release: Beta ... use at your own risk
    I will gladly put anything more you wish. Just let me know and it will be included in all future releases. I neglected to give either of us credit in the Windows source I have fixed this. Oh, and I gave you full credits on PCB-Gcode, unfortunately that is now lost Not sure the Google Group is much of an improvement.

    Jay

  13. #13
    Join Date
    Dec 2004
    Posts
    1137
    I have uploaded the command line version to a file hosting site.

    • Updated: 7/27/2008 10:29AM -5GMT | Added kudos to Daniel the original coder aka daKiller
    • Updated: 7/26/2008 10:29pM -5GMT | Tweaked the code a bit based on what I learned from the windows code. Source file cleaned up.

    You can get the source and executable here. All future update will be at this file host site. Look for new links as old versions may be deleted.

    Jay

    PS: PCB-Gcode is now located at www.pcbgcode.org

  14. #14
    Join Date
    Dec 2004
    Posts
    1137
    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

  15. #15
    Join Date
    Apr 2007
    Posts
    60
    Hi Jay C

    Could be something I am doing wrong but after optimizing a board nc file it would no longer show up graphically in NCPLOT. The file loads but nothing shows in the window (traces). I am running the windows version and have not tried the command line version.

    Richard

  16. #16
    Join Date
    Dec 2004
    Posts
    1137
    Richard, would you mind posting your before and after files here, or else PM me so I can give you my email address.

  17. #17
    Join Date
    Apr 2007
    Posts
    60
    I have attached the zip for the two files.

    Richard
    Attached Files Attached Files

  18. #18
    Join Date
    Dec 2004
    Posts
    1137
    Ok, I d/l'd NCPLot (I usually use Mach as my previewer) and can duplicate the same issue, but can't figure out what it doesn't like. Still looking. OTH, Mach and CAMBAM like it just fine so you should be good to go when you are ready to cut it.

    Now what is really strange is that if you copy and paste the test of the OPT file into NC ... it works ... hmmm

    Jay

  19. #19
    Join Date
    Aug 2007
    Posts
    6
    I've had issues where you don't have a blank line at the end of the file it doesn't like it, I have the same problem with 'Image to G-code' viewer on my windows machine

  20. #20
    Join Date
    Dec 2004
    Posts
    1137
    That's weird too. Since the code doesn't modify the contents of the paths, it just rearranges them. However, it doest tough the header, the first path, or the last path in the file so the extra line, if it's preset, will be in the same location. I confirmed this by looking at the HEX of both files side by side.

    Jay

Page 1 of 2 12

Similar Threads

  1. Cutting optimizer
    By kurt5 in forum Uncategorised CAM Discussion
    Replies: 5
    Last Post: 12-16-2022, 09:38 AM
  2. Replies: 4
    Last Post: 05-06-2007, 02:56 AM
  3. Gcode I think
    By Mr.Chips in forum DIY CNC Router Table Machines
    Replies: 2
    Last Post: 10-27-2006, 12:52 AM
  4. Replies: 0
    Last Post: 03-10-2005, 07:46 PM
  5. gcode to gcode converter
    By july_favre in forum Uncategorised CAM Discussion
    Replies: 4
    Last Post: 05-25-2004, 12:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •