you might've guessed by now that i'm an advocate for open source software, and that transfers into my hobbies as well.
a perfect case of the existence of powerful free and open source software is the
gEDA project, which (most notably) provides tools for
schematic capture and
printed circuit board design. however, it seems that, while each of the tools in the gEDA suite is powerful in its own right, the linkage between them is far from intimate, leading to confusion among first-time users. i figured i'd post my setup in hopes that maybe someone will stumble upon it when they decide to use open source software to design their hardware.
a quick
ls of any one of my audio projects would yield this:
brad@dagobah ~/Projects/audio/system/buf/v4 $ ls -l
01-chanleft.sch
02-chanright.sch
03-supply.sch
04-regulator.sch
board -> ../../../board
edit -> ../../../edit
print -> ../../../print
proj
v4.cmd
v4.net
v4.pcb
v4.pdf
v4.png
v4-gbr.zip
first, notice that the pages of the schematic are numbered such that a simple
*.sch expression yields the filenames in page order. this'll ensure that my scripts open and process the schematic files in the proper order.
second, let's look through the scripts that tie schematic capture to printed circuit board design. just three common bash scripts are used to manage all my audio projects:
edit,
print, and
board. the first script edits the schematic and pcb:
brad@dagobah ~/Projects/audio/system/buf/v4 $ cat edit
#!/bin/bash
source $(pwd)/proj
if [ "${1}" == "pcb" ]; then
pcb v${ver}.pcb
rm -f v${ver}.pcb-
if [ ! "$(ls | grep -e \.cnc -e \.gbr)" == "" ]; then
install -d gbr
rm -f v${ver}-gbr.zip
mv -f *.cnc *.gbr gbr/
pushd gbr > /dev/null
cp *.backmask.gbr gerber.gbs
cp *.frontmask.gbr gerber.gts
cp *.frontsilk.gbr gerber.gto
cp *.plated-drill.cnc gerber.drd
cp *.front.gbr gerber.gtl
cp *.back.gbr gerber.gbl
zip -9 -l ../v${ver}-gbr.zip gerber.{gbs,gts,gto,drd,gtl,gbl}
popd > /dev/null
rm -rf gbr
fi
else
gschem -q *.sch
rm -f *~ *.log
fi
sync
the second script generates a pdf file of the schematic files in the project:
brad@dagobah ~/Projects/audio/system/buf/v4 $ cat print
#!/bin/bash
source $(pwd)/proj
rm -f *.ps *.pdf
for schematic in *.sch; do
postscript="$(echo $schematic | sed -e 's/sch/ps/')"
gschem -q -p -o${postscript} -s/usr/share/gEDA/scheme/print.scm ${schematic}
ps2pdf ${postscript}
done
cat *.ps > v${ver}.ps
sed -e "s/\(%%Title:\).*/\1 $(echo ${prj}v${ver} | tr '[:lower:]' '[:upper:]')/" -i v${ver}.ps
ps2pdf v${ver}.ps
mv -f v${ver}.pdf TMP
rm -f *~ *.ps *.pdf *.log
mv -f TMP v${ver}.pdf
sync
the last script translates the schematics into input files for
PCB:
brad@dagobah ~/Projects/audio/system/buf/v4 $ cat board
#!/bin/bash
source $(pwd)/proj
rm -f v${ver}.{cmd,net,pcb}
gsch2pcb -o v${ver}.pcb *.sch
rm -f *~ *.log
sync
all the above scripts read in a small text file called
proj:
brad@dagobah ~/Projects/audio/system/buf/v4 $ cat proj
prj=buf
ver=4
that describes everything required to set up a design workflow from idea to circuit board. i also have some scripts that integrate the schematics into spice3f5 analyses. they basically rely on
gnetlist to do the dirty work, and a little bit of sed/awk to translate outputs into something readable by gnuplot for postscript output. maybe i'll cover those later, since there is a bit of scripting trickery involved.
a few noteworthy points:
(a) the
edit program opens both the schematic and pcb. if you run it without arguments, it opens up the schematic. if you run it with the 'pcb' argument, it'll edit the pcb. it also automatically handles gerber exports from the
PCB program, creating a zip file that is directly uploadable to
batchpcb and
advanced circuits.
(b) you can also use
gerbv (a part of gEDA) to examine your exported gerber files, if you wish.
in short, it's pretty simple to use these programs. the learning curve isn't shallow, for sure, but these scripts make my hobby life 1000X easier; maybe they can do the same for you.
~ brad.
p.s. these scripts are provided in the hope that they will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. enjoy. :)