1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337
|
<html>
<head>
<title>gschem symbol creation, the quick and easy tragesym way</title>
</head>
<body>
<h1>Creating gschem symbols quickly and easily using tragesym</h1>
<p>Creating symbols for schematic capture can be very time consuming,
error prone, and an all around pain. Luckily, gschem uses an open, text
base file format that is very easy to use with scripting. This short
tutorial describes how to use a third party tool, tragesym, to create
symbols very quickly (probably more quickly than with any commercial
package).</p>
<h4>Step 1: Obtain tragesym</h4>
<p>tragesym was written by Werner Hoch
<a HREF="mailto:werner.ho(AT)gmx.de"><werner.ho(AT)gmx.de></a> and is
downloadable from <a HREF="http://www.my-stuff.onlinehome.de/tragesym.html">
http://www.my-stuff.onlinehome.de/tragesym.html</A>. Once downloaded, just
unpack it in the directory you'd like to work in. Take a moment and go
over the COPYING file if you are not familiar with the liability restriction
and redistribution rights of GPL'd code.</p>
<h4>Step 2: Download you data sheet, and find the pin list</h4>
<p> For this example, we will be creating a symbol from the Philips
Semiconductor PCA9555 16-bit IIC IO port. The description of product and
datasheet is available at Philips:
<a HREF="http://www-us.semiconductors.philips.com/cgi-bin/pldb/pip/pca9555.html">
http://www-us.semiconductors.philips.com/cgi-bin/pldb/pip/pca9555.html</A>
Download the datasheet and open it with a pdf viewer that allows for copying text
out of the PDF, such as xpdf. Flip through the pages until you find the pinout for
the device:</p>
<img src="xpdf_open.jpg" border="0" hspace="0" vspace="0">
<h4>Step 3: Copy the pins from the data sheet, and put them somewhere</h4>
<p> The end goal is to get the pin list into a spreadsheet, like gnumeric,
unfortunately, xpdf doesn't copy/paste into a form gnumeric seems to like. The
easiest solution is to use an intermediary, like gedit. First, highlight all the
pins: </p>
<img src="xpdf_selected.jpg" border="0" hspace="0" vspace="0">
<p> And then open gedit, and hit the middle mouse button to paste them in: </p>
<img src="gedit_pasted.jpg" border="0" hspace="0" vspace="0">
<p> Next, a little bit of preprocessing need to be done so that the gnumeric text
import goes smoothly. We will tell gnumeric to use spaces as seperators, and to
see two seperators as one. Notice that some of the pins have extra spaces before
them. Correct this:</p>
<img src="gedit_corrected.jpg" border="0" hspace="0" vspace="0">
<P> Now, just highlight everything and hit copy </p>
<h4>Step 4: Import into gnumeric</h4>
<p> open up gnumeric, click the first cell (A1) and hit the paste button. A
dialog called "Importing structured text" should appear:</p>
<img src="gnumeric_import.jpg" border="0" hspace="0" vspace="0">
<p> click forward. The next page allows you to select how fields are seperated.
The default is by commas. Uncheck the 'Comma (,)' box, and check the 'Space' box
instead. Then select 'See two seperators as one'. Click Forward.
<img src="gnumeric_import2.jpg" border="0" hspace="0" vspace="0">
<p> Click apply to complete the import. </p>
<h4>Step 5: Get stuff in the right place</h4>
<p> Tragesym wants the columns in a specific order, template.src shows this:</p>
<pre>
[pins]
# tabseparated list of pin descriptions
# pinnr is the physical number of the pin
# seq is the pinseq= attribute, leave it blank if it doesn't matter
# type can be (in, out, i/o, oc, oe, pas, tp, tri, clk, pwr)
# style can be (line,dot,clk,dotclk,none). none if only want to add a net
# posit. can be (l,r,t,b) or empty for nets
# net specifies the name of the Vcc or GND name
# label represents the pinlabel.
# negation lines can be added with _Q_
# if you want to add a "_" or "\" use \_ and \\ as escape sequences
#-----------------------------------------------------
#pinnr seq type style posit. net label
#-----------------------------------------------------
</pre>
<p><font size="-1"><em>Note: i/o is a typo, it should be io</em></font></p>
<p> So we need to get all the pin numbers in column A, and all the labels
in column G. Its basically however you want to do it, but for example: </p>
Cut C1:C12 and paste into A13<BR>
Cut D1:D12 and paste into G13<BR>
Cut A1:A12 and paste into G1<BR>
Cut B1:B12 and paste int A1<BR>
<p> It should look like this: </p>
<img src="gnumeric_moved.jpg" border="0" hspace="0" vspace="0">
<p> you may want to sort by pin number at this point to make the order
of the labels a bit more consistent. This step is of course optional. Just
select all the data elements and click the sort button (little green down
arrow in the tool bar with the A..Z</p>
<img src="gnumeric_sorted.jpg" border="0" hspace="0" vspace="0">
<h4>Step 6: Fill in the type, style, and position columns</h4>
<p> First you probably want to just autofill the most common value
for these three columns. First enter that into the first row (most common
values for this symbol are probably io, line, and r (right).</p>
<img src="gnumeric_start.jpg" border="0" hspace="0" vspace="0">
<p> Now, highlight all three cells, grab the little square box in the lower
right hand corner of the selection box, and pull down to the last row</p>
<img src="gnumeric_filled.jpg" border="0" hspace="0" vspace="0">
<p> Next you'll want to change some of the values that need to be changed.
Look at the pin description table in the datasheet:</p>
<img src="xpdf_pins.jpg" border="0" hspace="0" vspace="0">
<p> INT is an output, so change its type column (column C) to out (from io).
A0, A1, and A3 are inputs, so change those colums to in. Also, change the VSS
and VDD type columns to pwr. (Note, the type column allows DRC checkers
for gschem to work. They check to see that connections are sane (ie, two
out nets are not connected together. If you don't care about this, you
don't really need to bother, ie, leave everything as io)<p>
<img src="gnumeric_type.jpg" border="0" hspace="0" vspace="0">
<p> The choice of which pins are on which side of the symbol is really up to
you, for this example, I just went off the datasheet: </p>
<img src="xpdf_block.jpg" border="0" hspace="0" vspace="0">
<p> So I'll change A0,A1,A2 and SCA/SCL over to l. For most symbols, you'll
want Vcc and GND to hook up automatically, and they won't appear in the symbol,
so delete their position values. If you have long runs of values you want to
change, you can use the highlight and pull method to change them all.</p>
<img src="gnumeric_posit.jpg" border="0" hspace="0" vspace="0">
<h4>Step 6: Connect up the power pins</h4>
<p> To connect up the power pins automatically, change the style column
to none (from line) and put the net name (Vcc/GND) in the net column
(column F). For some designs, you'll want the Vcc/GND pins accessable
on the symbol rather than automatically connecting into the Vcc and GND
nets. However, even if you do automatically connect them in, you can
still override this later in a schematic by adding a net attribute, ie:</p>
<pre>
net=+5V:24
</pre>
<p> Anyway, here is what gnumeric looks like after we connected the power
pins up </p>
<img src="gnumeric_pwr.jpg" border="0" hspace="0" vspace="0">
<h4>Step 7: Make it look pretty</h4>
<p> You can give pins that have special functions or features a graphical
depiction of that feature. For instance, a clock can have a triange on its
input, or an active low signal can have a bubble. In this symbol, INT
is an active low output, so lets make that aparent. First, change the sytle
from line to dot. This will put a bubble next to the pin. Next, put a
negation bar over INT by surrounding it with _'s, ie, _INT_. (Note: if
your imported labels already have underscores in them, you'll have to escape
them with a backslash. Just do a search and replace, s/_/\\_/).</p>
<img src="gnumeric_dot.jpg" border="0" hspace="0" vspace="0">
<h4>Step 7: Export it</h4>
<p> Next you'll want to export it into a tab delimiated file. Just do
File->Save. Browse to your tragesym directory, select
'Text export (configurable)' as the file format, enter
pca9555.src.1 into the file name box and hit ok.</P>
<img src="gnumeric_save.jpg" border="0" hspace="0" vspace="0">
<p> A silly dialog box will come up complaining about the extension,
just click yes. Next, a more usefull dialog box will appear asking you
to describe the output format. Select Tab for a seperator and Never for
Quoting. Click Apply.</P>
<img src="gnumeric_export.jpg" border="0" hspace="0" vspace="0">
<h4>Step 8: Make a header</h4>
<p> Copy the templete.src to pca9555.src.0 and edit it. You may need to
change version to your version of gschem so that gschem stops complaining
about outdated symbols. Do this in your templete.src so that you only need
to do it once. Anyway, just set name= to pca9555, device= to pca9555, and
footprint to whatever works for you (I really don't use this attribute,
some people might). And description is really your call too. Anyway, here
is what it might look like.</p>
<pre>
# This is the template file for creating symbols with tragesym.py
# every line starting with '#' is a comment line.
[options]
# rotate_labels rotates the pintext of top and bottom pins
# wordswap swaps labels if the pin is on the right side an looks like this:
# "PB1 (CLK)"
wordswap=yes
rotate_labels=no
sort_labels=yes
generate_pinseq=yes
sym_width=1400
pinwidthvertikal=400
pinwidthhorizontal=400
[geda_attr]
# name will be printed in the top of the symbol
# if you have a device with slots, you'll have to use slot= and slotdef=
# use comment= if there are special information you want to add
version=20030525
name=pca9555
device=pca9555
refdes=U?
footprint=sot616-1
description=IIC to Parallel IO
numslots=0
#slot=1
#slotdef=1:
#slotdef=2:
#slotdef=3:
#slotdef=4:
#comment=
#comment=
#comment=
[pins]
# tabseparated list of pin descriptions
# pinnr is the physical number of the pin
# seq is the pinseq= attribute, leave it blank if it doesn't matter
# type can be (in, out, i/o, oc, oe, pas, tp, tri, clk, pwr)
# style can be (line,dot,clk,dotclk,none). none if only want to add a net
# posit. can be (l,r,t,b) or empty for nets
# net specifies the name of the Vcc or GND name
# label represents the pinlabel.
# negation lines can be added with _Q_
# if you want to add a "_" or "\" use \_ and \\ as escape sequences
#-----------------------------------------------------
#pinnr seq type style posit. net label
#-----------------------------------------------------
</pre>
<h4>Step 9: Make the symbol</h4>
<p> Next, you'll want to use tragesym to make the .sym file. First,
concatinate your pin list and pin header into one source file </P>
<pre>
russ@russ:~/src/tragesym$ cat pca9555.src.0 pca9555.src.1 > pca9555.src
</pre>
<p> Next, use tragesym </p>
<pre>
russ@russ:~/src/tragesym$ ./tragesym.py pca9555.src pca9555.sym
</pre>
<p> If tragesym says you made a mistake, you can fix it in the spreadsheet
and go through the intermediary steps again, or just edit the .src file </p>
<h4>Step 10: Edit the symbol</h4>
<p> Open up the symbol with gschem</p>
<pre>
russ@russ:~/src/tragesym$ gschem pca9555.sym
</pre>
<p>Its not really necessary to move pins around, but you might, to make
your symbol easier to work with. So if you care, do that first.</p>
<img src="gschem_edited.jpg" border="0" hspace="0" vspace="0">
<p> These next two steps are neccessary however. First make all invisable
text visable by selecting Edit->Show/Hide Env Text or by using the key sequence
en, Zoom out so you can see everything (ve, view->Zoom Extents, or shift-z).
Hightlight everything with the mouse, and translate the symbol to the origin
(edit->Symbol Translate... or et). A little dialog will pop up, just enter 0
and hit OK (or enter). Ok, save your symbol (just click save) and exit gschem.
You can now install your symbol by copying it to /usr/share/gEDA/sym/local
(depending on your directory configuration)</p>
<p>This is a simple example with a small pincount, but this method really
pays off when you have high pin counts (ie, bga-272, tfqp-100, etc). You can
also create components from scratch using gnumeric. Numbered busses, for insance,
are easy to make. just enter D0, D1, select both, then pull down to fill the rest.
</p>
<p> Similary, I have a simple C program that generates large data busses for
use in schematics</p>
<pre>
#include <stdio.h>
#define LEN 800
#define SPC 200
int main(int argc, char **argv)
{
int i, start, end, j;
int spacing = SPC;
if (argc < 4) {
printf("%s root start end (%s SD 0 31)\n",
argv[0], argv[0]);
return 0;
}
if (argc == 5) spacing = atoi(argv[4]);
start = atoi(argv[2]);
end = atoi(argv[3]);
printf("v 20030223\n");
for (i = start, j = 1;
start < end ? i <= end : i >= end;
i += start < end ? : -1, j++) {
printf("N 200 %d %d %d 4\n{\n",
j * spacing, 200 + LEN, j * spacing);
printf("T %d %d 5 10 1 1 0 0\n", 200 + LEN / 2, spacing * j + 30);
printf("netname=%s%d\n}\n", argv[1], i);
}
return 0;
}
</pre>
<p> Just run ./make_bus A 31 0 > bus.sch, open bus.sch, copy, paste, viola.
Anyway, the exploitablity of the open, text based, gschem file formats are
endless.</p>
Comments? suggestions? additions? Email me:
<a HREF="mailto:Russ.Dill@asu.edu"><Russ.Dill@asu.edu></a>
|