4 This next board will introduce some additional concepts in @code{pcb}
5 that will help you with more complex board. It is assumed that you've
6 gone through the previous board, and those concepts will not be
7 re-explained. This board will be another single-sided board, but with
8 additional components. We will use a schematic to describe the
9 circuit, create some custom symbols and footprints, and learn to use
12 We will begin by creating our custom symbols and footprints. First,
13 we must create local symbols and footprint directories and teach the
14 tools to use them. My preference is to create subdirectories in the
15 project directory called @code{symbols} and @code{footprints}:
19 We then create some files to tell @code{gschem} and @code{gsch2pcb} to
20 look in these directories. The first is called @code{gafrc} and
21 contains just this one line:
27 The second is called @code{gschemrc} and contains just this one line:
33 The third is project-specific. The @code{gsch2pcb} program can read
34 its commands from a project file, and we will use this to tell it
35 about the @code{footprints} directory. The file is called
36 @code{fb-blinker.prj} and contains:
39 @include fb-blinker.prj
42 This project file tells @code{gsch2pcb} where to get element
43 descriptions, which schematics to read (we only have one), and what
44 base name to use for the various output files.
46 We must create two custom symbols for this project. The first is for
47 our power jack, and is a purely custom symbol. Creating such symbols
48 is beyond the scope of this tutorial. Please refer to the
49 @code{gschem} documentation for that. The second symbol uses the
50 @code{djboxsym} utility which you can download from the web (see
51 @url{http://www.gedasymbols.org/user/dj_delorie/tools/djboxsym.html}).
53 The first symbol is called @code{symbols/powerjack.sym} and looks like
58 There's a copy of this symbol in the source distribution for this
59 documentation. The second symbol is built from this @code{555.symdef}
70 Now, using those symbols, create your schematic, and name it
71 @file{fb-blinker-sch.sch}. There's a copy of the schematic file in
72 the source distribution also. It should look like this:
74 @center @image{fb-blinker-sch,367pt,284pt}
76 Using @code{gschem} and/or @code{gattrib}, set the @code{footprint}
77 and @code{value} attributes as follows:
79 @multitable @columnfractions 0.25 0.15 0.15 0.15
80 @item @tab @b{refdes} @tab @b{footprint} @tab @b{value}
81 @item @tab C1 @tab RCY100 @tab 1uF
82 @item @tab J1 @tab pj102.fp @tab PJ102
83 @item @tab LED1 @tab RCY100 @tab RED
84 @item @tab R1 @tab ACY400 @tab 100k
85 @item @tab R2 @tab ACY400 @tab 100k
86 @item @tab R3 @tab ACY400 @tab 3.3k
87 @item @tab U1 @tab DIP8 @tab LM555CN
90 Now we must create the custom footprint for the power jack. While
91 there are various contributed tools that can be used for large
92 footprints (like BGAs), for small parts like this the easiest way is
93 to create the footprint in @code{pcb} itself. This is done by
94 creating a ``board'' with vias and lines, then converting it to an
95 element and saving it.
97 Change to the footprints subdirectory and start @code{pcb}. It
98 doesn't matter how big the working area is, or the layer stackup.
99 Looking at the specs for our power jack, we note that measurements are
100 given in tenths of a millimeter, so we'll use a metric grid. To
101 start, set the grid to @b{1mm}, move the crosshairs to the center of
102 the board, and press @b{Ctrl-M} to set the mark. This will be the
103 reference point for all our measurements. By doing this with a large
104 grid value, we ensure that it will be easy to click on the same spot
107 Now set the grid to @b{0.1mm}, which we'll use to place all our vias
108 and lines. We're using vias to create pins, so we need to set the via
109 size and drill diameter. Click on the @b{Route Style} button to bring
110 up the route styles dialog, and set @b{Via hole} to 1.6mm and @b{Via
111 size} to 3.6mm. While we're here, set @b{Line width} to 0.15mm, we'll
112 need that when we draw the outline later.
114 Now, zoom in enough to see the grid points. Place one via 3mm to the
115 left of the mark, one 3mm to the right, and one 4.7mm above. Sequence
116 is important! The pins will be numbered in the same order as the via
117 creation. To place a via, select the @b{Via} tool, position the
118 crosshair, and press the left mouse button.
120 @center @image{fb-blinker-2} @image{fb-blinker-3}
122 Using the line tool, the same tool you used to draw copper traces in
123 the first board, we will draw an outline of the jack on the silk
124 layer. Select the line tool, and make the silk layer active. Draw as
125 much of a box as you can which extends 10.7mm to the right of the
126 mark, 3.7mm to the left, and 4.5mm above and below. Be careful not to
127 draw on top of your pins, or your board will have ink on the pins. It
128 should look something like this:
132 Now, set the grid back to 1mm so we can easily click on the mark.
133 Select everything by using the @mnuu{Select,Select all visible objects}
134 menu button. Position the crosshair on the mark and press @kbd{Ctrl-C}
135 to copy all the objects to the buffer. Use the @mnuu{Buffer,Convert
136 buffer to element} menu button to convert the buffer to an element.
137 You can now click somewhere else on the board to paste a copy of your
138 new element for inspection.
140 The first thing to do is check the pin numbers. Place the crosshair
141 on the mark and press the @kbd{D} key to turn on the pin numbers.
142 Check to make sure they're correct, then press @kbd{D} to turn them
147 Now, we're going to set the default position of the label. Place the
148 crosshair on the mark and press the @kbd{N} key. Change the element
149 name to @code{J?}. By default it shows up at the element's mark. Use
150 the selection tool and @kbd{S} key to position the label as shown
153 @center @image{fb-blinker-6} @image{fb-blinker-7}
155 Using the selection tool, position the crosshair on the element's mark
156 and click on it to select it. Press @kbd{Ctrl-C} to copy it to the
157 buffer, and use @mnuu{Buffer,Save buffer elements to file} to save your
158 new footprint to a file. Save it as @code{pj102.fp} in the
159 footprints directory. Note that the name of the file must match the
160 footprint attribute you used for the power jack in your schematics.
162 Congratulations! You've created your first custom footprint.
164 Now that we have our schematics and custom footprint, we need to
165 figure out how to start the board layout. The tool we will use is
166 @code{gsch2pcb}, which reads schematics and can create or update a
167 board to match. Since @code{gsch2pcb} doesn't use the same defaults
168 as @code{pcb}, we will create the board in @code{pcb} and only use
169 @code{gsch2pcb} in update mode.
171 When creating a non-trivial board, it's a good idea to start with a
172 larger board than your final size. For this project, the final size
173 will be 1.4 inches wide by 0.9 inches high. However, we'll start with
174 2 by 2 inch board to give us some room to move things around. Run
175 @code{pcb} and create your board, setting up the size, layers, and
176 styles just like in the last project. Make sure you set a 100 mil
177 grid, since the parts we're using are all designed with 100 mil
178 spacing in mind. Also, make sure @mnuu{Settings,Crosshair snaps to
179 pins and pads} is checked. Save this empty board as
180 @code{fb-blinker.pcb} and exit.
182 Now we run @code{gsch2pcb}, passing it the name of the project file:
185 $ gsch2pcb fb-blinker.prj
187 ---------------------------------
188 gEDA/gnetlist pcbpins Backend
189 This backend is EXPERIMENTAL
190 Use at your own risk!
191 ---------------------------------
193 Using the m4 processor for pcb footprints
195 ----------------------------------
196 Done processing. Work performed:
197 1 file elements and 6 m4 elements added to fb-blinker.new.pcb.
200 1. Run pcb on your file fb-blinker.pcb.
201 2. From within PCB, select "File -> Load layout data to paste buffer"
202 and select fb-blinker.new.pcb to load the new footprints into your existing layout.
203 3. From within PCB, select "File -> Load netlist file" and select
204 fb-blinker.net to load the updated netlist.
206 4. From within PCB, enter
208 :ExecuteFile(fb-blinker.cmd)
210 to update the pin names of all footprints.
215 What gsch2pcb does is remove elements from your board that don't exist
216 in the schematic, provide new elements that need to be added, generate
217 an updated netlist, and create a script that renames all the pins.
218 You don't need to use all these - for example, I rarely use the pin
219 renaming script - but we will this time, so you can learn how each
222 We will do as the hints above tell us to do. Run @code{pcb
223 fb-blinker.pcb} to bring up the empty board. Load the new element
224 data, which automatically changes you to the buffer tool. Click on
225 the board to place all those new parts. They'll all be in the same
226 place, but we'll fix that later. Load the new netlist, and run the
227 script. After closing any dialogs that may have come up, your board
228 should look like this:
232 The next step is to separate the elements so we can start laying out
233 our board. Use the @mnuu{Select,Disperse all elements} menu option,
234 which spreads apart the elements. Then, use the
235 @mnuu{Connect,Optimize rats nest} menu option (or the @kbd{O} key) to
236 draw all the rats on the board. These will help you figure out an
237 optimum layout of your elements. Your board should look something
238 like this (yours may vary depending on how the dispersal worked):
242 If you position the crosshair over U1 and press the @kbd{D} key,
243 you'll see that the pins are now labelled with the same labels as in
244 the schematic. You can use the @mnuu{View,Enable Pinout shows
245 number} menu checkbox to toggle between the symbolic labels and the
246 original pin numbers.
250 Now, as before, we want to rearrange the elements to minimise and
251 simplify the connections. This is where the rats come in handy. As
252 you rearrange the elements, the rats follow, so you can see how
253 rotating and moving elements affect the layout. As you move elements
254 around, press the @kbd{O} key to tell @code{pcb} to figure out the
255 best way of connecting everything in their new locations.
257 As you move the elements around, remember to pick up the power jack by
258 its mark, as the power jack's pins have metric spacing. The other
259 elements should be picked up by their pins, since they have inch
260 spacing. By picking up elements by their pins, you ensure that their
261 pins end up on the grid points when you put them down.
263 Rearrange your elements so that they look like this, somewhere near
264 the center of your board. Note that the rats nest will tell you when
265 you have the resistors backwards, since they don't have ``polarity''
266 like the LED or IC have.
270 As before, we want to move the refdes labels around so that they're
271 both visible and out of the way. To make this easier, use the
272 @mnuu{Settings,Only Names} option to keep the tools from
273 accidentally selecting elements or rat lines. Shut off the grid, and
274 use the selection and rotate tools, and the @kbd{S} size key, to make
275 the labels like this:
279 Now use @mnuu{Settings,Lock Names} to keep from accidentally moving
280 our labels later. We're still using our over-sized board. Now is the
281 time to reduce it to the final size. First, we have to move the
282 elements to the upper left corner of the board. Set the grid back to
283 100 mil, @mnuu{Select,Select all visible objects}, grab one of the
284 pins, and move everything up to the corner, as close as you can get
285 without touching the edges:
289 Click to de-select and change the board size to 1400 mils wide by 900
290 mils high. Don't forget to save often!
292 Again, we're planning on hand-soldering this board, so select
293 everything and make all the pins 10 mils bigger than the default.
295 Rather than route all the traces by hand, for this board we will use
296 the autorouter. There are a few key things you need to keep in mind
297 when using the autorouter. First, the autorouter will use all
298 available layers, so we must disable the layers we don't want it to
299 route on. To do this, click on the @b{component} button to disable
304 The autorouter also uses whatever the default style is, so select the
309 The autorouter uses the rats nest to determine what connections will
310 be autorouted, so press @kbd{O} now to make sure all the rats are
311 present and reflect the latest position of the elements. To do the
312 autorouting, simply select the @mnuu{Connects,Autoroute all rats}
317 In theory, you could consider your board ``done'' now, but to make it
318 look more professional, we will do two more steps. Use the
319 @mnuuu{Connects,Optimize routed tracks,Auto-Optimize} menu option
320 twice (or until no further changes happen) to clean up the traces left
325 And finally, select @mnuuu{Connects,Optimize routed tracks,Miter}
326 to miter the sharp corners:
330 Your board is done. As before, you can print your design or produce
331 Gerber files, according to how you're going to have your board made.