Mass Editing Similar Files

There are occasionally situations where you may need to edit multiple files that are all similar but not exactly the same. In these occasions, the method presented here can be useful for saving a lot of your valuable time.

This method leverages the power of git, diff, and patch in order to apply a single change across multiple files which are similar. You are using version control, right?. These instructions you are either using a Unix like system (macOS or Linux), or Cygwin in Windows, the basic idea is simple:

  1. git diff <edited file> > changes.patch
  2. find . -name <file name> -exec patch -p1 {} changes.patch \;

Where <edited file> is the full path to the file with your changes. You can also make more complex patches if you want, just read about git-diff.

Yes, the arguments to find are single dashes with full word arguments.

Example Usage

It’s often easier to see how to apply something when you get to see an example. Imagine a file structure such as:

~/Desktop/example_project
▶ tree .
.
├── common
│   └── config.h
├── project_1
│   ├── config.h
│   └── project_config.h
├── project_10
│   ├── config.h
│   └── project_config.h
├── project_2
│   ├── config.h
│   └── project_config.h
├── project_3
│   ├── config.h
│   └── project_config.h
├── project_4
│   ├── config.h
│   └── project_config.h
├── project_5
│   ├── config.h
│   └── project_config.h
├── project_6
│   ├── config.h
│   └── project_config.h
├── project_7
│   ├── config.h
│   └── project_config.h
├── project_8
│   ├── config.h
│   └── project_config.h
└── project_9
    ├── config.h
    └── project_config.h

11 directories, 21 files

In this example you want to add a single line to project_config.h, but don’t want to have to manually edit 10 different files. To get around this, you would edit any one of the project_config.h files with your changes:

▶ echo "#define A_NEW_CONFIG_OPTION" >> project_1/project_config.h

Finally, run the diff-patch process:

git diff project_1/project_config.h > changes.patch
find . -name project_config.h -exec patch -p1 {} changes.patch \;

Possible Caveats

This section lists some of the issues I’ve run into with this workflow. These issues mostly only apply to Windows.

  • Cygwin doesn’t come with patch installed by default, install it.
  • Windows also has a find utility, if /usr/bin isn’t fairly early in your PATH then Cygwin will use that instead. You’ll get an error message like “FIND: Parameter format not correct”. To fix this you can move /usr/bin to a higher priority in your PATH or you can explicitly call /usr/bin/find.
  • You may run into line ending errors when trying to apply the patch. Before running the command, you can convert the line endings of the files you want to edit with find . -name “name of files” –exec dos2unix {} \;
  • Be very sure to include the -name parameter, otherwise find will also search file contents, likely finding some of your files in the .git folder and modifying them. This can corrupt your git repository.

CNC Milled PCBs

This is a guest post from Thomas Amely on how to make your own CNC milled PCBs. Have fun making and enjoy the post!

Within the maker community there exists a sub-community of makers who have access to or have built their own CNC mills; I am one of those makers. Never being one to own a single purpose device I set out to mill circuits of my own design with my desktop CNC machine.

While many of my designs have reached a level of complexity which is well beyond the capabilities of this workflow, I still regularly create prototype circuits following this process. This is my workflow.

Hardware for Milled PCBs

The Machine

There are numerous sources on CNC mills of various sizes and capabilities but given the nature of milled circuits an important factor is going to be resolution in inches per step (or mm/step). My particular machine travels roughly .000833 inches per full step, this is a good resolution for through-hole circuits but circuits utilizing surface mount devices (SMDs) may require a finer resolution. Better resolution can be attained through different lead screws or microstepping. A word of caution, increasing resolution through microstepping WILL sacrifice accuracy. How much accuracy is sacrificed varies from one setup to the next.

The Working Fixture

The work surface of your CNC mill should be as level as possible since a deviation of as little as .001” could be the difference between properly engraving a board and barely scratching it. The spindle or router that will be used to mill your boards should be used to level the work surface with an appropriate end mill. Additionally the fixture should have a means of holding down the workpiece.

CNC Milled PCB Workpiece Hold-down
CNC Milled PCB Workpiece Hold-down

Tooling

Three kinds of bits should be considered when stocking up as they are not commonly found in local hardware stores: drill bits, engraver bits and end mills (optional for cutting the circuit out.)

For drill bits a good variety in common PCB through-hole sizes is a must but the definition of common sizes varies based on what you are doing. My go-to drill bits are .025”, .033” and .055” although you want to have a good range and doubles of each as you will snap bits.

The engraver bits are a little more complicated as different users will have different experiences depending on their machines. Myself, I use .2mm 45° engraving bits, they can be had cheaply on ebay. Experiment with cheap bits of various sizes and angles before you spend much money on good bits as you will break many. Also, fight the urge to buy engraving bits with 10° angles as they are great for producing violent shrapnel.

I list the end mills as optional for cutting the circuits out of the rest of the board, but in reality if you have have a CNC machine, a few end mills is a must. Expect to find the drill bits and engravers primarily in a 1/8” or 3mm shank (note: 1/8” ≠ 3mm).

Assorted PCB Drill Bits
Assorted PCB Drill Bits
Assorted Drill and End Mill Bits
Assorted Drill and End Mill Bits
Engraver Bit
Engraver Bit

Copper Clad

While you could get your copper clad from your local electronics store you might put a nice dent in your budget before you produce your first good circuit. Instead of paying for 2-3 USD for each single sided board find a source for boards online. One excellent source is eBay seller “abcfab”.

Try to avoid paying more than 0.50 USD per 4”x5” board. Keep in mind that copper clad comes in many different board and copper thicknesses.

Copper Clad
Copper Clad

Software for Milled PCBs

PCB Software

For the creation of my circuits I use the EAGLE free version. The main limitation of the free version is the max size of the board, the max board size is limited to 100mm x 80mm (roughly 3.95” x 3.15”.) There are some other limitations but they are not of much consequence for single sided boards of this size. This size limitation might be worth keeping in mind when ordering copper clad.

EAGLE can be downloaded from the Cadsoft website.

GCode Generator

To generate the GCode (the machine numerical control program language) I use the EAGLE open source plugin PCB-GCode. The plugin can be downloaded from the PCB-GCode forum.

Installation and use are very well documented in the file within the plugin zip folder under /pcb-gcode-3.X.X.X/docs/pcbgcode.pdf.

CNC Machine Control Software

In this category there are really only two mainstream options: Mach 3 and LinuxCNC. There are a few alternatives but I’m not sure many people use them. At any rate once you produce the GCode, what you run it on is really of no consequence so long as it does what it is supposed to do.

Design

Get It Down On Paper

As with any project the first step should be a well thought out circuit with a purpose. Try and work out all the details on paper (or digitally if you prefer).

When I start I list at the top of my page what I want the circuit to do, how it will do it and any additional notes that I should keep in mind during the process. This is especially useful if you have to order parts for your project and will spend a few days away from it. It’s a good idea in general to always have a notebook to jot down your ideas and thoughts.

For this example project I’ve decided to create an Arduino shield that allows me to control a high power RGB LED strip utilizing 3 IRF540 Power MOSFETs. While these MOSFETs are certainly overkill, they are components I had laying around from a previous project. I’ve also made notes on what pins I will use and the possibility of supplying the Arduino with power from the LED power supply.

Always keep notes for sanity's sake
Always keep notes for sanity's sake

Schematic on Paper

Before creating a schematic digitally I always begin by drawing one by hand. It doesn’t have to be pretty but it should make sense.

Extremely informal schematic
Extremely informal schematic

Breadboard It

Before milling anything I always test the circuit on a breadboard. There is no sense building a circuit that you hope will work when it takes only a few minutes to try it out. This is a simple check that will spare you a lot of frustration.

The circuit prototyp on a breadboard
The circuit prototyp on a breadboard

EAGLE Schematic

At this point I create my new project in EAGLE with a new schematic. EAGLE is very intuitive and similar to other schematic editors but there are many tutorials available to familiarize yourself with it if needed. I always start by adding a frame with key information and bringing in all the components I think I will need before connecting anything.

In this case I have an Arduino shield component, 3 N-channel MOSFETs 6 resistors and 5 wire-pad connections. Always verify that the pinouts of the components you are using are correct. Before connecting any wires, give the components descriptive names and values for easier reading and deciphering later on.

Necessary Components
Necessary Components

Once all of the components are on the schematic I try to wire them in the most orderly fashion possible. This is normally a painless process if you took the time to draw your schematic by hand.

Michael here, see my article on electronics schematic best practices for some more guidelines.

Components Connected
Components Connected

From this schematic I create a board and begin laying out components. Every person I know who uses a layout editor takes a different approach to laying out components. My main rule is to not fall in love with any layout. Working on a single sided PCB greatly limits routing options and the first layout I use is hardly ever the final layout. Here is a rough initial layout.

Initial Layout
Initial Layout

It is wishful thinking that I might be satisfied with the auto-route feature, but without having configured any of the optimization options, the auto-route is almost never useful for single sided boards. In this case the auto-route solution might have been suitable but I opted to modify the layout slightly and use wider traces for the high current sections.

Auto-Route Solution
Auto-Route Solution
My Routing Solution
My Routing Solution

Now that we have a design to mill we will run the PCB-GCODE plugin. Every single machine will have a different configuration based on the stepper drivers, the computer specs, the engraving bit and overall setup. Unfortunately there is no good setup that will work for every machine.

Make use of the configuration instructions provided with the plugin and have lots of patience. Additionally, make use of the drill files to ensure the plugin uses only drills you have on hand.

PCB-GCODE Plugin
PCB-GCODE Plugin

This job is run as a single pass but it can be configured to remove all material outside of traces. In the preview window I search for discontinuities and any other visible errors. Keep in mind that this preview is of the bottom of the board and therefore will appear backwards in the axis you have configured.

Mill Preview
Mill Preview

The plugin creates two files (or more depending on the configuration) a .drill file and a .etch file. Some machines can interpret these files or they can be simply renamed to have a .ngc or any other file extension.

LinuxCNC users want to make sure to specify G61 or G64 in their .etch files to avoid rounding corners due to trajectory control. I specify G64P.005 within the etch file, this keeps the mill within .005” of the GCode. For more information see the LinuxCNC wiki entry on trajectory control.

Milling

The last part of my milled pcb prototyping process is the actual milling. Once you have your machine set-up is fairly painless, however the process of setting up your machine can be very time consuming and frustrating. I often begin with drilling followed by etching but the order is of no real consequence and either can be chosen since they are separate files.

Drilling a CNC milled PCB
Drilling a CNC milled PCB
Etching a CNC milled PCB
Etching a CNC milled PCB

The finished board should then be inspected for shorts using a multimeter or similar device. On this particular board I found a short where a tiny bit of copper has not been removed. This is an easy fix but could have caused some serious problems later on.

Drilled and Etched
Drilled and Etched
A Shorted Connection
A Shorted Connection

While the copper-clad is still in the work fixture I evaluate if there are any additional changes I would like to make. I have opted to remove the bottom half of the board which has no connections.

Additional Changes
Additional Changes

Upon removing the board I sand the surface and corners as well as clean the trace gaps with a pick. Before soldering I perform one last thorough inspection with a magnifying device. My magnifying device of choice is a thread counter magnifier.

Closer examination of CNC milled PCB
Closer examination of CNC milled PCB

Now that the board is complete I notice a significant flaw in my board. I have no connection for 12V to go to the LED strip. I have the option to create another board or simply splice a wire to the 12V input. I chose the simpler option but have since updated my notes. This clearly demonstrates the iterative nature of prototyping.

Board front
Board front
Board rear
Board rear
Completed project
Completed project

Final Notes

As with any prototype build, I have taken notes along the way of what changes need to be applied to the next iteration.

For this prototype the next iteration will include a barrel jack, terminal binding posts to connect the led strip, and heat sinks if needed. This particular prototype will be used as part of a sunrise alarm clock for a few weeks before refining the design.

This process is one of many possible workflows, I hope it has given a good idea of what is possible.

Keep in mind that while this setup is designed to produce single sided circuits there are plenty of makers out there who design double sided circuits on their CNC mills. A similar process can be implemented with various software, machines and tooling. In designing your own work flow be patient, stay flexible and be willing to fail.

Design the Perfect PCB

Breadboards are amazing for prototyping and are an invaluable tool to any electronics tinkerer, but when you really want to get serious you will need to learn how to create your own PCB.

Making a PCB is no simple task, however, with the right commitment, a little bit of time, and this guide you will be able to make a working PCB the first time around. If you are persistent it will even look good!

Anatomy of a PCB

When you are on your computer, everything is at kind of an abstract level and it can be easy to forget that you are working with a physical medium. Before you just start throwing together a design, I think it is useful to know what you are actually doing.

In order to better understand your physical medium of choice see my article on the anatomy of a PCB. If you are already familiar with PCBs then feel free to skip on to the next section.

Designing Your Circuit

Before you can consider any physical designs or schematic connections you must have a clear idea of what you want your design to do. This means taking some time to sit down and define what you want to accomplish, consider the challenges, and pick the right components for the job.

Determining Your Goals

The first step in designing the perfect PCB is to have a well-defined set of goals that you would like your design to accomplish. To steal a little bit from the business world, you should always set SMART goals for your project, this means:

  • Specific
  • Measurable
  • Attainable
  • Realistic
  • Time Bound

As a personal example, I have started working on another side project for my own use. The bathroom in my apartment is too dark in the evening for me to get around in, but when I turn the light on it is way too bright and wakes me up.

To fix this little issue I thought I would just go buy a small lamp. Unfortunately, I am a little bit too picky and couldn’t find a lamp that I liked. That is when I had the idea to design one of my own. Of course, I’m not talking about just any lamp. I wanted a multi-color, adjustable brightness, wirelessly controlled lamp.

Sounds cool right? Of course it does! So before the idea was able to leave my head I jotted it down in my notebook and began planning.

At this point, my goals were pretty broad, let’s take a look at what I had:

  • Multi-color lamp
  • Adjustable brightness
  • Wireless control

Unfortunately none of these goals are very specific at all:

  • What do I mean by multi-color? Is that two colors, three, or any variable color?

  • What is adjustable brightness? I mean technically on and off would be two different brightness settings right?

  • Wireless control? Do I want to use Wi-Fi, Bluetooth, infrared, RF, Zigbee, sound? Any of these options would be possible.

Revising the project goals to be SMART led me to the following list of goals:

  • A continuously adjustable high-brightness RGB LED filtered through a fogged acrylic cover for even light dispersal.

  • Continuously variable brightness control that will allow me to choose any brightness setting between completely off and fully on.

  • Bluetooth low energy 4.0 wireless specification interface, controllable from an iOS or Android devices as well as an optional dedicated controller.

2016 Michael here, I never completed this project and just ended up buying a bunch of Philips Hue bulbs instead, but it’s still a good example.

With the exception of “time bound” these goals meet all of the criteria of a SMART design and allow me to proceed forward with a clear vision of what I want to accomplish.

By doing your research first and setting SMART goals for your project you place yourself on the right track to create that perfect design.

Visualizing Your Design

Now that you have a clear idea of what you want, it is time to start designing it. Before you start scouring the internet for parts or drawing crazy schematics in your notebook, I would advise you to take some time to develop a clear picture of how you want your final design to function.

Try to determine how your parts will work together to achieve the goals you set. This is a good time to be thinking about your design from a system level.

System level design for bluetooth LED lamp
System level design for bluetooth LED lamp

You may not know specifics like what supply voltages you will need or what connections need to be made, but you will be able to consider how each component will rely on the others and what additional components they will add to your design.

This is also a good time to consider the aesthetic aspect of your design. Are you trying to fit a certain form factor? Do you need to consider ergonomics (for example if you are designing a game controller)? Will you be able to pick up your design a year from now and understand exactly how it works? These are the types of details that, while seemingly insignificant, can be the difference between a good design and a great design.

I know all this talk of visualization may sound cheesy and like it won’t really get you anywhere, but I assure you it is worthwhile. If you don’t want to believe me, consider this quote from Nikola Tesla’s autobiography where he describes his creative process:

My method is different. I do not rush into actual work. When I get an idea I start at once building it up in my imagination. I change the construction, make improvements and operate the device in my mind. It is absolutely immaterial to me whether I run my turbine in thought or test it in my shop. I even note if it is out of balance. There is no difference whatever, the results are the same.

Of course the vast majority of us aren’t at the level of crazed genius that is Tesla, but the idea behind this method is all the same. By visualizing your design beforehand you save time, money, and frustration.

Tesla turns on a Nightlight
Tesla turns on a Nightlight

Choosing Parts

This is perhaps the most tedious step in the design process, but is crucial to a successful design. Choosing the right part for your design could be the difference between finishing your project and giving up in frustration.

See my article on choosing electronics components for my suggestions.

Sketching Your Connections

The final step before we switch over to software is to get a “first draft” of your design onto paper. Nikola Tesla would not approve, but he’s not around to stop you so don’t worry. This is a good way to get the specifics of your project organized in a coherent manner. I like to separate each system level block on a new page.

I also think it is useful to make a note here of what each important pin on the component does. It probably wouldn’t hurt to get started on your bill of materials as well, this may change as your design evolves, but it at least serves as a good starting point.

In addition to the basic information, you may also want to include some more detailed info about the part that you think may be important. For example, it may become tedious to refer back to the datasheet for I2C address information or possible pin configurations, these are good details to include in your notebook.

For sketching my designs, both electrical and mechanical, I like to use this excellent Maker's Notebook from MAKE.Amazon Link

My Maker's Notebook
My Maker's Notebook

With a well-defined grid, a page marker, the included organization features, and the extra pointers they include in the back, this isn’t your average notebook. The Maker’s Notebook is specially designed by makers, for makers, and I love mine.

2016 Michael here, while I still appreciate the Maker’s notebook, my current preference is the Baron Fig Dot Grid Confidant.

After you have finished sketching your design, you have completed all of the pre-layout checks and are ready to move on to the physical design of your PCB.

Putting the Design into Software

When I set out to design my first PCB I was told “Well, it’s your first PCB so it probably won’t work anyways, but that sounds interesting.” Even though this was discouraging to hear, I didn’t let it stop me and I ended up with a working design. I now want to take my experiences as well as the experiences of others and make it as simple as possible for you to design your own PCB.

Now that you have an idea of how you want the project to turn out, it’s time to start moving the design onto your computer

Choosing a CAD Package

The first step is to choose what CAD package you will be using in order to design your PCB. If you don’t already have a preference then see my suggestions here.

During the remainder of this article I will be using KiCad for explaining concepts of PCB design. I will do my best to cover the topics at a high level so you can easily transfer these ideas into the CAD package of your choosing, but if you are undecided I wholeheartedly encourage you to try KiCad for your next design.

Best Practices for Electrical Schematics

The difference between a good schematic and a bad schematic is a matter of how easy it is to understand. See this article for my thoughts on schematic design best practices.

Final Preparations for PCB Layout

Now that you have your schematic entered into the computer and all the connections have been validated, you can move on to physical layout of your PCB. This is the most complex part of the design process and there are far too many different possibilities for any single guide to provide a full list of guidelines in a sensible manner. That being said, I will do my best to provide general guidelines for producing a manufacturable and electrically sound PCB.

Choosing a Manufacturer

I’m sure it may seem like a strange suggestion to choose your manufacturer before you begin board layout, but I assure you there is a good reason for this, which will become clear in the upcoming sections.

No two PCB manufacturers are the same and each one has different limitations. See this article for my thoughts on choosing a PCB manufacturer.

Defining your Design Rules

After choosing a manufacturer you should make note of their manufacturing constraints. As an example, at the time of writing the minimum specifications for OSH Park were:

  • 6 mil copper traces
  • 6 mil spacing between traces
  • 13 mil drill diameter
  • 7 mil annular rings [Defined as (diameter of the pad - diameter of the hole) / 2]

This means that these should be the smallest features you use under any circumstances. Using smaller features will likely result in broken traces, overlap of traces and copper fills, or busted vias.

Once you determine these rules, you should head into your CAD software and define them. This will enable some design for manufacture (DFM) checks to take place as you design so your program will not allow you to perform operations that will cause you to have non-manufacturable boards.

This is one step of the process where EAGLE generally has a distinct advantage over KiCad, most board houses provide a design rules file that can be imported directly into EAGLE. This saves a few steps in defining design rules, and reduces the chances that you will end up with incorrectly defined rules.

Note: Just because your fabrication house can do a 6 mil trace doesn’t mean you should use exclusively 6 mil traces. You should use the largest traces possible that will still allow you to fit your design in the required space. Using larger traces improves reliability, decreases parasitic resistance, and as a whole results in a better circuit.

Do I Need a Ground Plane?

One of the more debatable topics in designing a PCB is deciding whether to include a ground plane or not. While it is nearly standard practice to include a ground plane in your design, this is not always required and can in some cases actually result in worse performance. But how can you know when you should and when you shouldn’t?

First, it helps to know what a ground plane is. Simply put, a ground plane is a copper layer on your PCB that acts as a common ground to many devices. It is called a ground plane because it often occupies an entire layer, which creates a planar surface to conduct charge.

Illustration showing the difference between a trace, the PCB, and the copper plane
Illustration showing the difference between a trace, the PCB, and the copper plane

What are the benefits of a ground plane? There are several benefits to using a ground plane in your design, the most common are to provide electromagnetic shielding, lower the resistance of the path to ground, and to assist with heat dissipation across the board. These benefits are excellent for the vast majority of designs, but there are also some drawbacks to using a ground plane in your design.

What are the drawbacks of a ground plane? Perhaps the largest drawback of using a ground plane is the increase in parasitic capacitance. Parasitic capacitance is an undesirable effect that will essentially cause your circuit to be less “responsive” than intended. For most applications this is just fine, but for exceptionally quick response circuits it may be worth removing the ground plane.

Ultimately, it is up to you to decide whether you need a ground plane or not. Here are a few guidelines to help you make the decision:

  • If your design is not particularly high performance, it’s your call.

  • If your design includes RF range signals, you should always use a ground plane.

  • If you have components that rely on fast changing input signals you may choose to not use a ground plane at all or to remove part of the ground plane around those inputs.

  • If you’re just not sure, use a ground plane. The chances are in your favor that the circuit will behave as expected with a ground plane, even if that is not required. The opposite is not quite true.

Special Considerations

In addition to considering the ground plane and adhering to design rules there are some other special cases in which you may need to consider other effects.

  • Designing for RF - If your design will be operating in the radio frequency range or using similar high frequency components, there are many special design factors to consider. This topic is too in depth to cover right here, right now, but this post from EEWeb outlines some good notes to get you started.

  • Mixed-signal designs - If your PCB carries both analog and digital signals then you will want to make certain that you have fully separated these signal paths. The fast changing voltages used in digital circuitry can cause your analog circuitry to behave erratically. Mixed-signal design is a whole field of study on its own (as-is RF) so if you are working with these designs it is probably best to seek the help of an experienced designer.

  • High voltage work - High voltage circuits require extra care when designing and testing so as to avoid exciting outcomes like heart-stopping electrocutions, electrical fire starting mishaps, or other disasters. If you are designing for high voltage applications then stop reading and seek the assistance of a grizzled old electrical engineer experienced in high-voltage designs.

Once you’re absolutely certain that you should be capable of designing the circuit yourself, you can move on to the next step.

Get to Work!

Finally, what we’ve been working towards the whole time. Now that you are a few hours (or days, or weeks) into the design process, you can finally start working on what you have been planning so carefully for.

At this point, you want to start converting your design from the schematic connections into a manufacturable board. See my article on PCB layout best practices for my suggestions on how to make this process as smooth as possible.

Final Design Checklist

Before moving on to the manufacturing phase I recommend that you run through my PCB Final Design Checklist to verify the design. This will take roughly an hour but can save you a lot of heartache later.

Manufacturing The Board

Since you should have chosen a manufacturer by now, this part of the process is going to be relatively easy.

The first step in preparing your design for manufacture is of course to perform the final design checklist. Since we covered that in the last section, it’s okay to go ahead with the rest of the manufacturing process.

Run a Design Rules Check

Before going any further, you will want to run one final DRC. This generally checks that your PCB layout matches the schematic and that your layout follows all of the design rules that you defined. If the DRC catches errors, you should review each one individually and either fix the problem or mark it as a false warning.

Another thing to check is that all of your connections have been made. Sometimes the DRC tool does not check connections, or your ratsnest may be too small to notice. You want to be extra certain that all of the board connections are complete before moving on.

Generate the Bill-of-Materials (BOM)

A bill-of-materials (BOM) is used by the assembly house, or for your own use. Either way, it is important to have a good list of your parts. Here are the important details to include in a BOM:

  • Component reference designator
  • Component package
  • Quantity required for one PCB
  • Description
  • Manufacturer
  • Manufacturer reference number
  • Supplier
  • Supplier reference number
  • Cost per unit
  • Alternative parts allowed, if applicable
  • Comments

Most CAD software can export a BOM automatically, but you will generally want to format it and make sure that everything is correct.

One reason to make a good BOM, even if you are not using assembly services, is because many parts suppliers will allow you to upload this file directly to their website and automatically purchase components. I know Mouser and Digi-Key support this, others may as well. This method will save you hours of time searching for components and adding them to your order.

Export the Board Files

Each fabrication house will have different requirements for how you should submit your design but nearly all of them accept one common file format called “Gerbers.” Some will even accept your CAD files directly, but this isn’t universal and you shouldn’t rely on it.

Each software has a different process to follow in order to get Gerber files out, here are some tutorials that show you how to export Gerber files from EAGLE or KiCad.

Final Manufacturing Checklist

As one final check before sending your design for manufacture I recommend verifying that you use the PCB Final Manufacturing Checklist before submitting your design.

Send it to Your Manufacturer

That’s it! Depending on the service you chose for manufacturing, the instructions will vary, but from here on out the process is relatively straightforward. Upload your files, cross your fingers, and hit submit.

The End

That brings us to the conclusion of this guide, I know you’ve been hit with a lot of information. If you read this entire article and the suggested supporting articles then you soaked up over 11,000 words of PCB designing goodies. That’s more information than a silverback gorilla retains in its whole life1!

I hope you’ve found at least parts of this guide to be helpful and that you will make use of it in your future designs. I attempted to make it general enough to be useful for any CAD package at any point in time. When searching how to do stuff like this it is incredibly easy to stumble across information that just isn’t relevant anymore, so I hope this will help.

I worked on this post off-and-on for about two weeks, even though I reviewed it several times before posting, I don’t make any claim that it’s perfect. If you see issues in my writing or think my advice is bad then feel free to let me know.

  1. Maybe, I have no idea.

PCB Layout Best Practices

To Autoroute or Not?

Should you use the wonderful autorouting features of your CAD package or not? For those who don’t know what an autorouter does, it automatically connects the traces in your board in a pattern that the software deems is most efficient. Some CAD packages also include an “Autoplacer” which will automatically place your components for you before routing.

In general you are probably better off avoiding both of these tools for simple hobby work or even moderately complex designs. Honestly, if you have a thorough understanding of your circuit, and you should by now, then you will be able to do a better job of placing and routing components.

There are of course a few exceptions to this guideline. If the design you are working on is complex and it would take you weeks or months to perform a proper layout by hand, then you should try to get access to an advanced CAD package to make use of the significant research these companies have put in to autorouting algorithms.

In addition, if you are just dreading the idea of sitting at a computer ensuring that your design is perfect, then you may just wish to place your necessary components, lock them into place, route the critical connections, and then run the autorouter. This is the recommended way to use the autorouter if you choose to do so.

Drawing the Board Outline

The first step is to draw the outline of your board. This layer tells your fab house where to cut to give you the right sized PCB.

BeagleBone Black cape, board outline layer
BeagleBone Black cape, board outline layer

To draw the board edge you will begin by switching to the layer that is designated for cutouts. Depending on your CAD package, this could be “Edges”, “Board”, “Cutout”, or something else along those lines.

After selecting the board edge layer make good use of your drawing grid to ensure that you have straight lines of a well-defined length. If your board needs to be a specific size then make sure you are using the correct measurement units for your grid. If you draw your board in mm instead of inches, you will get a little surprise when you try to place your parts and can’t fit them all on the board.

A few tips for drawing your board edges:

  • Set your drawing grid at a reasonable spacing. This will depend on what kind of resolution you need and make sure your cursor is set to snap to the grid.

  • If you are using EAGLE or another program that supports it, make use of the keyboard commands for defining lengths of segments.

  • Consider using alternate axes. Most CAD software supports some method of setting an alternative origin point, this will allow you to draw lines of specific length without needing to subtract coordinates in your head. If your CAD package supports #2 then you may not need to use this feature, but I have found it helpful in KiCad.

  • Ensure that all the edges line up exactly. If you have a spot on the board where two edges meet but don’t quite touch, then you should fix that now. Trying to send your board to the fab house like this will result in them responding to you with a solid “No thanks.” Fix this issue before it becomes a headache to fix.

Alternative Method: If your board doesn’t need to be any specific size or shape then you may want to wait until the end to draw your board edge. But if you have any predetermined requirements for the board, you will want to start with this step.

Placing Components

Next up, you will want to place all of your components inside the board outline. You should start with components that have a set physical location such as connectors or sensors that can’t be blocked.

After that, you will want to begin placing your ICs. Start with the largest ICs first and then place the smaller ICs as you go. ICs with more pins will require more room around them for routing traces and placing auxiliary components. Try to leave extra room around devices that have many pins.

Another thing to consider when placing devices is to try to keep all your ICs oriented in the same direction on the board. This is not a strict rule, but it can sure make assembly much simpler and is generally not a bad rule to follow. If it just isn’t possible then don’t worry about it.

Once all of your physical components and your ICs are in place you can place the supporting devices. Things like resistors, capacitors, diodes, etc. This is a good time to refer back to your design notes and make sure that any components which need to be physically close to an IC are in a good position. If you have components that have these requirements then I would recommend locking them in position after placement.

One final thing, you will want to consider leaving space for annotations and markings on the board. I’ll discuss these things in more detail in a bit, but you’ll want to make sure there is enough space around your components to leave some lettering near anything that may need it. For more info on this, jump down to the “Adding Some Style” section.

Making Connections

So, everything is in position and the board is starting to look like it will come together. The next step is to make it all work! You could just start by connecting pins all willy-nilly as you see fit, but taking some time to do it right will pay off in the end, which is coming sooner than you think.

There are two recommended ways of starting out laying your traces. You can begin by routing your power traces first and then focus on everything else, or if your design has high frequency signals you can begin by routing those first. Other than that, the rest of the connections are up to you.

While there isn’t any single “right” way to lay-out the rest of your PCB traces, there are some methods that are “more right” than others. You can see my recommendations below, and I hope to see a few more additions come from the community.

  • Make use of thick power supply traces. The power supply rail will most likely be the most active trace on your PCB and since it will be supplying the more current than any other trace it also deserves some special attention when determining how wide it should be. As a general guide I like to use 20 mil power traces. For low power circuits this is probably overkill and you could get away with less, for higher power circuits this may not always be enough. If you are designing circuitry that is going to draw current in the Ampère range as opposed to milliAmpère then I suggest taking a closer look at your trace width. This handy calculator will help you calculate the correct width to use for your traces.

  • Avoid routing two (or more) high frequency signal traces in parallel with each other. According to Ampère’s law (with Maxwell’s correction) we know that a changing current induces a magnetic field around the wire, we also know that a changing magnetic field induces a current perpendicular to the direction of the magnetic field. This effect can cause two parallel wires to couple together so that a change on one wire can induce a change on the other. You can avoid this by keeping high frequency traces separate and only crossing them in perpendicular alignment.

  • Try to group similar signals together. If you have a bunch of wires coming from a single device that all perform a similar function then you should try to keep them neatly grouped until it is absolutely necessary to split them up. This will allow you to more easily follow the signal path and will help you end up with a cleaner looking board after fabrication.

  • Minimize your use of vias, but not at the cost of dramatically increasing signal paths. This recommendation may just come as a result of my fascination with aesthetic design, but there is also a practical reason to use fewer vias. The simple point is that vias are a manufacturing risk. While it isn’t likely that your board house will mess up and drill a hole too large or break the conduction ring, it is completely possible. Having fewer vias on the board reduces this risk. Another benefit of reducing vias is that it results in a shorter signal path (even if only a tiny reduction). This type of caveat is really only important in RF designs, but if there is a way to improve a circuit, I’m always looking for it.

  • On the other hand you could, use two inline vias at every signal pin. I know this may make me look like a hypocrite or an otherwise very confused person but there are also situations in which more vias could help. If you are working on a prototype circuit, extra vias allow you to easily create test points, and to simply cut and reconfigure traces. This recommendation comes courtesy of a reader, James Edwards I believe, but I couldn’t find the original comment.

There are probably some more useful pointers that I’m just not thinking of, but nothing comes to mind right now. I will add more as I think of them.

Adding Some Style

You’re almost there, the last major step before moving on to manufacture is to add the finishing touches to the board. This may seem like it’s just aesthetics, but there are several practical reasons to include some extra markings on your board.

The first decision you need to make is whether or not you should include component reference numbers or values. As an example, do you want your final design to indicate that “this” resistor is R11 and has a value of 4.7k or do you want to just mark it as R11? Maybe you don’t want to mark it at all?

This is really up to you. My thought is that you will be one of the few people who actually looks at the board components and if you are looking at the board you will be able to easily pull up a schematic for reference. For that reason, I do not include reference numbers or component values on my final designs.

Having said that, there are some components that can benefit from a bit of labeling. Generally you will want to label any LEDs, buttons, switches, connectors, or otherwise important devices. I guess the argument could be made that ALL the components are important, but I am specifically referring to parts that would be good to know when using the device.

SparkFun gives some good advice on labeling in their PCB guide. I am particularly fond of the example shown below.

Proper labeling of an accelerometer breakout board
Proper labeling of an accelerometer breakout board

After all of the functionally important components have been labeled, you may have a bit of room left over for more labeling. Don’t overcrowd the board, but you may want to include your name or some sort of branding. Perhaps a logo? You can do this easily in EAGLE or KiCad using the built in tool or this online tool from Wayne & Layne.

PCB Final Manufacturing Checklist

  1. Hole diameter on drawing are finished sizes, after plating. Finished hole sizes are >=10 mils larger than lead Silkscreen legend text weight >=10 mils
  2. Pads >=15 mils larger than finished hole sizes
  3. Place through-hole components on 50 mil grid
  4. No silkscreen legend text over vias (if vias not soldermasked) or holes
  5. All legend text reads in one or two directions
  6. Components labeled left-right, top-bottom
  7. Company logo in silkscreen legend, company logo in foil, copyright notice on PCB, date code on PCB, PCB part number
  8. Assembly part number on PCB, for assembled boards
  9. Components >=0.2” from edge of PCB
  10. Ground planes where possible
  11. Test pad or test via on every net to allow in circuit test
  12. Test pads 200 mils from edge of board
  13. All polarized components checked
  14. No acute inside angles in foil
  15. Traces >= 20 mils from edge of PCB
  16. PCB revision on silkscreen legend
  17. Mounting holes matched 1:1 with mating parts
  18. Automated netlist check
  19. Manual netlist check
  20. Check netlist for nodes with only one connection
  21. CAD design rule check
  22. Tools on drill plot and NC drill file cross checked
  23. Soldermask over bare copper noted if needed
  24. PCB thickness, material, copper weight noted
  25. Trace width sufficient for current carried
  26. Minimum component body spacing
  27. SMD pad shapes checked
  28. Visual references for automated assembly
  29. Tooling holes for automated assembly
  30. Sufficient clearance for high voltage traces
  31. Component and trace keepout areas observed
  32. High frequency circuitry precautions observed
  33. Thermal relief pads for internal power layers
  34. Blind and buried vias only allowed on multilayer PCB
  35. Sufficient clearance for socketed ICs
  36. SMD component orientation arbitrary or consistent
  37. Ensure pin 1 interpretation and orientation consistent among all connectors of a given type on the board
  38. Standoffs on power resistors or other hot components
  39. Digital and analog signal commons joined at only one point
  40. EMI and RFI filtering as close as possible to exit and entry points in shielded areas
  41. Layout PCB so that any rework or repair of a component does not require removal of other components
  42. Extra connector and IC pins accessible on prototype boards, just in case
  43. Check all power and ground connections to ICs
  44. Provide ground test points, accessible and sized for scope ground clip
  45. Potentiometers should increase controlled quantity clockwise
  46. Bypass capacitors located close to IC power pins
  47. All silkscreen text located to be readable when the board is populated
  48. All ICs have pin one clearly marked, visible even when chip is installed
  49. High pin count ICs and connectors have corner pins numbered for ease of location
  50. Silk screen tick marks for every 5th or 10th pin on high pin count ICs and connectors
  51. Check for traces running under noisy or sensitive components
  52. Check IC pin count on layout vs. schematic
  53. No vias under metal-film resistors and similar poorly insulated parts
  54. Check for traces which may be susceptible to solder bridging due to low clearances Maximize distances between features where possible
  55. Check for dead-end traces
  56. Check for power not shorted to ground
  57. Provide multiple vias for high current and/or low impedance traces