# Gschem installation/run-time problems

## Gschem segfaults when I delete components on FC5 (and other Linux distributions)! Is there a work-around?

This bug seems to have appeared for users of Fedora Core 5 (and other linux distributions that use glib 2.10.x). The bug has been fixed by the developers and the bug fix will appear in the next version of gEDA/gaf.

In the mean time, you can work around this bug by setting the environment variable G_SLICE to “always-malloc”. Specifically, before you run gschem, do this:

bash:

    export G_SLICE=always-malloc

csh:

    setenv G_SLICE always-malloc

## After installation gschem does not work!? What could be wrong?

If you run gschem and you get a window without a menu bar, no colors, and the program terminates when you press a key with the following message:

    ERROR: Unbound variable: current-keymap

Or you get errors like this:

    Gtk-CRITICAL : file gtkpixmap.c: line 97 (gtk_pixmap_new): assertion `val != NULL’ failed.
    Gtk-CRITICAL : file gtkpixmap.c: line 97 (gtk_pixmap_new): assertion `val != NULL’ failed.
    Tried to get an invalid color: 0
    Tried to get an invalid color: 7
    Tried to get an invalid color: 0
    Tried to get an invalid color: 7

then gschem is not finding an rc file. There are two required rc files. The first is `system-gschemrc` and the second is `system-commonrc`.

- The system-gschemrc rc file should be installed when you install gschem and typically resides in `${prefix}/share/gEDA/system-gschemrc`. `${prefix}` is where you installed gschem (usually `/usr` or `/usr/local` or `$HOME/geda`). This file can also be installed in /etc/gEDA (the .debs packages do this).
- The system-commonrc rc file should be installed when you install the symbol library for gEDA/gaf. It resides in `${prefix}/share/gEDA/system-commonrc`. This file can also be installed in `/etc/gEDA` (the .debs packages do this). This file is not loaded directly by gschem. It is loaded by a “(load ...)” in the system-gschemrc rc file.

Make sure these file are installed. The gschem.log file (which is created everytime you run gschem) holds valuable debugging information which should help in determining what is wrong. Check this file for where gschem is looking for the rc files.

Also, some older releases of gEDA/gaf had some bugs when the rc files were installed in other locations (other that `${prefix}/share/gEDA`), so please upgrade to a more current release.

## "Add Components" offers no symbols! What can I do about it?

Make sure that at least one of your config files contains a valid path to a symbol library. At startup, gschem checks for the following config files (on a Debian system):

1. system gafrc file: `/etc/gEDA/system-gafrc`
2. user gafrc file: `~/.gEDA/gafrc`
3. local gafrc file: `$PWD/gafrc`
4. system gschemrc file: `/etc/gEDA/system-gschemrc`
5. user gschemrc file: `~/.gEDA/gschemrc`
6. local gschemrc file: `$PWD/gschemrc]`

All of these config files may or may not append paths to the library search list. If a config file conatins the command

    (reset-component-library)

the library search path will be emptied. Order is obviously important, as this command will erase any previously appended paths.

# Gschem usage

## How do I move a component?

Newbies with long-time Windows experience often ask this question. Here are three ways to easily move components with gschem:

One:

1. Grab the component with the middle mouse button. The component will follow the cursor around as you move it.
2. To place the component, release the middle mouse button. The component will stay where you placed it.

Two:

1. Select the component by clicking it with the left mouse button. The component will highlight.
2. Hit the “M” key on the keyboard. The component will now follow the cursor around as you move it.
3. To place the component, click the left mouse button. The component will stay where you placed it.

Three:

1. Select the component by clicking it with the left mouse button. The component will highlight.
2. Click the right mouse button. A pop-up menu will appear.
3. With the left mouse button, click on the “move” option in the pop-up menu.
4. Click on the component with the left mouse button. The component will now follow the cursor around as you move it.
5. To place the component, click the left mouse button. The component will stay where you placed it.

## How do I change the size of the text on a symbol?

1. Select the symbol.
2. Right click → down symbol (or do Hierarchy → down symbol). This takes you to the symbol editor.
3. Select the pinnumber you want to change.
4. Do Edit → Edit Text (or type keyboard shortcut “ex”).
5. Change the font size in the pop-up box.
6. Repeat for all desired text elements.
7. File → save
8. Right click → up (or Hierarchy → Up). Now you are back in the schematic editor.
9. With the symbol still selected do Edit → Update component (or use the keyboard shortcut “ep”). If this doesn’t work, just delete the symbol and reload it.

More generally, you can use this procedure to edit anything on a symbol. (Substitute “Edit Text” for your desired edit, of course.)

## Is there an explicit "no connect" symbol that I can/should place in the schematic to prevent gnetlist from thinking I've forgotten a connection?

Answer: misc → nc-left, nc-right, nc-top, nc-bottom.

Caution: occassionally this may create a net called “no_connect” (or “NC??”) which may lead to no-connect pins being connected together in gnetlist – which you probably _don’t_ want to happen.

## How do I print schematics from the command line?

Running the script `gschem-print.scm` will create the Postscript file that is specified on the command line.

The command line below creates a Postscript file from a schematic file (replace MY_SCH with the name of your schematic and GEDA_SCHEME_DIR with the name of the directory where your gEDA scheme files are installed):

    gschem -p -oMY_SCH.ps -sGEDA_SCHEME_DIR/gschem-print.scm MY_SCH.sch

The BASH script below, which I name `gschem-print`, creates a Postscript file for each schematic file that is specified on the command line and then outputs each Postscript file to the default printer:

    #!/bin/bash

    # gschem options
    # -oPS_FILENAME output to Postscript file PS_FILENAME
    # -sSCRIPT_FILENAME run script SCRIPT_FILENAME
    # -p autoplace windows

    for name in $*
    do
    base=”${name%.*}”
    gschem -p -o$base.ps -sGEDA_SCHEME_DIR/gschem-print.scm $base.sch
    lpr -P$PRINTER $base.ps
    done

## How can I get color postscript/PNG output?

Edit the `system-gschemrc` file or place the following into a `gschemrc` file (either `~/.gEDA/gschemrc` or a `gschemrc` file in the local directory where you invoke gschem):

    (output-color "enabled")      ; for color postscript output
    (image-color "enabled")       ; for color PNG output (enabled by default)

To control the background of the PS output, change the following line in either gschem-darkbg (for the default black colored background) or gschem-lightbg (for the alternative light colored background):

    (output-color-background 16 "black" "null" "0 0 0" 0 0 0)

The “0 0 0” is the RGB components (between 0..1) for the background color of the PS output.

To control the background of the PNG output, change the following line in either gschem-darkbg (for the default black colored background) or gschem-lightbg (for the alternative light colored background):

    (background-color 0 "grey94" "null" "1 1 1" 255 255 255)

The 255 255 255 are the RGB components for the background color of the PNG image.

## How can I get black and white postscript/PNG output?

For black and white PS output, place the following into a gschemrc file:

    (output-color "disabled")      ; for monochrome postscript output

For black and white PNG images, place the following into a gschemrc file:

    (image-color "disabled")       ; for monochromoe PNG output

## How can I insert schematics into my LaTex document?

1. Print the schematic to a file. This will be generic postscript (*.ps).
2. Convert the postscript file to epsi with the tool ps2epsi. This is a script from the ghostscript suite.
3. Include usepackage{graphicx} to the preamble of your latex document. Use the comand includegraphics to place your schematic.

A simple example:

    \documentclass{article}
    \usepackage{graphicx}
    \begin{document}
      \begin{image}
      \includegraphics[width=100mm]{ModulPID.epsi}
      \end{image}
    \end{document}

## How can I split postscript output over multiple pages?

gschem does not provide this functionality internally, however there is a program called “poster” which does exactly this. It can be downloaded from either here (GNU) or here (KDE Print).

## How do I unlock a locked component

When a component is locked it is unselectable using the middle mouse button however it is selectable using a window select. To window select a component click and hold the left mouse button and drag the mouse to create a rectangular region containing the component to be unlocked. Execute the command Edit → unLock to unlock the component.

# Gschem configuration/customization

Gschem is configurable in more ways than can be describe here. Look at “system-gschemrc” for suggestions what else can be done.

## How can I change the default size of floating text?

Put

    (text-size 10)

into your gschemrc and replace “10” with your favorite size.

## How can I have a different background color other than black?

Edit the system-gschemrc file and near the top you will find lines like:

    ;
    ; Start of color section
    ;
    ; Load up a color scheme has a light (almost white) background
    ; Comment out the first line and comment in the second line for a
    ; dark (black) background.  The dark background is the original look.
    ;
    (load (string-append gedadatarc "/gschem-darkbg")) ; dark background
    ;(load (string-append gedadatarc "/gschem-lightbg")) ; light background

Comment out the `darkbg` line (with a ;) and comment in the `lightbg` line. This will give you a light background instead of a black background. It also adjust all the other colors to be compatible with a light background.

If you want more control over the colors, please edit `${prefix}/share/gEDA/gschem-darkbg` or `${prefix}/share/gEDA/gschem-lightbg` or create your own file and load it in the `system-gschemrc` file.

IMHO, a black background is easier on the eyes for long periods of time.

## How can I get refdes automatically numbered when I draw a schematic?

Edit the system-gschemrc file or place the following into a gschemrc file (either `~/.gEDA/gschemrc` or a `gschemrc` file in the local directory where you invoke gschem):

    (load "$YOUR_INSTALL_PATH/share/gEDA/scheme/auto-uref.scm")  ; load the autonumbering script
    (add-hook! add-component-hook auto-uref)                     ; autonumber when adding a component
    (add-hook! copy-component-hook auto-uref)                    ; autonumber when copying a component

Please substitute $YOUR_INSTALL_PATH by the path where geda is installed.

## What are the mouse bindings in gschem?

By default you get:

- Left mouse button is used for picking and drawing
- Middle mouse button is either move object (just hold down the middle button over an object and move the mouse) or copy object (ALT key held down while holding down the middle button over object and move the mouse).
- Right mouse button is a popup menu.

You can change the middle button by adding the following to a gschemrc file:

    (middle-button "action")   ;default binding, move or copy an object

or:

    (middle-button "stroke")   ;draw mouse gestures/strokes (must install libstroke to enable

or:

    (middle-button "repeat")   ;repeat the last command executed

You can change the right button by adding the following to a gschemrc file:

    (third-button "popup")     ;default binding, show a popup menu

or:

    (third-button "mousepan")  ;use the mouse to pan around the schematic

For more information on these options, please see the `${install_prefix}/share/gEDA/system-gschemrc` file.

# Information on gschem symbols

## What's this business about heavy vs. light symbols?

This nomenclature arose from a discussion which frequently appears on the geda-user and geda-dev mailing lists. A light symbol is one which contains very few built-in attributes in the symbol itself. It requires that the user attach almost all attributes at the schematic level (e.g. using either gschem or gattrib). A heavy symbol is one which contains many attributes (such as package footprints, SPICE model names, etc.) built into the symbol file itself. A heavy symbol therefore requires very little attribute attachment at the schematic level – you just place it and you’re done.

The debate between proponents of heavy and light symbols is very detailed and involved. In caricature, proponents of heavy symbols belive that they provide better integration between gschem and PCB since the important layout attributes (such as footprint name) are already built into the symbol. This is considered a good thing for new users (noobs) who just want to design a simple board and don’t appreciate or don’t care about the zillions of variations that even a simple resistor might have (e.g. different footprint, TCR, precision, material composition, etc). Proponents of light symbols prefer to deal with attributes at the schematic level because they believe it to be more flexible. They are quick to point out that a library of heavy symbols will quickly grow into the thousands of parts with grotesquely long names trying to distinguish between the different variations of the part. They also point out that the utility �����gattrib” is the preferred tool for dealing with attributes at the schematic level (i.e. in the .sch file).

GEDA/gaf, as default configured, uses light symbols, although it can be configured to use heavy symbols. For further information, you may read these dicussions from the geda-user mailing list:

http://archives.seul.org/geda/user/Jun-2005/msg00001.html http://archives.seul.org/geda/dev/Oct-2005/msg00043.html

## I am using a symbol out of the library. How come it's not aligned to the grid?

The symbols in the symbol library, like those available at the gedasymbols website are contributed by users just like you. Some people use different grid settings than other people (e.g. 50mil vs. 100mil). If you discover a symbol which seems to be off the grid, try reducing your grid spacing, move the symbol so that it sits on your grid, then revert to your preferred grid settings.

Yes, the gEDA docs suggest that you use a 100mil grid spacing. But everybody likes to do things their own way, and there is no overall symbol dictator to enforce the rules on contributed symbols. Therefore, you just need to be aware of this possibility.

## How do I promote an invisible symbol attribute into the schematic?

Most attributes living in the symbol do not get promoted to the schematic unless they are visible. To promote invisible symbol attributes, look for the following keywords in the system-gschemrc file:

    (attribute-promotion “enabled”);
    (promote-invisible “disabled”) ; ⇐ This one
    (keep-invisible “enabled”)

Add to your gschemrc file:

    (promote-invisible “enabled”)

and you will get all the attributes promoted. The “keep-invisible” keyword will keep hidden those attributes that are hidden in the symbol file.

## What should I do about power pins on my symbols: Make them visible (explicit) or invisible (implicit)?

In the past, digital logic circuits often hid the power pin, and attached power nets using an attribute inside the symbol. Modern thought is that this is a bad practice (although religious wars still occasionally rage about this topic).

It’s marginally OK for an old logic circuit which is all 5V TTL to have hidden power and GND pins. If you only have +5V on your board, then hiding the power pin can simplify your schematic somewhat. However, few designers design such circuits nowadays; 5V TTL (and 5V CMOS) are rapidly becoming antique technologies.

It’s always been unacceptable to hide the power pins on analog chips. First, analog often has multiple power connections (VCC, VEE) which need to be explicitly drawn out. Second, good design practice is to place decoupling caps on each and every power pin. Sometimes one places an inductor in series with power also. Since these should be drawn into the schematic, it is best done by attaching them to an explicit power pin. Therefore, one should never use hidden power pins for analog symbols.

New logic circuits often use multiple supplies for different chip sections (OVDD, DVDD, etc). It is also typical to have several logic families on a single board (5V, 3.3V etc.). Therefore, it’s best to explicitly place and wire the power pins on the symbol. Hidden power pins are a recipe for disaster since you can all too easily misconnect a 5V part to a 3.3V power net, for example.

To paraphrase Nancy Reagan: Just say “no” to hidden power pins.

That said, it may still be usefull to detach the power pins from the functional part of the symbol. To do so, define a seperate power symbol and give it the same refdes as the functional part. A run of gsch2pcb will treat the siblings properly as one single component. As neither gschem nor gsch2pcb explicitely know that the component is only complete with both symbols defined, you have to check yourself. With this workaround, you can draw all power related circuitry in one corner of the schematic where it does not interfere with the signal nets. In many cases this is advantageous with analog circuits.

## Is there a specification or manual for creating gschem symbols? Where is it?

Yes. It is the Symbol Creation Guide.