
== Setting routing parameters

=== Current settings

==== Accessing the main dialog

The most important parameters are accessed from the following
drop-down menu:

image::images/Pcbnew_design_rules_dropdown.png[scaledwidth="28%"]

and are set in the Design Rules dialog.

==== Current settings

Current settings are displayed in the top toolbar.

image::images/Pcbnew_design_rules_top_toolbar.png[scaledwidth="95%"]

=== General options

The General options menu is available via the top toolbar link Preferences -> General dialog.

image::images/Pcbnew_preferences_menu.png[scaledwidth="40%"]

The dialog looks like the following:

image::images/Pcbnew_general_options_dialog.png[scaledwidth="80%"]

For the creation of tracks the necessary parameters are:

* *Tracks 45 Only*: Directions allowed for track segments are 0, 45 or
  90 degrees.
* *Double Segm Track*: When creating tracks, 2 segments will be
  displayed.
* *Tracks Auto Del*: When recreating tracks, the old one will be
  automatically deleted if considered redundant.
* *Magnetic Pads*: The graphic cursor becomes a pad, centered in the
  pad area.
* *Magnetic Tracks*: The graphic cursor becomes the track axis.

=== Netclasses

Pcbnew allows you to define different routing parameters for each
net. Parameters are defined by a group of nets.

* A group of nets is called a Netclass.

* There is always a netclass called "default".

* Users can add other Netclasses.

A netclass specifies:

* The width of tracks, via diameters and drills.
* The clearance between pads and tracks (or vias).
* When routing, Pcbnew automatically selects the netclass corresponding
  to the net of the track to create or edit, and therefore the routing
  parameters.

==== Setting routing parameters

The choice is made in the menu: Design Rules -> Design Rules.

==== Netclass editor

The Netclass editor allows you to:

* Add or delete Netclasses.

* Set routing parameters values: clearance, track width, via sizes.

* Group nets in netclasses.

image::images/Pcbnew_design_rules_editor_netclass_tab.png[scaledwidth="70%"]

==== Global Design Rules

The global design rules are:

* Enabling/disabling Blind/buried Vias use.

* Enabling/disabling Micro Vias use.

* Minimum Allowed Values for tracks and vias.

A DRC error is raised when a value smaller than the minimum value
specified is encountered. The second dialog panel is:

image::images/Pcbnew_design_rules_editor_global_tab.png[scaledwidth="70%"]

This dialog also allows to enter a "stock" of tracks and via sizes.

When routing, one can select one of these values to create a track or
via, instead of using the netclass's default value.

Useful in critical cases when a small track segment must have a
specific size.

==== Via parameters

Pcbnew handles 3 types of vias:

* Through vias (usual vias).
* Blind or buried vias.
* Micro Vias, like buried vias but restricted to an external layer to
  its nearest neighbor. They are intended to connect BGA pins to the
  nearest inner layer. Their diameter is usually very small and they are
  drilled by laser.

By default, all vias have the same drill value.

This dialog specifies the smallest acceptable values for via
parameters. On a board, a via smaller than specified here generates
a DRC error.

==== Track parameters

Specify the minimum acceptable track width. On a board, a track
width smaller than specified here generates a DRC error.

==== Specific sizes

image::images/Pcbnew_specific_size_options.png[scaledwidth="50%"]

One can enter a set of extra tracks and/or via sizes. While routing
a track, these values can be used on demand instead of the values
from the current netclass values.

=== Examples and typical dimensions

==== Track width

Use the largest possible value and conform to the minimum sizes given
here.

[options="header"]
|====
| Units | CLASS 1 | CLASS 2 | CLASS 3 | CLASS 4 | CLASS 5
| mm | 0.8 | 0.5 | 0.4 | 0.25 | 0.15
| mils | 31 | 20 | 16 | 10 | 6
|====

==== Insulation (clearance)

[options="header"]
|====
| Units | CLASS 1 | CLASS 2 | CLASS 3 | CLASS 4 | CLASS 5
| mm | 0.7 | 0.5 | 0.35 | 0.23 | 0.15
| mils | 27 | 20 | 14 | 9 | 6
|====

Usually, the minimum clearance is very similar to the minimum track
width.

=== Examples

==== Rustic

* Clearance: 0.35 mm (0.0138 inches).

* Track width: 0.8 mm (0.0315 inches).

* Pad diameter for ICs and vias: 1.91 mm (0.0750 inches).

* Pad diameter for discrete components: 2.54 mm (0.1 inches).

* Ground track width: 2.54 mm (0.1 inches).

image::images/Pcbnew_dr_example_rustic.png[scaledwidth="80%"]

==== Standard

* Clearance: 0.35 mm (0.0138 inches).

* Track width: 0.5 mm (0.0127 inches).

* Pad diameter for ICs: make them elongated in order to allow tracks to
  pass between IC pads and yet have the pads offer a sufficient adhesive
  surface (1.27 x 2.54 mm --> 0.05 x 0.1 inches).

* Vias: 1.27 mm (0.0500 inches).

image::images/Pcbnew_dr_example_standard.png[scaledwidth="80%"]

=== Manual routing

Manual routing is often recommended, because it is the only method
offering control over routing priorities. For example, it is
preferable to start by routing power tracks, making them wide and
short and keeping analog and digital supplies well separated. Later,
sensitive signal tracks should be routed. Amongst other problems,
automatic routing often requires many vias. However, automatic
routing can offer a useful insight into the positioning of footprints.
With experience, you will probably find that the automatic router is
useful for quickly routing the 'obvious' tracks, but the remaining
tracks will best be routed by hand.

=== Help when creating tracks

Pcbnew can display the full ratsnest, if the button
image:images/icons/modratsnest.png[] is activated.

The button image:images/icons/net_highlight.png[] allows one to highlight a
net (click to a pad or an existing track to highlight the corresponding
net).

The DRC checks tracks in real time while creating them. One cannot
create a track which does not match the DRC rules. It is possible to
disable the DRC by clicking on the button. This is, however, not
recommended, use it only in specific cases.

==== Creating tracks

A track can be created by clicking on the button
image:images/icons/add_tracks.png[]. A new track must
start on a pad or on another track, because Pcbnew must know the
net used for the new track (in order to match the DRC rules).

image::images/Pcbnew_creating_new_track.png[scaledwidth="80%"]

As you move the mouse, a track is drawn connecting the origin of the
track with the current mouse position. The track will be drawn with at
most two segments (for example, rightwards, then a switch to
diagonally). Clicking while routing locks in the corner node.

The direction that the track is drawn in first (e.g. right first, then
diagonally, or diagonally first then right) is called the "Track
Posture" and can be switched with the hotkey '/' or the button
image:images/icons/change_entry_orient.png[].

image:images/Pcbnew_routing_posture.png[]

Holding 'Ctrl' while routing in the non-legacy canvases constrains the
routing to a single horizontal or vertical segment. Switching posture
changes to a single diagonal segment. Holding 'Shift' while routing
removes the 'snap to object' gravity.

When creating a new track, Pcbnew shows links to nearest
unconnected pads.

End the track by double-clicking, by the pop-up menu or by the hotkey
'End'.

image::images/Pcbnew_track_in_progres_context.png[scaledwidth="60%"]

==== Moving and dragging tracks

When the button image:images/icons/add_tracks.png[] is active, the
track where the cursor is positioned can be moved with the hotkey 'M'.
If you want to drag the track you can use the hotkey 'G'.

==== Via Insertion

A via can be inserted only when a track is in progress:

* By the pop-up menu.

* By the hotkey 'V'.

* By switching to a new copper layer using the appropriate hotkey.

Holding 'Shift' while adding a via ends routing as soon as the via 
is placed. This is useful when adding a connection to a plane, so
the active layer doesn't change and no extra key need be pressed
to exit routing.

=== Select/edit the track width and via size

When clicking on a track or a pad, Pcbnew automatically selects the
corresponding Netclass, and the track size and via dimensions are
derived from this netclass.

As previously seen, the Global Design Rules editor has a tool to insert
extra tracks and via sizes.

* The horizontal toolbar can be used to select a size.

* When the button image:images/icons/add_tracks.png[] is active,
  the current track width can be selected from the pop-up menu
  (accessible as well when creating a track).

* The user can utilize the default Netclasses values or a specified value.

==== Using the horizontal toolbar

image::images/Pcbnew_track_toolbar.png[scaledwidth="95%"]

[cols="2,3"]
|=====
| image:images/Pcbnew_track_toolbar_track_width_selection.png[width="70%"]
| Track width selection. The symbol * is a mark for default Netclass
value selection.
| image:images/Pcbnew_track_toolbar_track_width_selection_in_use.png[width="70%"]
| Selecting a specific track width value.
The first value in the list is always the netclass value.
Other values are tracks widths entered from the Global Design Rules editor.
| image:images/Pcbnew_track_toolbar_via_size_selection.png[width="70%"]
| Via size selection.
The symbol * is a mark for default Netclass value selection.
| image:images/Pcbnew_track_toolbar_via_size_selection_in_use.png[width="70%"]
| Selecting a specific via dimension value.
The first value in the list is always the netclass value.
Other values are via dimensions entered from the Global Design Rules editor.
| image:images/icons/auto_track_width.png[]
| When enabled: Automatic track width selection.
When starting a track on an existing track, the new track has the same width as the existing track.
| image:images/Pcbnew_track_toolbar_grid_size_selection.png[width="70%"]
| Grid size selection.
| image:images/Pcbnew_track_toolbar_zoom_selection.png[width="70%"]
| Zoom selection.
|=====

==== Using the pop-up menu

One can select a new size for routing, or change to a previously created
via or track segment:

image::images/Pcbnew_track_context_menu.png[scaledwidth="70%"]
//TODO: add a link to Global changes section
If you want to change many via (or track) sizes, the best way is to
use a specific Netclass for the net(s) that must be edited (see
global changes).

=== Editing and changing tracks

==== Change a track

In many cases redrawing a track is required.

New track (in progress):

image::images/Pcbnew_new_track_in_progress.png[scaledwidth="70%"]

When finished:

image::images/Pcbnew_new_track_completed.png[scaledwidth="60%"]

Pcbnew will automatically remove the old track if it is redundant.

==== Global changes

Global tracks and via sizes dialog editor is accessible via the
pop-up window by right clicking on a track:

image::images/Pcbnew_track_global_edit_context_menu.png[scaledwidth="60%"]

The dialog editor allows global changes of tracks and/or vias for:

* The current net.

* The whole board.

image::images/Pcbnew_track_global_edit_dialog.png[scaledwidth="70%"]
