Routing USB and Differential Pairs in KiCad 8: Practical Basics

Many interfaces send data as a differential pair: two tracks carrying equal and opposite signals. USB uses D+ and D-, Ethernet, HDMI, CAN, RS-485 and LVDS all use pairs too. The receiver looks only at the difference between the two wires, so noise that appears equally on both is rejected. That only works if the two tracks are treated as a matched pair on the PCB.

This article explains the essentials of differential routing using USB 2.0 as the example, then shows KiCad 8's tools for routing and length-matching pairs.

Key Concepts

TermMeaning
Differential impedanceImpedance seen between the two tracks; USB 2.0 specifies 90 ohms nominal
CouplingKeeping the two tracks close and parallel so their fields cancel
Intra-pair skewLength difference between the P and N tracks of one pair
Reference planeThe solid ground plane under the pair that carries return current
Common-mode noiseNoise equal on both tracks, which the receiver rejects

How strict you must be depends on speed. USB full speed (12 Mbit/s), used by most microcontrollers such as the STM32F103 and RP2040, is forgiving: short tracks routed side by side over ground work well even if the impedance is not exactly 90 ohms. USB high speed (480 Mbit/s) is much less forgiving, and its layout should follow the chip vendor's layout guide closely, usually on a four-layer board.

Setting Width and Gap

Differential impedance depends on track width, gap between the tracks, copper thickness, dielectric height to the reference plane and the dielectric constant. Height is the hardest variable to change, which is why stackup matters so much.

Inputs for an edge-coupled microstrip pair:
  W  = track width
  S  = gap between the two tracks
  H  = dielectric height from track to ground plane
  T  = copper thickness
  Er = dielectric constant of the laminate

Smaller H  -> lower impedance for the same W
Wider W    -> lower impedance
Smaller S  -> tighter coupling, lower differential impedance
  1. Get your fab's stackup and the prepreg height between the outer layer and the first ground plane. Many fabs also offer an online impedance calculator for their stackups.
  2. Open KiCad Calculator Tools and select the transmission line tool with the coupled microstrip type, or use the fab's calculator.
  3. Enter H, T and Er, then adjust W and S until the differential impedance is close to 90 ohms.
  4. Enter the resulting width and gap in File > Board Setup > Design Rules > Net Classes for a USB class, in the DP Width and DP Gap columns.

Routing the Pair in KiCad 8

KiCad recognises a differential pair when two nets share a base name and end in P and N or + and -. Name the schematic labels USB_D+ and USB_D-, or USB_DP and USB_DN.

  1. Choose Route > Route Differential Pair (hotkey 6) and click on either pad of the pair. KiCad routes both tracks together using the net class width and gap.
  2. Keep the pair on the top layer, directly over the ground plane, with no vias if possible. If a layer change is unavoidable, use one via per track placed symmetrically, plus a ground via nearby.
  3. Approach pads symmetrically. Where the pair must split to reach pads, keep the uncoupled section as short as possible.
  4. Use Route > Tune Skew of a Differential Pair to add small meanders to the shorter track if there is a length mismatch from bends.
  5. Run DRC; net classes enforce the widths and gaps you set.

USB Connector Area Layout

  • Place the ESD protection device, for example a USBLC6-2SC6, right behind the connector so that a discharge is clamped before it reaches the microcontroller.
  • Route D+ and D- from connector to ESD device to microcontroller in a straight line, without stubs.
  • If your MCU needs series resistors on D+ and D- (check the datasheet; the RP2040 hardware design guide uses 27 ohm resistors), place them close to the MCU pins.
  • On a USB-C receptacle used for USB 2.0, connect the two D+ pads together and the two D- pads together, and fit 5.1 kilohm pull-down resistors on CC1 and CC2 so a USB-C host supplies 5 V.
  • Keep the pair away from crystals, switching regulators and the board edge, and avoid routing other signals between the two tracks.

Common Mistakes

  • Routing D+ and D- separately with the single-track router, leaving them far apart with different lengths.
  • Crossing a slot or split in the ground plane under the pair, which breaks the return path.
  • Swapping D+ and D- at the connector; USB does not correct this, and the device will not enumerate.
  • Using test points or long stubs on the pair, which create reflections at high speed.
  • Forgetting CC resistors on USB-C, so the board receives no power from C-to-C cables.

Summary

Differential pairs reject noise only when routed as a tightly coupled, length-matched pair over a continuous ground plane. Name nets with P/N or +/- suffixes, set width and gap for 90 ohms in a USB net class using your fab's stackup, and route with KiCad's differential pair router. Full-speed USB tolerates compromise on two layers; high-speed USB deserves four layers and the vendor layout guide.