:experimental:

[[erc]]
== Design verification with Electrical Rules Check

=== Introduction

The Electrical Rules Check (ERC) tool performs an automatic check of your
schematic. The ERC checks for any errors in your sheet, such as unconnected
pins, unconnected hierarchical symbols, shorted outputs, etc. ERC output is
reported as errors or warnings depending on the severity of the issue detected.

Naturally, an automatic check is not infallible, and it is not possible to
detect all design errors.  Such a check is still very useful, because it allows
you to detect many oversights and small errors. All detected issues should be
checked and addressed before proceeding.

The quality of the ERC is directly related to the care taken in declaring
electrical pin properties during symbol library creation.

image::images/en/dialog_erc.png[alt="ERC dialog",scaledwidth="70%"]

[[how-to-use-erc]]
=== How to use ERC

ERC can be started by clicking on the icon
image:images/icons/erc_24.png[ERC icon].

Warnings are placed on the schematic elements raising an ERC error (pins
or labels).

[NOTE]
====
* In this dialog window, when clicking on an error message you can jump
  to the corresponding marker in the schematic.
* In the schematic right-click on a marker to access the corresponding
  diagnostic message.
====

You can also delete error markers from the dialog and set specific ERC
messages to be suppressed by using the right-click context menu.

image::images/erc_ignore_warning.png[alt="Ignore ERC warning",scaledwidth="70%"]

[[example-of-erc]]
=== Example of ERC

image::images/erc_pointers.png[alt="ERC pointers",scaledwidth="70%"]

Here you can see four errors:

* Two outputs have been erroneously connected together (red arrow).
* Two inputs have been left unconnected (green arrow).
* There is an error on an invisible power port, power flag is missing
  (green arrow on the top).

[[displaying-diagnostics]]
=== Displaying diagnostics

By right-clicking on a marker the pop-up menu allows you to access the ERC
marker diagnostic window.

image::images/en/erc_pointers_info.png[alt="ERC pointers info",scaledwidth="70%"]

and when clicking on Marker Error Info you can get a description of the
error.

image::images/erc_pointers_message.png[alt="ERC pointers message",scaledwidth="80%"]

[[power-pins-and-power-flags]]
=== Power pins and Power flags

It is common to have an error or a warning on power pins, as shown in the
example above, even though all seems normal. This happens in designs where the
power is provided through connectors or other components that are not marked as
power sources (unlike a regulator output, which is represented by a Power Out
pin).  Therefore ERC won't detect any Power Out pin connected to the net and
will determine it is not driven by a power source.

To avoid this warning, connect the net to `PWR_FLAG` symbol on such a power net
as shown in the following example. The `PWR_FLAG` symbol is found in the `power` symbol library. Alternatively, connect any power output pin to the net; `PWR_FLAG` is simply a symbol with a single power output pin.

image::images/eeschema_power_pins_and_flags.png[alt="Power pins and flags",scaledwidth="70%"]

The error marker will then disappear.

Ground nets often need a `PWR_FLAG` as well, because voltage regulators have
outputs declared as power outputs, but their ground pins are typically marked as
power inputs. Therefore grounds can appear unconnected to a source unless a
`PWR_FLAG` symbol is used.

[[configuration]]
=== Configuration

The _Pin Conflicts Map_ panel in Schematic Setup allows you to configure
connectivity rules to define electrical conditions for errors and warnings based
on what types of pins are connected to each other

image::images/eeschema_erc_options.png[alt="Schematic ERC Pin Conflicts Map",scaledwidth="70%"]

Rules can be changed by clicking on the desired square of the matrix,
causing it to cycle through the choices: normal, warning, error.

image::images/eeschema_erc_severity.png[alt="Schematic ERC severity settings",scaledwidth="70%"]
The _Violation Severity_ panel in Schematic Setup lets you configure what types
of ERC messages should be reported as Errors, Warnings or ignored.

[[erc-report-file]]
=== ERC report file

An ERC report file can be generated and saved by checking the option
Write ERC report. The file extension for ERC report files is .erc. Here
is an example ERC report file.

----------------------------------------------------------------------
ERC control (4/1/1997-14:16:4)

***** Sheet 1 (INTERFACE UNIVERSAL)
ERC: Warning Pin input Unconnected @ 8.450, 2.350
ERC: Warning passive Pin Unconnected @ 8.450, 1.950
ERC: Warning: BiDir Pin connected to power Pin (Net 6) @ 10.100, 3.300
ERC: Warning: Power Pin connected to BiDir Pin (Net 6) @ 4.950, 1.400

>> Errors ERC: 4
----------------------------------------------------------------------
