Creating Gerber Files in EAGLE

29 September, 2008 (09:43) | Eagle, Tutorials | By: Chris

Creating Gerber Files in EAGLE

In this post, I’ll be using the gerber viewer found here (just download the latest version of the executable), and the information here is based on our use of PCBFabExpress. For this post, I feel like the video is much clearer in explaining the CAM Processor, as the actual text becomes very wordy in trying to describe the steps you need to take to produce your gerbers.

Gerber Files – What are they?

Gerber files contain information that board houses use to control their machinery to manufacture PCBs. With so many different layout programs, gerbers act as a bridge between designer and manufacturer. The most common format in use today is RS-274-X, but you should check with the board manufacturer that you’ll be using to ensure that you use the right format in your boards.

Using the CAM Processor

To create gerbers in EAGLE open your finished board, then click File -> CAM Processor. In the CAM Processor window, you’ll need to create one section for each gerber file that needs to be created. For a two layer board with silk screen and solder mask on both sides, you’ll create seven sections. The section name and prompt have no effect on the output, so put a descriptive name in the section box. The checkboxes in Style should be correct (pos. coord, optimize, and fill pads should be checked), and both the x and y offsets should be set to zero.

The table below shows what device, file extension, and layers need to be selected for each section. To make the file name dynamic, I use the variables that you can look up in EAGLE’s help. Specifically, I use %P to get the path of the board and %N to get the name (without the extension) of the board. So, in my file section, I entered %P\Gerbers\%N.extension, where extension is the extension for the particular section. This lets me use the same processor job for any board I need gerbers for, and all I need to do is create the gerbers directory.

To create the first section, enter CMP in the section name, %P\Gerbers\%N.cmp for the file, select GERBER_RS274X as the device, and select Top, Pads, and Vias in the layer box. Click Add, and it will duplicate this section. Repeat the process until you’ve created all the sections in the table above. Once you’ve created all of the sections, click process job (make sure you’ve created the Gerbers folder in the same directory as your board file) and EAGLE will create all the gerber files you need.

Viewing the Gerbers

Once you’ve created your gerbers, you should always use a gerber viewer to ensure they were processed correctly. An error in version 5.1.0 caused some errors in this particular board that, if we hadn’t checked, would have made our boards unusable if they had been manufactured with those errors. If you’ve installed the gerber viewer I linked at the beginning of this post, open it up, click on the folder icon, navigate to your gerber files, select them all and click open. This will show you what the board house is going to see when they manufacture your PCBs. If everything looks correct, zip your files up and send them to your board house to be manufactured.

One important thing to note (and another reason to check your files) is that all text will be converted to a vector format. If your text is in any other format, it may be stretched or skewed. If you use vector based text, your text should look the same in your gerbers as it does on your board.

Now that we’ve covered the basics from start to finish, I’ll spend the next few posts going into more detail on a few things I’ve touched on in the past. As always, contact me with any questions or suggestions.

Site Maintenance

23 September, 2008 (20:34) | Admin Posts | By: admin

If you’re visiting our site tonight, you may see the site layout and design changing.  Please excuse us as we find a cleaner, better look for www.ece101.com.  Thanks!

UART communication with a PIC

12 September, 2008 (20:32) | PIC, Tutorials | By: Joshua

UART communication is an easy way to communicate between two microcontrollers, between a microcontroller and some peripheral, or even between the microcontroller and the computer. UART serial communication is the equivalent of RS-232 on a computer, though the logic levels are different and requires a converter. The UART is easy to use, but you have to get the setup exactly right or else it won’t work. It would help to have access to an oscilloscope to make sure your output looks reasonable, but after we’re through, hopefully you won’t need it.

On the hardware side of things, life is great. Hook the transmit end of one device to the receive end of the other. Do the same thing with the other device. And there you are. No capacitors, no pull-up resistors, nothing complicated. Quite nice.

With that out of the way, let’s approach the not much more difficult software side of things. First, we should familiarize ourselves with some of the variables that we’re going to need and how they’re going to affect our communication.

SPBRG – Serial Port Baud Rate Generator: This eight bit register is used in conjunction with SPBRGH to set the baud rate based on the frequency of the clock.  

SPBRGH- Serial Port Baud Rate Generator High: This is used if you want to slow down the baud rate even more than you can with SPBRG.  As you can see in the equation below, the bigger these two numbers are, the lower your baud rate will be.  This equation assumed asynchronous, 8-bit communication.

Equation for Baud Rate

BRG16 – 16 bit Baud Rate Generator:  Set this bit if you want 16-bit communication instead of 8.  Setting this will automatically cause BRGH to be ignored.

BRGH – High Baud Rate Generator:  This changes that 64 in the equation up there to 16, allowing faster baud rates.

SYNC – Synchronous/Asynchronous Communication:  Set this bit if you have a peripheral that you want to run off a master clock in synchronous mode.  Clearing the bit allows asynchronous communication.

TXEN – Transmit Enable: This enables the transmitter circuitry of the UART.

SPEN – Send Enable: This starts the UART circuitry and automatically makes some configuration changes to enable sending through the UART.

CREN – Receive Enable: This starts the UART circuitry and automatically makes some configuration changes to enable receiving through the UART.

RCREG – Receive Register: The value received will be placed in this 8-bit register.  

TXREG – Transmit Register:  The 8-bit value to be transmitted gets placed in this register.  Placing the value inside this register initiates the transmission.

RCIF – Receive Interrupt Flag:  When the RCREG is full, this bit gets set.

TXIF – Transmit Interrupt Flag: This bit goes high when the transmission register becomes empty, signifying that transmission is complete.

Almost all of this information was gathered from different parts of data sheets from Microchip. I maintain that your best reference is the data sheet for your PIC.  However, I’m just trying to make it so you don’t have to wade through so much.

In the next post, we’ll put these pieces together to make a fully functional UART and figure out the little quirks for setting everything up.

Creating Devices in EAGLE Part II – The Symbol and Device

6 September, 2008 (07:34) | Eagle, Tutorials | By: Chris

Creating Devices in EAGLE Part II – The Symbol and Device

For those who watch only the video, please also read the first paragraph as it has a few notes that I didn’t cover in the video.

Having created the package for the 2.5 Digit LCD in the last post, I’ll be creating the corresponding symbol and device in this post.  You can have more than one package associated with a symbol in one device.  You can also use the same package over in other devices in association with their respective devices.  So when creating a standard package, like a TSOP or QFP, it would be best to give it a more generic name, such as TSOP-44, so you can use it with other devices.  Also, for those wanting to have the names and values on either the package or the symbol, just add the text “>NAME” and “>VALUE” (without the quotes of course) to your symbol and/or package.

The Symbol

To create the symbol, click the Symbol button on the top toolbar from any window within your library.  When prompted for a name, enter an appropriate name for the symbol (I used 2.5_DIG_LCD), click Ok, and then click Ok to again to confirm that you want to create a new symbol.  This will bring you to a window heavily resembling that of the schematic window.

To start creating the symbol, there are a few things to note on the datasheet.  The first is that this particular device has 16 signal pins, one of which is a common pin.  Common practice for creating symbols is to have the power pins on top, grounds on bottom, inputs on the left, and outputs on the right.  Since the common pin can be either power or ground, the other fifteen pins can be considered either inputs or outputs, depending on the selection for the common pin.  For this reason, I’ll be putting the common pin on one side (as it can be considered as the opposite – input or output – of the other fifteen pins), and the fifteen signal pins on the other side.

To place pins, select the pin tool and begin placing them on the page.  The order on the symbol isn’t so important as their is no physical meaning to the order of the pins.  I placed fifteen pins on the right and one on the left with enough space between the two sides to clearly display the pin names.  For the fifteen pins on the right, I placed them one grid space apart.  This helps to keep the symbol reasonably sized in comparison to other symbols you’ll be placing on your schematic.  As with the order, there is no physical meaning related to how far apart they are, it just helps keep the symbol size reasonable.

After the pins have been placed, I draw a box (using the Wire tool) so I can tell which pins go together once a part is placed in a schematic.  This may seem trivial, but I recently inherited a schematic that has a dozen pins just floating in the schematic.  You can’t tell which pins go together just by looking, so the first thing I’ll be doing is recreating those symbols.

With the pins placed, now they just need to be given names.  Select the Name tool, and give each pin a name corresponding to a signal from the datasheet.  If you did this on the package as well (sorry, I didn’t), it makes connecting the package and symbol very straightforward.

Finally, to have the name display on the schematic, use the text tool and place “>NAME” on your symbol.  This can be done on the package as well so that the name will come out in the silkscreen.  Though this part doesn’t have a value like a resistor or capacitor, the text “>VALUE” will display any values you set.

The Device

The last step is creating the device by combining the package and symbol.  Click Device on the top toolbar, enter a name and press Ok.  In the device window, click Add on the left toolbar and add the symbol you just created.  In the lower-right corner, click New and select the package you created.  Finally, click Connect to display the connection dialog.  If you named all of the pads in your package and all of the pins in your symbol, you just need to click connect 16 times.  If you didn’t, you need to make sure that you connect the right pad to the right pin; otherwise you’re schematic will look correct, and your board will seem correct, but it won’t work the way you expect it to.

Congratulations

If you’ve gone through the previous posts, you should be able to use the basic features of EAGLE to create quite an array of boards.  Some boardhouses will even take your board files to create your boards, taking the task of creating gerber files off your shoulders.  However, since a lot of people use boardhouses that require gerbers, including myself, my next post will be a tutorial on creating gerber files.  Until then, tell me what areas you need help with, and I’ll be sure to include them in my upcoming posts.

Creating Devices in EAGLE Part I – The Package

29 August, 2008 (00:00) | Eagle, Tutorials | By: Chris

Creating Devices in EAGLE Part I – The Package

Now with better videos!

While EAGLE includes plenty of parts in the libraries that come with it, I’ve never done a project (besides the example for this site) that didn’t require at least a couple of devices that I couldn’t find in EAGLE.  Sometimes I’ve even thought that they were probably somewhere in those libraries, but it was easier to create them myself because I found that it’s pretty quick once I learned a few tricks.

If you don’t have the datasheet and the physical parameters for your device, find the data sheet on the manufacturer’s web page or a place like Digi-Key.  Find the package dimensions and make sure you know whether or not you’re reading the dimensions in millimeters or inches (or some other unit), because you’ll need to set your grid appropriately.

Creating the Package

To start, open a new library by clicking File->New->Library.  You’ll see a blank screen that doesn’t seem to have much.  Looking at the top toolbar, you’ll see three buttons to the right of the print button.  From left to right they are: Device, Package, and Symbol.  Clicking on any of these will display a dialog that allows you to start creating a new device.  We’ll start with the package, so click on Package and enter a name in the dialog.  This example will be a 2.5 digit LCD, so I chose 2.5_DIG_LCD because spaces are not allowed (the datasheet is here).

Clicking OK will take you to the package layout screen, and it’s nearly identical to the board layout screen.  The first thing I like to do is create my package outline using the wire tool.  While this can be done graphically, packages can have awkward dimensions that I think are easier to do using the text commands.  Just above the layout area is a text box where you can enter text commands and recall previously used text commands.  If you open the General Help and select Editor Commands, you’ll be able to get the syntax and all the details on using the text commands.  Open the Wire command and look at the first syntax line.  For those unfamiliar with the notation in the syntax, here’s a quick rundown:

  • anything in square brackets is optional
  • the vertical bar indicates that there are different choices for the parameter
  • the bullet represents x-y coordinates
  • text inside single quotes indicate string values
  • unquoted text indicates numeric values

The most important dimensions of the package are the maximum width and length.  For this LCD, the package is 30mm x 26.17mm (I’m ignoring the 1mm tab on the left side).  To create this package outline, verify that your grid is in units of mm, then type “WIRE (0 0) (30 0) (30 26.17) (0 26.17) (0 0);” in the command box without the quotes.  This creates a wire that starts at (0 0) and follows the path created by the other points.  The semicolon terminates the command and is equivalent to double-clicking a wire you are creating with the graphical tool.  You can continue the wire from your last point by omitting the semicolon.

With the package outline completed, the only other necessary step is to place the pads (if you’re creating a package that uses SMDs, the process is similar, but you’ll need to read the help on the SMD command).  On the lower-right corner of the package on the datasheet it shows that the center of the end pads are 6.11mm in from the edge of the package and that they are spaced by 2.54mm.  Also, the two rows of pads are 28.67mm apart.  This is 2.5mm wider than the package, so each row of pins is 1.25mm away from the package.  To create the first two pads, type “PAD (6.11 -1.25) (8.65 -1.25)” in the command box.  You aren’t limited to creating two at a time, so feel free to add the other six in this line, or do all 16 at once.  The other row of pads will have the same x values, but the y value will be 27.42.  For example, the first pad will be at (6.11 27.42).

Once you’ve created all of the pads, you’ve done everything that is necessary to create your package.  To make the layout more readable, I would suggest putting something in the package to indicate that it is a 2.5 digit LCD (or whatever you’re making).  To do this quickly, I selected the text tool and entered “188″ as my text.  On the top toolbar I changed the layer to 21 tPlace (to match the package outline) and made the font as large as possible, then I placed it inside the package.  Now when I use this in a project, I’ll be able to identify the package for this LCD.

Last word

I’ve started using blip.tv as my video host because of the way YouTube mangled my videos.  Like YouTube, blip uses flash, but it also permits for much higher resolutions.  I hope they work out and I hope the audio is getting better.  I’ll be remaking the first few videos as soon as time permits.  As always, feel free to post comments, questions, or suggestions.  In my next post I’ll be doing the symbol and device to wrap up this topic, then I’ll be going back to some of things that were touched on in previous posts that deserve a more thorough explanation.

Programming with the PICkit 2, a Breadboard, and ICSP

23 August, 2008 (22:46) | PIC, Tutorials | By: Joshua

Programming your PIC without a demo board is a straightforward task, when you know what you’re doing (aren’t they all?). With the proper hardware, setting up your programmer should take almost no time at all. To do this, you will need two data sheets; the data sheet for the PICkit 2 and the data sheet for the PIC you plan on programming.

First, you need the proper hardware. This includes:

  • The PICkit2 Programmer
  • Two 6 position .100″ pitch male headers (Found at Digi-Key here)
  • 6 position cable (an IDE cable works though its pitch is too narrow to be pretty)
  • Breadboard with .100″ pitch holes. I believe this is standard.

But, wait, doesn’t the PICkit 2 data sheet show some resistors, capacitors, and even a diode? Yes, yes it does. However, those are all isolation circuitry. You only need those parts when you’re going to be putting other circuitry on the pins used for programming. If you aren’t going to use those pins for I/O, just connect them directly to the header without any additional circuitry. If so, follow the directions on the data sheet for the PICkit 2. From personal experience, the values used are very rough, so if you don’t have them on hand, use the closest you have and it will probably work. And, whatever you do, do not AC couple the Data or Clock programming lines to ground with a capacitor. Seems like common sense, but I was trying to decouple a node that I was sharing with the Clock and didn’t think things through. Don’t imitate my mistakes.

Second, find the proper pins on your PIC to attach to. Using Figure 3.1 from the PICkit 2 data sheet, you can see what signals are on each pin of the PICkit 2. Of the six pins, five are used. Ground (or VSS) and VDD are straightforward enough. VPP is a high voltage programming line which goes up to 12 volts to tell the microcontroller that it is being programmed. Then, the important pins are the Data and Clock lines.

The Clock line on the PIC’s data sheet will be denoted either by ICSPCLK (In Circuit Serial Programming CLocK) or PGC (ProGramming Clock). Again, make sure that there is not a capacitive load on this line or you will not be able to program your PIC.

The Data line on the PIC’s data sheet will be denoted either by ICSPDAT (In Circuit Serial Programming DATa) or PGD (ProGramming Data). This also needs to be free of a capacitive load.

All you need to do is to wire the five active lines to five consecutive, free rows on your breadboard and you’ll be able to attach your male header easily to the board and then to the PICkit 2 programmer. Using the software is covered in another tutorial. Then, if you have multiple PICs you need to program, you can switch between the different PICs with ease.

See? Quite straightforward. All the information is in the data sheets but I hope I helped make them more intelligible and saved you some time scouring them for the important information.

Copying Layouts and Schematics in EAGLE

22 August, 2008 (00:00) | Eagle, Tutorials | By: Chris

Merging – A Complicated Process

One of the biggest frustrations I faced when I started using EAGLE was the apparent inability to merge a board in EAGLE.  I say merge, because making a copy of a current project is simple: just go to File, click Save As…, and you’ll create a new copy of your board and/or schematic.   If you want to combine two boards and/or two schematics, it seems like you can’t.  You can only have one schematic/board pair open at a time and you can’t copy between instances of EAGLE.  After some digging and experimenting though, I can tell you it is possible and I’ll tell you how to do it.

Combining Two Boards

Let’s imagine you’re working on a project with a friend or classmate and want to divide the work.  You do your part of the board, your partner does the other part, and at the end you plan on doing a copy-paste and send the board off to a boardhouse.  But when it comes time to copy and paste, you realize that it doesn’t work out.  For whatever reason, EAGLE has a less obvious approach to solving this problem.  Here’s how you do it:

1. Open one of the board files that you want to copy.

2. Using the Group tool, select the entire board.

3. Select the Cut tool, right click on your board and select Cut: Group.  (Note: Newer versions of EAGLE support copying as well.  However, if the schematic is open you will see errors about backannotation.)

4. Close your board (and schematic if it’s open) and create a new board (File -> New -> Board)

5. Click the Paste toolbar button and your copied board should appear.  Place it on the new board.

6. Save and close the new board.

7. Repeat the process, copying as many additional boards as you’d like into your new board file.

8. To add additional traces, use the Wire tool.  Since there are no signals associated with these traces, you’ll have to double-click when you want to end the trace.

Combining Two Boards with Schematics

Now let’s say you want to combine the two boards and define connections on the schematic so you can check for errors and have a complete schematic for your project for future reference.  To do this, you copy the board (as described above) and then the schematic (using the same method as for the board).  You’ll see errors about inconsistencies, but once you have copied the last schematic, these errors should go away.  In order to keep component names consistent, you need to copy the schematics in the same order that you copied the boards.

A Simple Schematic and Board in EAGLE – Part II

15 August, 2008 (16:52) | Eagle, Tutorials | By: Chris

Seven Segment LED – Board

In this post, I’ll cover doing the board layout for the seven segment led. For reference, I’ve included the same toolbar buttons in this post as I did last time. Some of them don’t apply to laying out a board, but since they’re the basic tools you’ll use, it’s a good refresher.

Toolbar Buttons

Add – adds components to the schematic

Autoroute – attempts to route all incomplete connections (airwires) on the board

Board (Schematic) – switches from the schematic to the board (and vice versa)

Copy – copies components (and applicable values) already placed on the schematic

DRC – performs a design rule check on your board (I’ll cover this with creating gerber files)

ERC – performs an electrical rule check (more on this later)

Errors – lists the errors found by the DRC and ERC

Group – allows multiple components to be selected

Invoke – allows adding normally implicit pins to the schematic

Mirror – flips components

Move – moves components

Name – changes the name of a component, net, or trace

Net – creates an electrical connection between two pins on the schematic

Polygon – used to create ground (and power) planes on boards

Ratsnest – cleans up the airwires showing connections that still need to be made on the board

Ripup – removes already routed traces from the board

Rotate – rotates components

Route – routes traces on the board (only used on airwires)

Value – changes the value of a component (such as a resistor)

Wire – routes traces on the board without being restricted to airwires

Board Layout

With the schematic open from last time, click on the Board button. EAGLE will ask you if you want to create the board from the schematic. Click yes and EAGLE will place all the parts from your schematic in a new board file. The screen should look something like the picture below.

The white box to the right of the parts is the largest board that can be made with the freeware version of EAGLE. Start by moving all of your parts inside the square. After some initial planning, I moved my parts around as shown below.

On most boards, it is good practice to use one side of the board as a ground plane. You can still route other traces on that side of the board and it ensures that your grounds are all well-connected. You can think of it as a very wide trace going to all of your grounds. To do this, press the Polygon button, make sure the bottom layer is selected on the top toolbar (it should read “16 Bottom”, not “1 Top”) and create a box around your board. Click the Name button and rename the polygon to the name of your ground supply (GND in my case). This will make the bottom layer of your board a ground plane. Any signals you route on the bottom layer will be isolated from the ground plane, but too many traces can isolate areas of the bottom layer so that they are no longer part of the ground plane. Click ratsnest and you should see the grounds of your through-hole component connected to the ground plane that now fills the bottom layer. In the picture below, you’ll see the ground connections of the BNC connector as crosses through the hole. This cross forms a thermal break. Rather than not routing the board at all around that drill hole, some of the copper is removed so that it can be easily soldered. Otherwise, you would be trying to heat the entire ground plane when you tried to solder the connector to the board.

All that remains is to route the traces between components. This process is similar to creating a net on the schematic. Select the Route tool, click where you want to start and EAGLE will select the airwire of the trace you are trying to route to show you where you need to end. Click along the way to set the path it will follow, right-clicking to change the bend, and finally, click the end of the trace to finish it. If EAGLE isn’t sure which trace you are trying to route, it will highlight the airwire of the trace it thinks you want to route. If it selects the correct airwire, left click again to begin routing. If it selects the wrong one, right click to cycle through the other nearby airwires and left click when the correct one is selected. I started by routing the power traces and the dip switch outputs to the inputs of the decoder. I also connected the decoder grounds to the ground plane. To do this, you can start routing the trace as you normally would, bring it out from the pad and click to anchor the trace, then switch the trace layer to Bottom, and double click. This will automatically create a via and will connect your trace to the ground plane. Then I figured out where the resistors needed to go for easy routing between the decoder and the LED. You can see my placement in the picture below.

You can also see that my traces aren’t all the same size. Particularly, I made my power (VDD) traces wider. This reduces resistance and, consequently, the voltage dropped between the BNC connector input and the power pins of the decoder and the inputs of the DIP switches. The trace width can be changed on the top toolbar while the Route tool is being used. It can also be changed after routing the traces using the Change tool (the wrench on the toolbar, not shown in my list), selecting Width, then selecting the width you want to change traces to, and lastly clicking the traces that you want to change to your selected width.

I could route the traces from the decoder through the resistors to the LED pins using both sides of the boards, but here we’ll use the space between the resistor pads to keep all traces on the top layer. To do this and not have DRC errors, you’ll need to change the width of traces going between the pads. In the picture below, you’ll see what I mean (and the completed board).

Now that we have the basics out of the way, my next few posts will be shorter, less wordy, and more useful for those with prior experience. As always, feel free to ask questions or correct any of my mistakes. If you’re confused, I recommend checking out the video.