To be independent of later releases of the spice3 library, you should first define a new "private" library. From the eagle control panel, select the menu entry File/New/Library. A new window containing the library editor comes up.
We will now define a simple voltage divider consisting of two equal
resistors. Click onto "edit symbol"
and write "divby2" into the white text frame. Satisfy the upcoming requester
with "yes". You will now get a grid to define your pins on. Don't ever
change this grid during pin placement, otherwise it may be impossible to
connect a wire to it.
But first draw a small 2x2 frame around the origin cross, using wire
(double click on the end point to finish). Then you should attach a name
of the part. This is just the name which appears later in the schematics.
Don't mix this up with the "divideby2"-string which will be later on the
"value" string. Change layer
to "Names", then edit text
to insert ">NAME". Place it on the lower right of the frame. Then change
layer
to "Values", then
edit text
to insert ">VALUE".
Place it on top of the frame.
Now you will define the pins. Click on pin .
A new button line comes up at the top. In this line, "change Direction"
to "Pas", and select length short
.
Place the first pin left of the frame.
Select orientation bottom ,
and place the pin at the bottom. Finally, select orientation right
,
and place the pin right of the frame. Using change name
,
assign new names IN, COM , OUT to the pins by clicking on it. Make all
of the names invisible using change visible off
. The whole thing should now look like this:
You are done with the symbol. Save
your work under the name "private.lbr".
Next we need a package (remember that eagle is a layout system).
In this case, we don't want the layout function and can assign any existing
"dummy" package to it. In the spice3.lbr library, there is a dummy12 package
we can copy into the new library. Select the menu File/Open and select
the spice3.lbr (you did move it to the eagle distribution, didn't you?).
Edit package "dummy12"
and define a group
, then
cut
it. Go back to your new
library, selecting the menu File/Open "private.lbr ". Edit package
new: "DUMMY12", and paste
.
Voila, you are done with the package.
Finally you have to define a new device
"divby2" which contains the right symbol and package. Add
the symbol "divby2". Assign the package
"DUMMY12". Define a prefix
"X" for the device (this will tell the environment that the corresponding
spice3 model file contains a subcircuit). After that, connect
the symbol pins to the package pins. You don't have to worry about wrong
layout connections here, so just click three times "Connect". Before clicking
"OK", have a short look at the connections list. It will be sorted alphabetically:
COM, IN, OUT. The order of pins in the subcircuit file must match this!
If
you can't live with this restriction, you can place a string "spiceorder
pinname1 pinname2 ... " on the spice layer of the symbol. This way you
can rearrange the pin assignment, but be warned: Don't try to change the
special parts of the spice3 library (like the VMETER), because that would
fail!
Don't forget to save the
whole library. The next step is to define the corresponding subcircuit
file "DIVBY2.mod".
Use your favorite text editor to enter this lines:
.SUBCKT DIVBY2 COM IN OUT
R1 IN OUT 1K
R2 OUT COM 1K
.ENDS
and you are done. Try to use the library
in a schematic and see how it simulates with a DC sweep.
A final hint: You can easily generate big subcircuit files, if you draw a schematic for the circuit, simulate it and cut/paste the core function out of the spice3 netlist file (ends with .inp) with you text editor.
previous | next | eaglesp3 index | eagle index | Dr. Ulrich Backes |