[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: CVS update: Makefile.am
User: ahvezda
Date: 05/08/20 22:05:05
Modified: . Makefile.am tutorial.html
Added: . tutorial-old.html
Log:
Updated to Bill Wilson's latest gsch2pcb tutorial version
Revision Changes Path
1.2 +2 -1 eda/geda/devel/docs/gsch2pcb_tutorial/Makefile.am
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Makefile.am
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/docs/gsch2pcb_tutorial/Makefile.am,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- Makefile.am 7 Jan 2004 04:11:25 -0000 1.1
+++ Makefile.am 21 Aug 2005 02:05:05 -0000 1.2
@@ -2,7 +2,8 @@
docsdir = @GEDADOCDIR@/tutorials/gsch2pcb
-docs_DATA = gschem-warmup.html transistor-guide.html tutorial.html
+docs_DATA = gschem-warmup.html transistor-guide.html tutorial.html \
+ tutorial-old.html
EXTRA_DIST = $(docs_DATA)
1.4 +176 -53 eda/geda/devel/docs/gsch2pcb_tutorial/tutorial.html
(In the diff below, changes in quantity of whitespace are not shown.)
Index: tutorial.html
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/docs/gsch2pcb_tutorial/tutorial.html,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- tutorial.html 9 Mar 2005 04:17:50 -0000 1.3
+++ tutorial.html 21 Aug 2005 02:05:05 -0000 1.4
@@ -13,8 +13,8 @@
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 version 0.9 is packaged with gEDA, but some of the steps below
-will require gsch2pcb 1.0. This tutorial is functional and intended to
+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.
@@ -22,13 +22,22 @@
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.
+automatically be driven by changes in the schematics. Back annotation
+from PCB to gschem is currently not possible.
</blockquote>
<h3> Tutorial Release Notes </h3>
<blockquote>
<ul>
- <li>If you have versions less than gschem 20030525 or PCB 1.99 these
+ <li> Starting with the PCB-20050609 snapshot, PCB has a new Gtk
+ user interface which replaces the old Xaw interface and this tutorial
+ will describe using the Gtk interface. If you are using the Xaw PCB,
+ you can look at this
+ <a href="tutorial-old.html" name="tutorial-old.html">
+ older version of this tutorial,</a> which is also not up to date
+ with info on the gEDA gafrc files.
+ </li>
+ <li>If you have a gschem version less than 20030525 these
tutorial examples may not work as expected.
</li>
<li>If you have gEDA version 20030901 installed such that you are
@@ -46,12 +55,24 @@
</li>
<li><h5> Mini Changelog</h5>
<ul>
- <li> 1/10/2004 - corrected my sloppy PCB file elements which had
+ <li> 6/23/2005
+ <blockquote>
+ Added gafrc file info to setup section.<br>
+ Updated the tutorial to use the Gtk PCB.
+ </blockquote>
+ </li>
+ <li> 1/10/2004
+ <blockquote>
+ Corrected my sloppy PCB file elements which had
silkscreen lines overlapping solder pads.
+ </blockquote>
</li>
- <li> 12/23/2003 - added comments about new CVS PCB versions which
+ <li> 12/23/2003
+ <blockquote>
+ Added comments about new CVS PCB versions which
have the m4 and newlib directories default installed under
/usr/share or /usr/local/share.
+ </blockquote>
</li>
</ul>
</li>
@@ -87,19 +108,21 @@
<b>m4 elements</b> and <b>file elements</b>.
When rou run PCB, the gschem <b>footprint</b> attribute
value will appear as the displayed element name when you
-select <b>description</b> from the <b>Screen</b> menu because gsch2pcb
-uses this field to keep track of which <b>footprint</b> corresponds
-to a particular PCB element.
+select <b>Description</b> from the <b>Screen->Displayed Element Name</b>
+menu because gsch2pcb uses this field to keep track of which
+<b>footprint</b> corresponds to a particular PCB element.
<p>
The gschem <b>refdes</b> 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
-<b>name on PCB</b> from the <b>Screen</b> menu.
+<b>Reference Designator</b> from the
+<b>Screen->Displayed Element Name</b> menu.
+
<p>
The gschem <b>value</b> attribute value is the particular component value
such as BC546, 7400, 1K, etc. When you run PCB, this
<b>value</b> will appear as the displayed element name when you select
-<b>value</b> from the <b>Screen</b> menu.
+<b>Value</b> from the <b>Screen->Displayed Element Name</b> menu.
</blockquote>
@@ -111,8 +134,9 @@
default PCB elements, but you can also provide for creating your own custom
libraries of gschem symbols and PCB elements.
<ul>
- <li> Somewhere, probably under your home directory, create your
- directory structure. Use directory names you like, but
+ <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:
<blockquote><pre>
@@ -121,31 +145,73 @@
gaf/gschem-sym/transistors/ You can organize your custom symbols into subdirectories.
gaf/pcb-elements/ Where I put the custom PCB file elements I create.
These can also be organized into subdirectories.
-gaf/myproject1/
-gaf/myproject2/
+gaf/myproject1/ And finally, separate directories for each
+gaf/myproject2/ design project.
...
</pre></blockquote>
- With this organization, your custom gschem symbols and PCB elements can
- be common to all of your projects and is good enough to get you started.
+ 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 <b>file element</b>
+ below: There can be project specific PCB <b>file element</b>
subdirectories or <b>m4 element</b> files. Or, CAD administrators can
set up site wide custom PCB <b>file element</b> directories and
<b>m4 element</b> files.
</li>
<p>
- <li> <b>gschem setup: </b> So gschem will be able to find any custom
- symbols you will make and put in <b>gaf/gschem-sym</b> create the
- file <b>~/.gEDA/gschemrc</b> with this content (plus an entry for each
- additional <b>gschem-sym </b> subdirectory you want):
+ <li> <b>gEDA setup (for new versions released >= 2005): </b>
+ 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
+ <b>component-library</b> lines to either a user
+ <b>${HOME}/gafrc</b> file or a project specific <b>gafrc</b> file
+ in the project directory. There is also a system wide
+ <b>${GEDADATA}/system-gafrc</b> file administrators can set up.
+ The <b>HOME</b> and <b>GEDADATA</b> environment variables must
+ be respectively set for those <b>gafrc</b> files to be found.
+ For our directory structure setup above, we could add these lines
+ to <b>${HOME}/gafrc</b>
+ (plus lines for each additional <b>gschem-sym </b>
+ subdirectory you want):
<blockquote><pre>
(component-library "${HOME}/gaf/gschem-sym")
(component-library "${HOME}/gaf/gschem-sym/transistors")
</pre></blockquote>
- <b>gnetlist setup: </b> gnetlist will also need to find these symbols
- so duplicate those lines into <b>~/.gEDA/gnetlistrc</b>.
+ or, in each project directory there could be a <b>gafrc</b> file with
+ the lines:
+ <blockquote><pre>
+(component-library "../gaf/gschem-sym")
+(component-library "../gaf/gschem-sym/transistors")
+ </pre></blockquote>
+ </li>
+
+ <li> <b>gEDA setup (for old versions released <= 2004): </b>
+ The <b>gafrc</b> 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 <b>component-library</b> setup lines
+ in multiple rc files that apply to the various gEDA programs:
+ <uL>
+ <li> <b>gschem program setup: </b> create the file <b>~/.gEDA/gschemrc</b>
+ with this content:
+ <blockquote><pre>
+(component-library "${HOME}/gaf/gschem-sym")
+(component-library "${HOME}/gaf/gschem-sym/transistors")
+ </pre></blockquote>
+ </li>
+ <li>
+ <b>gnetlist program setup: </b> gnetlist will also need to find these
+ symbols so duplicate those lines into <b>~/.gEDA/gnetlistrc</b>.
+ </li>
+ </ul>
+ </li>
<p>
+ <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 <b>/etc/gEDA/</b> for settings
@@ -179,7 +245,7 @@
gschem, gsch2pcb, and PCB packages.
</blockquote>
-
+<a name="SIMPLE_EXAMPLE">
<h3> Simple Example </h3>
<blockquote>
Let's generate a trivial design from schematics to PCB layout
@@ -417,16 +483,32 @@
<h4> Layout PCB Files</h4>
<blockquote>
When you run PCB on a <b>.pcb</b> file for the first time as in Step 1
- below, you should set up various intial values. I usually set a
- 25 mil grid spacing with <b>Screen->25 mil</b> for the bulk of my
+ below, you should set up various initial values.
+ I usually set a
+ 25 mil grid spacing with <b>Screen->Grid Setting->25 mil</b>
+ for the bulk of my
layout work and then change grid spacing to smaller values as needed
- for tight layout situations. You should also set the default line
+ for tight layout situations. Note that if you have enabled millimeter
+ units with <b>Screen->Enable millimeter grid units</b> you will see
+ a set of millimeter size options to select from instead of mils in the
+ <b>Screen->Grid Setting</b> menu. You may change between millimeter
+ and mil grid units at any time when doing a layout.
+ You should also set the default line
and via sizes you
- want for Signal, Power, Fat, and Skinny drawing in the
- <b>Sizes->adjust...</b> menu. Then select the routing style you want
- to use from the <b>Sizes</b> menu. You can set your
- board size now or wait until later with <b>Edit->change board size</b>.
- And it may be useful to you to set <b>Screen->display grid</b>.
+ 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 <b>Route Style</b>
+ 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 <b>File->Preferences</b>
+ window and select the <b>Sizes</b> 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 <b>Screen->Enable visible grid</b>.
+<br>
</blockquote>
<table cellspacing=10>
@@ -457,6 +539,10 @@
<td>
Use the middle mouse button to grab and move elements one
at a time until you have separated all the elements.
+ <br>
+ Or, you can let PCB spread out the elements with
+ <b>Select->Disperse all elements</b> before you fine tune
+ the positions with the middle mouse button.
</td>
</tr></table>
</td>
@@ -504,12 +590,16 @@
</table>
<blockquote>
- Note: you can use the PCB auto placement feature instead of
- manually placing the components as described above. To do this
+ Note: you can use the PCB auto placement
+ feature instead of manually placing (or dispersing with the
+ <b>Select->Disperse ...</b> commands)
+ the components as described in Step 2 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 <b>Select->auto place selected elements</b>.
- Then you can manually tune the PCB generated placements.
+ autoplaced (if this is the first PCB run, just <b>Select->Select all
+ objects</b>) then do <b>Select->Auto place selected elements</b>.
+ 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.
<p>
At this point you can start routing traces between pins connected
by rats nest lines. On the left PCB toolbar,
@@ -524,10 +614,10 @@
<p>
A very useful operation with the <b>SEL</b>
tool is to select multiple objects and then cut or copy them to a
- buffer with the menu <b>Buffer->cut selection to buffer</b> (or copy).
+ buffer with the menu <b>Buffer->Cut selection to buffer</b> (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 <b>Buffer->paste buffer to layout</b>. With
+ any time later with <b>Buffer->Paste buffer to layout</b>. With
this you can move layout
areas around or step and repeat common trace patterns. To
select multiple objects with the <b>SEL</b> tool, click and drag
@@ -536,7 +626,8 @@
<p>
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 <b>Screen->value</b>.
+ something like this. For this view I've selected
+ <b>Screen->Displayed element name->Value</b>.
<p>
<center><table border=1>
<tr bgcolor=#b0b0a8>
@@ -551,9 +642,39 @@
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/"
- name="1.99 development">PCB 1.99 development </a> site.
+ name="PCB development">PCB development </a> site.
Or the docs may be installed somewhere on your system.
The Debian package has them installed in <b>/usr/share/doc/pcb/html/</b>.
+ 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
+ <b>Window->Key Reference</b> 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 <b>File->Preferences</b> window the
+ <i>Use separate window for command entry</i> option, then when
+ you bring up the Command window with <b>Window->Command Entry</b>
+ (or the ':' key), you will see a <b>Command Reference</b> 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.
+ <p>
+ For example, say you
+ have in the <b>Preferences->Increments</b> 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
+ <b>Select->Change size of selected objects->Increment lines by 5 mils.</b>
+ 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 '<b>:</b>') and type in the command:
+ <blockquote><pre>
+ <i>changesize(selectedlines, +3, mils)</i>
+ </pre></blockquote>
+ 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.
</blockquote>
@@ -773,7 +894,7 @@
Found a cpinlist head with a netname! [Vee]
No elements to add so not creating board.new.pcb
</pre></blockquote>
-Where the gEDA gnetlist program seems a bit excited about finding the new
+Where the gEDA gnetlist program seems a bit "excited" about finding the new
Vcc and Vee <b>net</b> attributes we just added, and a new netlist
was generated. Now I think the schematic looks
cleaner:
@@ -811,12 +932,14 @@
right for this 1 amp
diode with slightly fatter leads. It needs about a 42 mil (#58) drill.
<p>
- Run <b>pcb</b> and the first thing to do is go to the <b>Sizes</b>
- menu and select <b>adjust "Signal" sizes</b>. Set the via hole
- to 42 and the via size to 70 or larger as you like. Then make
- sure you use this via
- size by selecting <b>Sizes->use "Signal" routing style</b>. Select
- <b>Screen->25 mil</b> and <b>Screen->display grid</b>.
+ Run <b>pcb</b> and the first thing to do is select the <b>Signal</b>
+ routing style and edit its sizes (press the <b>Route Style</b> button)
+
+ Set the <b>Via hole</b> size
+ to 42 and the <b>via size</b> to 70 or larger as you like.
+ Select
+ <b>Screen->Grid setting->25 mil</b> and
+ <b>Screen->Enable visible grid</b>.
Zoom in a couple of steps, then make the element:
</blockquote>
@@ -875,12 +998,12 @@
Select the vias and the outline just drawn using the <b>SEL</b> tool
and finish making the element:
<ul>
- <li><b>Buffer->cut selection to buffer</b> and move the cursor
+ <li><b>Buffer->Cut selection to buffer</b> and move the cursor
to the center of the left via and click.
</li>
- <li><b>Buffer->convert buffer to element</b>
+ <li><b>Buffer->Convert buffer to element</b>
</li>
- <li><b>Buffer->save buffer elements to file</b> and navigate to
+ <li><b>Buffer->Save buffer elements to file</b> and navigate to
<b>~/gaf/pcb-elements</b> and save the element as
<b>D400-1A</b> since it's a package for a 1A diode with
400 mil spaced pins. Or give it any descriptive name you like.
@@ -1259,7 +1382,7 @@
<hr>
<address>
<p align=center>
- <a href="http://web.wt.net/~billw/gsch2pcb/gsch2pcb.html"
+ <a href="http://members.dslextreme.com/users/billw/gsch2pcb/gsch2pcb.html"
name="www.gkrellm.net">gsch2pcb Home</a>
<br>
Bill Wilson <A HREF="mailto:bill--at--gkrellm.net">bill--at--gkrellm.net</A>
1.1 eda/geda/devel/docs/gsch2pcb_tutorial/tutorial-old.html
Index: tutorial-old.html
===================================================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html>
<head>
<title>gsch2pcb tutorial</title>
</head>
<body background="./images/paper1.gif">
<center><h2>gschem -> gsch2pcb -> PCB</h2></center>
<hr width=100% size=2>
<blockquote>
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 version 0.9 is packaged with gEDA, but some of the steps below
will require gsch2pcb 1.0. 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.
<p>
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.
</blockquote>
<h3> Tutorial Release Notes </h3>
<blockquote>
<ul>
<li>If you have versions less than gschem 20030525 or PCB 1.99 these
tutorial examples may not work as expected.
</li>
<li>If you have gEDA version 20030901 installed such that you are
using its included gsch2pcb 0.9 and you are getting an error:
<blockquote><pre>
ERROR: Unbound variable: open-output-pipe
</pre></blockquote>
then the problem is syntax in <i>gnet-gsch2pcb.scm</i> that worked
in guile 1.4 but does not work in guile 1.6. You'll need to upgrade to
using at least gsch2pcb 1.0.1 to solve this problem.
</li>
<li>As of about 1/9/2004 CVS PCB versions changed to using a hi
resolution output file format which will require using at
least gsch2pcb-1.4.
</li>
<li><h5> Mini Changelog</h5>
<ul>
<li> 1/10/2004 - corrected my sloppy PCB file elements which had
silkscreen lines overlapping solder pads.
</li>
<li> 12/23/2003 - added comments about new CVS PCB versions which
have the m4 and newlib directories default installed under
/usr/share or /usr/local/share.
</li>
</ul>
</li>
</blockquote>
<h3> Terminology </h3>
<blockquote>
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 <b>footprint, value,</b> and
<b>refdes</b> attribute.
<p>
The schematic <b>footprint</b> 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
<b>m4 elements</b> and <b>file elements</b>.
When rou run PCB, the gschem <b>footprint</b> attribute
value will appear as the displayed element name when you
select <b>description</b> from the <b>Screen</b> menu because gsch2pcb
uses this field to keep track of which <b>footprint</b> corresponds
to a particular PCB element.
<p>
The gschem <b>refdes</b> 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
<b>name on PCB</b> from the <b>Screen</b> menu.
<p>
The gschem <b>value</b> attribute value is the particular component value
such as BC546, 7400, 1K, etc. When you run PCB, this
<b>value</b> will appear as the displayed element name when you select
<b>value</b> from the <b>Screen</b> menu.
</blockquote>
<h3> Setup </h3>
<blockquote>
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.
<ul>
<li> Somewhere, probably under your home directory, create your
directory structure. Use directory names you like, but
this tutorial will reference the directory name structure
I use:
<blockquote><pre>
gaf/
gaf/gschem-sym/ Where I put the custom gschem symbols I create.
gaf/gschem-sym/transistors/ You can organize your custom symbols into subdirectories.
gaf/pcb-elements/ Where I put the custom PCB file elements I create.
These can also be organized into subdirectories.
gaf/myproject1/
gaf/myproject2/
...
</pre></blockquote>
With this organization, your custom gschem symbols and PCB elements can
be common to all of your projects and is good enough to get you started.
However, I'll mention other possibilities which will be revealed
below. There can be project specific PCB <b>file element</b>
subdirectories or <b>m4 element</b> files. Or, CAD administrators can
set up site wide custom PCB <b>file element</b> directories and
<b>m4 element</b> files.
</li>
<p>
<li> <b>gschem setup: </b> So gschem will be able to find any custom
symbols you will make and put in <b>gaf/gschem-sym</b> create the
file <b>~/.gEDA/gschemrc</b> with this content (plus an entry for each
additional <b>gschem-sym </b> subdirectory you want):
<blockquote><pre>
(component-library "${HOME}/gaf/gschem-sym")
(component-library "${HOME}/gaf/gschem-sym/transistors")
</pre></blockquote>
<b>gnetlist setup: </b> gnetlist will also need to find these symbols
so duplicate those lines into <b>~/.gEDA/gnetlistrc</b>.
<p>
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 <b>/etc/gEDA/</b> for settings
you can make.
For example, I like the light gschem background, so I also put in
my <b>~/.gEDA/gschemrc</b> the line:
<blockquote><pre>
(load (string-append gedadatarc "/gschem-lightbg")) ; light background
</pre></blockquote>
</li>
<li> <b>PCB setup: </b> A PCB distribution usually is set up so that
PCB will automatically look in a <b>packages</b> subdirectory of the
working directory. So, to make PCB find all the custom elements I
put in <b>gaf/pcb-elements</b> 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 <b>pcb-elements</b> directory in a
<b>project</b> file. But if you do want to make the link,
in directory <b>gaf/myproject1</b> enter the command:
<blockquote><pre>
ln -s ../pcb-elements packages
</pre></blockquote>
</li>
<li> <b> gsch2pcb setup: </b> In each of your project directories, create
a gsch2pcb project file which can be named anything that does not
end in <i>.sch</i>.
A poject file will be created in the example below.
</li>
</ul>
This is all the setup you need beyond the initial install of the
gschem, gsch2pcb, and PCB packages.
</blockquote>
<a name="SIMPLE_EXAMPLE">
<h3> Simple Example </h3>
<blockquote>
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.
<p>
Assuming you setup the directory structure described
above, go to the <b>gaf/myproject1</b> directory and create
a file named <b>project</b> with this content:
<blockquote><pre>
schematics one.sch two.sch
output-name board
</pre></blockquote>
<h4> Create schematic: one.sch</h4>
<blockquote>
If you are using gschem for the first time, try stepping through
this simple
<a href="gschem-warmup.html" name="gschem-warmup.html">gschem warmup. </a>
<br>
Run <b>gschem one.sch</b> and create this schematic (the second opamp
is redundant, but this is just a tutorial):
<p>
<table border=1>
<tr bgcolor=#b0b0a8>
<td>
<img src="images/one-sch-1.png" alt="images/one-sch-1.png"
border="0" align="top"><br> <center>one.sch</center>
</td>
<td>
<ul>
<li> Add component <b>title-B.sym</b> from the <b>titleblock</b>
library. Hit keys <b>ve</b> to zoom to the titleblock extents.
Lock the titleblock with the menu <b>Edit->Lock</b>.
<li> Add components:<br>
From the <b>analog</b> library three <b>resistor-1.sym</b> and
two <b>dual-opamp-1.sym</b>.<br>
From the <b>io</b> library one <b>output-2.sym</b>.<br>
From the <b>power</b> library one <b>gnd-1.sym</b>
two <b>vcc-1.sym</b> and two <b>vee-1.sym</b>
</li>
<li> Move components with the middle mouse button and rotate
selected components by hitting keys <b>er</b> until everything
is placed nicely. Rotate the bottom opamp and mirror it with
the <b>ei</b> keys.
</li>
<li> Use the <b>n</b> key and the mouse to draw net connections.
</li>
</ul>
</td>
</tr>
</table>
<p>
Edit the attributes of the components on the schematic.
<p>
<table border=1>
<tr bgcolor=#b0b0a8>
<td>
<img src="images/one-sch-2.png" alt="images/one-sch-2.png"
border="0" align="top"><br> <center>one.sch</center>
</td>
<td>
For each component, select it and bring up its attributes
window by hitting keys <b>ee</b>. Do not edit the <b>refdes</b>
attribute here, but do make these edits:
<ul>
<li> For resistors and the opamps, add visible <b>value</b>
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.
</li>
<li> For the resistors, add a <b>footprint</b> attribute and
give it the value <b>R025</b> which is the PCB <i>m4 element</i>
for a 1/4 watt resistor. Make this attribute invisible.
</li>
<li> For the opamps, edit the already existing <b>footprint</b>
attribute to be <b>DIL 8 300</b>. Yes, include those spaces
because <b>DIL</b> is a <b>m4 element</b> 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 <b>slot</b> attribute of
the second opamp to be <b>2</b>. Its I/O pin numbers should
change from (1,2,3) to (5,6,7).
</li>
<li> For the output module port, edit its <b>net</b> attribute
to be <b>vmixer:1</b> and make it invisible. Edit its <b>value</b>
attribute to be <b>Vmixer</b>.
</li>
</ul>
</td>
</tr>
</table>
<p>
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 <b>footprint</b> (and even <b>value</b>)
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 <b>ec</b> keys) for all
remaining components instead of adding them from the library.<br>
Anyway, we're done for now with <b>one.sch</b>, so save it with
the menu <b>File->Save Page</b> and quit gschem.
</blockquote>
<h4> Create schematic: two.sch</h4>
<blockquote>
This will be really trivial and stupid since we're doing it only to
demonstrate multiple schematic capability. Run <b>gschem two.sch:</b>
<p>
</blockquote>
<table border=1>
<tr bgcolor=#b0b0a8>
<td>
<img src="images/two-sch-1.png" alt="images/two-sch-1.png"
border="0" align="top"><br> <center>two.sch</center>
</td>
<td>
<ul>
<li> Add component <b>title-B.sym</b> as you did in one.sch.
<li> Add components:<br>
From the <b>io</b> library one <b>input-2.sym</b>.<br>
From the <b>analog</b> library one <b>resistor-1.sym</b>.<br>
From the <b>transistor</b> library one <b>2N3904-1.sym</b>.<br>
From the <b>power</b> library one <b>gnd-1.sym</b>,
one <b>vcc-1.sym</b> and one <b>vee-1.sym</b>.<br>
From the <b>connector</b> library one <b>BNC-1.sym</b>
</li>
<li> Move components and draw nets as before.
</li>
<li> Edit component attributes:<br>
Input module port: edit <b>net</b> attribute to be invisible
and have value <b>vmixer:1</b>
so this net will be connected
to the <b>vmixer</b> in one.sch.
Make the <b>value</b> attribute be <b>Vmixer</b>.<br>
Resistor: give it invisible <b>footprint</b> attribute
<b>R025</b>
and a visible <b>value</b> attribute 10K.<br>
Transistor: add <b>value</b> attribute <b>2N3904</b> and
invisible <b>footprint</b> attribute <b>TO92</b>.<br>
BNC connector: add invisible <b>footprint</b> attribute
<b>CONNECTOR 2 1</b>.
which is a <b>m4 element</b> 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.
</li>
</ul>
</td>
</tr>
</table>
<blockquote>
<p>
Unfortunately, the 2N3904 symbol we added has the text "2N3904" as an
integral part of its symbol. So when we add the <b>value</b> 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 <b>value</b>
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 <b>device</b> attribute
is wrong and should be <b>NPN_TRANSISTOR</b> 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 <b>device</b> attributes.
<p>
Now we are done with the schematics except for assigning <b>refdes</b>
attributes and we can use the command <b>refdes_renum</b> to do this
for both schematics at once. So, save <b>two.sch</b>, quit gschem and run:
<blockquote><pre>
$ refdes_renum --pgskip one.sch two.sch
</pre></blockquote>
and run gschem on the schematics again to see how the components
have been given a <b>refdes</b> attribute. The <i>--pgksip</i> option
makes numbering begin at 101 for one.sch and at 201 for two.sch.
But you should know that
running <b>refdes_renum</b> 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 <b>refdes_renum</b>
that components will keep an
existing <b>refdes</b> 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 <b>refdes_renum</b> and start a PCB
layout, to be safe you will
need to manually add (unique) <b>refdes</b> attributes for any
schematic components you might add. Also note that <b>refdes_renum</b> 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.
</blockquote>
<h4> Generate PCB Files from Schematics</h4>
<blockquote>
We have to fix one thing in <b>one.sch</b> before we can proceed.
Run <b>gschem one.sch</b> and notice that <b>refdes_renum</b> has
given our opamps <b>refdes</b> values of <b>U101</b> and <b>U102</b>
and did not know we really want to be using two opamps out of a single
TL072 package. That's why we edited the <b>slot</b> attribute of the
second opamp. We have to go back and fix this by editing the
<b>refdes</b> attribute of the second opamp to be <b>U101</b> so
both opamps will have the same <b>refdes</b>
and there will be only one TL072 package on our pc board.
<p>
Now, since we have already set up a gsch2pcb <b>project</b> file,
all we need to do to create an initial set of PCB files is to run
gsch2pcb:
<blockquote><pre>
~/gaf/myproject1$ gsch2pcb project
0 file elements and 7 m4 elements added to board.pcb.
</pre></blockquote>
Since the project file specifed <b>board</b> as the output-name,
the PCB files created are named <b>board.pcb</b> and <b>board.net</b>.
<p>
If you get output from gsch2pcb like:
<i>2 unknown elements added to board.pcb.</i>, then run with the -v
flag: <b>gsch2pcb -v project</b> and the gsch2pcb output will tell
you which schematic components don't have a known <b>footprint</b>. 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
<a href="tutorial.html#CUSTOM_M4"> Custom M4 Elements </a> section.
</blockquote>
<h4> Layout PCB Files</h4>
<blockquote>
When you run PCB on a <b>.pcb</b> file for the first time as in Step 1
below, you should set up various intial values. I usually set a
25 mil grid spacing with <b>Screen->25 mil</b> for the bulk of my
layout work and then change grid spacing to smaller values as needed
for tight layout situations. You should also set the default line
and via sizes you
want for Signal, Power, Fat, and Skinny drawing in the
<b>Sizes->adjust...</b> menu. Then select the routing style you want
to use from the <b>Sizes</b> menu. You can set your
board size now or wait until later with <b>Edit->change board size</b>.
And it may be useful to you to set <b>Screen->display grid</b>.
</blockquote>
<table cellspacing=10>
<tr>
<td>
<table border=1>
<tr bgcolor=#b0b0a8>
<td>
<img src="images/board-1.png" alt="images/board-1.png"
border="0" align="top"><br> <center>Step 1</center>
</td>
<td>
Run <b>pcb board.pcb</b>
<p>
You'll see grouped into a big pile the PCB elements for all
the schematic component footprints.
</td>
</tr></table>
</td>
<td>
<table border=1>
<tr bgcolor=#b0b0a8>
<td>
<img src="images/board-2.png" alt="images/board-2.png"
border="0" align="top"><br> <center>Step 2</center>
</td>
<td>
Use the middle mouse button to grab and move elements one
at a time until you have separated all the elements.
</td>
</tr></table>
</td>
</tr>
<tr>
<td>
<table border=1>
<tr bgcolor=#b0b0a8>
<td>
<img src="images/board-3.png" alt="images/board-3.png"
border="0" align="top"><br> <center>Step 3</center>
</td>
<td>
<ul>
<li><b>File->load netlist file</b> and select <b>board.net</b>
</li>
<li><b>Connects->optimize rats-nest</b>
</li>
<li>As you move elements around in later steps,
it will clean up the lines to re-do the optimize rats-nest.
</li>
</ul>
</tr></table>
</td>
<td>
<table border=1>
<tr bgcolor=#b0b0a8>
<td>
<img src="images/board-4.png" alt="images/board-4.png"
border="0" align="top"><br> <center>Step 4</center>
</td>
<td>
Select the <b>ROT</b> tool and move elements with the
middle mouse button and rotate them with the left mouse
button until the rats-nest lines look minimized. Hit the
<b>f</b> key with the mouse on a pin to highlight
particular routes to help visualize the routes. <b>Shift f</b>
to unhighlight.
</td>
</tr></table>
</td>
</tr>
</table>
<blockquote>
Note: you can use the PCB auto placement feature instead of
manually placing 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 <b>Select->auto place selected elements</b>.
Then you can manually tune the PCB generated placements.
<p>
At this point you can start routing traces between pins connected
by rats nest lines. On the left PCB toolbar,
select the <b>LINE</b> 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 <b>f</b> 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.
<p>
A very useful operation with the <b>SEL</b>
tool is to select multiple objects and then cut or copy them to a
buffer with the menu <b>Buffer->cut selection to buffer</b> (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 <b>Buffer->paste buffer to layout</b>. With
this you can move layout
areas around or step and repeat common trace patterns. To
select multiple objects with the <b>SEL</b> tool, click and drag
to select rectangular regions, and SHIFT click to toggle additional
selections to the currently selected set.
<p>
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 <b>Screen->value</b>.
<p>
<center><table border=1>
<tr bgcolor=#b0b0a8>
<td>
<img src="images/board-5.png" alt="images/board-5.png"
border="0" align="top">
</td>
</tr>
</table></center>
<p>
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/"
name="1.99 development">PCB 1.99 development </a> site.
Or the docs may be installed somewhere on your system.
The Debian package has them installed in <b>/usr/share/doc/pcb/html/</b>.
</blockquote>
<h3>Modifying Schematics</h3>
<blockquote>
The process of transfering schematic modifications to your PCB layout is
made very simple by using gsch2pcb. After the first <b>board.pcb</b>
was created when you initially ran gsch2pcb,
each time you run gschem on
your schematics and make changes, run <b>gsch2pcb project</b>. Then run
<b>pcb board.pcb</b> and do whatever is necessary based on the work
gsch2pcb has done. Each time gsch2pcb is run, this will happen:
<ul>
<li> gsch2pcb always generates a new <b>board.net</b>. If the net
was changed, load the new netlist file when you run pcb.
<li> If you added components (with a footprint attribute) to a schematic
gsch2pcb will generate a <b>board.new.pcb</b> containing all the
new PCB elements corresponding to the footprints.
You then run <b>pcb board.pcb</b> and load the <b>board.new.pcb</b>
with new elements into
the existing layout with <b>File->load layout data to paste-buffer</b>.
Place the new elements, load the new netlist, and route new traces.<br>
</li>
<li> If you deleted components from a schematic, gsch2pcb will delete
the corresponding PCB elements from <b>board.pcb</b>. You only
need to run <b>pcb board.pcb</b> and clean up dangling traces from
around the deleted elements.
</li>
<li> If you change an existing component's <b>footprint</b>, gsch2pcb
will delete the corresponding old element from <b>board.pcb</b>
and add the new element to <b>board.new.pcb</b>.
</li>
<li> If you changed schematic component <b>value</b> attributes, the
value changes will be forward annotated to <b>board.pcb</b> in place.
</li>
</ul>
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.
<p>
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 <b>name on PCB</b> name because that is reserved for schematic
component <b>refdes</b> attributes and gsch2pcb will want to delete
elements which have a non-empty <b>name on PCB</b> and don't match
any schematic component <b>refdes</b>.
<p>
Now, so far we've only used <b>m4 elements</b> in our layout so let's
modify a schematic to use a <b>file element</b>. 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
<b>/usr/local/share/pcb/newlib, /usr/share/pcb/newlib</b>, or possibly
something else (depending on the <i>prefix</i> specified when PCB
was installed). PCB versions before 20031113 used <b>pcb_lib</b> instead
of <b>newlib</b> in the locations
<b>/usr/local/pcb_lib, </b> or <b>/usr/lib/pcb_lib,</b>.
Once you find your <b>newlib</b> directory,
look at the file names in each subdirectory. Each file name
is a name which may be used as a <b>footprint</b> attribute
for a schematic component. For example, there is the file
<b>xxx/newlib/2_pin_thru-hole_packages/0.125W_Carbon_Resistor</b>
so if we wanted 1/8 watt resistors on our layout, we could
use <b>0.125W_Carbon_Resistor</b> as the resistor <b>footprint</b>
attribute instead of <b>R025</b>. Try changing, say resistor R101 to
use <b>0.125W_Carbon_Resistor</b> in <b>one.sch</b> and
then run <b>gsch2pcb project</b>. If gsch2pcb does not find
this element, then you need to add your <b>newlib</b>
directory to your <b>project</b> file with a line like:
<blockquote><pre>
elements-dir /usr/lib/newlib
</pre></blockquote>
If gsch2pcb does find it, you will get:
<blockquote><pre>
~/gaf/myproject1$ gsch2pcb project
board.pcb is backed up as board.pcb.bak1.
1 elements deleted from board.pcb.
1 file elements and 0 m4 elements added to board.new.pcb.
</pre></blockquote>
Now you need to run <b>pcb board.pcb</b>. You will see that the
element for resistor R101 is gone and that you will get the
new element by loading <b>board.new.pcb</b> with
<b>File->load layout data to paste-buffer</b>.
<p>
</blockquote>
<h3>Custom gschem Symbols</h3>
<blockquote>
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 <b>dual-opamp-1.sym</b> 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 <b>net</b> attributes in this tutorial.
It's possible with gschem for symbols to
have <b>net</b> 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 these
steps (however, your gEDA symbol install directory may be something
different like <b>/usr/local/share/gEDA/sym/</b>):
<blockquote><pre>
cd /usr/share/gEDA/sym/analog/
cp dual-opamp-1.sym ~/gaf/gschem-sym/opamp-dual.sym
cd ~/gaf/gschem-sym
gschem opamp-dual.sym
</pre></blockquote>
</blockquote>
<table cellspacing=10>
<tr>
<td>
<table border=1>
<tr bgcolor=#b0b0a8>
<td>
<img src="images/gschem-sym-1.png" alt="images/gschem-sym-1.png"
border="0" align="top"><br> <center>Step 1</center>
</td>
<td>
<ul>
<li>Hit keys <b>en</b> to make attributes visible.
</li>
<li>Hit keys <b>ve</b> to view extents.
</li>
<li>Left mouse click on pin 8 to select it.
</li>
</ul>
</td>
</tr></table>
</td>
<td>
<table border=1>
<tr bgcolor=#b0b0a8>
<td>
<img src="images/gschem-sym-2.png" alt="images/gschem-sym-2.png"
border="0" align="top"><br> <center>Step 2</center>
</td>
<td>
<ul>
<li>Hit <b>Delete</b> key to delete pin 8.
</li>
<li>Similarly select and delete pin 4.
</li>
<li>Double click to select and edit the <b>slotdef</b>
lines. Edit them by removing the pins 4 and 8.
</ul>
</td>
</tr></table>
</td>
</tr>
<tr>
<td>
<table border=1>
<tr bgcolor=#b0b0a8>
<td>
<img src="images/gschem-sym-3.png" alt="images/gschem-sym-3.png"
border="0" align="top"><br> <center>Step 3</center>
</td>
<td>
From the menu <b>Add->Attribute</b>
<ul>
<li>Add a <b>net</b> attribute with value <b>Vcc:8</b>
Select <b>Show Name & Value</b> and make it invisible.
</li>
<li>Add a <b>net</b> attribute with value <b>Vee:4</b>
Make it <b>Show Name & Value</b> and invisible.
</li>
<li>Make the <b>device</b> attribute be just <b>OPAMP</b>.
</li>
</ul>
Clean up by moving these new attributes as shown.<br>
Change the footprint default if you wish.
</tr></table>
</td>
</tr>
</table>
<blockquote>
When all the edits are done, it's very important when editing
symbols to do a <b>Edit->Symbol Translate</b> to zero before saving.
Do that and then save the symbol with <b>File->Save Page</b>
I made the <b>footprint</b> default be <b>DIP8</b> because I have
that as a custom element.
<p>
Run <b>gschem one.sch</b>. Select and delete with the <b>Delete</b>
key both opamps. Also delete the <b>Vcc</b> and <b>Vee</b> symbols that
were connected to them. Bring up the Add Components window
and from the <b>gschem-sym</b> library which should now have your
new custom symbol, place two of the <b>opamp-dual.sym</b>
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 <b>footprint</b> be <b>DIL 8 300</b>, add a <b>value</b>
attribute of <b>TL072</b>, and make the <b>refdes</b> of both
opamps be <b>U101</b>. Make the <b>slot</b> of the second opamp
be <b>2</b>. 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 <b>DIL</b> package from the layout. If you did everything
right, running gsch2pcb should give:
<blockquote><pre>
~/gaf/myproject1$ gsch2pcb project
Found a cpinlist head with a netname! [Vcc]
Found a cpinlist head with a netname! [Vee]
Found a cpinlist head with a netname! [Vcc]
Found a cpinlist head with a netname! [Vee]
Found a cpinlist head with a netname! [Vcc]
Found a cpinlist head with a netname! [Vee]
Found a cpinlist head with a netname! [Vcc]
Found a cpinlist head with a netname! [Vee]
No elements to add so not creating board.new.pcb
</pre></blockquote>
Where the gEDA gnetlist program seems a bit excited about finding the new
Vcc and Vee <b>net</b> attributes we just added, and a new netlist
was generated. Now I think the schematic looks
cleaner:
<p>
<center><table border=1>
<tr bgcolor=#b0b0a8>
<td>
<img src="images/one-sch-3.png" alt="images/one-sch-3.png"
border="0" align="top"><br> <center>one.sch</center>
</td>
</tr>
</table></center>
<p>
And if you run <b>pcb board.pcb</b> 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 <b>net</b>
attribute has worked.
<p>
For complete details on making symbols, read through the
Symbol Creation Document on the
<a href="http://www.geda.seul.org/docs/index.html"
name="gEDA Documentation"> gEDA Documentation </a> page.<br>
</blockquote>
<h3>Custom <i>file elements</i></h3>
<blockquote>
You can create custom <b>file elements</b>
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.
<p>
Run <b>pcb</b> and the first thing to do is go to the <b>Sizes</b>
menu and select <b>adjust "Signal" sizes</b>. Set the via hole
to 42 and the via size to 70 or larger as you like. Then make
sure you use this via
size by selecting <b>Sizes->use "Signal" routing style</b>. Select
<b>Screen->25 mil</b> and <b>Screen->display grid</b>.
Zoom in a couple of steps, then make the element:
</blockquote>
<table cellspacing=10>
<tr>
<td>
<table border=1>
<tr bgcolor=#b0b0a8>
<td>
<img src="images/pcb-el-1.png" alt="images/pcb-el-1.png"
border="0" align="top"><br> <center>Step 1</center>
</td>
<td>
<ul>
<li>Select the <b>VIA</b> tool and place two vias 400 mils
apart.</li>
<li>With the mouse on the left via, hit the <b>n</b>
key and give the via the name <b>1</b>. Give the
right via the name <b>2</b>
</li>
<li> Pin 1 will be the cathode and this must agree with the
pin numbers in your diode gschem symbol.
</li>
</ul>
</td>
</tr></table>
</td>
<td>
<table border=1>
<tr bgcolor=#b0b0a8>
<td>
<img src="images/pcb-el-2.png" alt="images/pcb-el-2.png"
border="0" align="top"><br> <center>Step 2</center>
</td>
<td>
<ul>
<li>Select the <b>Silk</b> layer and the <b>LINE</b> tool.
</li>
<li>Draw the component outline as shown with line width set
to 10 mils and the grid setting set to 10 mils.
</li>
<li>Draw the left fat cathode indicator with three lines after
setting the line width to 20 mils.
</li>
<li> Don't let silk layer lines overlap solder pads. </li>
</ul>
</td>
</tr></table>
</td>
</tr>
</table>
<blockquote>
Select the vias and the outline just drawn using the <b>SEL</b> tool
and finish making the element:
<ul>
<li><b>Buffer->cut selection to buffer</b> and move the cursor
to the center of the left via and click.
</li>
<li><b>Buffer->convert buffer to element</b>
</li>
<li><b>Buffer->save buffer elements to file</b> and navigate to
<b>~/gaf/pcb-elements</b> and save the element as
<b>D400-1A</b> since it's a package for a 1A diode with
400 mil spaced pins. Or give it any descriptive name you like.
</ul>
<b>Note:</b> if you save the element with a name which is the same
as a <b>m4 element</b>, gsch2pcb will preferentially use the m4
element unless you give gsch2pcb the --use-files (or -f) option.
You may put <b>use-files</b> in a project file if you want to always
give priority to using <b>file elements</b>. 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:
<blockquote><pre>
Pin(0 0 70 20 70 42 "" "1" 0x00000001)
to:
Pin(0 0 70 20 70 42 "" "1" 0x00000101)
</pre></blockquote>
You can now use <b>D400-1A</b> in a gschem schematic symbol
<b>footprint</b> attribute and gsch2pcb will find it provided
you have made the <b>packages</b> link described in the <b>Setup</b>
section. If you have not made that link, you can still tell gsch2pcb
about the elements directory with a line in a project file:
<blockquote><pre>
elements-dir ~/gaf/pcb-elements
</pre></blockquote>
Possibly you've noticed, but there are some things not right about the
<b>myproject1</b> 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="transistor-guide.html" name="transistor-guide.html">
transistor guide.</a>
<p>
From the transistor guide, you can see that the problem here is that
the <b>TO92</b> element has its pins numbered
in the less common (3,2,1) configuration while the <b>2N3904-1.sym</b>
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 <b>en</b> keys
(and don't be confused by the <b>pinseq</b> attribute that nearly
covers up the <b>pinnumber</b>). And in PCB, you can see the <b>TO92</b>
pin numbers by hitting the <b>d</b> key with the mouse over
the element. To be sure you are seeing pin numbers and not pin
names, select <b>Screen->pinout shows number</b>.
<p>
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="gsch2pcb-libs-20040110.tar.gz"
name="gsch2pcb-libs-20040110.tar.gz"> gschem/PCB libraries </a>.
Untar them under ~/gaf to mirror the setup of our example
and there will also be a
<b>~/gaf/pcb-elements.Readme</b> which documents the PCB elements.
<blockquote>
<i>Note: as of 1/10/2004 I've corrected the tarball pcb elements
to not overlap solder pads with silk layer lines.</i>
</blockquote>
If you untar them somewhere else,
you will need to make sure that gschem knows about them with
gschemrc/gnetlistrc <b>component-library</b> lines and that
gsch2pcb can find them with <b>elements-dir</b> lines in a
project file.
<p>
If you install them, you can fix Q201 in <b>two.sch</b>
by changing its footprint to <b>TO-92</b> which is my custom
element with (1,2,3) pin numbering.
Then run <b>gsch2pcb project</b>
and then <b>pcb board.pcb</b> and load the new element for
the transistor. In the next images, <b>two.sch</b> is showing
the <b>footprint</b> attribute visible to emphasize it, and it also
shows a new symbol for the 2N3904 which I created from my
custom <b>npn-ebc.sym</b> 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 <b>footprint</b> attribute for
resistors R102 and R103 in <b>one.sch</b> to my custom
1/8 watt <b>R0w8</b> and 1/4 watt <b>R0w4</b> 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 <b>0.125W_Carbon_Resistor</b> 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 <b>R0w4</b> is slightly less
than in <b>R025</b> to improve component density.
</blockquote>
<center><table cellspacing=30>
<tr>
<td>
<table border=1>
<tr bgcolor=#b0b0a8>
<td>
<img src="images/two-sch-2.png" alt="images/two-sch-2.png"
border="0" align="top"><br><center> two.sch</center>
</ul>
</td>
</tr></table>
</td>
<td>
<table border=1>
<tr bgcolor=#b0b0a8>
<td>
<img src="images/board-6.png" alt="images/board-6.png"
border="0" align="top"><br>
</td>
</tr></table>
</td>
</tr>
</table></center>
<blockquote>
</blockquote>
<a name="CUSTOM_M4">
<h3>Custom <i>m4 elements</i> (Requires gsch2pcb >= 1.0)</h3>
<blockquote>
First, some words about how to find out about
the default <b>m4 elements</b>
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 <b>file elements</b>. 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 <b>/usr/share/pcb/m4</b> or
<b>/usr/local/share/pcb/m4</b>, while on earlier PCB versions it could be
<b>/usr/X11R6/lib/X11/pcb/m4</b> (run <i>gsch2pcb --help</i> or
<i>gsch2pcb -v project</i> 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 <i>is</i> somewhere
different from the above three, then gsch2pcb won't be finding your
<b>m4 elements</b> in the above examples and you will need to add
the correct m4 directory to your <b>project</b> file with a line like:
<blockquote><pre>
m4-pcbdir /path/to/pcb/m4
</pre></blockquote>
Just read the <b>.inc</b> files in the m4 install directory. For
example, in the <b>misc.inc</b> file you will find the <b>R025</b> element
we've used and it starts out with:
<blockquote><pre>
# -------------------------------------------------------------------
# the definition of a resistor (0.25W) package
# $1: canonical name
# $2: name on PCB
# $3: value
define(`PKG_R025',
`Element(0x00 "$1" "$2" "$3" 120 30 0 100 0x00)
(
...
</pre></blockquote>
The information you can extract from this is that a m4 <b>PKG_</b> macro
named <b>R025</b> is being defined and it takes 3 arguments. Now, all PCB
<b>m4 element</b> macros take at least three
arguments and these are automatically
filled in by gsch2pcb with the gschem attributes <b>footprint</b> for
<b>canonical name</b>, <b>refdes</b> for <b>name on PCB</b>, and
<b>value</b> for <b>value</b>. The "canonical name" used in these
m4 files is just an older way of referring to the current PCB usage of
<b>description</b> as mentioned above in the <b>Terminology</b> section.
Since these args are automatically filled in, you don't need to specify
any additional args to <b>R025</b> when you use it as a gschem
<b>footprint</b>. But now look at the very next m4 element define
in <b>misc.inc</b>:
<blockquote><pre>
# -------------------------------------------------------------------
# the definition of a SIL package without a common pin
# $1: canonical name
# $2: name on PCB
# $3: value
# $4: number of pins
define(`PKG_SIL',
`define(`MAXY', `eval(`$4' * 100 -50)')
Element(0x00 "$1" "$2" "$3" 160 10 3 100 0x00)
(
...
</pre></blockquote>
From this you can determine there is a <b>SIL</b> package you can use
as a <b>footprint</b>. 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 <b>CONNECTOR 2 1</b> element specifying 1 column we used
in our example above, you might think we could have used <b>SIL 2</b>.
But you would be wrong! Because if you read the macro body you will see
that if the argument is <b>2</b> 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 <b>misc.inc</b> here's a summary
of what you will find as possible elements you can use:
<blockquote><pre>
Package Args you need to supply
SD 1 number of pins of a ZIP package
MULTIWATT15 0
R025 0
SIL 1 number of pins (we know now must be >= 4)
CSIL 1 number of pins
QFP132 0
LED 1 diameter of LED
DIODE_LAY 1 pin separation
AXIAL_LAY 1 pin separation
CRYSTAL 1 package width
OSC 0
ISA8 0
OVEN_OSC 0
RADIAL_CAN 1
SMD_BASE 2 length and width of surface mount device
SMD_CHIP 1 package length
</pre></blockquote>
And so on for the other <b>.inc</b> files...
<p>
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
<b>file element</b> approach. So for most of your custom elements I
suggest you are better off staying with <b>file elements</b>. 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 <b>m4 element</b> would be to copy and modify to
our taste the existing
m4 macro for IC packages (the <b>DIL</b> macro) into a m4 file gsch2pcb
will search. The destination m4 file can be any of these:
<ul>
<li><b>pcb.inc</b> in our <b>myproject1</b> directory and the custom
element will be local to this project.
</li>
<li><b>~/.pcb/pcb.inc</b> and the element will be known to all of
our projects.
</li>
<li><b>/path/to/anyfile</b> if this path is made known to gsch2pcb
by adding a line to a project file like:
<blockquote><pre>
m4-file /path/to/anyfile
</pre></blockquote>
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:
<blockquote><pre>
~/gaf/myproject1/project
~/.gsch2pcb
/usr/local/etc/gsch2pcb
/etc/gsch2pcb
</pre></blockquote>
</li>
</ul>
For this tutorial, I'll use the first <b>pcb.inc</b> way, so copy over
the existing macro file:
<blockquote><pre>
cd /usr/local/share/pcb/m4 (or /usr/share/pcb/m4 or /usr/X11R6/lib/X11/pcb/m4)
cp dil.inc ~/gaf/myproject1/pcb.inc
cd ~/gaf/myproject1
</pre></blockquote>
Now, edit the <b>pcb.inc</b> 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 <b>60</b>
to <b>70</b> on the <b>PIN</b> lines.
When done, this should
be the entire contents of the new <b>pcb.inc</b> file:
<blockquote><pre>
# -------------------------------------------------------------------
# the definition of a dual-inline package N and similar types
# $1: canonical name
# $2: name on PCB
# $3: value
# $4: number of pins
# $5: package size (300, 600, 900 + 100 for socket space)
#
define(`PKG_DILFAT',
`define(`MAXY', `eval(`$4' / 2 * 100)')
define(`MAXX', `eval(`$5' + 100)')
define(`CENTERX', `eval(MAXX / 2)')
Element(0x00 "$1" "$2" "$3" eval(CENTERX + 20) 100 3 100 0x00)
(
forloop(`i', 1, eval($4 / 2),
`PIN(50, eval(i * 100 -50), 70, 28, i)
')
forloop(`i', 1, eval($4 / 2),
`PIN(eval(MAXX -50), eval(MAXY - i * 100 +50), 70, 28, eval(i + $4/2))
')
ElementLine(0 0 0 MAXY 10)
ElementLine(0 MAXY MAXX MAXY 10)
ElementLine(MAXX MAXY MAXX 0 10)
ElementLine(0 0 eval(CENTERX - 50) 0 10)
ElementLine(eval(CENTERX + 50) 0 MAXX 0 10)
ElementArc(CENTERX 0 50 50 0 180 10)
Mark(50 50)
)')
</pre></blockquote>
Run <b>gschem one.sch</b> and edit the <b>footprint</b> attribute of
the opamps to be <b>DILFAT 8 300</b>.
Then run <b>gsch2pcb project</b>
and gsch2pcb will remove the <b>DIL</b> element from <b>board.pcb</b>
and add into <b>board.new.pcb</b> a new <b>DILFAT</b> element from your
custom m4 file <b>pcb.inc</b>. Run <b>pcb board.pcb</b> and
load the <b>board.new.pcb</b> into
your layout. Move the new element with its fatter pins to the location
left vacant by the removal of the old element.
</blockquote>
<h3>Multi-user Setup (requires gsch2pcb >= 1.0)</h3>
<blockquote>
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:
<ul>
<li> Put site wide custom PCB <b>file elements</b> under, for example,
<b>/usr/local/share/pcb/pcb-elements</b>. Make this directory
searched by gsch2pcb for all users by putting a line into
<b>/etc/gsch2pcb</b> or <b>/usr/local/etc/gsch2pcb</b>:
<pre>
elements-dir /usr/local/share/pcb/pcb-elements
</pre>
If there are any site wide custom PCB <b>m4 element</b> files,
for example, <b>/usr/local/share/pcb/pcb.inc</b>, add another
line into <b>/etc/gsch2pcb</b> or <b>/usr/local/etc/gsch2pcb</b>:
<pre>
m4-file /usr/local/share/pcb/pcb.inc
</pre>
</li>
<li> If the default PCB m4 install is not
<b>/usr/local/share/pcb/m4, /usr/share/pcb/m4,</b> or
<b>/usr/X11R6/lib/X11/pcb/m4</b>, then make the install location
known to all users of gsch2pcb by putting into
<b>/etc/gsch2pcb</b> or <b>/usr/local/etc/gsch2pcb</b> the line:
<pre>
m4-pcbdir /path/to/pcb/m4
</pre>
If the m4 program is gm4 instead of m4, add to the gsch2pcb file:
<pre>
m4-command gm4
</pre>
</li>
<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 <b>component-library</b> lines for them.
</li>
</ul>
With the above, users will have access to site wide libraries
and only need to put in a design <b>project</b> file
lines for <b>schematics</b> and <b>output-name</b>. But they
also are free to have their own additional user and/or project
specific symbol and element libraries.
</blockquote>
<h3>PC Board Fabrication</h3>
<blockquote>
Someday I may add some notes here on how I make pc boards.
</blockquote>
<hr>
<address>
<p align=center>
<a href="http://web.wt.net/~billw/gsch2pcb/gsch2pcb.html"
name="www.gkrellm.net">gsch2pcb Home</a>
<br>
Bill Wilson <A HREF="mailto:bill--at--gkrellm.net">bill--at--gkrellm.net</A>
<br>
</p>
</address>
</body>
</html>