When drawing a schematic in Eagle, it's a pretty common occurrence that you will need to create a part. There are a few good resources for finding parts already created in Eagle: Sparkfun, CadSoft's site, GitHub. Sometimes, it's faster and easier to just create your own rather than scouring the Interwebs for that part library that *might* exist. Let me show you some tricks that will make this process quick and relatively painless.
First, a vocabulary lesson.
Package - This is how the part will physically connect to the board. The package for a part describes all the holes and pads needed to accommodate the part.
Symbol - This is what you will see when drawing a schematic. It will give you some indication as to what mechanical properties the part has, or if it is a microcontroller, it's a box with some pins coming out the sides.
Device - This is the combination of a Package and a Symbol. This allows us to create complex devices, using Packages and Symbols as building blocks.
Library - This is a container for one or many Devices. Typically, parts are grouped into a Library by type and manufacturer.
Gather The Data
Grab the pdf datasheet for the part. Octopart, All-Datasheet, the manufacturer's site, or your favorite parts distributor should have these for download. If those options fail you, grab your calipers and continue on.
Plot the Coords
Print out your datasheet and grab a blank sheet of paper. We are going to map all the features of the part to a coordinate system. Pick a good point for the origin. This will make your calculations easier. Plot the points for the drill holes, pads, and outline of the part on paper. Write down all the points in '(x y) drill_diameter' format, or '(x y) width height' if they are SMD pads. The (x y) coordinate is the center point of the pad.
I should point out that the way a manufacturer's datasheet describes a part layout may not be the same way that Eagle visualizes it. When we layout a package in Eagle, we are looking through the top of the board. Many times, the datasheet will have the part layout shown as a bottom view. If this is the case, we need to flip the pins and pads along a vertical or horizontal axis before inputting them into Eagle. For this particular example, the relay's function is symmetrical along the horizontal axis, so it doesn't matter.
Construct the Package
Now, here's where things get fun. We are going to use some Eagle commands to make quick work of laying out this part. Create a new Library, then, a new Package. Set your grid based on whatever measurements you are using (IN or MM):
GRID MM 0.5;
Set the layer you want to alter:
Use data you collected to make quick work of placing pads. Click on the Pad icon, set the pad diameter to 'auto' from the drop-down menu, and then punch in the following commands to set your drill diameter and place your pads. Note that there is not a comma between the x and y coordinates. Eagle doesn't like commas, apparently.
SET DRILL_MENU drill_diameter; PAD 'name' (x y); SMD width height 'name' (x y);
If you need to change the orientation of a pad, just right click on it, go to properties, and change the angle. Now, Make an outline for your part:
LAYER tPlace; WIRE 0 (x1 y1) (x2 y2) (x3 y3) (x4 y4) (x1 y1);
Place your ">NAME" and ">VALUE" tags.
LAYER tNames; TEXT >NAME LAYER tValues; TEXT >VALUE
Note that the omission of the semicolon when using the TEXT command will allow you to place the text with the mouse.
Boom. You are done with Package creation. This is typically the biggest chore of creating parts. Using the command line saves us the time of hunting and clicking for the right options, changing the grid and zoom levels, clicking on pads to name them, and the tedious task of finding the right coordinates with the mouse.
If you want to know more about any of these commands, just type:
Draw the Symbol
Next, save your work and create a new Symbol. Typically, I will just copy the schematic symbol from the pdf freehand with the wire tool onto the Symbols layer, place and name the pins (make sure to use the same name for corresponding pins and pads!), drop in the >NAME and >VALUE tags just like we did for the Package, and we're done with the symbol editing.
Build the Device
Finally, and this is the easy part, bind together the Package and Symbol to create a Device. Add the Symbol we just created into left window (via the 'Add' button). Select the new Package we created (via the 'New' button). Then, connect all the pins and pads together.
Pat yourself on the back. You just created a new Device! Now, repeat for as many devices as you need to create.
You can speed up this process even more by reusing other people's work. Maybe, the symbol is already created, but it is in a different package, or vice-versa. Import the symbol or package you need into your library and use it. Make sure to give credit to the appropriate people or organizations for any work you use.
Here are some general guidlines to follow when making parts in Eagle:
- Map the pins, pads, and outline of the part to exact coordinates on paper.
- When naming pins and pads, be consistent!
- Shortcut drawing the Package or Symbol, if you can, by importing from another Library into your Library.
- The Eagle command line is your friend.
I hope these tips will help you to create some quality parts libraries, quickly. Feel free to contact me with any of your Eagle-related tips and comments.