3dprintforums logo


Results 1 to 4 of 4

Thread: Schematic Capture to dxf File - using gEDA, Inkscape, and pstoedit

  1. #1
    Registered
    Join Date
    Dec 2004
    Location
    usa
    Posts
    229
    Downloads
    0
    Uploads
    0

    Schematic Capture to dxf File - using gEDA, Inkscape, and pstoedit

    Hey everyone,

    I have been on a quest to figure out how to do pcb milling using the gEDA suite of pcb CAD software. My goal has been to go from schematic to milled pcb with free and open source software, including the operating system - I use Ubuntu/Linux. So far, I have found a way to go from "electronic schematic diagram" to ".dxf file" using the gEDA suite, Inkscape scalable vector graphics editor, and pstoedit. The free software tool chain is broken when I get to the CAM software, but my hope is that gcam and other free CAM programs will progress in their capabilities. After the CAM software, I am back into FOSS with emc2 running the g-code and milling the pcb.

    There is one small glitch to the method I am using, which I will explain later. Still, I think I am able to produce acceptable .dxf files for producing milled pcb's.

    The only free alternatives for pcb CAD seem to be gEDA, KiCad, and Eagle. I appreciate that Eagle has released a free version of their proprietary software. But, Eagle is not really free, because you are bound by the 100mm x 80mm (4 x 3.2 inch) board size. I do not like that limitation, so I chose to learn the gEDA suite. Also, the Eagle .sch and .brd files are not in ASCII, so there is no looking at the files to learn things and change things. The gEDA suite's file formats are transparent. It is not that hard to learn the file structure of the .sch and .pcb files.

    In the 'free' version of Eagle you are only allowed to draw your schematic on a single page. I do not like that limitation either. Gschem, the gEDA suite's schematic capture software, has no sheet restriction, so you can spread your schematic over several pages and get readable printouts on paper. I also think the schematic symbols and printouts are much more elegant and readable in gEDA/gschem than in Eagle.

    Another reason I wanted to find out how to use gEDA is that I wanted to end up with a .dxf file, not a g-code file. I want a perfect outline of the pcb traces, pads, and polygons (ground planes) in .dxf file format. Then, in a CAM program I can decide what copper to mill away. I can decide what is 'island' and 'ocean'. The Eagle to g-code method, which converts the Eagle .brd file to a g-code file using 'PCB-Gcode' software, gives you a trace isolation routing. You cannot decide how to remove or (not remove) the excess copper on the board. However, with a .dxf file that contains a perfect outline of the pcb artwork, you can decide in the CAM software exactly what copper is removed and how. I want that kind of control over the milling process.

    Here is why I want control over how the ground plane is milled: Often the 'clearance' of several pads and traces will combine to cut off a chunk of the ground plane from any copper connection to the electrical ground source. I have noticed that the gEDA/pcb software will cause a chunk of the ground plane to disappear, if there is no connection to it from the ground source. If gEDA/pcb did not do this, there would be a chunk of copper that has a 'floating' voltage. This 'floating' piece of copper would not be tied to positive or negative, so it's potential could fluctuate and create instability and noise in the circuit. I want a .dxf file of the exact outline as it looks in the gEDA/pcb software. Then the ground plane will be reproduced exactly as it looks in the 'pcb' software, with no floating chunks of copper.

    The gEDA suite has a large community of people who are constantly adding to the schematic symbol and pcb symbol libraries, and the software keeps getting better and better. It is relatively easy to make custom symbols, it has auto routing, it can do multi-layer boards, it produces gerber files, it has a gerber viewer (gerbv), you can use it to prepare netlists for spice simulations, etc. There is a bit of a steep learning curve, but there is a lot of documentation on how to use it, and you can ask and answer questions or make suggestions on a very friendly email list.

    And did I mention that gEDA, Inkscape, and pstoedit are free, as in liberty? Donations are welcome through the Linux Fund - http://linuxfund.org/projects/pcb and http://www.linuxfund.org/projects/inkscape. I have made a small donation to gEDA/PCB and I plan to give back more to gEDA and Inkscape in the future. Maybe there is a way to send a few buck to the people working on pstoedit, also.

    ***

    Now that I have made my argument as to why I like to use the gEDA suite and why I want a '.dxf file' step in the software tool chain before producing a g-code file, I will explain how I am getting from schematic capture to .dxf file.

    How I get from the schematic capture in 'gschem' to the finished pcb artwork in gEDA/pcb is covered in documentation and tutorials that can be found on the web. So, I will start at the point where I have completed the artwork for a pcb in gEDA/pcb.

    With the .pcb file loaded in gEDA/pcb, I choose 'File > Export layout...', a window appears, and I click on the 'ps' button. This produces another window. I make sure 'multi-file' is checked and I click the 'OK' button. This produces multiple PostScript files of all the copper layers, solder mask, silkscreen, drill routing, etc.



    Now I need to do some conversion of the .ps files in Inkscape. So after starting Inkscape, I load the <filename>.ps.back.ps or the <filename>.ps.front.ps file. A window called 'PDF Import Settings' pops up. I leave the default settings and click 'OK'.

    Now that the .ps file is loaded into Inkscape, I 'Ctrl+A' select all. I now choose from the menu 'Object > Ungroup'. I then select and delete the unnecessary text at the bottom and some empty objects, which have appeared. What is left is the pcb artwork only.

    The next operation is why I need to use Inkscape. It is my understanding that lines are stored in .pdf and .ps and .svg files as 'strokes'. These have no thickness. Extra data in the .pdf, .ps, or .svg file determines the stroke's width, joint shape, cap shape, dash style, etc. When I tried converting a .ps file directly to .dxf, I got results like this:



    Most of the square pads do not show. The circles are now octagons. And all of the copper traces are now lines with no thickness. The ground plane is not recognizable. This is an unusable file.

    Inkscape allows me to solve this by having the ability to convert the 'strokes' (lines) into 'paths' (objects that have a closed outline). To do this, I select the whole pcb image, and I select 'Path > Stroke to Path' from the menu bar. All of the copper traces are now converted to separate objects. All of these objects have borders that are overlapping all over the pcb image; so, I need to combine the separate overlapping objects into single composite objects.

    Before doing that, this next step is important. Deselect everything and then reselect everything. If you do not do this, the entire image will disappear on the next step. This is probably a bug in Inkscape.

    I then go to the menu and select 'Path > Union' This does a boolean union operation on the objects that are overlapping, and combines them into single objects. At this point you have a complex outline of all of the traces, pads, and polygons. This step also causes the drill holes to disappear, which is good, since that is what the copper layer looks like in its gerber file, anyway. This saves me from removing all of the drill holes in the image by hand. My thought is that you want the tiny drill bits that are used to drill the hole in the pcb to see a clean copper surface when drilling out each hole, not ragged edges of copper and fiberglass.

    Inkscape has the ability to save the .ps file as a .dxf. I do not use this feature, though, because all of the curved objects are converted into over-simplified straight-lined polygons. Here is an example .dxf produced by Inkscape and viewed in qcad:



    I do not know how Inkscape does the conversion to .dxf, but it is not precise enough for pcb artwork. A workaround is to scale the artwork by 10x or 100x, save the .ps file in Inkscape as a .dxf file, and then in the CAM program rescale the artwork down by the same factor. When saving the file at these larger sizes, the artwork has sufficient detail.

    However, I think a better method is to use the open source command line tool 'pstoedit'. Once the .ps image is completed in Inkscape, I save it as a .ps file. I open up a command line terminal and navigate to the directory that contains the .ps file I want to convert. Then I run this command:

    $pstoedit -f dxf_s <in>.ps <out>.dxf

    The '-f dxf_s' option gets pstoedit to handle curves much more accurately. There is also a '-f dxf' option, but '-f dxf_s' does a better job.

    Finally, I am left with a .dxf file that contains perfect outlines of all of the objects in the pcb artwork! Here is a screenshot of a pcb that I designed in the gEDA suite and then converted through this process to a .dxf file:



    You can see in the circled area that a portion of the ground plane has been left out of the pcb artwork. This is good, since that chunk of copper would be floating with no connection to the ground source.

    ***

    Now, for the small glitch in the software tool chain that I mentioned at the beginning of this post:

    I am happy with the results I am getting, but I think there is a slight problem with Inkscape that I hope will eventually be improved. I have Inkscape version 0.47, so maybe it has been fixed in the current version. Or maybe there is some setting that I am missing. Or I am doing something wrong. I welcome any advice on this.

    The problem is that the 'Stroke to Path' command changes the shape of the rounded ends of the lines (strokes). The perfect half circles at the end of each line are slightly altered in seemingly random ways. Here is an example of a line made in gEDA/pcb, exported as a .ps file, loaded into Inkscape, and given the 'Stroke to Path' command:

    Before:



    After:



    As you can see the ends of the lines alter the shape of the 45 degree bend. At first I wondered if it could be an error in the way that gEDA/pcb creates the data contained in the .ps file. But, I did some small experiments and I found that lines (strokes) that are created in a new Inkscape .svg file exhibit the same type of errors when given the 'Stroke to Path' command. Here is an example of a green line drawn in Inkscape showing its nodes as little gray diamonds:



    And here is the same green line after the 'Stroke to Path' command:



    You can see that the ends are altered, especially on the right end of the line. On the left end the nodes are not spaced equally.

    These slight alterations to the ends of the lines show up in the final .dxf file, as well. Here are some close-ups in qcad of what the pcb artwork outlines look like after being converted from .ps to .dxf using 'pstoedit':





    The perfect 45 degree rounded corners created in gEDA/pcb are now quite lumpy and bumpy. My hope is that the Inkscape developers improve the results of the 'Stroke to Path' command. Perhaps in future updates, Inkscape could provide the user with some control over increasing the resolution of the conversion from stokes to paths.

    Even with these lumpy corners, I think the results are sufficient to produce good milled pcb's. I have not finished building my cnc mill yet, so it will be a while before I can fully test this method. My hope is that some of you who have pcb milling capabilities will try the 'gEDA-Inkscape-pstoedit to dxf' method to mill some pcb's and share your results.

    Ultimately, I would like gEDA/pcb to allowed me to export directly to .dxf, with a 'dxf' button in the 'Export layout...' window. The challenge is to convert all of the strokes to properly shaped objects and then 'boolean union' all of the objects together. Maybe 'pstoedit' could be incorporated into gEDA/pcb as the backend program that converts the Postscript data to a .dxf file.

    This feature is on my personal gEDA/PCB wishlist, anyway.

    Please, let me know what you think.

    Thanks,
    Dave

    Similar Threads:


  2. #2
    Registered
    Join Date
    Dec 2004
    Location
    usa
    Posts
    229
    Downloads
    0
    Uploads
    0
    An alternate place in the software tool chain to put a 'DXF' button could be in gEDA's gerber viewer program - gerbv. Under gerbv's 'File' menu, there is an 'Export' command, which gives you the choices to save the file as a PNG, PDF, SVG, or a PostScript file. A 'DXF' choice could be added to the list.

    This might be a better place than in the gEDA/pcb program, since gerber files are the universal file format for pcb manufacture.

    With the conversion happening in gerbv, any pcb CAD program that can create gerber files could use gerbv to turn pcb artwork into .dxf outlines.

    Edit:

    If both gEDA/pcb and gEDA/gerbv used the same backend program to internally convert from ".ps to 'path to stroke + union' to dxf", then an 'Export as DXF' button could be available in both programs.

    Last edited by dfro; 01-21-2010 at 03:25 PM.


  3. #3
    Registered
    Join Date
    Dec 2004
    Location
    usa
    Posts
    229
    Downloads
    0
    Uploads
    0

    Gerber to dxf using gEDA, Inkscape, and pstoedit

    Here is my next discovery:

    'Gerber to dxf using gEDA, Inkscape, and pstoedit'

    I have found another route through the gEDA suite's software to produce a .ps file that then get converted in Inkscape and pstoedit to a .dxf file outline.

    But now, any software that can produce a gerber file can use this method. So, those of you using using a different pcb CAD program, like Eagle, can export your pcb artwork as a gerber file and use this process to make .dxf files.

    ***

    I start in gEDA/pcb with the finished artwork by choosing 'File > Export layout...', then I click the 'gerber' button in the next window. Or I could generate a gerber file from within Eagle or any other pcb CAD program.

    Now, I open gEDA's gerbv (Gerber Viewer) program and select 'File > Open Layer(s)..'. I browse to where I saved the gerber file and click 'Open'. The file is now loaded into gerbv for viewing.

    Next, I choose 'File > Export... > PostScript', and a .ps file of the artwork is saved.

    Then I do the 'Stroke to Path' and 'Union' steps in Inkscape that I described earlier. Followed by the step using pstoedit and it '-f dxf_s' option.

    I am left with a very decent .dxf file containing an almost perfect outline of the pcb traces, pads, and polygons!

    Here are a few examples of the result:





    Give it a try an let me know how it works for you.

    Thanks,
    Dave



  4. #4
    Registered
    Join Date
    Dec 2004
    Location
    usa
    Posts
    229
    Downloads
    0
    Uploads
    0
    I have tweaked the process a little to get a better result in Inkscape. Rob, at the Inkscape forum offered some help:

    http://www.inkscapeforum.com/viewtopic.php?f=28&t=4279

    He, thinks that the 'Stroke to Path' problem looks like a mathematical rounding error. That makes sense to me.

    So now, the first thing I do, after loading the .ps file into Inkscape, is to scale it x10. I do all of the 'ungroup', 'path to stroke', and 'union' operations on it and then scale it back to normal size. At 10x the size, the 'Path to Stroke' does better at converting the end caps on the lines; and, after the 'Union' operation, the 45 deg. and 90 deg. corners are smoother on the traces.

    You might think scaling 100x would be even better. However, by scaling x100 in Inkscape and then doing 'Path to Stroke' and 'Union', a new set of problems arise.

    gEDA/pcb creates the solid ground plane out of multiple polygons that are butted up against each other, and meant to be treated as one solid object. At x100 scale, tiny slivers of white background show between some of them. They are 'boolean union'-ing into a single object, but with long, thin slivers taken out of the solid ground plane. The scaling seems to be slightly offsetting the nodes - looks like another rounding error to me.

    So, x10 gets good results. I am very happy with it.



    Dave



Posting Permissions

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


About CNCzone.com

    We are the largest and most active discussion forum from DIY CNC Machines to the Cad/Cam software to run them. The site is 100% free to join and use, so join today!

Follow us on

Facebook Dribbble RSS Feed