Creating Your Own Symbols in gschem
September 23, 2010 40 Comments
Before writing another tutorial on SPICE, I thought of spending some time on creating symbols. This will be necessary because we will be looking at op-amp circuits next. There are op-amps in the gschem library but there are incompatibilities between those and the model files which the manufacturers provide. While trying to figure out how to create symbols, I found an excellent 3 part tutorial on this. I will take you through the creation of an op-amp symbol in this tutorial but I still feel this video will do better than that. Take a look at these before reading on:
There are two references you need to look at while making your own symbols. Both are from gEDA. Here are the links:
Custom Symbol Creation – LM741
LM741 – the op-amp everyone knows of. It would be a good idea to have the datasheet with you so go ahead and download it from National Semiconductor. Have a look at the pin details of the LM741. This is the symbol we need to make:
Looks simple? Well it is 🙂
First make a separate directory for all your symbols. Opening gschem. Now save this blank file in the directory you just created. However, change the extension to sym. For this tutorial, lets name it as LM741.sym. We now have a blank sheet. However, there still is the title block – that big rectangle on the entire sheet. Delete it by dragging a rectangle around the title block and hitting the delete key.
Next zoom in till you can see the smallest grid spacing. You should have something like this:
Next we need to draw the pins. As the video says, start by clicking at a point away from the triangle, then click on the triangle. In the following figure, I’ve marked points 1 and 2. You first need to click near 1 and then near 2.
Do the same for the remaining 4 pins.
Looks cluttered? Lets fix that. Double click the pin we created first (non-inverting terminal) and set the following attributes (you’ll find them in the table already).
- pintype: in
- pinlabel: +
- pinnumber: 3
- pinseq: 1
Next, without closing the dialog box, click the pin below it (inverting terminal) and set the following values
- pintype: in
- pinlabel: –
- pinnumber: 2
- pinseq: 2
The center pin on top (Vcc) :
- pintype: pas
- pinlabel: Vcc (Uncheck the Vis? checkbox)
- pinnumber: 7
- pinseq: 3
The center pin below (Vee)
- pintype: pas
- pinlabel: Vee (Uncheck the Vis? checkbox)
- pinnumber: 4
- pinseq: 4
And finally the rightmost output pin
- pintype: out
- pinlabel: Out (Uncheck the Vis? checkbox)
- pinnumber: 6
- pinseq: 5
Rotate the pinnumber for the Voltage pins so they can be read correctly. Next select the + and – signs (the pinlabels). You can hold the Ctrl to select multimple components. With these two selected, go to Edit > Color and set the value to Graphic. Your symbol should now look like this:
We’re almost done. We need to add two more attributes to the schematic. Before that go to Edit>Show/Hide Inv Text to show all the hidden attributes. Make sure nothing is selected (all the text should be black). Now place you mouse somewhere above the symbol (zoom out a little if you need to) and press a on your keyboard twice (hit aa). The Add Attribute dialog should appear. Select device from the drop-down menu and set Value to LM741. Uncheck Visible and click OK. You should see the device name on the sheet at the place where you positioned the mouse before calling this dialog. Click on an empty area of the sheet to unselect the device attribute we just created. Place the mouse below this attribute and call the Add Attribute dialog again. This time select refdes and set its value to X?. This is what you should have now:
Finally, go to Edit > Symbol Translate. And we’re done. Save and exit gschem.
Before we stop, we have one more thing remaining to do. We did create the symbol correctly. But gschem should know we created it. To do this add the following line to your gafrc (located in ~/.gEDA). Create the file in ~/.gEDA if it doesn’t exist.
(component-library "<path of symbols directory>")
For example, if the directory is located in ~/EDA,
Save the file and exit. Make sure that the path does not contain ~ or environment variables ($HOME will not work). You can however use a path like “./symbols”.
To check if our symbol got added, open gschem and go to the Add Component dialog. You should see the symbol we just made under the symbols section.
Thats it for this tutorial. Try making a few more symbols yourself. Slowly you can have your own library of symbols depending on the kind of circuits you design. In my next post, we’ll look at how we can use this symbol in our schematic. We will also look at subckt – a way to decompose your circuit into smaller blocks. The op-amp’s characteristics are defined using subckts.
Stay tuned for the next tutorial. Hope you liked this one 🙂