Name

gschem2xpcb — Create an xpcb board from a gschem schematic

Synopsis

gschem2xpcb [OPTIONS...]

PURPOSE

This program will read a schematic from gschem (part of gEDA) and create a new xpcb layout with all the parts placed on the schematic. There are a couple other programs which attempt to do this, that I found to be unacceptable. They are called gsch2pcb and gschem2pcb and come with gEDA. They create an incredible mess with all the parts placed on top of each other. This program places parts outside the margin of your board in such a way that they do not overlap. It also tries to sort parts by refdes before placing to make it easier to find the parts, although small parts may be placed in gaps left by larger parts and thus end up out of order. The parts are placed outside the board margin so they don't get in the way as you are manually placing the parts.

OPTIONS

--two This is the third option

--input_file

The name of the schematic file to read. Default value: "-". Example: --input_file=board.sch

--output_file

The name of the layout file to write Default value: "-" Example: --output_file=board.pcb

--board_size_x

The width of the finished board Default value: 550000 (5.5 inches) Units: 0.01mils Example: --board_size_x=550000

--board_size_y

The height of the finished board Default value: 400000 (4.0 inches) Units: 0.01mils Example: --board_size_y=400000

--working_size_x

The width of the working area while placing components around the margin of the board. Default value: 900000 (9.0 inches) Units: 0.01mils Example: --working_size_x=900000

--working_size_y

The height of the working area while placing components around the margin of the board. Default value: 700000 (7.0 inches) Units: 0.01mils. Example: --working_size_x=700000

--searchdirs

A colon separted list of directories to search for component footprints. All subdirectories will be searched. Default value: "/home/whitis/surface_mount/output/xpcb:\ /home/whitis/surface_mount/hand_drawn" Example: --searchdirs="/usr/local/share/pcb/newlib:/home/me/footprints"

--sort_by_refdes

Default Value: 1 Example: --sort_by_refdes=0 (disable) Example: --sort_by_refdes=1 (enable) Example: --sort_by_refdes (enable)

--vertical

Determines whether to use row major or column major order to layout new parts. Default value=1 Example: --vertical=0

--debug

Amount of debugging information to print Default value: 0 Example: --debug (turn on debugging) Example: --debug=5 (even more debugging)

--verbose

Amuunt of status information to display while processing. Default: 1 (on) Example: --verbose=0 (quiet)

--show_params

If set to 1, will show parameter values after parsing command line options Default value=0

--help

If set to 1, the program will display help information and then exit Default value: 0 Example: --help

RETURN VALUES

DESCRIPTION

The file sample.png contains a sample of the output of the program on a real project so you can see what the output looks like. Actually, there were so many components I ended up splitting it into two boards.

Compare it to sample_othertools.png that shows what you get after running gEDA gsch2pcb and pcb autoplace on the board. It looked even worse before the autoplace.

"xpcb" refers to the program foolishly renamed "pcb" located at http://pcb.sourceforge.net/ This program was originally more sensibly named XPcb.

gschem refers to the schematic capture program produced by gEDA project.

This program does not attempt to autoplace components to minimize trace length based on the netlist connections. This is difficult and of dubious value. Most boards have components that need to be placed in specific locations, such as connectors, switches, LEDS, joysticks, potentiometers, LCD displays, keypads, and certain test points. And there are other components whose placement cannot be deduced by such a program: decoupling capacitors. The xpcb program has such a feature built in; when run it ties up your computer for an hour and you are still left with a bunch of components placed on top of each other. It might work better if you manually placed some components and then selectively use it on groups of components:

  • manually place all your connectors
  • let the program attempt to autoplace ICs only
  • manually rearrange ICs
  • manually place decoupling capacitors
  • let the program attempt autoplacement of remaining passive components.

Another trick you may want to try for manually placing components on the board is to temporarily delete VCC, GND, and similar nets from the netlist file. These nets generate ratsnest lines that are generally more of a hinderance than a help during rough placement.

Table 1. Feature comparison

Program:gschem2xpcbgschem2pcbgsch2pcb 
LanguageCshell scriptC 
Lines:15401231270 
License: other GPL (bad)GPL (bad) 
obsolete M4 partsno***yesyes 
new Element filesyesnoyes 
multiple sheetsnonoyes 
Places parts:non-overlappingoverlappingoverlapping 
Outside margin:yesnono 
Updates existing boardnonoyes 
Imports netlistnonono 
ratsnest optimazationnonono 
User defined search pathyesnono** 
Handles element file extensionsyesnono 

* Use "cat" to combine multiple schematic files together first. The program won't be bothered by the extra file headers.

** gsch2pcb lets you specify a (single?) directory but you can't exclude existing GPL tainted library directories or change the search order (which starts with obsolete format library symbols first).

***IF you want to use obsolete M4 parts, I suggest writing a small translator program to convert them to element files. This is basically what xpcb does anywya. The QueryLibrary.sh shell script could be called for each symbol to produce an element file. The ListLibraryContents.sh shell script will list the components in each library In determining object extents, the program leaves a little space at the top for the REFDES but does not try to actually calculate the space used by the REFDES. The following script will almost do the job.

   #!/bin/bash
   mkdir /tmp/junk
   for i in *.list; do 
      name=`basename $i .list`
      echo "###Processing Library $name"
      fgrep -v "#" $i | ( 
	 export IFS=":"
	 while read a b c; do 
	    echo "a=$a b=$b c=$c"
	     ./QueryLibrary.sh . pcblib "$a" "$b" "$c" >/tmp/junk/$a.xpcb_element
	 done 
      ) 
   done

However, QueryLibrary.sh hangs if $c contains spaces. Please bear in mind that converting old m4 libraries has absolutely zero priority for me since I will NEVER use GPL licensed parts.

Manually load netlist in xpcb once you have opened the new board.

Line breaks are not allowed in the middle of an Element, ElementLine, ElementArc, Pin, or Pad line. Some M4 generated parts contain indiscriminate line breaks. This program works fine on parts generated by the "save buffer elements to file" command in xpcb and on parts generated by the opensymbol project.

For each footprint "footprint" specified in the schematic file, the program will by default search for files named "footprint" and "footprint.xpcb_element". You can add additional directories to the search path.

Some of the functions implemented by this program are:

  • parse enough of the schematic file to extract the refdes and footprint information from each symbol.
  • pfully parse element files into C data structures
  • determine object extents
  • keep track of which portions of the board are used or unused.
  • recursive directory search

I did not extend gsch2pcb because it had an unacceptable license and poor coding style.

If you don't understand why GPL is a bad thing, visit GPL considered Harmful

ERRORS

DIAGNOSTICS

EXAMPLES

   gschem2xpcb --input_file=board.sch --output_file=board.pcb
   cvs add -m "created board.pcb" board.pcb

ENVIRONMENT

This program does not respond to any environment variables except those which may influence the loader or C library.

SIGNALS

CONFORMING TO

PORTABILITY

This program should port easily to most UNIX compatible systems even cygwin over windoze.

LOCATION

/usr/bin/myprogram

FILES

TIPS

NOTES

BUGS

REPORTING BUGS

Report bugs to whitis@freelabs.com.

AUTHORS

This program was written by Mark Whitis

COPYRIGHT

Copyright 2004 by Mark Whitis. Some Rights Reserved.

LICENSE

http://www.freelabs.com/~whitis/software/license.html

DOWNLOAD

http://www.freelabs.com/~whitis/software/gschem2xpcb/download/

INSTALLATION

   mkdir /dist
   cd /dist
   wget http://www.freelabs.com/~whitis/software/gschem2xpcb/download/gschm2xpcb_latest.tar.gz
   make clean
   make 
   make install

HISTORY

This program was originally created in Nov 2003 by Mark Whitis

MORE INFORMATION

LINKS