Tiling PCBs with Gerbmerge

22 Mar 2009

Gerbmerge is a great script written in Python that does exactly like what it sounds like it would do, it merges smaller gerber files into one large gerber file. I've been meaning to learn how to use it for a long time seeing how it'll give me more control over what I send to the PCB printers. I can either tile an individual board design to fill a minimum size quota or I can build a larger board filled with a variety of different boards within it. A good example of when you may use gerbmerge is for Advanced Circuits' "33 Each" special where you pay $33 for each board and there is a maximum size of 60 sq. inches. It makes much more sense to tile your boards and fill the space to get the most for your money rather than send out an single small board and still pay the same price

My instructions on how to use Gerbmerge is geared towards Mac / Unix since I'm on the Mac OS.

  1. Go to http://ruggedcircuits.com/gerbmerge// and head to the Introduction section. At the end of that section is a link that guides you to where you can download Gerbmerge. Choose the unix version.

  2. Go to http://simpleparse.sourceforge.net/ and download the SimpleParser python package for Unix (the .tar.gz file). The Gerbmerge documentation mentions that the eGenix mxbase tools are required as well however gerbmerge functioned fine without installing them. Perhaps they are already installed.

  3. Extract the files from the SimpleParser download and navigate to the extracted folder in Terminal. Type:

    python setup.py install
  4. Extract the files from the Gerbmerge archive and navigate to the extracted folder in Terminal. The same as above (you may need to run this with sudo), type:

    python setup.py install
  5. Despite the fact that gerbmerge appeared to install correctly, typing 'gerbmerge' from Terminal did not work. This step will help you fix this. If gerbmerge appears to run when you type its name in Terminal, then please disregard this step.

    My computer did not seem to know where gerbmerge lived, so I had to tell it explicitly. Type:

    sudo nano /usr/local/bin/gerbmerge

    Change the location in this script to the location of your gerbmerge scripts, mine were installed at: /Library/Python/2.5/site-packages/gerbmerge/gerbmerge.py.

  6. Create folders for your work, for example:

    /Users/rory/Documents/gerbm-projects/<project name>

    (will contain your gerber files and layout configuration file)

  7. First begin by generating all the gerber files for your board design. If you're using Eagle, I created a job file that can be used in the CAM processor. gerb274x-gerbm.cam

    Place this file in the "cam" folder within your installation of Eagle.

  8. Open your board design in Eagle and use the cam processor to generate your gerber files.

  9. Copy the generated gerber files to your newly created project folder. There should be eight (8) files in total.

  10. Now is time to create a layout.cfg file to tell gerbmerge where your gerber files are and some information about them. This helps gerbmerge figure out how to automatically tile your board design. Download this sample layout file: layout.cfg

  11. Save the layout.cfg file to the same folder as your project gerber files. Open it up in your favorite editor.

  12. For projdir, change this to the absolute path of your project gerber files. For PanelWidth and PanelHeight, set this to the size of the desired board.
    Under project specifications, create a section like this:

    [board name]
    Repeat = 10

    Where "Prefix" ends with the prefix of your gerber files.

    And lastly, set "Repeat" equal to the number of times you'd like your board to tile within the panel size.

  13. Save your file and within terminal, navigate to your profile folder and type:

    gerbmerge layout.cfg
  14. If the script has been run successfully, you will be asked to agree to the above terms. If you had an error, gerbmerge will complain that it cannot find the files you specified in your layout.cfg. Open this file up and double-check your settings.

  15. If everything went well and you've agreed to the terms, it will begin automatically trying to place your files for the best possible arrangement. I found that after about 30 seconds, you can hit CTRL+C and you'll have a decent enough tiling. Within the project folder you should now have a bunch of new gerber files. These gerber files contain the tiled boards.

Before sending this off to any PCB printing house, be sure to double check with a gerber viewing tool. I like gerbv for unix. It's quite easy to install in linux using a native package manager. I unfortunately haven't had any luck running it on my Mac, but if I do I'll write up instructions here as well.