1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6 <link rel=
"stylesheet" media=
"screen" type=
"text/css" href=
"./style.css" />
7 <link rel=
"stylesheet" media=
"screen" type=
"text/css" href=
"./design.css" />
8 <link rel=
"stylesheet" media=
"print" type=
"text/css" href=
"./print.css" />
10 <meta http-equiv=
"Content-Type" content=
"text/html; charset=utf-8" />
15 <h1 class=
"sectionedit739"><a name=
"gschem_-_gsch2pcb_-_pcb" id=
"gschem_-_gsch2pcb_-_pcb">gschem -
> gsch2pcb -
> PCB
</a></h1>
19 This is a tutorial on the process of using gsch2pcb as an
20 interface between gschem and PCB.
21 It assumes the gEDA, PCB and gsch2pcb packages
22 are already installed and ready to use. Starting with gEDA
20030901,
23 gsch2pcb is packaged with gEDA and doesn
't need to be separately installed.
24 This tutorial is functional and intended to
25 generate results as quickly as possible. It is not a complete reference
26 on gschem or PCB, but it does show with a simple example design
27 all the steps one might need to take.
31 The goal is to use gsch2pcb as the bridge between gschem and PCB so
32 that the schematics can always be in sync with the PCB layout
33 because all element additions or deletions in the layout will
34 automatically be driven by changes in the schematics. Back annotation
35 from PCB to gschem is currently not possible.
39 See the
<a href=
"geda-gsch2pcb_tutorial_releasenotes.html" class=
"wikilink1" title=
"geda-gsch2pcb_tutorial_releasenotes.html">release notes
</a> for the history of this tutorial.
43 <!-- EDIT739 SECTION "gschem -> gsch2pcb -> PCB" [1-947] -->
44 <h2 class=
"sectionedit740"><a name=
"terminology" id=
"terminology">Terminology
</a></h2>
48 With gschem, you add symbols representing electronic components to a
49 schematic. A symbol is a group of pins, attributes, and lines showing
50 an iconic representation of an electronic component.
51 Pins in symbols are connected to other pins by drawing a net
52 connection between them. Attributes are just named tags attached to
53 symbols to convey some bit of information. For using the schematic with PCB,
54 there are three of these attributes which are relevant and must be
55 specified. Each added symbol should have a
<strong>footprint, value,
</strong> and
56 <strong>refdes
</strong> attribute.
60 The schematic
<strong>footprint
</strong> attribute value of a symbol is the name of the
61 PCB element to be placed on the layout for that instance of the symbol.
62 A PCB element is a group of pins, pads, and silk layer outlines physically
64 to electronic components. It is probably a source of confusion for
65 newcomers to PCB that elements are of two different types. There are the
66 original m4 macro generated PCB elements and since PCB version
1.7
68 newlib style file elements. A file element is a single fixed element
69 in a single file. However, many m4 macro element definitions may exist in a
70 single m4 element file. The macros can be given arguments to provide
71 programmable elements of variable number of pins or spacings.
72 Using these two types will be covered
73 in this tutorial and I will be referring to
74 these distinct element types as
75 <strong>m4 elements
</strong> and
<strong>file elements
</strong>.
76 When you run PCB, the gschem
<strong>footprint
</strong> attribute
77 value will appear as the displayed element name when you
78 select
<strong>Description
</strong> from the
<strong>Screen→Displayed Element Name
</strong>
79 menu because gsch2pcb uses this field to keep track of which
80 <strong>footprint
</strong> corresponds to a particular PCB element.
84 The gschem
<strong>refdes
</strong> attribute value is the reference designator
85 on the schematic such as Q1, U1, R1, etc. When you run PCB, this
86 refdes will appear as the displayed element name when you select
87 <strong>Reference Designator
</strong> from the
88 <strong>Screen→Displayed Element Name
</strong> menu.
92 The gschem
<strong>value
</strong> attribute value is the particular component value
93 such as BC546,
7400,
1K, etc. When you run PCB, this
94 <strong>value
</strong> will appear as the displayed element name when you select
95 <strong>Value
</strong> from the
<strong>Screen→Displayed Element Name
</strong> menu.
99 <!-- EDIT740 SECTION "Terminology" [948-3253] -->
100 <h2 class=
"sectionedit741"><a name=
"setup" id=
"setup">Setup
</a></h2>
104 You should have a directory structure in mind for organizing your
105 design projects. The install of gEDA
106 and PCB gives you a set of default gschem symbols and
107 default PCB elements, but you can also provide for creating your own custom
108 libraries of gschem symbols and PCB elements.
112 <li class=
"level1"><div class=
"li"> Somewhere, probably under your home directory, create a directory structure for your projects. Use directory names you like, but this tutorial will reference the directory name structure I use:
</div>
115 <pre class=
"code">gaf/
116 gaf/gschem-sym/ Where I put the custom gschem symbols I create.
117 gaf/gschem-sym/transistors/ You can organize your custom symbols into subdirectories.
118 gaf/pcb-elements/ Where I put the custom PCB file elements I create.
119 These can also be organized into subdirectories.
120 gaf/myproject1/ And finally, separate directories for each
121 gaf/myproject2/ design project.
126 With this organization, any custom gschem symbols and PCB elements you make can be common to all of your projects and this is good enough to get you started. However, I
'll mention other possibilities which will be revealed below: There can be project specific PCB
<strong>file element
</strong> subdirectories or
<strong>m4 element
</strong> files. Or, CAD administrators can set up site wide custom PCB
<strong>file element
</strong> directories and
<strong>m4 element
</strong> files.
130 <li class=
"level1"><div class=
"li"> <strong>gEDA setup (for new versions released
>=
2005):
</strong> the gschem, gnetlist, and other programs you may use such as gattrib, etc, all need to be able to find any custom symbols you will make, so you need to make your custom gschem symbol directories known to these programs in a gEDA gafrc file by adding
<strong>component-library
</strong> lines to either a user
<strong>${HOME}/gafrc
</strong> file or a project specific
<strong>gafrc
</strong> file in the project directory. There is also a system wide
<strong>${GEDADATA}/system-gafrc
</strong> file administrators can set up. The
<strong>HOME
</strong> and
<strong>GEDADATA
</strong> environment variables must be respectively set for those
<strong>gafrc
</strong> files to be found. For our directory structure setup above, we could add these lines to
<strong>${HOME}/gafrc
</strong> (plus lines for each additional
<strong>gschem-sym
</strong> subdirectory you want):
</div>
133 <pre class=
"code">(component-library
"${HOME}/gaf/gschem-sym
")
134 (component-library
"${HOME}/gaf/gschem-sym/transistors
")
</pre>
137 or, in each project directory (like myproject1 and myproject2) there could be a
<strong>gafrc
</strong> file with the lines:
139 <pre class=
"code">(component-library
"../gschem-sym
")
140 (component-library
"../gschem-sym/transistors
")
</pre>
142 <li class=
"level1"><div class=
"li"> <strong>gEDA setup (for old versions released
>=
2004):
</strong> The
<strong>gafrc
</strong> file is not supported. Well, the feature was actually introduced mid
2004, but to get the full functionality described here (relative paths) you really need a
2005 gEDA. Anyway, when using an older gEDA it is necessary to duplicate the
<strong>component-library
</strong> setup lines in multiple rc files that apply to the various gEDA programs:
</div>
144 <li class=
"level2"><div class=
"li"> <strong>gschem program setup:
</strong> create the file
<strong>~/.gEDA/gschemrc
</strong> with this content:
</div>
149 <pre class=
"code">(component-library
"${HOME}/gaf/gschem-sym
")
150 (component-library
"${HOME}/gaf/gschem-sym/transistors
")
</pre>
152 <li class=
"level1"><div class=
"li"> <strong>gnetlist program setup:
</strong> gnetlist will also need to find these symbols so duplicate those lines into
<strong>~/.gEDA/gnetlistrc
</strong>.
</div>
156 <li class=
"level1"><div class=
"li"> If you want a more detailed customization of gschem and gnetlist, you can override other initializations that are setup in the global rc files. In Debian, look at rc files in
<strong>/etc/gEDA/
</strong> for settings you can make. For example, I like the light gschem background, so I also put in my
<strong>~/.gEDA/gschemrc
</strong> the line:
</div>
159 <pre class=
"code">(load (build-path geda-rc-path
"gschem-colormap-lightbg
")) ; light background
</pre>
161 <li class=
"level1"><div class=
"li"> <strong>PCB setup:
</strong> A PCB distribution usually is set up so that PCB will automatically look in a
<strong>packages
</strong> subdirectory of the working directory. So, to make PCB find all the custom elements I put in
<strong>gaf/pcb-elements
</strong> I make a link in each of my project directories. Note that this link is actually not required when using gsch2pcb because, as described below, you may alternatively specify the
<strong>pcb-elements
</strong> directory in a
<strong>project
</strong> file. But if you do want to make the link, in directory
<strong>gaf/myproject1
</strong> enter the command:
</div>
164 <pre class=
"code">ln -s ../pcb-elements packages
</pre>
166 <li class=
"level1"><div class=
"li"> <strong> gsch2pcb setup:
</strong> In each of your project directories, create a gsch2pcb project file which can be named anything that does not end in
<em>.sch
</em>. A project file will be created in the example below.
</div>
172 This is all the setup you need beyond the initial install of the gschem, gsch2pcb, and PCB packages.
176 <!-- EDIT741 SECTION "Setup" [3254-7853] -->
177 <h2 class=
"sectionedit742"><a name=
"simple_example" id=
"simple_example">Simple Example
</a></h2>
181 Let
's generate a trivial design from schematics to PCB layout
182 almost as quickly as possible and then we can use it as a base for
183 doing some more advanced stuff. I
'll complicate it just a bit by
184 making it a two schematic design.
189 Assuming you setup the directory structure described
190 above, go to the
<strong>gaf/myproject1
</strong> directory and create
191 a file named
<strong>project
</strong> with this content:
194 <pre class=
"code">schematics one.sch two.sch
195 output-name board
</pre>
198 <!-- EDIT742 SECTION "Simple Example" [7854-8329] -->
199 <h3 class=
"sectionedit743"><a name=
"create_schematiconesch" id=
"create_schematiconesch">Create schematic: one.sch
</a></h3>
204 If you are using gschem for the first time, try stepping through
205 this simple
<a href=
"geda-gschem_warmup.html" class=
"wikilink1" title=
"geda-gschem_warmup.html">gschem warmup
</a>.
209 <a href=
"media/geda/one-sch-1.png" class=
"media" target=
"_blank" title=
"geda:one-sch-1.png"><img src=
"media/geda/one-sch-1.png" class=
"medialeft" title=
"one.sch" alt=
"one.sch" /></a> Run
<strong>gschem one.sch
</strong> and create this schematic (the second opamp is redundant, but this is just a tutorial):
212 <li class=
"level1"><div class=
"li"> Open the select components dialog (type
<strong>i
</strong>)
</div>
214 <li class=
"level1"><div class=
"li"> Make sure, the drop down menu at the bottom of the dialog is set to “Default behavior - reference component”.
</div>
216 <li class=
"level1"><div class=
"li"> Add the components:
</div>
218 <li class=
"level2"><div class=
"li"> From the
<strong>Basic devices
</strong> library three
<strong>resistor-
1.sym
</strong> and two
<strong>dual-opamp-
1.sym
</strong>.
</div>
220 <li class=
"level2"><div class=
"li"> From the
<strong>Input/output
</strong> library one
<strong>output-
2.sym
</strong>.
</div>
222 <li class=
"level2"><div class=
"li"> From the
<strong>Power rails
</strong> library one
<strong>gnd-
1.sym
</strong>, two
<strong>vcc-
1.sym
</strong> and two
<strong>vee-
1.sym
</strong></div>
226 <li class=
"level1"><div class=
"li"> Move components with the middle mouse button and rotate selected components by hitting keys
<strong>er
</strong> until everything is placed nicely. Rotate the bottom opamp and mirror it with the
<strong>ei
</strong> keys.
</div>
228 <li class=
"level1"><div class=
"li"> Use the
<strong>n
</strong> key and the mouse to draw net connections.
</div>
234 The large frame of the titleblock is a component too. It has been locked for convienience to prevent the mouse from catching it all the time. To unlock it, select it by dragging with left mouse button held down and press [e - shift-L]. You can find title blocks with different sizes in the
<strong>Titleblocks
</strong> library. Remember, to lock the new title block with [el] while the title block is selected.
238 <!-- EDIT743 SECTION "Create schematic: one.sch" [8330-9731] -->
239 <h3 class=
"sectionedit744"><a name=
"edit_the_attributes_of_the_components_on_the_schematic" id=
"edit_the_attributes_of_the_components_on_the_schematic">Edit the attributes of the components on the schematic.
</a></h3>
243 <a href=
"media/geda/one-sch-2.png" class=
"media" target=
"_blank" title=
"geda:one-sch-2.png"><img src=
"media/geda/one-sch-2.png" class=
"mediaright" title=
"one.sch" alt=
"one.sch" /></a> For each component, select it and bring up its attributes window by hitting keys
<strong>ee
</strong>. Do not edit the
<strong>refdes
</strong> attribute here, but do make these edits:
246 <li class=
"level1"><div class=
"li"> For resistors and the opamps, add visible
<strong>value
</strong> attributes and assign appropriate values to them (
10K, TL072). Move these newly visible attributes to nice locations with the middle mouse button. Zoom in and repeat clicking the middle mouse button if it is difficult to select them.
</div>
248 <li class=
"level1"><div class=
"li"> For the resistors, add a
<strong>footprint
</strong> attribute and give it the value
<strong>R025
</strong> which is the PCB
<em>m4 element
</em> for a
1/
4 watt resistor. Make this attribute invisible.
</div>
250 <li class=
"level1"><div class=
"li"> For the opamps, edit the already existing
<strong>footprint
</strong> attribute to be
<strong>DIL
8 300</strong>. Yes, include those spaces because
<strong>DIL
</strong> is a
<strong>m4 element
</strong> that takes two args. We
're telling it to make a dual in line package with
8 pins in a
300 mil package. Edit the
<strong>slot
</strong> attribute of the second opamp to be
<strong>2</strong>. Its I/O pin numbers should change from (
1,
2,
3) to (
5,
6,
7).
</div>
252 <li class=
"level1"><div class=
"li"> For the output module port, edit its
<strong>net
</strong> attribute to be
<strong>vmixer:
1</strong> and make it invisible. Edit its
<strong>value
</strong> attribute to be
<strong>Vmixer
</strong>.
</div>
258 It may have occurred to you that this editing will be painful for a
259 schematic with a large number of components that don
't have reasonable
260 initial attribute values. At least for the footprints,
261 there are a couple of things that could help. You can create your own
262 library symbols having an initial
<strong>footprint
</strong> (and even
<strong>value
</strong>)
263 attribute default that covers most of your uses. Or, when you add your
264 first component, edit it to have a good footprint default and then copy it
265 (select it and hit the
<strong>ec
</strong> keys) for all
266 remaining components instead of adding them from the library.
<br/>
271 Anyway, we
're done for now with
<strong>one.sch
</strong>, so save it with
272 the menu
<strong>File→Save Page
</strong> and quit gschem.
276 <!-- EDIT744 SECTION "Edit the attributes of the components on the schematic." [9732-11682] -->
277 <h3 class=
"sectionedit745"><a name=
"create_schematictwosch" id=
"create_schematictwosch">Create schematic: two.sch
</a></h3>
281 This will be really trivial and stupid since we
're doing it only to
282 demonstrate multiple schematic capability.
283 <a href=
"media/geda/two-sch-1.png" class=
"media" target=
"_blank" title=
"geda:two-sch-1.png"><img src=
"media/geda/two-sch-1.png" class=
"medialeft" title=
"two.sch" alt=
"two.sch" /></a> Run
<strong>gschem two.sch:
</strong>
286 <li class=
"level1"><div class=
"li"> Add component
<strong>title-B.sym
</strong> as you did in one.sch.
</div>
288 <li class=
"level1"><div class=
"li"> Add components:
</div>
290 <li class=
"level2"><div class=
"li"> From the
<strong>Input/Output
</strong> library one
<strong>input-
2.sym
</strong>.
</div>
292 <li class=
"level2"><div class=
"li"> From the
<strong>Basic Devices
</strong> library one
<strong>resistor-
1.sym
</strong>.
</div>
294 <li class=
"level2"><div class=
"li"> From the
<strong>Transistors
</strong> library one
<strong>2N3904-
1.sym
</strong>.
</div>
296 <li class=
"level2"><div class=
"li"> From the
<strong>Power rails
</strong> library one
<strong>gnd-
1.sym
</strong>, one
<strong>vcc-
1.sym
</strong> and one
<strong>vee-
1.sym
</strong>.
</div>
298 <li class=
"level2"><div class=
"li"> From the
<strong>Connectors
</strong> library one
<strong>BNC-
1.sym
</strong>.
</div>
302 <li class=
"level1"><div class=
"li"> Move components and draw nets as before.
</div>
304 <li class=
"level1"><div class=
"li"> Edit component attributes:
</div>
306 <li class=
"level2"><div class=
"li"> Input module port: edit
<strong>net
</strong> attribute to be invisible and have value
<strong>vmixer:
1</strong> so this net will be connected to the
<strong>vmixer
</strong> in one.sch. Make the
<strong>value
</strong> attribute be
<strong>Vmixer
</strong>.
</div>
308 <li class=
"level2"><div class=
"li"> Resistor: give it invisible
<strong>footprint
</strong> attribute
<strong>R025
</strong> and a visible
<strong>value
</strong> attribute
10K.
</div>
310 <li class=
"level2"><div class=
"li"> Transistor: add
<strong>value
</strong> attribute
<strong>2N3904
</strong> and invisible
<strong>footprint
</strong> attribute
<strong>TO92
</strong>.
</div>
312 <li class=
"level2"><div class=
"li"> BNC connector: add invisible
<strong>footprint
</strong> attribute
<strong>CONNECTOR
2 1</strong>. which is a
<strong>m4 element
</strong> that takes arguments and we
're telling it to make a connector with
2 rows and
1 column. We put a BNC connector on the schematic, but I
'm pretending we
'll just jumper wires from this pc board header to a panel mounted connector.
</div>
320 Unfortunately, the
2N3904 symbol we added has the text “
2N3904” as an
321 integral part of its symbol. So when we add the
<strong>value
</strong> attribute
322 (which we want so the PCB layout will show appropriate values), there are
323 two “
2N3904” designations visible on our schematic unless we would
324 make the
<strong>value
</strong> attribute invisible. This is not good and for this example
325 we have to live with it, but note that in most cases it
's not a good
326 idea to hardwire information into symbols like this.
327 Also the default
<strong>device
</strong> attribute is wrong and should be
<strong>NPN_TRANSISTOR
</strong>
328 but it won
't affect this tutorial. This is just to inform you that currently
329 there are some symbols in gschem that carry over outdated
330 attribute usage from older versions of gschem. If you get into
331 running spice on schematics, then your symbols will need to have
332 proper
<strong>device
</strong> attributes.
336 Now we are done with the schematics except for assigning
<strong>refdes
</strong>
337 attributes and we can use the command
<strong>refdes_renum
</strong> to do this
338 for both schematics at once. So, save
<strong>two.sch
</strong>, quit gschem and run:
341 <pre class=
"code">$ refdes_renum --pgskip one.sch two.sch
</pre>
345 Run gschem on the schematics again to see how the components
346 have been given a
<strong>refdes
</strong> attribute. The
<em>–pgksip
</em> option
347 makes numbering begin at
101 for one.sch and at
201 for two.sch.
348 But you should know that
349 running
<strong>refdes_renum
</strong> is really only useful for an initial
350 numbering. If you later edit your schematics and add or delete
351 components, there is no guarantee when rerunning
<strong>refdes_renum
</strong>
352 that components will keep an
353 existing
<strong>refdes
</strong> value. If in the meantime you
've generated
354 a pc board using gsch2pcb, this reference designator number mixup
355 will put your schematics out of sync with your PCB layout. So,
356 after you initially run
<strong>refdes_renum
</strong> and start a PCB
357 layout, to be safe you will
358 need to manually add (unique)
<strong>refdes
</strong> attributes for any
359 schematic components you might add. Also note that
<strong>refdes_renum
</strong> may
360 number your resistors differently than it did for my examples here
361 depending on the order in which resistors were added. Keep that in
362 mind when comparing your eventual PCB layout to what you see in the
367 <!-- EDIT745 SECTION "Create schematic: two.sch" [11683-15311] -->
368 <h3 class=
"sectionedit746"><a name=
"generate_pcb_files_from_schematics" id=
"generate_pcb_files_from_schematics">Generate PCB Files from Schematics
</a></h3>
372 We have to fix one thing in
<strong>one.sch
</strong> before we can proceed.
373 Run
<strong>gschem one.sch
</strong> and notice that
<strong>refdes_renum
</strong> has
374 given our opamps
<strong>refdes
</strong> values of
<strong>U101
</strong> and
<strong>U102
</strong>
375 and did not know we really want to be using two opamps out of a single
376 TL072 package. That
's why we edited the
<strong>slot
</strong> attribute of the
377 second opamp. We have to go back and fix this by editing the
378 <strong>refdes
</strong> attribute of the second opamp to be
<strong>U101
</strong> so
379 both opamps will have the same
<strong>refdes
</strong>
380 and there will be only one TL072 package on our pc board.
385 Now, since we have already set up a gsch2pcb
<strong>project
</strong> file,
386 all we need to do to create an initial set of PCB files is to run
390 <pre class=
"code">~/gaf/myproject1$ gsch2pcb project
391 0 file elements and
7 m4 elements added to board.pcb.
</pre>
395 Since the project file specifed
<strong>board
</strong> as the output-name,
396 the PCB files created are named
<strong>board.pcb
</strong> and
<strong>board.net
</strong>.
400 NB: more recent advice is to create an empty board using pcb first; then every use of gsch2pcb will generate changes to that layout as described below (Modifying Schematics).
401 The reason for this is that gsch2pcb
's default settings are quite different than pcb
's these days,
402 and the consensus is that pcb
's defaults are better for most uses.
403 One caveat with this is that if you use pcb2panel to combine multiple layouts into a single panelized layout,
404 you will get unusable results if the boards were created with a mix of gsch2pcb and [recent] pcb defaults
405 without editing the layer stacks, which may require further work. (mjm, Aug
2008)
409 If you get output from gsch2pcb like:
410 <em>2 unknown elements added to board.pcb.
</em>, then run with the -v
411 flag:
<strong>gsch2pcb -v project
</strong> and the gsch2pcb output will tell
412 you which schematic components don
't have a known
<strong>footprint
</strong>. Either
413 you forgot to add the attribute, the
414 attribute value is wrong,
415 or the PCB element for it is missing from your installation. But if
416 gsch2pcb can
't find any elements and all
7 are unknown, then probably
417 gsch2pcb can
't find your PCB m4 install directory. In this case,
418 look at the first part of the
419 <a href=
"geda-gsch2pcb_tutorial.html#custom_m4_elements_requires_gsch2pcb_1.0" class=
"wikilink1" title=
"geda-gsch2pcb_tutorial.html"> Custom M4 Elements
</a> section.
423 <!-- EDIT746 SECTION "Generate PCB Files from Schematics" [15312-17550] -->
424 <h3 class=
"sectionedit747"><a name=
"layout_pcb_files" id=
"layout_pcb_files">Layout PCB Files
</a></h3>
429 <h4><a name=
"set_the_defaults" id=
"set_the_defaults">Set the defaults
</a></h4>
433 <a href=
"media/geda/board-1.png" class=
"media" target=
"_blank" title=
"geda:board-1.png"><img src=
"media/geda/board-1.png" class=
"medialeft" title=
"pcb, step 1" alt=
"pcb, step 1" /></a>Run
<strong>pcb board.pcb
</strong>. You
'll see grouped into a big pile the PCB elements for all
434 the schematic component footprints. This is ok, we will clean up this mess later.
438 When you run PCB on a
<strong>.pcb
</strong> file for the first time, you should set up various initial values.
439 I usually set a
25 mil grid spacing with
<strong>Screen→Grid Setting→
25 mil
</strong>
440 for the bulk of my layout work and then change grid spacing to smaller values as needed
441 for tight layout situations. Note that if you have enabled millimeter
442 units with
<strong>Screen→Enable millimeter grid units
</strong> you will see
443 a set of millimeter size options to select from instead of mils in the
444 <strong>Screen→Grid Setting
</strong> menu. You may change between millimeter
445 and mil grid units at any time when doing a layout.
449 You should also set the default line and via sizes you
450 want for the Signal, Power, Fat, and Skinny drawing route styles.
451 Simply select one of these four route styles at the
452 lower left of the PCB window and then press the
<strong>Route Style
</strong>
453 button to edit the sizes. You can set your
454 board size now or wait until later while working on the layout.
455 To change the board size, bring up the
<strong>File→Preferences
</strong>
456 window and select the
<strong>Sizes
</strong> page. Other design rule
457 checking and increment sizes can also be edited in the Preferences
458 window. You should review PCB documentation for definitions of
459 these items. And you may find it useful to select
<strong>Screen→Enable visible grid
</strong>.
464 <h4><a name=
"disperse_the_components" id=
"disperse_the_components">Disperse the Components
</a></h4>
468 <a href=
"media/geda/board-2.png" class=
"media" target=
"_blank" title=
"geda:board-2.png"><img src=
"media/geda/board-2.png" class=
"mediaright" title=
"step 2" alt=
"step 2" /></a>
469 Use the middle mouse button to grab and move elements one
470 at a time until you have separated all the elements.
474 Or, you can let PCB spread out the elements with
475 <strong>Select→Disperse all elements
</strong> before you fine tune
476 the positions with the middle mouse button.
481 <h4><a name=
"load_the_netlist" id=
"load_the_netlist">Load the Netlist
</a></h4>
485 <a href=
"media/geda/board-3.png" class=
"media" target=
"_blank" title=
"geda:board-3.png"><img src=
"media/geda/board-3.png" class=
"medialeft" title=
"Step 3" alt=
"Step 3" /></a>
488 <li class=
"level1"><div class=
"li"> Go to
<strong>File→load netlist file
</strong> and select
<strong>board.net
</strong> </div>
490 <li class=
"level1"><div class=
"li"> Do
<strong>Connects→optimize rats-nest
</strong>. Now, the pins and pads of components should be connected with straight lines according to the schematic. These are “rats”.
</div>
496 To minimize confusion, PCB tries to draw the rats of complex connections such that the sum of all rats is as short as possible. Try to drag an element to the other side of the working area. The rats will follow like a rubber band, but the end of the rats will not jump to a different node, although the resulting length might be shorter. The action
<strong>optimize rats-nest
</strong> rats will make the rats jump to this “better” geometry. This action can be applied conviniently anytime with a troke of the the key
<strong>o
</strong>.
501 <h4><a name=
"place_the_components" id=
"place_the_components">Place the Components
</a></h4>
505 <a href=
"media/geda/board-4.png" class=
"media" target=
"_blank" title=
"geda:board-4.png"><img src=
"media/geda/board-4.png" class=
"mediaright" title=
"Step 4" alt=
"Step 4" /></a>You will have to replace the rats with traces that can be etched in copper. After “Disperse all elements” the rats are usually in a random mess with lots of crossings. You should move and rotate the components around and try to disentangle the rats as much as possible. The key to a well routed pcb is proper placement of the components. Although PCB tries to clean up the rats lines while you move the components around, it is good practice to occasionly initiate rats optimization with the
<strong>o
</strong>-key.
510 Select the
<strong>ROT
</strong> tool (
<strong>F-
9</strong>) to move elements with the
511 middle mouse button and rotate them with the left mouse button.
512 The right mouse button will move the viewport to the canvas when zoomed in.
513 Zoom in and out with the mouse wheel or alternatively with
<strong>z
</strong> and
<strong>Shift z
</strong>.
514 Hit the
<strong>f
</strong> key while the mouse hovers over a pin to highlight
515 the particular that touches this pin to help visualize the routes.
516 Use
<strong>Shift f
</strong> to unhighlight. You can undo changes anytime with the
<strong>u
</strong> key.
520 Note: you can use the PCB auto placement
521 feature instead of manually placing (or dispersing with the
522 <strong>Select→Disperse …
</strong> commands)
523 the components as described above. To do this,
524 you would load the netlist, select the components you want to be
525 autoplaced (if this is the first PCB run, just
<strong>Select→Select all
526 objects
</strong>) then do
<strong>Select→Auto place selected elements
</strong>.
527 Then you can again manually tune the PCB generated placements.
528 The auto place function should place elements more intelligently than the
529 disperse function, but it is also much slower as layouts get larger.
534 <h4><a name=
"replace_rats_nests_with_routes" id=
"replace_rats_nests_with_routes">Replace rats nests with routes
</a></h4>
538 <a href=
"media/geda/board-5.png" class=
"media" target=
"_blank" title=
"geda:board-5.png"><img src=
"media/geda/board-5.png" class=
"medialeft" title=
"Step 5" alt=
"Step 5" /></a> At this point you can start routing traces between pins connected
539 by rats nest lines. On the left PCB toolbar,
540 select the
<strong>LINE
</strong> tool, select the layer you want to draw on
541 (solder, component, etc), and start drawing lines by selecting
542 endpoints with the left
543 mouse button. Again, it can help to use the
<strong>f
</strong> key to highlight
544 routes that need to be connected.
545 If you want to stop the current trace so you can start
546 drawing a new trace somewhere else, finish the current trace with
547 a middle mouse click. Or you can play with auto routing here.
551 A very useful operation with the
<strong>SEL
</strong>
552 tool is to select multiple objects and then cut or copy them to a
553 buffer with the menu
<strong>Buffer→Cut selection to buffer
</strong> (or copy).
554 You can immediately paste the buffer contents or abort the current
555 paste by selecting another tool. The buffer contents can be pasted
556 any time later with
<strong>Buffer→Paste buffer to layout
</strong>. With
557 this you can move layout
558 areas around or step and repeat common trace patterns. To
559 select multiple objects with the
<strong>SEL
</strong> tool, click and drag
560 to select rectangular regions, and SHIFT click to toggle additional
561 selections to the currently selected set.
565 When you
've finished routing the traces (PCB will congratulate you if all
566 traces are routed when you optimze the rats nest) the board can look
567 something like this. For this view I
've selected
568 <strong>Screen→Displayed element name→Value
</strong>.
572 You will want more information on using PCB and there is a set
573 of html docs in the PCB source tarball. I don
't know of a link to
574 put here, but you can get the latest tarball from the
575 <a href=
"http://sourceforge.net/projects/pcb/" class=
"urlextern" title=
"http://sourceforge.net/projects/pcb/" rel=
"nofollow">PCB development
</a> site.
576 Or the docs may be installed somewhere on your system.
577 The Debian package has them installed in
<strong>/usr/share/doc/pcb/html/
</strong>.
578 PCB also has some convenient “live” documentation that can
579 help you become familiar with keyboard shortcuts or keyboard commands.
580 Bring up the keyboard shortcuts window with the menu
581 <strong>Window→Key Reference
</strong> and you
'll probably find just reading
582 through the shortcuts available will teach you a lot about what you
584 If you have selected in the
<strong>File→Preferences
</strong> window the
585 <em>Use separate window for command entry
</em> option, then when
586 you bring up the Command window with
<strong>Window→Command Entry
</strong>
587 (or the
':
' key), you will see a
<strong>Command Reference
</strong> expander
588 arrow. Click on the arrow and a command reference will be shown
589 which lists some commands you can type in that may not be available
590 from the menus or a keyboard shortcut.
596 have in the
<strong>Preferences→Increments
</strong> page configured a size
597 increment of
5 mils. With this you can select some lines and
598 then increase their width by
5 mils by selecting from the menu
599 <strong>Select→Change size of selected objects→Increment lines by
5 mils.
</strong>
600 However, suppose you want to be changing widths by random values and it
's
601 inconvenient to be changing the Preferences each time. For this,
602 you can select some lines,
603 bring up the command window (hit
'<strong>:
</strong>') and type in the command:
606 <pre class=
"code"> changesize(selectedlines, +
3, mils)
</pre>
610 and the selected lines
611 will increase by
3 mils. This command is now in a history list
612 which you can recall and quickly edit in the command window to change
613 sizes by other values.
618 <h4><a name=
"looking_at_the_other_side_of_the_board" id=
"looking_at_the_other_side_of_the_board">Looking at the other side of the board
</a></h4>
622 In some layouts it is important to put components on either side of
623 the board, although not for the preceeding example. In such a case
624 the
'tab
' key can be used to flip the board over and view it from the
625 back while the
'b
' key can be used to put a selected component on the
626 other side of the board.
627 On dual sided boards it is also important to note what side a particular
628 layer of traces is on. This can be seen, and set, in the
629 File→Preferences→Layers→Groups dialog. Layers on the
'component
' side
630 will be on the top of the board and layers on the
'solder
' side will be on
631 the bottom. In this dialog you should make sure that all layers which are to
632 be fabricated in the same step (i.e. etched with photo-lithography) are grouped
637 <!-- EDIT747 SECTION "Layout PCB Files" [17551-25982] -->
638 <h2 class=
"sectionedit748"><a name=
"modifying_schematics" id=
"modifying_schematics">Modifying Schematics
</a></h2>
642 The process of transfering schematic modifications to your PCB layout is
643 made very simple by using gsch2pcb. After the first
<strong>board.pcb
</strong>
644 was created when you initially ran gsch2pcb,
645 each time you run gschem on
646 your schematics and make changes, run
<strong>gsch2pcb project
</strong>. Then run
647 <strong>pcb board.pcb
</strong> and do whatever is necessary based on the work
648 gsch2pcb has done. Each time gsch2pcb is run, this will happen:
651 <li class=
"level1"><div class=
"li"> gsch2pcb always generates a new
<strong>board.net
</strong>. If the net was changed, load the new netlist file when you run pcb. *
</div>
656 If you added components (with a footprint attribute) to a schematic
657 gsch2pcb will generate a
<strong>board.new.pcb
</strong> containing all the
658 new PCB elements corresponding to the footprints.
659 You then run
<strong>pcb board.pcb
</strong> and load the
<strong>board.new.pcb
</strong>
660 with new elements into
661 the existing layout with
<strong>File→load layout data to paste-buffer
</strong>.
662 Place the new elements, load the new netlist, and route new traces.
<br/>
666 <li class=
"level1"><div class=
"li"> If you deleted components from a schematic, gsch2pcb will delete the corresponding PCB elements from
<strong>board.pcb
</strong>. You only need to run
<strong>pcb board.pcb
</strong> and clean up dangling traces from around the deleted elements.
</div>
670 <li class=
"level1"><div class=
"li"> If you change an existing component
's
<strong>footprint
</strong>, gsch2pcb will delete the corresponding old element from
<strong>board.pcb
</strong> and add the new element to
<strong>board.new.pcb
</strong>.
</div>
674 <li class=
"level1"><div class=
"li"> If you changed schematic component
<strong>value
</strong> attributes, the value changes will be forward annotated to
<strong>board.pcb
</strong> in place.
</div>
679 So by using gsch2pcb, all PCB element changes are driven by the
680 schematics and you should never need to manually add or delete elements
681 for schematic components.
686 However, you will need to manually add PCB
687 elements that are not part of the schematics such as pc board mounting
688 holes. For these manually added PCB elements, make sure you never give
689 them a
<strong>name on PCB
</strong> name because that is reserved for schematic
690 component
<strong>refdes
</strong> attributes and gsch2pcb will want to delete
691 elements which have a non-empty
<strong>name on PCB
</strong> and don
't match
692 any schematic component
<strong>refdes
</strong>.
697 Now, so far we
've only used
<strong>m4 elements
</strong> in our layout so let
's
698 modify a schematic to use a
<strong>file element
</strong>. But first, it would
699 help to know about the default elements PCB provides. Depending
700 on the location of your PCB install there will be a directory
701 <strong>/usr/local/share/pcb/newlib, /usr/share/pcb/newlib
</strong>, or possibly
702 something else (depending on the
<em>prefix
</em> specified when PCB
703 was installed). PCB versions before
20031113 used
<strong>pcb_lib
</strong> instead
704 of
<strong>newlib
</strong> in the locations
705 <strong>/usr/local/pcb_lib,
</strong> or
<strong>/usr/lib/pcb_lib,
</strong>.
706 Once you find your
<strong>newlib
</strong> directory,
707 look at the file names in each subdirectory. Each file name
708 is a name which may be used as a
<strong>footprint
</strong> attribute
709 for a schematic component. For example, there is the file
710 <strong>xxx/newlib/
2_pin_thru-hole_packages/
0.125W_Carbon_Resistor
</strong>
711 so if we wanted
1/
8 watt resistors on our layout, we could
712 use
<strong>0.125W_Carbon_Resistor
</strong> as the resistor
<strong>footprint
</strong>
713 attribute instead of
<strong>R025
</strong>. Try changing, say resistor R101 to
714 use
<strong>0.125W_Carbon_Resistor
</strong> in
<strong>one.sch
</strong> and
715 then run
<strong>gsch2pcb project
</strong>. If gsch2pcb does not find
716 this element, then you need to add your
<strong>newlib
</strong>
717 directory to your
<strong>project
</strong> file with a line like:
720 <pre class=
"code">elements-dir /usr/lib/newlib
</pre>
724 If gsch2pcb does find it, you will get:
727 <pre class=
"code">~/gaf/myproject1$ gsch2pcb project
728 board.pcb is backed up as board.pcb.bak1.
729 1 elements deleted from board.pcb.
730 1 file elements and
0 m4 elements added to board.new.pcb.
</pre>
734 Now you need to run
<strong>pcb board.pcb
</strong>. You will see that the
735 element for resistor R101 is gone and that you will get the
736 new element by loading
<strong>board.new.pcb
</strong> with
737 <strong>File→load layout data to paste-buffer
</strong>.
741 <!-- EDIT748 SECTION "Modifying Schematics" [25983-29788] -->
742 <h2 class=
"sectionedit749"><a name=
"custom_gschem_symbols" id=
"custom_gschem_symbols">Custom gschem Symbols
</a></h2>
746 A common way to generate a custom symbol is to start with an
747 existing symbol and modify it. One thing I don
't like about
748 the
<strong>dual-opamp-
1.sym
</strong> we used is that the power pins are
749 repeated on each symbol. While some will prefer this, I
750 think it makes a page full of opamps
751 look a little cluttered and it presents a good opportunity to
752 learn about
<strong>net
</strong> attributes in this tutorial.
753 It
's possible with gschem for symbols to
754 have
<strong>net
</strong> attributes which can assign pins to a particular
755 net. Instead of hooking up each opamp pin
8 to Vcc and pin
4 to
756 to Vee on the schematic, we can have that happen automatically and
757 eliminate the pins on the schematic. To do this, just copy the
758 original symbol to our custom gschem symbol directory, giving it
759 a new name, and edit it. Do the steps described below. (Your gEDA symbol install directory may be something
760 different like
<strong>/usr/local/share/gEDA/sym/
</strong>):
765 <h5><a name=
"make_attributes_visible" id=
"make_attributes_visible">Make Attributes Visible
</a></h5>
769 <a href=
"media/geda/gschem-sym-1.png" class=
"media" target=
"_blank" title=
"geda:gschem-sym-1.png"><img src=
"media/geda/gschem-sym-1.png" class=
"medialeft" title=
"Step 1" alt=
"Step 1" /></a>
771 <pre class=
"code">cd /usr/share/gEDA/sym/analog/
772 cp dual-opamp-
1.sym ~/gaf/gschem-sym/opamp-dual.sym
774 gschem opamp-dual.sym
</pre>
776 <li class=
"level1"><div class=
"li"> Hit keys
<strong>en
</strong> to make attributes visible.
</div>
778 <li class=
"level1"><div class=
"li"> Hit keys
<strong>ve
</strong> to view extents.
</div>
780 <li class=
"level1"><div class=
"li"> Left mouse click on pin
8 to select it.
</div>
786 <h5><a name=
"remove_the_visible_supply_pins" id=
"remove_the_visible_supply_pins">Remove the Visible Supply Pins
</a></h5>
790 <a href=
"media/geda/gschem-sym-2.png" class=
"media" target=
"_blank" title=
"geda:gschem-sym-2.png"><img src=
"media/geda/gschem-sym-2.png" class=
"medialeft" title=
"Step 2" alt=
"Step 2" /></a> * Hit
<strong>Delete
</strong> key to delete pin
8.
793 <li class=
"level1"><div class=
"li"> Similarly select and delete pin
4.
</div>
795 <li class=
"level1"><div class=
"li"> Double click to select and edit the
<strong>slotdef
</strong> lines. Edit them by removing the pins
4 and
8.
</div>
801 <h5><a name=
"add_global_nets_to_in_numbers" id=
"add_global_nets_to_in_numbers">Add global Nets to in Numbers
</a></h5>
805 <a href=
"media/geda/gschem-sym-3.png" class=
"media" target=
"_blank" title=
"geda:gschem-sym-3.png"><img src=
"media/geda/gschem-sym-3.png" class=
"medialeft" title=
"Step 3" alt=
"Step 3" /></a>From the menu
<strong>Add→Attribute
</strong>
808 <li class=
"level1"><div class=
"li"> Add a
<strong>net
</strong> attribute with value
<strong>Vcc:
8</strong> Select
<strong>Show Name
&amp; Value
</strong> and make it invisible.
</div>
810 <li class=
"level1"><div class=
"li"> Add a
<strong>net
</strong> attribute with value
<strong>Vee:
4</strong> Make it
<strong>Show Name
&amp; Value
</strong> and invisible.
</div>
812 <li class=
"level1"><div class=
"li"> Make the
<strong>device
</strong> attribute be just
<strong>OPAMP
</strong>.
</div>
818 Clean up by moving these new attributes as shown.
822 Change the footprint default if you wish.
823 When all the edits are done, it
's very important when editing
824 symbols to do a
<strong>Edit→Symbol Translate
</strong> to zero before saving.
825 Do that and then save the symbol with
<strong>File→Save Page
</strong>
826 I made the
<strong>footprint
</strong> default be
<strong>DIP8
</strong> because I have
827 that as a custom element.
832 <h5><a name=
"run_gschem_with_the_new_symbol" id=
"run_gschem_with_the_new_symbol">Run gschem with the New Symbol
</a></h5>
836 <a href=
"media/geda/one-sch-3.png" class=
"media" target=
"_blank" title=
"geda:one-sch-3.png"><img src=
"media/geda/one-sch-3.png" class=
"medialeft" title=
"one.sch" alt=
"one.sch" /></a> Run
<strong>gschem one.sch
</strong>. Select and delete with the
<strong>Delete
</strong>
837 key both opamps. Also delete the
<strong>Vcc
</strong> and
<strong>Vee
</strong> symbols that
838 were connected to them. Bring up the Add Components window
839 and from the
<strong>gschem-sym
</strong> library which should now have your
840 new custom symbol, place two of the
<strong>opamp-dual.sym
</strong>
841 Move them to the right place on the schematic and don
't forget to
842 mirror and rotate the bottom opamp as before. Edit the attributes
843 of each opamp giving them the same attributes they had, that
844 is make the
<strong>footprint
</strong> be
<strong>DIL
8 300</strong>, add a
<strong>value
</strong>
845 attribute of
<strong>TL072
</strong>, and make the
<strong>refdes
</strong> of both
846 opamps be
<strong>U101
</strong>. Make the
<strong>slot
</strong> of the second opamp
847 be
<strong>2</strong>. If you don
't make the attributes the same as they were
848 before, gsch2pcb will think it is a different component and delete the
849 existing
<strong>DIL
</strong> package from the layout. If you did everything
850 right, running gsch2pcb should give:
853 <pre class=
"code">~/gaf/myproject1$ gsch2pcb project
854 Found a cpinlist head with a netname! [Vcc]
855 Found a cpinlist head with a netname! [Vee]
856 Found a cpinlist head with a netname! [Vcc]
857 Found a cpinlist head with a netname! [Vee]
858 Found a cpinlist head with a netname! [Vcc]
859 Found a cpinlist head with a netname! [Vee]
860 Found a cpinlist head with a netname! [Vcc]
861 Found a cpinlist head with a netname! [Vee]
862 No elements to add so not creating board.new.pcb
</pre>
866 Where the gEDA gnetlist program
867 seems a bit “excited” about finding the new
868 Vcc and Vee
<strong>net
</strong> attributes we just added, and a new netlist
869 was generated. Now I think the schematic looks
870 cleaner. And if you run
<strong>pcb board.pcb
</strong> and load the new netlist and then
871 optimize the rats nest, PCB should tell you the board is complete
872 which means connecting the opamp power pins via the
<strong>net
</strong>
873 attribute has worked.
877 For complete details on making symbols, read through the
878 <a href=
"geda-scg.html" class=
"wikilink1" title=
"geda-scg.html">Symbol Creation Document
</a> on the
879 <a href=
"geda-documentation.html" class=
"wikilink1" title=
"geda-documentation.html">gEDA Documentation
</a> page.
883 <!-- EDIT749 SECTION "Custom gschem Symbols" [29789-34042] -->
884 <h2 class=
"sectionedit750"><a name=
"custom_file_elements" id=
"custom_file_elements">Custom file elements
</a></h2>
888 You can create custom
<strong>file elements
</strong>
889 in the middle of running PCB on any layout or you can run PCB
890 just for making the element. As a demonstration, lets make a
891 custom element for a
1N4004 diode. There are axial packages
892 provided by PCB, but we want to be sure the drill size will be
894 diode with slightly fatter leads. It needs about a
42 mil (#
58) drill.
899 Run
<strong>pcb
</strong> and the first thing to do is select the
<strong>Signal
</strong>
900 routing style and edit its sizes (press the
<strong>Route Style
</strong> button)
901 Set the
<strong>Via hole
</strong> size
902 to
42 and the
<strong>via size
</strong> to
70 or larger as you like.
904 <strong>Screen→Grid setting→
25 mil
</strong> and
905 <strong>Screen→Enable visible grid
</strong>.
906 Zoom in a couple of steps, then make the element:
907 <a href=
"media/geda/pcb-el-1.png" class=
"media" target=
"_blank" title=
"geda:pcb-el-1.png"><img src=
"media/geda/pcb-el-1.png" class=
"medialeft" title=
"Step 1" alt=
"Step 1" /></a>
910 <li class=
"level1"><div class=
"li"> Select the
<strong>VIA
</strong> tool and place two vias
400 milsapart.
</div>
912 <li class=
"level1"><div class=
"li"> With the mouse on the left via, hit the
<strong>n
</strong> key and give the via the name
<strong>1</strong>. Give the right via the name
<strong>2</strong></div>
914 <li class=
"level1"><div class=
"li"> Pin
1 will be the cathode and this must agree with the pin numbers in your diode gschem symbol.
</div>
920 <a href=
"media/geda/pcb-el-2.png" class=
"media" target=
"_blank" title=
"geda:pcb-el-2.png"><img src=
"media/geda/pcb-el-2.png" class=
"mediaright" title=
"Step 2" alt=
"Step 2" /></a>
923 <li class=
"level1"><div class=
"li"> Select the
<strong>Silk
</strong> layer and the
<strong>LINE
</strong> tool.
</div>
925 <li class=
"level1"><div class=
"li"> Draw the component outline as shown with line width set to
10 mils and the grid setting set to
10 mils.
</div>
927 <li class=
"level1"><div class=
"li"> Draw the left fat cathode indicator with three lines after setting the line width to
20 mils.
</div>
929 <li class=
"level1"><div class=
"li"> Don
't let silk layer lines overlap solder pads.
</div>
934 Select the vias and the outline just drawn using the
<strong>SEL
</strong> tool
935 and finish making the element:
939 <li class=
"level1"><div class=
"li"> <strong>Buffer→Cut selection to buffer
</strong> and move the cursor to the center of the left via and click.
</div>
941 <li class=
"level1"><div class=
"li"> <strong>Buffer→Convert buffer to element
</strong></div>
943 <li class=
"level1"><div class=
"li"> <strong>Buffer→Save buffer elements to file
</strong> and navigate to
<strong>~/gaf/pcb-elements
</strong> and save the element as
<strong>D400-
1A
</strong> since it
's a package for a
1A diode with
400 mil spaced pins. Or give it any descriptive name you like.
</div>
949 <strong>Note:
</strong> if you save the element with a name which is the same
950 as a
<strong>m4 element
</strong>, gsch2pcb will preferentially use the m4
951 element unless you give gsch2pcb the –use-files (or -f) option.
952 You may put
<strong>use-files
</strong> in a project file if you want to always
953 give priority to using
<strong>file elements
</strong>. The m4 element names appear
954 to use upper case, so you could also avoid the problem by using
955 lower case in your file element names. Also, the only way I know to make
956 the pin
1 of the symbol square is to edit the D400-
1A file manually and
957 change the square flag in the Pin “
1” line. For example, change the
961 <pre class=
"code"> Pin(
0 0 70 20 70 42 "" "1" 0x00000001)
963 Pin(
0 0 70 20 70 42 "" "1" 0x00000101)
</pre>
967 You can now use
<strong>D400-
1A
</strong> in a gschem schematic symbol
968 <strong>footprint
</strong> attribute and gsch2pcb will find it provided
969 you have made the
<strong>packages
</strong> link described in the
<strong>Setup
</strong>
970 section. If you have not made that link, you can still tell gsch2pcb
971 about the elements directory with a line in a project file:
974 <pre class=
"code">elements-dir ~/gaf/pcb-elements
</pre>
978 Possibly you
've noticed, but there are some things not right about the
979 <strong>myproject1
</strong> example. For one thing, silk layer lines are
980 overlapping solder pads on some of the elements, and for another,
981 the transistor is backwards on the layout!
982 You otherwise shouldn
't have a problem like this when working
983 with gschem and PCB, but transistor pin numbering can be confusing.
984 If you will be using transistors in your designs, here
's a description
986 making sure my gschem transistor symbol pin numbering is
987 coordinated with PCB element pin numbers:
988 <a href=
"geda-transistor_guide.html" class=
"wikilink1" title=
"geda-transistor_guide.html">transistor guide.
</a>
993 From the transistor guide, you can see that the problem here is that
994 the
<strong>TO92
</strong> element has its pins numbered
995 in the less common (
3,
2,
1) configuration while the
<strong>2N3904-
1.sym
</strong>
996 is like a npn-ebc symbol which needs a (
1,
2,
3) numbering. You can
997 see the
2N3904 pin numbers in gschem by hitting the
<strong>en
</strong> keys
998 (and don
't be confused by the
<strong>pinseq
</strong> attribute that nearly
999 covers up the
<strong>pinnumber
</strong>). And in PCB, you can see the
<strong>TO92
</strong>
1000 pin numbers by hitting the
<strong>d
</strong> key with the mouse over
1001 the element. To be sure you are seeing pin numbers and not pin
1002 names, select
<strong>Screen→pinout shows number
</strong>.
1007 I have libraries with transistor symbols and elements that you might
1008 find useful, so as a convenience you can get your custom
1009 libraries initially populated by installing my
1010 <a href=
"http://www.geda.seul.org/docs/current/tutorials/gsch2pcb/gsch2pcb-libs-20040110.tar.gz" class=
"urlextern" title=
"http://www.geda.seul.org/docs/current/tutorials/gsch2pcb/gsch2pcb-libs-20040110.tar.gz" rel=
"nofollow"> gschem/PCB libraries
</a>.
1011 Untar them under ~/gaf to mirror the setup of our example
1012 and there will also be a
1013 <strong>~/gaf/pcb-elements.Readme
</strong> which documents the PCB elements.
1014 <i
>Note: as of
1/
10/
2004 I
've corrected the tarball pcb elements
1015 to not overlap solder pads with silk layer lines.
</i
>
1016 If you untar them somewhere else,
1017 you will need to make sure that gschem knows about them with
1018 gschemrc/gnetlistrc
<strong>component-library
</strong> lines and that
1019 gsch2pcb can find them with
<strong>elements-dir
</strong> lines in a
1025 If you install them, you can fix Q201 in
<strong>two.sch
</strong>
1026 by changing its footprint to
<strong>TO-
92</strong> which is my custom
1027 element with (
1,
2,
3) pin numbering.
1028 Then run
<strong>gsch2pcb project
</strong>
1029 and then
<strong>pcb board.pcb
</strong> and load the new element for
1030 the transistor. In the next images,
<strong>two.sch
</strong> is showing
1031 the
<strong>footprint
</strong> attribute visible to emphasize it, and it also
1032 shows a new symbol for the
2N3904 which I created from my
1033 custom
<strong>npn-ebc.sym
</strong> as described in my transistor guide.
1034 In the updated board.pcb layout,
1035 if you compare the outline appearance of the transistor to the original
1036 layout you see that the orientation is now correct and that silk layer
1037 lines don
't overlap the solder pads.
1038 I also changed the
<strong>footprint
</strong> attribute for
1039 resistors R102 and R103 in
<strong>one.sch
</strong> to my custom
1040 1/
8 watt
<strong>R0w8
</strong> and
1/
4 watt
<strong>R0w4
</strong> elements to
1041 illustrate the differences in style you can have with
1042 custom elements. You can also see the R101 style after its
1043 footprint was changed to
<strong>0.125W_Carbon_Resistor
</strong> as suggested
1044 above. As you evaluate the differences in these styles, I
'll mention
1045 that for my custom elements I wanted to maximize room to display
1046 value and refdes text (the
0.125W… element body could be a little
1047 larger) and I wanted the solder pad diameter a little larger
1048 so it will be more forgiving of board fabrication technique.
1049 Also, the resistor pin spacing for my
<strong>R0w4
</strong> is slightly less
1050 than in
<strong>R025
</strong> to improve component density.
1054 <a href=
"media/geda/two-sch-2.png" class=
"media" target=
"_blank" title=
"geda:two-sch-2.png"><img src=
"media/geda/two-sch-2.png" class=
"medialeft" title=
"two.sch" alt=
"two.sch" /></a> <a href=
"media/geda/board-6.png" class=
"media" target=
"_blank" title=
"geda:board-6.png"><img src=
"media/geda/board-6.png" class=
"mediaright" title=
"pcb" alt=
"pcb" /></a>
1058 <!-- EDIT750 SECTION "Custom file elements" [34043-40504] -->
1059 <h2 class=
"sectionedit751"><a name=
"custom_m4_elements_requires_gsch2pcb_10" id=
"custom_m4_elements_requires_gsch2pcb_10">Custom m4 elements (Requires gsch2pcb
>=
1.0)
</a></h2>
1060 <div class=
"level2">
1063 First, some words about how to find out about
1064 the default
<strong>m4 elements
</strong>
1065 available in PCB. I think there is some documention forthcoming
1066 in the PCB project, but at this point I don
't know of anything
1068 and you can
't just look at filenames as you can for
1069 the
<strong>file elements
</strong>. Not only that, but many of these elements
1070 require arguments and you need to determine what they are.
1071 So for now all I can say is that the best
1072 way to find out what
's available is to read the m4 element files and
1073 for this you need to know where the PCB
1074 m4 files install location is. As of PCB
20031113 this install
1075 directory will most likely be
<strong>/usr/share/pcb/m4
</strong> or
1076 <strong>/usr/local/share/pcb/m4
</strong>, while on earlier PCB versions it could be
1077 <strong>/usr/X11R6/lib/X11/pcb/m4
</strong> (run
<em>gsch2pcb –help
</em> or
1078 <em>gsch2pcb -v project
</em> to see which of these directories gsch2pcb
1079 is using). But if your install is somewhere else you will
1080 have to track it down. By the way, if the m4 directory
<em>is
</em> somewhere
1081 different from the above three, then gsch2pcb won
't be finding your
1082 <strong>m4 elements
</strong> in the above examples and you will need to add
1083 the correct m4 directory to your
<strong>project
</strong> file with a line like:
1086 <pre class=
"code">m4-pcbdir /path/to/pcb/m4
</pre>
1090 Just read the
<strong>.inc
</strong> files in the m4 install directory. For
1091 example, in the
<strong>misc.inc
</strong> file you will find the
<strong>R025
</strong> element
1092 we
've used and it starts out with:
1095 <pre class=
"code"># -------------------------------------------------------------------
1096 # the definition of a resistor (
0.25W) package
1097 # $
1: canonical name
1100 define(`PKG_R025
',
1101 `Element(
0x00 "$
1" "$
2" "$
3" 120 30 0 100 0x00)
1107 The information you can extract from this is that a m4
<strong>PKG_
</strong> macro
1108 named
<strong>R025
</strong> is being defined and it takes
3 arguments. Now, all PCB
1109 <strong>m4 element
</strong> macros take at least three
1110 arguments and these are automatically
1111 filled in by gsch2pcb with the gschem attributes
<strong>footprint
</strong> for
1112 <strong>canonical name
</strong>,
<strong>refdes
</strong> for
<strong>name on PCB
</strong>, and
1113 <strong>value
</strong> for
<strong>value
</strong>. The “canonical name” used in these
1114 m4 files is just an older way of referring to the current PCB usage of
1115 <strong>description
</strong> as mentioned above in the
<strong>Terminology
</strong> section.
1116 Since these args are automatically filled in, you don
't need to specify
1117 any additional args to
<strong>R025
</strong> when you use it as a gschem
1118 <strong>footprint
</strong>. But now look at the very next m4 element define
1119 in
<strong>misc.inc
</strong>:
1122 <pre class=
"code"># -------------------------------------------------------------------
1123 # the definition of a SIL package without a common pin
1124 # $
1: canonical name
1127 # $
4: number of pins
1128 define(`PKG_SIL
',
1129 `define(`MAXY
', `eval(`$
4' *
100 -
50)
')
1130 Element(
0x00 "$
1" "$
2" "$
3" 160 10 3 100 0x00)
1136 From this you can determine there is a
<strong>SIL
</strong> package you can use
1137 as a
<strong>footprint
</strong>. It has
4 arguments, but only the first three are
1138 handled automatically so there is one argument you must give when using it.
1139 You get a flash of insight and realize this is a “Single In Line” package!
1140 So, instead of the
<strong>CONNECTOR
2 1</strong> element specifying
1 column we used
1141 in our example above, you might think we could have used
<strong>SIL
2</strong>.
1142 But you would be wrong! Because if you read the macro body you will see
1143 that if the argument is
<strong>2</strong> the second forloop can
't handle it.
1144 In fact, it will only work for arguments
>=
4. If you ever run gsch2pcb
1145 and it appears stuck in an infinite loop, a m4 macro argument problem
1146 is likely the cause. As you look through
<strong>misc.inc
</strong> here
's a summary
1147 of what you will find as possible elements you can use:
1150 <pre class=
"code">Package Args you need to supply
1151 SD
1 number of pins of a ZIP package
1154 SIL
1 number of pins (we know now must be
>=
4)
1155 CSIL
1 number of pins
1157 LED
1 diameter of LED
1158 DIODE_LAY
1 pin separation
1159 AXIAL_LAY
1 pin separation
1160 CRYSTAL
1 package width
1165 SMD_BASE
2 length and width of surface mount device
1166 SMD_CHIP
1 package length
</pre>
1170 And so on for the other
<strong>.inc
</strong> files…
1175 The reality is that the m4 setup is less user friendly (you can
't create
1176 the elements graphically) and more complicated (you need to understand
1177 m4 macros) than the simple
1178 <strong>file element
</strong> approach. So for most of your custom elements I
1179 suggest you are better off staying with
<strong>file elements
</strong>. However,
1180 with the m4 macro method a single element
1181 definition that takes arguments gives you a programmable
1182 element which can be very useful for large pin count packages.
1183 It is particularly nice for IC packages with variable widths
1184 and number of pins, so a good example
1185 of using a custom
<strong>m4 element
</strong> would be to copy and modify to
1186 our taste the existing
1187 m4 macro for IC packages (the
<strong>DIL
</strong> macro) into a m4 file gsch2pcb
1188 will search. The destination m4 file can be any of these:
1191 <li class=
"level1"><div class=
"li"> <strong>pcb.inc
</strong> in our
<strong>myproject1
</strong> directory and the custom element will be local to this project.
</div>
1195 <li class=
"level1"><div class=
"li"> <strong>~/.pcb/pcb.inc
</strong> and the element will be known to all of our projects.
</div>
1199 <li class=
"level1"><div class=
"li"> <strong>/path/to/anyfile
</strong> if this path is made known to gsch2pcb by adding a line to a project file like:
<pre class=
"code">m4-file /path/to/anyfile
1203 Depending on whether you want the file known only to this project, to all of your projects, or to all projects of all users, this line may be added to any of the project files:
1205 <pre class=
"code">~/gaf/myproject1/project
1207 /usr/local/etc/gsch2pcb
1215 For this tutorial, I
'll use the first
<strong>pcb.inc
</strong> way, so copy over
1216 the existing macro file:
1219 <pre class=
"code">cd /usr/local/share/pcb/m4 (or /usr/share/pcb/m4 or /usr/X11R6/lib/X11/pcb/m4)
1220 cp dil.inc ~/gaf/myproject1/pcb.inc
1221 cd ~/gaf/myproject1
</pre>
1225 Now, edit the
<strong>pcb.inc
</strong> file you just copied and cut everything
1226 out except for the PKG_DIL macro. Change the name of
1227 the package to something like PKG_DILFAT because the change we
'll make
1228 will be to make larger diameter pins. Actually, we could leave the name
1229 alone and our new definition would override the old one, but for now
1230 let
's go with the new name. Change the pin diameter from
<strong>60</strong>
1231 to
<strong>70</strong> on the
<strong><acronym title=
"Personal Identification Number">PIN
</acronym></strong> lines.
1232 When done, this should
1233 be the entire contents of the new
<strong>pcb.inc
</strong> file:
1236 <pre class=
"code"># -------------------------------------------------------------------
1237 # the definition of a dual-inline package N and similar types
1238 # $
1: canonical name
1241 # $
4: number of pins
1242 # $
5: package size (
300,
600,
900 +
100 for socket space)
1244 define(`PKG_DILFAT
',
1245 `define(`MAXY
', `eval(`$
4' /
2 *
100)
')
1246 define(`MAXX
', `eval(`$
5' +
100)
')
1247 define(`CENTERX
', `eval(MAXX /
2)
')
1248 Element(
0x00 "$
1" "$
2" "$
3" eval(CENTERX +
20)
100 3 100 0x00)
1250 forloop(`i
',
1, eval($
4 /
2),
1251 `PIN(
50, eval(i *
100 -
50),
70,
28, i)
1253 forloop(`i
',
1, eval($
4 /
2),
1254 `PIN(eval(MAXX -
50), eval(MAXY - i *
100 +
50),
70,
28, eval(i + $
4/
2))
1256 ElementLine(
0 0 0 MAXY
10)
1257 ElementLine(
0 MAXY MAXX MAXY
10)
1258 ElementLine(MAXX MAXY MAXX
0 10)
1259 ElementLine(
0 0 eval(CENTERX -
50)
0 10)
1260 ElementLine(eval(CENTERX +
50)
0 MAXX
0 10)
1261 ElementArc(CENTERX
0 50 50 0 180 10)
1267 Run
<strong>gschem one.sch
</strong> and edit the
<strong>footprint
</strong> attribute of
1268 the opamps to be
<strong>DILFAT
8 300</strong>.
1269 Then run
<strong>gsch2pcb project
</strong>
1270 and gsch2pcb will remove the
<strong>DIL
</strong> element from
<strong>board.pcb
</strong>
1271 and add into
<strong>board.new.pcb
</strong> a new
<strong>DILFAT
</strong> element from your
1272 custom m4 file
<strong>pcb.inc
</strong>. Run
<strong>pcb board.pcb
</strong> and
1273 load the
<strong>board.new.pcb
</strong> into
1274 your layout. Move the new element with its fatter pins to the location
1275 left vacant by the removal of the old element.
1279 <!-- EDIT751 SECTION "Custom m4 elements (Requires gsch2pcb >= 1.0)" [40505-48192] -->
1280 <h2 class=
"sectionedit752"><a name=
"multi-user_setup_requires_gsch2pcb_10" id=
"multi-user_setup_requires_gsch2pcb_10">Multi-user Setup (requires gsch2pcb
>=
1.0)
</a></h2>
1281 <div class=
"level2">
1284 The above examples are oriented towards a single user with projects and
1285 custom gschem and PCB libraries under his home directory. Here
's a
1286 way to set up for multiple users who need to share resources:
1289 <li class=
"level1"><div class=
"li"> Put site wide custom PCB
<strong>file elements
</strong> under, for example,
<strong>/usr/local/share/pcb/pcb-elements
</strong>. Make this directory searched by gsch2pcb for all users by putting a line into
<strong>/etc/gsch2pcb
</strong> or
<strong>/usr/local/etc/gsch2pcb
</strong>:
<pre class=
"code">elements-dir /usr/local/share/pcb/pcb-elements
1293 If there are any site wide custom PCB
<strong>m4 element
</strong> files, for example,
<strong>/usr/local/share/pcb/pcb.inc
</strong>, add another line into
<strong>/etc/gsch2pcb
</strong> or
<strong>/usr/local/etc/gsch2pcb
</strong>:
1295 <pre class=
"code">m4-file /usr/local/share/pcb/pcb.inc
1301 <li class=
"level1"><div class=
"li"> If the default PCB m4 install is not
<strong>/usr/local/share/pcb/m4, /usr/share/pcb/m4,
</strong> or
<strong>/usr/X11R6/lib/X11/pcb/m4
</strong>, then make the install location known to all users of gsch2pcb by putting into
<strong>/etc/gsch2pcb
</strong> or
<strong>/usr/local/etc/gsch2pcb
</strong> the line:
<pre class=
"code">m4-pcbdir /path/to/pcb/m4
1305 If the m4 program is gm4 instead of m4, add to the gsch2pcb file:
1307 <pre class=
"code">m4-command gm4
1313 <li class=
"level1"><div class=
"li"> If there are site wide custom gschem symbols under some directory, you will have to edit the system gschemrc and gnetlistrc files and add
<strong>component-library
</strong> lines for them.
</div>
1318 With the above, users will have access to site wide libraries
1319 and only need to put in a design
<strong>project
</strong> file
1320 lines for
<strong>schematics
</strong> and
<strong>output-name
</strong>. But they
1321 also are free to have their own additional user and/or project
1322 specific symbol and element libraries.
1326 <!-- EDIT752 SECTION "Multi-user Setup (requires gsch2pcb >= 1.0)" [48193-49830] -->
1327 <h2 class=
"sectionedit753"><a name=
"pc_board_fabrication" id=
"pc_board_fabrication">PC Board Fabrication
</a></h2>
1328 <div class=
"level2">
1331 The tutorial should cover pcb fabrication too.
1336 <h5><a name=
"photo-lithography" id=
"photo-lithography">Photo-lithography
</a></h5>
1337 <div class=
"level5">
1341 Use File→Export layout→ps to make a postscript file suitable for printing
1342 on a transparency. Note the presence of the
'mirror
' and
'ps-invert
' options
1343 which you may need depending on your process.
1347 Open the ps file and print only the pages that you will actually need for
1348 fabrication. There are a large number of pages here, many of which you may
1353 If you find that your pads and traces don
't print on the same page, or are
1354 placed on the wrong side you need to check the settings under File→Preferences→Layers
1355 to group the layers appropriately and place them on the correct side.
1360 <h5><a name=
"machining" id=
"machining">Machining
</a></h5>
1361 <div class=
"level5">
1365 <a href=
"http://www.lpkf.com" class=
"urlextern" title=
"http://www.lpkf.com" rel=
"nofollow">LPKF
</a> (and probably other companies) have a pcb plotting machines that accept gerber files.
1366 These files can be produced by choosing File→Export Layout→gerber which produces a large number of files. The files
1367 can be viewed using
<a href=
"http://geda.seul.org/tools/gerbv/index.html" class=
"urlextern" title=
"http://geda.seul.org/tools/gerbv/index.html" rel=
"nofollow">gerbv
</a> and the visualization saved. Once you are satisfied with the output gerber files just
1368 hand them off to whomever controls the pcb plotting machine and wait for the boards to be completed!
1373 <!-- EDIT753 SECTION "PC Board Fabrication" [49831-] --></body>