The eagle cam waltz

By Tom

Every time I have to produce gerbers of PCB to send to a PCB house, I curse the horror that is the eagle cam processor dialog box. Invariably it takes several goes to get all the right settings at the same time and verify the files. Then I send them of and they phone back to remind me that Ive been an idiot and…

So when faced with producing 5 sets of gerbers for Student Robotics I set about automating the process. I turns out that eagle have actually built in command line cam processing for this exact reason.

Hence I knocked up this script, it produces the 4 files I believe you need to send to either Pcbtrain, Leff circuits, Cambridge circuits or spirit circuits and so I guess others too:

#!/bin/bash
EXPECTED_ARGS=3
E_BADARGS=65

if [ $# -lt $EXPECTED_ARGS ]
then
  echo "Usage: `basename $0` [4/5][file.brd] [outputprefix] <xshift  yshift>"
  echo "output files in gerbers/outputprefixfile.{gbr,drd}}"
  exit $E_BADARGS
fi

if [ $1 -eq "5" ]
then
    egl="/opt/eagle-5.2.0/bin/eagle" # path to eagle 5 binary
    echo 'using eagle 5'

elif [ $1 -eq "4" ]
then
    egl="/opt/eagle/bin/eagle" # path to eagle 4 binary
    echo 'using eagle 4'
else
    echo "error second argument must be 4 or 5 indicating eagle version to use"
    exit
fi

if [ $# -gt $EXPECTED_ARGS ]
then
    of1="-x$4 -y$5"
else
    of1=""
fi
echo $of1
echo $egl

$egl -X -dGERBER_RS274X  $of1 -o$3-top.gbr $2 top pad via
$egl -X -dGERBER_RS274X  $of1 -o$3-bottom.gbr $2 bottom pad via
$egl -X -dGERBER_RS274X  $of1 -o$3-dim.gbr $2 dimension
$egl -X -dexcellon  $of1 -o$3-drill.drd $2 drills

usage is
makegerb.sh [4/5][file.brd] [outputprefix] <xshift yshift>
output files in gerbers/outputprefixfile.{gbr,drd}}

eg:
./makegerb.sh 4 ../power/power.brd pwr-

uses eagle 4 binary to process the board file ../power/power.brd and produces outputfiles:
../power/gerbers/pwr-top.gbr
../power/gerbers/pwr-bottom.gbr
../power/gerbers/pwr-dim.gbr
../power/gerbers/pwr-drill.drd
plus a bunch of .gpi and .dri files you can ignore these, I’m sure its possible to suppress these but time didn’t permit.

xshift and yshift are optional integer arguments that shift the output away from the origin, units inches(yuk!)

you may need to check the eagle paths, included are the default ones.

you can view the output using gerbv, its good but frustratingly simple.

It is pretty bodgy but works ok, if you find this usefull, It would be nice to know.

It of course comes with the usual no strings disclaimer, especially because I wrote it in the early hours of the morning, approaching a deadline.

Leave a Reply