What are electrical types used for?
The electrical type is used by the electrical rule check (ERC) to determine if you made an obvious mistake. ERC is really quite limited. All it does is read all electrical types of pins connected to a particular net and check their combination against the error matrix.
Example: By default connecting two output pins together will result in an error. (Makes sense as one output can be high and one can be low resulting in a short circuit between the positive supply and ground.)
How to select the correct type (for default interpretation)
To make ERC as useful as possible one needs to take care which electrical types to assign to pins.
The datasheet of your component is a good start for this.
- Pins through which your component is supplied (vcc, gnd, vss, …) are power inputs.
- Digital and analog input pins are inputs.
- Input pins must be driven, see below
- Digital and analog output pins are output (For digital pins, use this only if the pin is push and pull capable or has an internal pull-up or pull-down network.)
- output pins can not be connected to other output pins or bidirectional (avoiding of possible short circuit)
- Certain bus pins (sda of i2c) , … are bidirectional
- Any pin that can be in both input or output state depending on current system state.
- Pins for passive devices and pins that are always only connected to other passive devices are passive
- Pins that are intended to supply power to other devices use power output (output pin of a dc/dc converter, a voltage regulator, …)
- multiple power output pins can not be connected (avoiding of power supply short) see below
- Not connected is used for all pins of the footprint that have no function in the symbol. (You can make them invisible to reduce clutter but don’t stack them. Otherwise they will be connected with each other.)
- NC pins can still be connected in kicad but there will be an error in ERC. Note that stacked NC pins are connected.
- Open collector is used for open collector or open drain outputs (output pins that need an external pull up)
- Open emitter are used for open emitter or open source outputs (output pins that need an external pull down)
- Tri-state is used for output pins that have a high impedance state (high Z) Such pins have the following possible states.
- High -> low impedance connection to high signal voltage (in most cases the positive supply voltage)
- Low -> low impedance connection to low signal voltage (in most case GND)
- High Z -> no connection to anything. (high impedance state)
- Pins who can be both input or output depending on configuration (a typical GPIO pin) can be either marked as bidirectional or unspecified. See below.
“Unspecified” vs. bidirectional for configurable pins
KiCad has a pin type unspecified. This type creates an ERC error no matter what the pin of this type is connected to. It really should only be used to force users to make project specific symbols for components with software configurable pins.
A typical example is a GPIO pin of a micro controller. There is an alternative for a more lenient setup. You can make such a GPIO pin as a bidirectional pin. This weakens ERC but allows the user to directly use the symbol as is in their schematic and still get some use out of it. (Users can also still make a more specific symbol specialized to the final configuration, but they are not forced to do so.)
Another example is the symbol for a generic connector. Here the lenient alternative is passive but unspecified would also be a logical alternative as the symbol designer does not know what the connector represents. (Again unspecified is best used in a setting where one wants to force project specific symbols encoding the real pin type.)
Input pins need to be driven
Pins marked as input need to be connected to something that can drive them. Anything that is not a input or power input pin does fulfill this role.
Connecting Multiple (Power) Output Pins
If you have multiple output pins or power output pins that need to be connected in parallel then you have a choice to make. Let ERC complain about connecting multiple power output pins or give only one of these pins the type output. (The other pins would get the type passive in the later case.)
Such a configuration benefits greatly from being stacked. (all pins on top of each other with all but one pin set to invisible. Make sure the visible pin is the one with the correct electrical type.) The reason being is that if they are not stacked then it would be possible to connect one of the pins marked as non output to something where ERC would otherwise complain. Stacking ensures that this can not happen.
Stacking pins in versions 4.x and earlier
The symbol editor does not like having different settings in a stack. Workaround: finish all settings of the pins while they are not stacked and move them on top of each other as the last step.
(If you open the pin properties of any stacked pin, all pins in the stack get changed by the editor.)
Invisible Power Input Pins
Another special case are invisible power input pins. They are global labels. This is how power symbols are implemented in kicad. Do not use invisble power input pins in any application other than power symbols as they restrict how you can use your symbol. (The use of multiple power lines becomes impossible. Review of a schematic is hindered by connections being invisible.)
Convert symbol from use of invisible power input pins to separate power pin unit (Disclaimer: written for version 4, details in the answers might differ for newer versions.)
When is a pin “power input” or “power output”?
A pin is power input if it is a consumer of power. It is power output if it is the source for power. (outputs of a dc/dc converter, of a ldo, …)
The power flag is used to tell ERC that a pin that is not a power output is the source of power. This is needed if the supply is via a generic connector, or if a passive component is in series to the power supply (a fuse, the inductor of a filter, …)
The direction the current flows alone is not what determines if it is a power input. You also need to take into account the potential of the pin compared to the potential of its counterpart.
Now lets look at the pin with the more positive potential. It is power out iff the current flows out and power in otherwise.
For the more negative pin the current direction is exactly opposite. (The current flows out of the positive pin into the negative pin -> both are power output.)
It gets tricky if the power output side shares a common pin with the power input side. In such cases power input should take precedence. (As the whole circuit will not work if there is no external power provided to the common pin.)
Side note: The current directions mentioned above use the convention of “technical current direction”. In most materials electrons are the charge carriers. Sadly our mathematical models define them as having a negative charge. This means they move (on average) opposite to the technical current direction.
Further reading regarding power symbols: