Friday, April 8, 2011

9 - Eagle: PCB Layout

o learn how to use Eagle, we are going to create a simple breakout board for a popular USB IC. The FT232RL is a USB to TTL serial converter. This section covers the physical layout of the PCB.
We've got the schematic captured and the connections should be made correctly. The next step is to arrange various components on a board and then send the board files out to a manufacturer (also called a fabrication or 'fab' house).
Layout is an art and engineers make bad artists.  It's all about the small polishing - text labels, stand off holes, correct footprints. Just keep turning out PCBs and you'll see your layouts improve dramatically with practice.
Before you do anything, turn on vector fonts! If you don't, your silkscreen text will be off on every PCB you create:
From the Eagle control panel, click Options->User Interface
Select 'Always vector font'.
Above is a breakdown of all the different buttons in the Layout window. You can view the name of each button by hovering over the button with your mouse. Many of the short-cuts from the Schematic window still apply:
  • Press escape at any time to stop the current action and return to the Layout window
  • F7 to move a part
  • Alt+F7 to group a bunch together
  • F3 to delete a part
  • F4 to rename a part (change C7 to C2)
  • F5 to re-value a part (change 0.1uF to 10uF, etc)
  • F6 to smash a part (be able to move the name and value tags)
  • F9 to start routing a wire
  • Alt+F9 to rip up a wire
If you get this error while moving bits around:
This just means that you are trying to put a component outside of the allowed area. With the Light edition of Eagle, you can only place components in quadrant I (upper right quadrant), whereas the components show up by default in quadrant II (upper left quadrant). Just move the parts to a positive X and Y coordinate and you should be ok.
Starting with our current layout:
The first thing to do is correct the board outline. I don't know why Eagle slightly offsets the default border.
Make sure you're on a 0.1" grid by pressing F10. Then hit F7 and hold control while clicking near the origin. This will grab the frame corner and force it onto the 0.1" grid. Make the bottom left corner sit at (0,0):
Do this for the other three corners bringing them in to make a 1.5x1.0" square board size.
Now go to town bringing the components into the board area. Keep in mind the gold color un-routed 'air' wires. The less twisted you make these by creatively arranging your components, the easier the trace routing will be.
Remember:
  • Press F7 to move a component
  • Right click to rotate
  • Hold control to grab a component at its origin
  • Scroll wheel to zoom in/out
Hit the Ratsnest button from time to time to recalculate the air wires.
Here are the components arranged in a basic configuration. Another beef I have with Eagle is the default colors for the various layers make it impossible to see what is going to be printed on the silkscreen layer. Let's change the 'tPlace' layer to pure white and change the 'tDocu' layer to lemon yellow.
Click on the 'Display' button, scroll down to layer 51 and double click on the gray box next to 'tDocu':
Then click on the gray 'Color' box and change it to something interesting like lemon yellow, then click ok. Anything you do on this layer will now be yellow. Do the same for layer 21 'tPlace'.
Now this is starting to make sense! Anything in yellow is just there to indicate physical size. The yellow part of the USB connector is only there to indicate that the connector sticks over the edge that far. Only the white part of the USB connector footprint will actually show up on the silkscreen print on our PCB. Anything in light gray (tNames and tValues layers) will not printon the silkscreen layer. They're just there for your own reference. We can of course change how the various layers are processed (and include the value and name layers on the silkscreen) but this can cause a lot of squeezing and hassle. It's up to you and your design but we will leave the part indicators and values out of this layout.
The next thing we need to do, for all PCB layouts, is to add stand-off holes. These holes will allow you to insert a simple screw and hold a stand-off in place. Without standoffs, PCBs will sit uneven against a flat surface (because of the bumpy solder joints protruding on the bottom of the board). Having a PCB sit flat against a surface is also a bad idea electrically - I've sent $200 up in smoke because some bits of clipped wire shorted against the bottom of my board when I was troubleshooting it.
I like to use 4-40 screws and 0.25" diameter plastic standoffs on everything. These 4-40 screws need a 0.13" diameter hole and the standoffs have a 0.25" outside diameter that we will need to take into account. If you have not already done so, add four of the 'Stand-Off' components to the schematic (and therefore PCB). This component was created to couple the 0.13" drill with a keepout ring. This keepout ring helps show were the screw head will fall. If you fail to take this keepout layer into account, the screw will go through the hole, but the screw head may run into or short components.
Throw four standoff holes around the corners of your board.
Ahah! Now I see why I made that keepout circle. You can see where the standoffs would have run into the USB connector. Looks like we've got some bumping to do...
By using the group (Alt+F7) and the move (F7) commands, I increased the border to 1.5x1.2" which is a bit bigger than I would like, but for the purposes of this tutorial, we're not going to stress tight packing of components - rather we want to stress the basics for a good PCB. Notice how I flipped and dropped C3 and C4 down a bit? Time to add labels!
A 'C2' label is handy when you're populating a board or when you're troubleshooting a complex circuit, but on a day to day basis, you probably won't need to know where C2 is. On the other hand, the TX and RX pins will probably be used every time you use the board! You really should label anything that will be connected to the outside world. To add a text label to a pin, click on the 'Text' button:
A window will pop up asking you what text you would like to add. Type 'TX' and press enter. You will notice that the text may be appearing on an odd layer. Be sure that you add text on the tPlace layer.
Drop down the layer menu and select tPlace for top silkscreen text
Once you've placed 'TX', press escape. Eagle will now show the text window again. Enter 'RX' and press enter. Repeat for RX, VCC, and GND. When done, press escape twice to return to the layout window.
In this case we have VCC/GND/TX/RX to label:
Make sure you add your labels to the 'tPlace' layer!
To check which pin is connected to which net, hit the eye button and click on a pin.
Checkout the text at the bottom of the Eagle window - pin 1 is VCC. Do this for all the pins and arrange the labels accordingly. You should also take the font size down to 0.05:
To change the font size, click on the Wrench ('Change' button), select 'Size', then 0.05. Now click on each text that you want to change the size on.
Labels in place and lined up
Try to get all the labels with the same vertical and horizontal alignment. This is a nit picky aesthetic thing, but it shows on the final board.
You will have many board revisions. It's always good to add a date code to the board so that you can match your files to the board version in hand. Add text to the bottom copper layer to an inconspicuous spot. The easiest way to do this is to add text to the top copper layer then hit the mirror button (you can also hit the scroll wheel on the mouse to move the component to a different layer). This will automatically mirror the text and drop it to the bottom layer.
6-3-07 mirrored, on the bottom copper layer, and underneath the USB connector. There shouldn't be any signal traces in this part of the board so we're not wasting space. You could add text to the bottom silkscreen layer but some fab houses don't allow bottom silkscreen (it adds an extra printing step).
Also add some text to the top silkscreen layer indicating what the board is, what it does, who made it, etc.
Above is the completed board ready for trace routing.
Many people swear up and down that an auto-router is a bad idea. It may be, but if we're not concerned about trace impedance or high speed signals, an auto-router is a great way to whip up protos. Spend your time innovating, not routing mundane traces.
To auto-route the board, click on the 'Auto' button. The defaults are all fine except for the 50mil grid:
Change the Routing Grid to 8 (our fab house uses 8 mil traces and spaces).
Demo board auto-routed. Eagle files / PDF
It's not immaculate, but it will work just fine and the router took under 2 seconds to route. It would probably take me 5-10 minutes by hand. I will hand route sensitive parts of certain boards, but this is a very simple proto.
Things to check on every layout:
  • Date code
  • Silkscreen title and pin labels
  • Standoff holes
  • All connections routed
  • TX and RX routed correctly
  • Print off 1:1 and check footprints
Routing TX and RX correctly? What does this mean? I can't tell you how many times I've heard newbies say 'well my PCB would have worked, but the manufacturer swapped the TX and RX pins'. No, the manufacturer did not swap them, the newbie neglected to actually read the datasheet (RTFD!). Sometimes an RX pin is an input. Sometimes an RX pin is an output. If you get it wrong, you'll look like a dunce. Read the datasheet and verify that everything is kosher. In the case of our FT232RL breakout, the TX pin is an output and RX pin is an input (pretty standard). I'm going to change the silkscreen indicators to read 'RX-I' and 'TX-O'. This should remove any doubt in my mind when I'm using the board a year from now - and so I don't have to go digging up the datasheet.
The last thing to check - print off 1:1 means to print on paper and 1 to 1 scale of the board layout. Then place the components on top the paper to verify that everything fits their associated footprint.
Another quick note about printing layouts - this can be a great way to create an assembly sheet. While you've got the PCB editor open, press Alt+F11. This will turn off all the layers that are not pertinent to assembly. Print this, I normally scale it up 3 times, and hand write in what parts go where. Quick and effective way to create a cheat sheet for PCB population. Pressing F11 will bring back the normal layers but you may want to activate/deactivate a few others.
Now that we've got the board laid out, stand-off holes in place, date code in place, and accurate pin labels, it's time to mash up the layers and create some gerber files.
What's a gerber?
There are lots of different layout packages out there (Protel, Orcad, Eagle, PCB, etc). One way or another all the PCB fab houses out there need a way to control their machines to work with your layout files. The universal format is something called Gerber Files. Basically these are txt files with coordinates that tell the PCB machines to go to location X,Y and do something (drill, expose, etch, print, etc). Because there are different layers to your PCB, you need to create different text files for the different layers. This is where the Eagle CAM program comes into play.
Once you're good and happy with your PCB layout (there is no turning back after you submit the files!), click on the CAM button to bring up the processor. This window will allow you to do different things to different layers. Eagle comes with a couple default *.cam files. The most common ones are the gerb274x.cam and excellon.cam. I got tired of running two seperate processors. I am also a hold over from Protel and a different naming convention so I created my own single file CAM processor. You can snag it here. The sfe-gerb274x.cam is based on the default Eagle file with a few tweaks:
  • Layers are renamed for easier reading - top copper, bottom silkscreen, etc.
  • All the mirroring is turned off - this will make gerber inspection much easier
  • A top paste layer was added in case you want to create a solder paste stencil
  • Excellon drill file is created along with the 6 magic layers
  • Drill file is 2:4 Leading (remember this!)
What are these magical layers you ask of? Anytime you transmit a PCB layout to a fab house, you need to pass them 7 files, and 7 files only:
  • Top Copper (GTL)
  • Top Soldermask (GTS)
  • Top Silkscreen (GTO)
  • Bottom Copper (GBL)
  • Bottom Soldermask (GBS)
  • Bottom Silkscreen (GBO)
  • Drill File (2:4 leading - remember this)
What is this GTL, GTS? These are the file extensions that the CAM processor will produce. A silkscreen is also called an 'overlay' (hence, GTO). And for your reference, a soldermask is also called a solder 'stop layer' because the soldermask prevents solder from being where it is not wanted.
Some fab houses will charge extra for a bottom silkscreen layer. You can just ignore this layer if you need to. You will also see a GTP file extension. This is the Gerber Top Paste file. You can use this file to get a solder paste stencil cut it you want. One would think that a GTP file would be the same as the GTS (top soldermask file). But no!
On the left, the soldermask layer. On the right, the top paste layer. The soldermask layer exposes the pads and the vias. You wouldn't want solder paste in vias! So the paste layer only has the SMD component pads exposed.
To create these layers, click on File->Open->Job
And select the sfe-gerb274x.cam file. Then click 'Process Job'. Some status bars will blink by, and within a few seconds, you should have a handful of extra files in your project directory:
The magic 7 gerber files
Something I highly recommend is to review the gerber files before submitting them for fabrication. Viewing just what is going to the fab house can exposed potential problems that were shrouded before by all the extra layers and graphics in the Eagle layout window. There are some free viewers out there that will let you view the gerber layers together. Most of the free viewers require you to enter an email, require 15 seconds for them to advertise at you, limited to one layer, or other really annoying limitations. Luckily, Viewplot still exists. This free program will let you open and look at your layers easily and you don't have to fill out any silly forms to get to the download link! Be sure to select the drill file type '2:4 Leading' to matchup the holes to the layers.
Simple
But oh wait, what is that?
Silkscreen on top of a via
This silkscreen being broken up by the via is not a big deal. Mostly this is just to show how difficult it can be to detect problems from within the layout program. By viewing what you're actually submitting to the fab house, you can see exactly what they are going to deliver - be it good or bad. Review your gerber files before you submit! You'll save yourself time and monstrous amounts of money. If you want a $50 coaster, I'll sell you a truck full.
Zip these 7 files together and shoot them off to the fab house of your choice (Shameless Plug: we use BatchPCB). Depending on who you use and how deep your pockets are, you'll have to sit on your hands for 1 day up to 20 days. What do I do? I start other designs! While this board is being fabbed in 2 weeks, I create and submit a new design 7 days into it. That way I always have a new PCB proto coming in every few days. It's like Christmas every week! What am I getting this week? Is it going to work? I can't wait to test out my new cat tracker!

With the magic of television, I can jump 20 days into the future and show you...
http://www.sparkfun.com/images/tutorials/BeginningEmbedded/9-EaglePCBs/EP-33.jpg
In the flesh
It looks great! Time to whip out some parts and the soldering iron.
http://www.sparkfun.com/images/tutorials/BeginningEmbedded/9-EaglePCBs/EP-34.jpg
Assemble your new board!
Soldering was not too bad. Silkscreen looks good. Standoffs look good. Time for testing!
Always assume a proto will short out the first time you use it. Be very cautious and be ready to kill power immediately. Plugging this board onto the computer - guess what happens?
http://www.sparkfun.com/images/tutorials/BeginningEmbedded/9-EaglePCBs/EP-36.jpg
Uh-oh
What went wrong? Nothing is heating up. Nothing smoked or popped. The FT232 IC doesn't seem to be enumerating onto the USB bus. But why? Let's check the schematic one more time...
http://www.sparkfun.com/images/tutorials/BeginningEmbedded/9-EaglePCBs/EP-37.jpg
FT232 Breakout v1.0 Schematic
Son of a... This is why we prototype! Mistakes like this happens to the best of us. What is the problem you ask? Checkout the GND pin on the USB connector. It's not connected to anything. Without a ground connection to the board, no current can flow, the FT232RL will never enumerate. The board is shot! Or is it?
http://www.sparkfun.com/images/tutorials/BeginningEmbedded/9-EaglePCBs/EP-35.jpg
The green wire fix
(I know the wire is not green, but this is the nick-name for an oops! fix) This is my final thoughts on PCB layout - anyone can layout a PCB, but it takes a true magician to get a bad PCB working. Scratch, cut, splice, and otherwise modify your PCB until you get it working. This example was an easy fix. I've seen some really impressive fixes over the years.
Don't immediately throw up your hands and layout a new board. Instead, make sure you get every bit of the functionality of your board working, by any means necessary, and then make all the revisions. Otherwise, you'll constantly spin your wheels with PCB revisions.
Things to remember:
  • Be sure to save your schematic as a new file name: *-v11
  • Be sure to update the date code on the board
  • Be sure to update the silkscreen on the board
http://www.sparkfun.com/images/tutorials/BeginningEmbedded/9-EaglePCBs/EP-38.jpg
Updated v1.1 schematic with GND connection on the USB connector
http://www.sparkfun.com/images/tutorials/BeginningEmbedded/9-EaglePCBs/EP-39.jpg
Updated v1.1 board layout with new GND connection, updated silkscreen and date code

8 - Eagle: Schematics

Welcome to the wonderful world of PCB creation! We've used a few software packages over the years (namely Protel DXP) and have found Eagle Layout Editor from CadSoft to be very easy to use, very cost effective, and very powerful.
Eagle is free! There are some limitations in place, but basic students and non-profit groups can use it. Protel is currently about $12,000 a seat.
Eagle is not the 'hobbyists' tool you may think it is. I've seen some very complex 8-layer BGA boards going into a firewall/router consumer product. I too was amazed to hear it was created in Eagle. It can be done, you just need to dream up the device!
There are a few files that you will need to download for this workshop.
  1. Download Eagle itself. Currently we use v4.16 (~8MB). Versions are available for Windows, Linux, and Mac. If the above link does not work, google ?eagle pcb download? to get the latest version.
  2. Download the SparkFun Eagle Library. This is the collection of all the components SparkFun designs with and therefore components and footprints that have been tested. Unzip and place the SparkFun.lbr file into the Eagle\lbr directory. If the above link does not work, google ?sparkfun eagle library? to get the latest collection. 
  3. Download the SparkFun Eagle keyboard shortcuts. Place this file in the Eagle\scr directory. If the above link does not work, google ?sparkfun eagle shortcut?.
  4. Download the SparkFun CAM file. Place this file in the Eagle\cam directory. This file is responsible for creating the gerber files for submission to a PCB fab house.
Note: The SparkFun Eagle shortcut key script file has an .scr extension. This is a common virus infiltration method. If you choose to download our keyboard shortcuts, and you don't trust us, rename the file to a .txt extension and view it in a text viewer. There's nothing there but text and Eagle commands. Just be sure to rename the file to the .scr extension so that Eagle will use it.
To learn how to use Eagle, we are going to create a simple breakout board for a popular USB IC. The FT232RL is a USB to TTL serial converter.
http://www.sparkfun.com/images/tutorials/BeginningEmbedded/9-EaglePCBs/EP-34.jpg
What is a USB to TTL converter?
Once the FT232RL is attached to the USB port on your computer, you will need to install some simple drivers (available for Windows, Linux, Mac), and then you will see a Virtual Com Port (VCP) appear on your computer. You can then use hyperterminal to open this new com port number. Any letters that are typed in hyperterminal are converted to a USB packet in the background, sent down the USB cable to the FT232RL where it reconstructs the serial information and passes these letters out the TX pin on the IC at whatever baud rate you choose. If you have a device connected to this TX pin, it will hear the serial letter and react. This will effectively give your device USB connectivity and you won't need to know a thing about how USB actually works!
This IC is very popular, but only comes in surface mount device (SMD) packages (sound familiar?). So let's spin a simple PCB that will allow us to use this handy IC.
When in doubt, follow the manufacturer's recommended circuit. This 'typical' application is just what we need.
This is a bare-minimum feature setup for the FT232R. Just what we need for simple TX/RX to USB. We want to plug the FT232RL on to the USB port, have it bus powered, and possibly power the rest of our circuit. Our ATmega8 uses 5V so we'll tie VCCIO to the USB 5V. A USB connector, a couple 0.1uF caps, a bigger tantalum cap, a ferrite bead, this doesn't look so bad!
Before we can get started, we need to create or locate a library part for the FT232RL. I really don't like using other people's footprints and schematic parts but in this case, FTDI has created some free libraries for their parts. This page should have the Eagle library (search the page for FT232RL) but if not, google 'ft232rl eagle footprint'. We also have this part proven in theSparkFun.lbr library. Use their library, use ours, create your own, it doesn't matter. But because we are most comfortable with our own parts (we know they work!) we will be using theSparkFun.lbr file for this tutorial.
Now let's add the FT232RL part to our schematic. Close the library editor and go back to the Eagle Control Panel. Click on File->New->Project. Name this new project 'FT232-Breakout'. Right click on the FT232-Breakout project and create a new Schematic:
The schematic editor should open. Now go back to the Eagle Control Panel and expand the SparkFun Library:
You should see a long list of parts. Highlight the FT232RL-Basic part and in the right screen click on ADD. The schematic editor will pop up allowing you to place the FT232RL.
Now save your schematic!
I like to use a board name and a version number within the file name. -v10, -v11, v12, etc as 1.0, 1.1, and 1.2 advance through layout changes.
Now add these other items to your schematic:
  • 1 x FRAME-LETTER : This will add a nice frame to your schematic. Add all parts inside this frame.
  • 3 x CAP (Device name CAP0603) : 0.1uF/0.01uF 0603 capacitors
  • 1 x CAP_POL (Device name CAP_POL1206) : 10uF tantalum capacitor
  • 1 x INDUCTOR (Device name INDUCTOR0603) : Ferrite bead
  • 4 x STAND-OFF( Device name STAND-OFF): This part will add a hole and a keepout ring for a #4-40 screw. These can be used to raise your board up off a surface or to mount your board to an enclosure.
  • USB (Device name USBPTH) : USB Type B through-hole connector
  • M04 (Device name M04PTH) : Four pin 0.1" connector
  • GND (Device name GND) : Ground connections
  • VCC (Device name VCC) : Power connections
Parts added to the schematic
You can click on the button you need on the menu on the left side of the screen. You can also hover over each button and its name will pop up. This works great for beginners but as you advance, you'll want to speed up layout by using keyboard shortcuts. Here are some of the basic quick keys:
  • Press escape at any time to stop the current action and return to the schematic window
  • F7 to move a part
  • Alt+F7 to group a bunch together
  • F3 to delete a part
  • F4 to rename a part (change C7 to C2)
  • F5 to re-value a part (change 0.1uF to 10uF, etc)
  • F6 to smash a part (be able to move the name and value tags)
  • F9 to start a wire
  • Alt+F9 to add a label to a wire
NEVER change the grid size in the schematic editor. Leave it on 0.1inch steps and don't use the alternate 0.01 step. If you do, you won't be able to hook wires to the pin tie points.
Now we just need to begin wiring nets. Arrange the pieces so that there is as little net overlaps as possible.
Primordial FT232RL breakout
To wire a pin (TXD) to a far point (the 4-pin connector for example), instead of sending a wire half way across the page, we use net names. The green wire is not physically seen on the schematic, but Eagle knows to connect the two points on the layout because the two green wires have the same name.
Press F9 and click on pin 1 (TXD). Bring out the net a couple square widths and left click again to end the net. Press Alt+F9 to name the net. Click on the wire you just created. You should see a net name (like N$5) appear and be floating. Anchor it to the wire and TX pin:
To change the name on the N$5 wire, press F4 (Name command) and click on N$5. A window will appear - type 'TX' and press return. The TX pin should be correctly labeled and we have a few of the schematic connections.
To rename a device (change U$1 to U1), press F4 and then click on the device you want to rename. This also works to rename a net.
To change the value of a component (0.1uF to 10uF) press F5 and click on the device you want to change the value of. To move a device, press F7 (move command) and click on the device you wish to move. Now with a little renaming and rearranging the various components:
We've thrown a 4-pin connector into the schematic and used a very stripped down schematic symbol for the FT232R. For the purposes of this tutorial, we really only care about VCC/GND/TX/RX - the bare minimum. If you need access to more of the pins, use the more complete FT232R symbol and break them out!
Use the mirror command and rename the 4-pin connector (press F4 to rename a device):
Eagle files / PDF
I probably could have wired JP1 directly to the various pins but I wanted to demonstrate the net/name properties. This will also make it easier to label the pins on the PCB. Speaking of which, if you have not already, click on the 'Board' button to open the PCB editor:
All right! We've got the components onto a board and most of the nets connected, time for PCB layout!
How to copy and paste in Eagle Schematic:
This is perhaps the most counter intuitive part of Eagle. As with any new technical software, it's like learning a new language. Once you know the intricacies, you'll love it.
To copy one thing within a schematic is reasonably simple. Click on the 'Copy' button, then click on the thing you want to copy and that thing (component, wire, net name) will be duplicated and floating under your cursor. Drop it wherever you want it.
To copy a group of stuff within a schematic is completely wacky. First click on the group command:
You are going to create a frame around the stuff you want to group together. Left click and hold on one corner. Drag to the opposite corner. Now release the mouse button. The items that are part of the group should now be highlighted like this:
Now click on the Cut button. I know you don't want to delete these items - this is just how it works. Click on cut, move your mouse cursor to the middle of the group, and left click. Nothing happened right? That's okay. The group of items has been copied to the buffer. Now click on the paste button:
You should now have a copy of the group of items floating around. Drop these items wherever you need them in the schematic, or hit escape to return to the schematic window. I know, very odd but this type of group/modify steps comes in very handy over time.