1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:
lang=
"en"
6 <meta http-equiv=
"Content-Type" content=
"text/html; charset=utf-8" />
7 <title>geda:gsch2pcb_tutorial
</title>
8 <meta name=
"generator" content=
"DokuWiki Release rc2007-05-24" />
9 <meta name=
"robots" content=
"index,follow" />
10 <meta name=
"date" content=
"2007-08-04T14:46:19-0400" />
11 <meta name=
"keywords" content=
"geda,gsch2pcb_tutorial" />
12 <link rel=
"search" type=
"application/opensearchdescription+xml" href=
"http://geda.seul.org/wiki/lib/exe/opensearch.php" title=
"geda Wiki" />
13 <link rel=
"start" href=
"http://geda.seul.org/wiki/" />
14 <link rel=
"contents" href=
"http://geda.seul.org/wiki/geda:gsch2pcb_tutorial?do=index" title=
"Index" />
15 <link rel=
"alternate" type=
"application/rss+xml" title=
"Recent Changes" href=
"http://geda.seul.org/wiki/feed.php" />
16 <link rel=
"alternate" type=
"application/rss+xml" title=
"Current Namespace" href=
"http://geda.seul.org/wiki/feed.php?mode=list&ns=geda" />
17 <link rel=
"alternate" type=
"text/html" title=
"Plain HTML" href=
"http://geda.seul.org/wiki/_export/xhtml/geda:gsch2pcb_tutorial" />
18 <link rel=
"alternate" type=
"text/plain" title=
"Wiki Markup" href=
"http://geda.seul.org/wiki/_export/raw/geda:gsch2pcb_tutorial" />
19 <link rel=
"stylesheet" media=
"all" type=
"text/css" href=
"lib/exe/css" />
20 <link rel=
"stylesheet" media=
"screen" type=
"text/css" href=
"lib/exe/001css" />
21 <link rel=
"stylesheet" media=
"print" type=
"text/css" href=
"lib/exe/002css" />
24 <div class=
"dokuwiki export">
26 <div class=
"tocheader toctoggle" id=
"toc__header">Table of Contents
</div>
27 <div id=
"toc__inside">
30 <li class=
"level1"><div class=
"li"><span class=
"li"><a href=
"#gschem_-_gsch2pcb_-_pcb" class=
"toc">gschem -
> gsch2pcb -
> PCB
</a></span></div>
32 <li class=
"level2"><div class=
"li"><span class=
"li"><a href=
"#terminology" class=
"toc">Terminology
</a></span></div></li>
33 <li class=
"level2"><div class=
"li"><span class=
"li"><a href=
"#setup" class=
"toc">Setup
</a></span></div></li>
34 <li class=
"level2"><div class=
"li"><span class=
"li"><a href=
"#simple_example" class=
"toc">Simple Example
</a></span></div>
36 <li class=
"level3"><div class=
"li"><span class=
"li"><a href=
"#create_schematicone.sch" class=
"toc">Create schematic: one.sch
</a></span></div></li>
37 <li class=
"level3"><div class=
"li"><span class=
"li"><a href=
"#edit_the_attributes_of_the_components_on_the_schematic" class=
"toc">Edit the attributes of the components on the schematic.
</a></span></div></li>
38 <li class=
"level3"><div class=
"li"><span class=
"li"><a href=
"#create_schematictwo.sch" class=
"toc">Create schematic: two.sch
</a></span></div></li>
39 <li class=
"level3"><div class=
"li"><span class=
"li"><a href=
"#generate_pcb_files_from_schematics" class=
"toc">Generate PCB Files from Schematics
</a></span></div></li>
40 <li class=
"level3"><div class=
"li"><span class=
"li"><a href=
"#layout_pcb_files" class=
"toc">Layout PCB Files
</a></span></div></li>
43 <li class=
"level2"><div class=
"li"><span class=
"li"><a href=
"#modifying_schematics" class=
"toc">Modifying Schematics
</a></span></div></li>
44 <li class=
"level2"><div class=
"li"><span class=
"li"><a href=
"#custom_gschem_symbols" class=
"toc">Custom gschem Symbols
</a></span></div></li>
45 <li class=
"level2"><div class=
"li"><span class=
"li"><a href=
"#custom_file_elements" class=
"toc">Custom file elements
</a></span></div></li>
46 <li class=
"level2"><div class=
"li"><span class=
"li"><a href=
"#custom_m4_elements_requires_gsch2pcb_1.0" class=
"toc">Custom m4 elements (Requires gsch2pcb
>=
1.0)
</a></span></div></li>
47 <li class=
"level2"><div class=
"li"><span class=
"li"><a href=
"#multi-user_setup_requires_gsch2pcb_1.0" class=
"toc">Multi-user Setup (requires gsch2pcb
>=
1.0)
</a></span></div></li>
48 <li class=
"level2"><div class=
"li"><span class=
"li"><a href=
"#pc_board_fabrication" class=
"toc">PC Board Fabrication
</a></span></div></li></ul>
55 <h1><a name=
"gschem_-_gsch2pcb_-_pcb" id=
"gschem_-_gsch2pcb_-_pcb">gschem -
> gsch2pcb -
> PCB
</a></h1>
59 This is a tutorial on the process of using gsch2pcb as an interface between gschem and PCB. It assumes the gEDA, PCB and gsch2pcb packages are already installed and ready to use. Starting with gEDA
20030901, gsch2pcb is packaged with gEDA and doesn’t need to be separately installed. This tutorial is functional and intended to generate results as quickly as possible. It is not a complete reference on gschem or PCB, but it does show with a simple example design all the steps one might need to take.
63 The goal is to use gsch2pcb as the bridge between gschem and PCB so that the schematics can always be in sync with the PCB layout because all element additions or deletions in the layout will automatically be driven by changes in the schematics. Back annotation from PCB to gschem is currently not possible.
67 See the
<a href=
"geda_gsch2pcb_tutorial_releasenotes.html" class=
"wikilink1" title=
"geda:gsch2pcb_tutorial_releasenotes">release notes
</a> for the history of this tutorial.
71 <!-- SECTION "gschem -> gsch2pcb -> PCB" [1-947] -->
72 <h2><a name=
"terminology" id=
"terminology">Terminology
</a></h2>
76 With gschem, you add symbols representing electronic components to a schematic. A symbol is a group of pins, attributes, and lines showing an iconic representation of an electronic component. Pins in symbols are connected to other pins by drawing a net connection between them. Attributes are just named tags attached to symbols to convey some bit of information. For using the schematic with PCB, there are three of these attributes which are relevant and must be specified. Each added symbol should have a
<strong>footprint, value,
</strong> and
<strong>refdes
</strong> attribute.
80 The schematic
<strong>footprint
</strong> attribute value of a symbol is the name of the PCB element to be placed on the layout for that instance of the symbol. A PCB element is a group of pins, pads, and silk layer outlines physically corresponding to electronic components. It is probably a source of confusion for newcomers to PCB that elements are of two different types. There are the original m4 macro generated PCB elements and since PCB version
1.7 there are also the newlib style file elements. A file element is a single fixed element in a single file. However, many m4 macro element definitions may exist in a single m4 element file. The macros can be given arguments to provide programmable elements of variable number of pins or spacings. Using these two types will be covered in this tutorial and I will be referring to these distinct element types as
<strong>m4 elements
</strong> and
<strong>file elements
</strong>. When you run PCB, the gschem
<strong>footprint
</strong> attribute value will appear as the displayed element name when you select
<strong>Description
</strong> from the
<strong>Screen
→Displayed Element Name
</strong> menu because gsch2pcb uses this field to keep track of which
<strong>footprint
</strong> corresponds to a particular PCB element.
84 The gschem
<strong>refdes
</strong> attribute value is the reference designator on the schematic such as Q1, U1, R1, etc. When you run PCB, this refdes will appear as the displayed element name when you select
<strong>Reference Designator
</strong> from the
<strong>Screen
→Displayed Element Name
</strong> menu.
88 The gschem
<strong>value
</strong> attribute value is the particular component value such as BC546,
7400,
1K, etc. When you run PCB, this
<strong>value
</strong> will appear as the displayed element name when you select
<strong>Value
</strong> from the
<strong>Screen
→Displayed Element Name
</strong> menu.
92 <!-- SECTION "Terminology" [948-3250] -->
93 <h2><a name=
"setup" id=
"setup">Setup
</a></h2>
97 You should have a directory structure in mind for organizing your design projects. The install of gEDA and PCB gives you a set of default gschem symbols and default PCB elements, but you can also provide for creating your own custom libraries of gschem symbols and PCB elements.
100 <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>
103 <pre class=
"code">gaf/
104 gaf/gschem-sym/ Where I put the custom gschem symbols I create.
105 gaf/gschem-sym/transistors/ You can organize your custom symbols into subdirectories.
106 gaf/pcb-elements/ Where I put the custom PCB file elements I create.
107 These can also be organized into subdirectories.
108 gaf/myproject1/ And finally, separate directories for each
109 gaf/myproject2/ design project.
113 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.
116 <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>
119 <pre class=
"code">(component-library
"${HOME}/gaf/gschem-sym
")
120 (component-library
"${HOME}/gaf/gschem-sym/transistors
")
</pre>
123 or, in each project directory there could be a
<strong>gafrc
</strong> file with the lines:
125 <pre class=
"code">(component-library
"../gaf/gschem-sym
")
126 (component-library
"../gaf/gschem-sym/transistors
")
</pre>
128 <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>
130 <li class=
"level2"><div class=
"li"> <strong>gschem program setup:
</strong> create the file
<strong>~/.gEDA/gschemrc
</strong> with this content:
</div>
135 <pre class=
"code">(component-library
"${HOME}/gaf/gschem-sym
")
136 (component-library
"${HOME}/gaf/gschem-sym/transistors
")
</pre>
138 <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>
142 <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>
145 <pre class=
"code">(load (string-append gedadatarc
"/gschem-lightbg
")) ; light background
</pre>
147 <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>
150 <pre class=
"code">ln -s ../pcb-elements packages
</pre>
152 <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 poject file will be created in the example below.
</div>
157 This is all the setup you need beyond the initial install of the gschem, gsch2pcb, and PCB packages.
161 <!-- SECTION "Setup" [3251-7817] -->
162 <h2><a name=
"simple_example" id=
"simple_example">Simple Example
</a></h2>
166 Let’s generate a trivial design from schematics to PCB layout almost as quickly as possible and then we can use it as a base for doing some more advanced stuff. I’ll complicate it just a bit by making it a two schematic design.
170 Assuming you setup the directory structure described above, go to the
<strong>gaf/myproject1
</strong> directory and create a file named
<strong>project
</strong> with this content:
172 <pre class=
"code">schematics one.sch two.sch
177 <!-- SECTION "Simple Example" [7818-8290] -->
178 <h3><a name=
"create_schematicone.sch" id=
"create_schematicone.sch">Create schematic: one.sch
</a></h3>
182 If you are using gschem for the first time, try stepping through this simple
<a href=
"http://geda.seul.org/wiki/geda:gschem_warmup" class=
"wikilink1" title=
"geda:gschem_warmup">gschem warmup
</a>.
186 <a href=
"_detail/geda_one-sch-1.html" class=
"media" 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):
189 <li class=
"level1"><div class=
"li"> Add components:
</div>
191 <li class=
"level2"><div class=
"li"> From the
<strong>analog
</strong> library three
<strong>resistor-
1.sym
</strong> and two
<strong>dual-opamp-
1.sym
</strong>.
</div>
193 <li class=
"level2"><div class=
"li"> From the
<strong>io
</strong> library one
<strong>output-
2.sym
</strong>.
</div>
195 <li class=
"level2"><div class=
"li"> From the
<strong>power
</strong> library one
<strong>gnd-
1.sym
</strong>, two
<strong>vcc-
1.sym
</strong> and two
<strong>vee-
1.sym
</strong></div>
199 <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>
201 <li class=
"level1"><div class=
"li"> Use the
<strong>n
</strong> key and the mouse to draw net connections.
</div>
206 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 default library. Remember, to lock the new title block with [el] while the tiotle block is selected.
210 <!-- SECTION "Create schematic: one.sch" [8291-9493] -->
211 <h3><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>
215 <a href=
"_detail/geda_one-sch-2.html" class=
"media" 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:
218 <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>
220 <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>
222 <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>
224 <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>
229 It may have occurred to you that this editing will be painful for a schematic with a large number of components that don’t have reasonable initial attribute values. At least for the footprints, there are a couple of things that could help. You can create your own library symbols having an initial
<strong>footprint
</strong> (and even
<strong>value
</strong>) attribute default that covers most of your uses. Or, when you add your first component, edit it to have a good footprint default and then copy it (select it and hit the
<strong>ec
</strong> keys) for all remaining components instead of adding them from the library.
<br/>
234 Anyway, we’re done for now with
<strong>one.sch
</strong>, so save it with the menu
<strong>File
→Save Page
</strong> and quit gschem.
238 <!-- SECTION "Edit the attributes of the components on the schematic." [9494-11442] -->
239 <h3><a name=
"create_schematictwo.sch" id=
"create_schematictwo.sch">Create schematic: two.sch
</a></h3>
243 This will be really trivial and stupid since we’re doing it only to demonstrate multiple schematic capability.
<a href=
"_detail/geda_two-sch-1.html" class=
"media" 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>
246 <li class=
"level1"><div class=
"li"> Add component
<strong>title-B.sym
</strong> as you did in one.sch.
</div>
248 <li class=
"level1"><div class=
"li"> Add components:
</div>
250 <li class=
"level2"><div class=
"li"> From the
<strong>io
</strong> library one
<strong>input-
2.sym
</strong>.
</div>
252 <li class=
"level2"><div class=
"li"> From the
<strong>analog
</strong> library one
<strong>resistor-
1.sym
</strong>.
</div>
254 <li class=
"level2"><div class=
"li"> From the
<strong>transistor
</strong> library one
<strong>2N3904-
1.sym
</strong>.
</div>
256 <li class=
"level2"><div class=
"li"> From the
<strong>power
</strong> library one
<strong>gnd-
1.sym
</strong>, one
<strong>vcc-
1.sym
</strong> and one
<strong>vee-
1.sym
</strong>.
</div>
258 <li class=
"level2"><div class=
"li"> From the
<strong>connector
</strong> library one
<strong>BNC-
1.sym
</strong>.
</div>
262 <li class=
"level1"><div class=
"li"> Move components and draw nets as before.
</div>
264 <li class=
"level1"><div class=
"li"> Edit component attributes:
</div>
266 <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>
268 <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>
270 <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>
272 <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>
279 Unfortunately, the
2N3904 symbol we added has the text “
2N3904” as an integral part of its symbol. So when we add the
<strong>value
</strong> attribute (which we want so the PCB layout will show appropriate values), there are two “
2N3904” designations visible on our schematic unless we would make the
<strong>value
</strong> attribute invisible. This is not good and for this example we have to live with it, but note that in most cases it’s not a good idea to hardwire information into symbols like this. Also the default
<strong>device
</strong> attribute is wrong and should be
<strong>NPN_TRANSISTOR
</strong> but it won’t affect this tutorial. This is just to inform you that currently there are some symbols in gschem that carry over outdated attribute usage from older versions of gschem. If you get into running spice on schematics, then your symbols will need to have proper
<strong>device
</strong> attributes.
283 Now we are done with the schematics except for assigning
<strong>refdes
</strong> attributes and we can use the command
<strong>refdes_renum
</strong> to do this for both schematics at once. So, save
<strong>two.sch
</strong>, quit gschem and run:
285 <pre class=
"code">$ refdes_renum --pgskip one.sch two.sch
289 Run gschem on the schematics again to see how the components have been given a
<strong>refdes
</strong> attribute. The
<em>–pgksip
</em> option makes numbering begin at
101 for one.sch and at
201 for two.sch. But you should know that running
<strong>refdes_renum
</strong> is really only useful for an initial numbering. If you later edit your schematics and add or delete components, there is no guarantee when rerunning
<strong>refdes_renum
</strong> that components will keep an existing
<strong>refdes
</strong> value. If in the meantime you’ve generated a pc board using gsch2pcb, this reference designator number mixup will put your schematics out of sync with your PCB layout. So, after you initially run
<strong>refdes_renum
</strong> and start a PCB layout, to be safe you will need to manually add (unique)
<strong>refdes
</strong> attributes for any schematic components you might add. Also note that
<strong>refdes_renum
</strong> may number your resistors differently than it did for my examples here depending on the order in which resistors were added. Keep that in mind when comparing your eventual PCB layout to what you see in the images below.
293 <!-- SECTION "Create schematic: two.sch" [11443-15046] -->
294 <h3><a name=
"generate_pcb_files_from_schematics" id=
"generate_pcb_files_from_schematics">Generate PCB Files from Schematics
</a></h3>
298 We have to fix one thing in
<strong>one.sch
</strong> before we can proceed. Run
<strong>gschem one.sch
</strong> and notice that
<strong>refdes_renum
</strong> has given our opamps
<strong>refdes
</strong> values of
<strong>U101
</strong> and
<strong>U102
</strong> and did not know we really want to be using two opamps out of a single TL072 package. That’s why we edited the
<strong>slot
</strong> attribute of the second opamp. We have to go back and fix this by editing the
<strong>refdes
</strong> attribute of the second opamp to be
<strong>U101
</strong> so both opamps will have the same
<strong>refdes
</strong> and there will be only one TL072 package on our pc board.
302 Now, since we have already set up a gsch2pcb
<strong>project
</strong> file, all we need to do to create an initial set of PCB files is to run gsch2pcb:
304 <pre class=
"code">~/gaf/myproject1$ gsch2pcb project
305 0 file elements and
7 m4 elements added to board.pcb.
309 Since the project file specifed
<strong>board
</strong> as the output-name, the PCB files created are named
<strong>board.pcb
</strong> and
<strong>board.net
</strong>.
313 If you get output from gsch2pcb like:
<em>2 unknown elements added to board.pcb.
</em>, then run with the -v flag:
<strong>gsch2pcb -v project
</strong> and the gsch2pcb output will tell you which schematic components don’t have a known
<strong>footprint
</strong>. Either you forgot to add the attribute, the attribute value is wrong, or the PCB element for it is missing from your installation. But if gsch2pcb can’t find any elements and all
7 are unknown, then probably gsch2pcb can’t find your PCB m4 install directory. In this case, look at the first part of the
<span class=
"curid"><a href=
"http://geda.seul.org/wiki/geda:gsch2pcb_tutorial#custom_m4_elements_requires_gsch2pcb_1.0" class=
"wikilink1" title=
"geda:gsch2pcb_tutorial"> Custom M4 Elements
</a></span> section.
317 <!-- SECTION "Generate PCB Files from Schematics" [15047-16644] -->
318 <h3><a name=
"layout_pcb_files" id=
"layout_pcb_files">Layout PCB Files
</a></h3>
323 <h4><a name=
"set_the_defaults" id=
"set_the_defaults">Set the defaults
</a></h4>
327 <a href=
"_detail/geda_board-1.html" class=
"media" 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 the schematic component footprints. This is ok, we will clean up this mess later.
331 When you run PCB on a
<strong>.pcb
</strong> file for the first time, you should set up various initial values. I usually set a
25 mil grid spacing with
<strong>Screen
→Grid Setting
→25 mil
</strong> for the bulk of my layout work and then change grid spacing to smaller values as needed for tight layout situations. Note that if you have enabled millimeter units with
<strong>Screen
→Enable millimeter grid units
</strong> you will see a set of millimeter size options to select from instead of mils in the
<strong>Screen
→Grid Setting
</strong> menu. You may change between millimeter and mil grid units at any time when doing a layout.
335 You should also set the default line and via sizes you want for the Signal, Power, Fat, and Skinny drawing route styles. Simply select one of these four route styles at the lower left of the PCB window and then press the
<strong>Route Style
</strong> button to edit the sizes. You can set your board size now or wait until later while working on the layout. To change the board size, bring up the
<strong>File
→Preferences
</strong> window and select the
<strong>Sizes
</strong> page. Other design rule checking and increment sizes can also be edited in the Preferences window. You should review PCB documentation for definitions of these items. And you may find it useful to select
<strong>Screen
→Enable visible grid
</strong>.
340 <h4><a name=
"disperse_the_components" id=
"disperse_the_components">Disperse the Components
</a></h4>
344 <a href=
"_detail/geda_board-2.html" class=
"media" title=
"geda:board-2.png"><img src=
"_media/geda_board-2.png" class=
"mediaright" title=
"step 2" alt=
"step 2" /></a> Use the middle mouse button to grab and move elements one at a time until you have separated all the elements.
348 Or, you can let PCB spread out the elements with
<strong>Select
→Disperse all elements
</strong> before you fine tune the positions with the middle mouse button.
353 <h4><a name=
"load_the_netlist" id=
"load_the_netlist">Load the Netlist
</a></h4>
357 <a href=
"_detail/geda_board-3.html" class=
"media" title=
"geda:board-3.png"><img src=
"_media/geda_board-3.png" class=
"medialeft" title=
"Step 3" alt=
"Step 3" /></a>
360 <li class=
"level1"><div class=
"li"> Go to
<strong>File
→load netlist file
</strong> and select
<strong>board.net
</strong> </div>
362 <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>
367 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>.
372 <h4><a name=
"place_the_components" id=
"place_the_components">Place the Components
</a></h4>
376 <a href=
"_detail/geda_board-4.html" class=
"media" 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.
380 Select the
<strong>ROT
</strong> tool (
<strong>F-
9</strong>) to move elements with the middle mouse button and rotate them with the left mouse button. The right mouse button will move the viewport to the canvas when zoomed in. Zoom in and out with the mouse wheel or alternatively with
<strong>z
</strong> and
<strong>Shift z
</strong>. Hit the
<strong>f
</strong> key while the mouse hovers over a pin to highlight the particular that touches this pin to help visualize the routes. Use
<strong>Shift f
</strong> to unhighlight. You can undo changes anytime with the
<strong>u
</strong> key.
384 Note: you can use the PCB auto placement feature instead of manually placing (or dispersing with the
<strong>Select
→Disperse
…</strong> commands) the components as described above. To do this, you would load the netlist, select the components you want to be autoplaced (if this is the first PCB run, just
<b
>Select
→Select all objects
</b
>) then do
<strong>Select
→Auto place selected elements
</strong>. Then you can again manually tune the PCB generated placements. The auto place function should place elements more intelligently than the disperse function, but it is also much slower as layouts get larger.
389 <h4><a name=
"replace_rats_nests_with_routes" id=
"replace_rats_nests_with_routes">Replace rats nests with routes
</a></h4>
393 <a href=
"_detail/geda_board-5.html" class=
"media" 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 by rats nest lines. On the left PCB toolbar, select the
<strong>LINE
</strong> tool, select the layer you want to draw on (solder, component, etc), and start drawing lines by selecting endpoints with the left mouse button. Again, it can help to use the
<strong>f
</strong> key to highlight routes that need to be connected. If you want to stop the current trace so you can start drawing a new trace somewhere else, finish the current trace with a middle mouse click. Or you can play with auto routing here.
397 A very useful operation with the
<strong>SEL
</strong> tool is to select multiple objects and then cut or copy them to a buffer with the menu
<strong>Buffer
→Cut selection to buffer
</strong> (or copy). You can immediately paste the buffer contents or abort the current paste by selecting another tool. The buffer contents can be pasted any time later with
<strong>Buffer
→Paste buffer to layout
</strong>. With this you can move layout areas around or step and repeat common trace patterns. To select multiple objects with the
<strong>SEL
</strong> tool, click and drag to select rectangular regions, and SHIFT click to toggle additional selections to the currently selected set.
401 When you’ve finished routing the traces (PCB will congratulate you if all traces are routed when you optimze the rats nest) the board can look something like this. For this view I’ve selected
<strong>Screen
→Displayed element name
→Value
</strong>.
405 You will want more information on using PCB and there is a set of html docs in the PCB source tarball. I don’t know of a link to put here, but you can get the latest tarball from the
<a href=
"http://sourceforge.net/projects/pcb/" class=
"urlextern" title=
"http://sourceforge.net/projects/pcb/" rel=
"nofollow">PCB development
</a> site. Or the docs may be installed somewhere on your system. The Debian package has them installed in
<strong>/usr/share/doc/pcb/html/
</strong>. PCB also has some convenient “live” documentation that can help you become familiar with keyboard shortcuts or keyboard commands. Bring up the keyboard shortcuts window with the menu
<strong>Window
→Key Reference
</strong> and you’ll probably find just reading through the shortcuts available will teach you a lot about what you can do with PCB. If you have selected in the
<strong>File
→Preferences
</strong> window the
<em>Use separate window for command entry
</em> option, then when you bring up the Command window with
<strong>Window
→Command Entry
</strong> (or the
':
' key), you will see a
<strong>Command Reference
</strong> expander arrow. Click on the arrow and a command reference will be shown which lists some commands you can type in that may not be available from the menus or a keyboard shortcut.
409 For example, say you have in the
<strong>Preferences
→Increments
</strong> page configured a size increment of
5 mils. With this you can select some lines and then increase their width by
5 mils by selecting from the menu
<strong>Select
→Change size of selected objects
→Increment lines by
5 mils.
</strong> However, suppose you want to be changing widths by random values and it’s inconvenient to be changing the Preferences each time. For this, you can select some lines, bring up the command window (hit ‘
<strong>:
</strong>’) and type in the command:
411 <pre class=
"code"> changesize(selectedlines, +
3, mils)
415 and the selected lines will increase by
3 mils. This command is now in a history list which you can recall and quickly edit in the command window to change sizes by other values.
419 <!-- SECTION "Layout PCB Files" [16645-24283] -->
420 <h2><a name=
"modifying_schematics" id=
"modifying_schematics">Modifying Schematics
</a></h2>
424 The process of transfering schematic modifications to your PCB layout is made very simple by using gsch2pcb. After the first
<strong>board.pcb
</strong> was created when you initially ran gsch2pcb, each time you run gschem on your schematics and make changes, run
<strong>gsch2pcb project
</strong>. Then run
<strong>pcb board.pcb
</strong> and do whatever is necessary based on the work gsch2pcb has done. Each time gsch2pcb is run, this will happen:
427 <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>
432 If you added components (with a footprint attribute) to a schematic gsch2pcb will generate a
<strong>board.new.pcb
</strong> containing all the new PCB elements corresponding to the footprints. You then run
<strong>pcb board.pcb
</strong> and load the
<strong>board.new.pcb
</strong> with new elements into the existing layout with
<strong>File
→load layout data to paste-buffer
</strong>. Place the new elements, load the new netlist, and route new traces.
<br/>
436 <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>
440 <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>
444 <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>
449 So by using gsch2pcb, all PCB element changes are driven by the schematics and you should never need to manually add or delete elements for schematic components.
453 However, you will need to manually add PCB elements that are not part of the schematics such as pc board mounting holes. For these manually added PCB elements, make sure you never give them a
<strong>name on PCB
</strong> name because that is reserved for schematic component
<strong>refdes
</strong> attributes and gsch2pcb will want to delete elements which have a non-empty
<strong>name on PCB
</strong> and don’t match any schematic component
<strong>refdes
</strong>.
457 Now, so far we’ve only used
<strong>m4 elements
</strong> in our layout so let’s modify a schematic to use a
<strong>file element
</strong>. But first, it would help to know about the default elements PCB provides. Depending on the location of your PCB install there will be a directory
<strong>/usr/local/share/pcb/newlib, /usr/share/pcb/newlib
</strong>, or possibly something else (depending on the
<em>prefix
</em> specified when PCB was installed). PCB versions before
20031113 used
<strong>pcb_lib
</strong> instead of
<strong>newlib
</strong> in the locations
<strong>/usr/local/pcb_lib,
</strong> or
<strong>/usr/lib/pcb_lib,
</strong>. Once you find your
<strong>newlib
</strong> directory, look at the file names in each subdirectory. Each file name is a name which may be used as a
<strong>footprint
</strong> attribute for a schematic component. For example, there is the file
<strong>xxx/newlib/
2_pin_thru-hole_packages/
0.125W_Carbon_Resistor
</strong> so if we wanted
1/
8 watt resistors on our layout, we could use
<strong>0.125W_Carbon_Resistor
</strong> as the resistor
<strong>footprint
</strong> attribute instead of
<strong>R025
</strong>. Try changing, say resistor R101 to use
<strong>0.125W_Carbon_Resistor
</strong> in
<strong>one.sch
</strong> and then run
<strong>gsch2pcb project
</strong>. If gsch2pcb does not find this element, then you need to add your
<strong>newlib
</strong> directory to your
<strong>project
</strong> file with a line like:
459 <pre class=
"code">elements-dir /usr/lib/newlib
463 If gsch2pcb does find it, you will get:
465 <pre class=
"code">~/gaf/myproject1$ gsch2pcb project
466 board.pcb is backed up as board.pcb.bak1.
467 1 elements deleted from board.pcb.
468 1 file elements and
0 m4 elements added to board.new.pcb.
472 Now you need to run
<strong>pcb board.pcb
</strong>. You will see that the element for resistor R101 is gone and that you will get the new element by loading
<strong>board.new.pcb
</strong> with
<strong>File
→load layout data to paste-buffer
</strong>.
476 <!-- SECTION "Modifying Schematics" [24284-28089] -->
477 <h2><a name=
"custom_gschem_symbols" id=
"custom_gschem_symbols">Custom gschem Symbols
</a></h2>
481 A common way to generate a custom symbol is to start with an existing symbol and modify it. One thing I don’t like about the
<strong>dual-opamp-
1.sym
</strong> we used is that the power pins are repeated on each symbol. While some will prefer this, I think it makes a page full of opamps look a little cluttered and it presents a good opportunity to learn about
<strong>net
</strong> attributes in this tutorial. It’s possible with gschem for symbols to have
<strong>net
</strong> attributes which can assign pins to a particular net. Instead of hooking up each opamp pin
8 to Vcc and pin
4 to to Vee on the schematic, we can have that happen automatically and eliminate the pins on the schematic. To do this, just copy the original symbol to our custom gschem symbol directory, giving it a new name, and edit it. Do the steps described below. (Your gEDA symbol install directory may be something different like
<strong>/usr/local/share/gEDA/sym/
</strong>):
486 <h5><a name=
"make_attributes_visible" id=
"make_attributes_visible">Make Attributes Visible
</a></h5>
490 <a href=
"_detail/geda_gschem-sym-1.html" class=
"media" title=
"geda:gschem-sym-1.png"><img src=
"_media/geda_gschem-sym-1.png" class=
"medialeft" title=
"Step 1" alt=
"Step 1" /></a>
492 <pre class=
"code">cd /usr/share/gEDA/sym/analog/
493 cp dual-opamp-
1.sym ~/gaf/gschem-sym/opamp-dual.sym
495 gschem opamp-dual.sym
498 <li class=
"level1"><div class=
"li"> Hit keys
<strong>en
</strong> to make attributes visible.
</div>
500 <li class=
"level1"><div class=
"li"> Hit keys
<strong>ve
</strong> to view extents.
</div>
502 <li class=
"level1"><div class=
"li"> Left mouse click on pin
8 to select it.
</div>
508 <h5><a name=
"remove_the_visible_supply_pins" id=
"remove_the_visible_supply_pins">Remove the Visible Supply Pins
</a></h5>
512 <a href=
"_detail/geda_gschem-sym-2.html" class=
"media" 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.
515 <li class=
"level1"><div class=
"li"> Similarly select and delete pin
4.
</div>
517 <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>
523 <h5><a name=
"add_global_nets_to_in_numbers" id=
"add_global_nets_to_in_numbers">Add global Nets to in Numbers
</a></h5>
527 <a href=
"_detail/geda_gschem-sym-3.html" class=
"media" 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>
530 <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>
532 <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>
534 <li class=
"level1"><div class=
"li"> Make the
<strong>device
</strong> attribute be just
<strong>OPAMP
</strong>.
</div>
539 Clean up by moving these new attributes as shown.
543 Change the footprint default if you wish. When all the edits are done, it’s very important when editing symbols to do a
<strong>Edit
→Symbol Translate
</strong> to zero before saving. Do that and then save the symbol with
<strong>File
→Save Page
</strong> I made the
<strong>footprint
</strong> default be
<strong>DIP8
</strong> because I have that as a custom element.
548 <h5><a name=
"run_gschem_with_the_new_symbol" id=
"run_gschem_with_the_new_symbol">Run gschem with the New Symbol
</a></h5>
552 <a href=
"_detail/geda_one-sch-3.html" class=
"media" 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> key both opamps. Also delete the
<strong>Vcc
</strong> and
<strong>Vee
</strong> symbols that were connected to them. Bring up the Add Components window and from the
<strong>gschem-sym
</strong> library which should now have your new custom symbol, place two of the
<strong>opamp-dual.sym
</strong> Move them to the right place on the schematic and don’t forget to mirror and rotate the bottom opamp as before. Edit the attributes of each opamp giving them the same attributes they had, that is make the
<strong>footprint
</strong> be
<strong>DIL
8 300</strong>, add a
<strong>value
</strong> attribute of
<strong>TL072
</strong>, and make the
<strong>refdes
</strong> of both opamps be
<strong>U101
</strong>. Make the
<strong>slot
</strong> of the second opamp be
<strong>2</strong>. If you don’t make the attributes the same as they were before, gsch2pcb will think it is a different component and delete the existing
<strong>DIL
</strong> package from the layout. If you did everything right, running gsch2pcb should give:
554 <pre class=
"code">~/gaf/myproject1$ gsch2pcb project
555 Found a cpinlist head with a netname! [Vcc]
556 Found a cpinlist head with a netname! [Vee]
557 Found a cpinlist head with a netname! [Vcc]
558 Found a cpinlist head with a netname! [Vee]
559 Found a cpinlist head with a netname! [Vcc]
560 Found a cpinlist head with a netname! [Vee]
561 Found a cpinlist head with a netname! [Vcc]
562 Found a cpinlist head with a netname! [Vee]
563 No elements to add so not creating board.new.pcb
567 Where the gEDA gnetlist program seems a bit “excited” about finding the new Vcc and Vee
<strong>net
</strong> attributes we just added, and a new netlist was generated. Now I think the schematic looks cleaner. And if you run
<strong>pcb board.pcb
</strong> and load the new netlist and then optimize the rats nest, PCB should tell you the board is complete which means connecting the opamp power pins via the
<strong>net
</strong> attribute has worked.
571 For complete details on making symbols, read through the
<a href=
"geda_scg.html" class=
"wikilink1" title=
"geda:scg">Symbol Creation Document
</a> on the
<a href=
"http://geda.seul.org/wiki/geda:documentation" class=
"wikilink1" title=
"geda:documentation">gEDA Documentation
</a> page.
575 <!-- SECTION "Custom gschem Symbols" [28090-32343] -->
576 <h2><a name=
"custom_file_elements" id=
"custom_file_elements">Custom file elements
</a></h2>
580 You can create custom
<strong>file elements
</strong> in the middle of running PCB on any layout or you can run PCB just for making the element. As a demonstration, lets make a custom element for a
1N4004 diode. There are axial packages provided by PCB, but we want to be sure the drill size will be right for this
1 amp diode with slightly fatter leads. It needs about a
42 mil (#
58) drill.
584 Run
<strong>pcb
</strong> and the first thing to do is select the
<strong>Signal
</strong> routing style and edit its sizes (press the
<strong>Route Style
</strong> button) Set the
<strong>Via hole
</strong> size to
42 and the
<strong>via size
</strong> to
70 or larger as you like. Select
<strong>Screen
→Grid setting
→25 mil
</strong> and
<strong>Screen
→Enable visible grid
</strong>. Zoom in a couple of steps, then make the element:
<a href=
"_detail/geda_pcb-el-1.html" class=
"media" title=
"geda:pcb-el-1.png"><img src=
"_media/geda_pcb-el-1.png" class=
"medialeft" title=
"Step 1" alt=
"Step 1" /></a>
587 <li class=
"level1"><div class=
"li"> Select the
<strong>VIA
</strong> tool and place two vias
400 milsapart.
</div>
589 <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>
591 <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>
596 <a href=
"_detail/geda_pcb-el-2.html" class=
"media" title=
"geda:pcb-el-2.png"><img src=
"_media/geda_pcb-el-2.png" class=
"mediaright" title=
"Step 2" alt=
"Step 2" /></a>
599 <li class=
"level1"><div class=
"li"> Select the
<strong>Silk
</strong> layer and the
<strong>LINE
</strong> tool.
</div>
601 <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>
603 <li class=
"level1"><div class=
"li"> Draw the left fat cathode indicator with three lines after setting the line width to
20 mils.
</div>
605 <li class=
"level1"><div class=
"li"> Don’t let silk layer lines overlap solder pads.
</div>
610 Select the vias and the outline just drawn using the
<strong>SEL
</strong> tool and finish making the element:
613 <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>
615 <li class=
"level1"><div class=
"li"> <strong>Buffer
→Convert buffer to element
</strong></div>
617 <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>
622 <strong>Note:
</strong> if you save the element with a name which is the same as a
<strong>m4 element
</strong>, gsch2pcb will preferentially use the m4 element unless you give gsch2pcb the
–use-files (or -f) option. You may put
<strong>use-files
</strong> in a project file if you want to always give priority to using
<strong>file elements
</strong>. The m4 element names appear to use upper case, so you could also avoid the problem by using lower case in your file element names. Also, the only way I know to make the pin
1 of the symbol square is to edit the D400-
1A file manually and change the square flag in the Pin “
1” line. For example, change the line:
624 <pre class=
"code"> Pin(
0 0 70 20 70 42 "" "1" 0x00000001)
626 Pin(
0 0 70 20 70 42 "" "1" 0x00000101)
630 You can now use
<strong>D400-
1A
</strong> in a gschem schematic symbol
<strong>footprint
</strong> attribute and gsch2pcb will find it provided you have made the
<strong>packages
</strong> link described in the
<strong>Setup
</strong> section. If you have not made that link, you can still tell gsch2pcb about the elements directory with a line in a project file:
632 <pre class=
"code">elements-dir ~/gaf/pcb-elements
636 Possibly you’ve noticed, but there are some things not right about the
<strong>myproject1
</strong> example. For one thing, silk layer lines are overlapping solder pads on some of the elements, and for another, the transistor is backwards on the layout! You otherwise shouldn’t have a problem like this when working with gschem and PCB, but transistor pin numbering can be confusing. If you will be using transistors in your designs, here’s a description of my approach to making sure my gschem transistor symbol pin numbering is coordinated with PCB element pin numbers:
<a href=
"http://geda.seul.org/wiki/geda:transistor_guide" class=
"wikilink1" title=
"geda:transistor_guide">transistor guide.
</a>
640 From the transistor guide, you can see that the problem here is that the
<strong>TO92
</strong> element has its pins numbered in the less common (
3,
2,
1) configuration while the
<strong>2N3904-
1.sym
</strong> is like a npn-ebc symbol which needs a (
1,
2,
3) numbering. You can see the
2N3904 pin numbers in gschem by hitting the
<strong>en
</strong> keys (and don’t be confused by the
<strong>pinseq
</strong> attribute that nearly covers up the
<strong>pinnumber
</strong>). And in PCB, you can see the
<strong>TO92
</strong> pin numbers by hitting the
<strong>d
</strong> key with the mouse over the element. To be sure you are seeing pin numbers and not pin names, select
<strong>Screen
→pinout shows number
</strong>.
644 I have libraries with transistor symbols and elements that you might find useful, so as a convenience you can get your custom libraries initially populated by installing my
<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>. Untar them under ~/gaf to mirror the setup of our example and there will also be a
<strong>~/gaf/pcb-elements.Readme
</strong> which documents the PCB elements.
<i
>Note: as of
1/
10/
2004 I’ve corrected the tarball pcb elements to not overlap solder pads with silk layer lines.
</i
> If you untar them somewhere else, you will need to make sure that gschem knows about them with gschemrc/gnetlistrc
<strong>component-library
</strong> lines and that gsch2pcb can find them with
<strong>elements-dir
</strong> lines in a project file.
648 If you install them, you can fix Q201 in
<strong>two.sch
</strong> by changing its footprint to
<strong>TO-
92</strong> which is my custom element with (
1,
2,
3) pin numbering. Then run
<strong>gsch2pcb project
</strong> and then
<strong>pcb board.pcb
</strong> and load the new element for the transistor. In the next images,
<strong>two.sch
</strong> is showing the
<strong>footprint
</strong> attribute visible to emphasize it, and it also shows a new symbol for the
2N3904 which I created from my custom
<strong>npn-ebc.sym
</strong> as described in my transistor guide. In the updated board.pcb layout, if you compare the outline appearance of the transistor to the original layout you see that the orientation is now correct and that silk layer lines don’t overlap the solder pads. I also changed the
<strong>footprint
</strong> attribute for resistors R102 and R103 in
<strong>one.sch
</strong> to my custom
1/
8 watt
<strong>R0w8
</strong> and
1/
4 watt
<strong>R0w4
</strong> elements to illustrate the differences in style you can have with custom elements. You can also see the R101 style after its footprint was changed to
<strong>0.125W_Carbon_Resistor
</strong> as suggested above. As you evaluate the differences in these styles, I’ll mention that for my custom elements I wanted to maximize room to display value and refdes text (the
0.125W
… element body could be a little larger) and I wanted the solder pad diameter a little larger so it will be more forgiving of board fabrication technique. Also, the resistor pin spacing for my
<strong>R0w4
</strong> is slightly less than in
<strong>R025
</strong> to improve component density.
652 <a href=
"_detail/geda_two-sch-2.html" class=
"media" 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=
"_detail/geda_board-6.html" class=
"media" title=
"geda:board-6.png"><img src=
"_media/geda_board-6.png" class=
"mediaright" title=
"pcb" alt=
"pcb" /></a>
656 <!-- SECTION "Custom file elements" [32344-38805] -->
657 <h2><a name=
"custom_m4_elements_requires_gsch2pcb_1.0" id=
"custom_m4_elements_requires_gsch2pcb_1.0">Custom m4 elements (Requires gsch2pcb
>=
1.0)
</a></h2>
661 First, some words about how to find out about the default
<strong>m4 elements
</strong> available in PCB. I think there is some documention forthcoming in the PCB project, but at this point I don’t know of anything to refer you to and you can’t just look at filenames as you can for the
<strong>file elements
</strong>. Not only that, but many of these elements require arguments and you need to determine what they are. So for now all I can say is that the best way to find out what’s available is to read the m4 element files and for this you need to know where the PCB m4 files install location is. As of PCB
20031113 this install directory will most likely be
<strong>/usr/share/pcb/m4
</strong> or
<strong>/usr/local/share/pcb/m4
</strong>, while on earlier PCB versions it could be
<strong>/usr/X11R6/lib/X11/pcb/m4
</strong> (run
<em>gsch2pcb
–help
</em> or
<em>gsch2pcb -v project
</em> to see which of these directories gsch2pcb is using). But if your install is somewhere else you will have to track it down. By the way, if the m4 directory
<em>is
</em> somewhere different from the above three, then gsch2pcb won’t be finding your
<strong>m4 elements
</strong> in the above examples and you will need to add the correct m4 directory to your
<strong>project
</strong> file with a line like:
663 <pre class=
"code">m4-pcbdir /path/to/pcb/m4
667 Just read the
<strong>.inc
</strong> files in the m4 install directory. For example, in the
<strong>misc.inc
</strong> file you will find the
<strong>R025
</strong> element we’ve used and it starts out with:
669 <pre class=
"code"># -------------------------------------------------------------------
670 # the definition of a resistor (
0.25W) package
674 define(`PKG_R025
',
675 `Element(
0x00 "$
1" "$
2" "$
3" 120 30 0 100 0x00)
681 The information you can extract from this is that a m4
<strong>PKG_
</strong> macro named
<strong>R025
</strong> is being defined and it takes
3 arguments. Now, all PCB
<strong>m4 element
</strong> macros take at least three arguments and these are automatically filled in by gsch2pcb with the gschem attributes
<strong>footprint
</strong> for
<strong>canonical name
</strong>,
<strong>refdes
</strong> for
<strong>name on PCB
</strong>, and
<strong>value
</strong> for
<strong>value
</strong>. The “canonical name” used in these m4 files is just an older way of referring to the current PCB usage of
<strong>description
</strong> as mentioned above in the
<strong>Terminology
</strong> section. Since these args are automatically filled in, you don’t need to specify any additional args to
<strong>R025
</strong> when you use it as a gschem
<strong>footprint
</strong>. But now look at the very next m4 element define in
<strong>misc.inc
</strong>:
683 <pre class=
"code"># -------------------------------------------------------------------
684 # the definition of a SIL package without a common pin
689 define(`PKG_SIL
',
690 `define(`MAXY
', `eval(`$
4' *
100 -
50)
')
691 Element(
0x00 "$
1" "$
2" "$
3" 160 10 3 100 0x00)
697 From this you can determine there is a
<strong>SIL
</strong> package you can use as a
<strong>footprint
</strong>. It has
4 arguments, but only the first three are handled automatically so there is one argument you must give when using it. You get a flash of insight and realize this is a “Single In Line” package! So, instead of the
<strong>CONNECTOR
2 1</strong> element specifying
1 column we used in our example above, you might think we could have used
<strong>SIL
2</strong>. But you would be wrong! Because if you read the macro body you will see that if the argument is
<strong>2</strong> the second forloop can’t handle it. In fact, it will only work for arguments
>=
4. If you ever run gsch2pcb and it appears stuck in an infinite loop, a m4 macro argument problem is likely the cause. As you look through
<strong>misc.inc
</strong> here’s a summary of what you will find as possible elements you can use:
699 <pre class=
"code">Package Args you need to supply
700 SD
1 number of pins of a ZIP package
703 SIL
1 number of pins (we know now must be
>=
4)
704 CSIL
1 number of pins
706 LED
1 diameter of LED
707 DIODE_LAY
1 pin separation
708 AXIAL_LAY
1 pin separation
709 CRYSTAL
1 package width
714 SMD_BASE
2 length and width of surface mount device
715 SMD_CHIP
1 package length
719 And so on for the other
<strong>.inc
</strong> files
…
723 The reality is that the m4 setup is less user friendly (you can’t create the elements graphically) and more complicated (you need to understand m4 macros) than the simple
<strong>file element
</strong> approach. So for most of your custom elements I suggest you are better off staying with
<strong>file elements
</strong>. However, with the m4 macro method a single element definition that takes arguments gives you a programmable element which can be very useful for large pin count packages. It is particularly nice for IC packages with variable widths and number of pins, so a good example of using a custom
<strong>m4 element
</strong> would be to copy and modify to our taste the existing m4 macro for IC packages (the
<strong>DIL
</strong> macro) into a m4 file gsch2pcb will search. The destination m4 file can be any of these:
726 <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>
730 <li class=
"level1"><div class=
"li"> <strong>~/.pcb/pcb.inc
</strong> and the element will be known to all of our projects.
</div>
734 <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
738 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:
740 <pre class=
"code">~/gaf/myproject1/project
742 /usr/local/etc/gsch2pcb
750 For this tutorial, I’ll use the first
<strong>pcb.inc
</strong> way, so copy over the existing macro file:
752 <pre class=
"code">cd /usr/local/share/pcb/m4 (or /usr/share/pcb/m4 or /usr/X11R6/lib/X11/pcb/m4)
753 cp dil.inc ~/gaf/myproject1/pcb.inc
758 Now, edit the
<strong>pcb.inc
</strong> file you just copied and cut everything out except for the PKG_DIL macro. Change the name of the package to something like PKG_DILFAT because the change we’ll make will be to make larger diameter pins. Actually, we could leave the name alone and our new definition would override the old one, but for now let’s go with the new name. Change the pin diameter from
<strong>60</strong> to
<strong>70</strong> on the
<strong><acronym title=
"Personal Identification Number">PIN
</acronym></strong> lines. When done, this should be the entire contents of the new
<strong>pcb.inc
</strong> file:
760 <pre class=
"code"># -------------------------------------------------------------------
761 # the definition of a dual-inline package N and similar types
766 # $
5: package size (
300,
600,
900 +
100 for socket space)
768 define(`PKG_DILFAT
',
769 `define(`MAXY
', `eval(`$
4' /
2 *
100)
')
770 define(`MAXX
', `eval(`$
5' +
100)
')
771 define(`CENTERX
', `eval(MAXX /
2)
')
772 Element(
0x00 "$
1" "$
2" "$
3" eval(CENTERX +
20)
100 3 100 0x00)
774 forloop(`i
',
1, eval($
4 /
2),
775 `PIN(
50, eval(i *
100 -
50),
70,
28, i)
777 forloop(`i
',
1, eval($
4 /
2),
778 `PIN(eval(MAXX -
50), eval(MAXY - i *
100 +
50),
70,
28, eval(i + $
4/
2))
780 ElementLine(
0 0 0 MAXY
10)
781 ElementLine(
0 MAXY MAXX MAXY
10)
782 ElementLine(MAXX MAXY MAXX
0 10)
783 ElementLine(
0 0 eval(CENTERX -
50)
0 10)
784 ElementLine(eval(CENTERX +
50)
0 MAXX
0 10)
785 ElementArc(CENTERX
0 50 50 0 180 10)
791 Run
<strong>gschem one.sch
</strong> and edit the
<strong>footprint
</strong> attribute of the opamps to be
<strong>DILFAT
8 300</strong>. Then run
<strong>gsch2pcb project
</strong> and gsch2pcb will remove the
<strong>DIL
</strong> element from
<strong>board.pcb
</strong> and add into
<strong>board.new.pcb
</strong> a new
<strong>DILFAT
</strong> element from your custom m4 file
<strong>pcb.inc
</strong>. Run
<strong>pcb board.pcb
</strong> and load the
<strong>board.new.pcb
</strong> into your layout. Move the new element with its fatter pins to the location left vacant by the removal of the old element.
795 <!-- SECTION "Custom m4 elements (Requires gsch2pcb >= 1.0)" [38806-46493] -->
796 <h2><a name=
"multi-user_setup_requires_gsch2pcb_1.0" id=
"multi-user_setup_requires_gsch2pcb_1.0">Multi-user Setup (requires gsch2pcb
>=
1.0)
</a></h2>
800 The above examples are oriented towards a single user with projects and custom gschem and PCB libraries under his home directory. Here’s a way to set up for multiple users who need to share resources:
803 <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
807 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>:
809 <pre class=
"code">m4-file /usr/local/share/pcb/pcb.inc
815 <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
819 If the m4 program is gm4 instead of m4, add to the gsch2pcb file:
821 <pre class=
"code">m4-command gm4
827 <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>
832 With the above, users will have access to site wide libraries and only need to put in a design
<strong>project
</strong> file lines for
<strong>schematics
</strong> and
<strong>output-name
</strong>. But they also are free to have their own additional user and/or project specific symbol and element libraries.
836 <!-- SECTION "Multi-user Setup (requires gsch2pcb >= 1.0)" [46494-48129] -->
837 <h2><a name=
"pc_board_fabrication" id=
"pc_board_fabrication">PC Board Fabrication
</a></h2>
841 The tutorial should cover pcb fabrication too.
845 <!-- SECTION "PC Board Fabrication" [48130-] --></div>