Skip to main content

<trace />

Overview

The <trace /> element represents an electrical connection between two or more points in your circuit. Traces can connect components, nets, or specific pins on components.

Basic Usage

Here's a simple example connecting two components:

export default () => (
<board width="10mm" height="10mm">
<resistor name="R1" resistance="1k" footprint="0402" pcbX={-2} schX={-2} />
<capacitor name="C1" capacitance="100nF" footprint="0402" pcbX={2} />
<trace
from=".R1 > .pin1"
to=".C1 > .pin1"
/>
</board>
)
PCB Circuit Preview

Trace Properties

PropertyDescriptionExample
fromStarting point of the trace using a port selector".R1 > .pin1"
toEnding point of the trace using a port selector".C1 > .pin1"
maxLengthMaximum length the trace can be (optional)"10mm"
minLengthMinimum length the trace must be (optional)"5mm"
widthWidth of the trace (optional)"0.2mm"

Connecting to Nets

Traces can connect to named nets like power and ground:

export default () => (
<board width="10mm" height="10mm">
<resistor name="R1" resistance="1k" footprint="0402" />
<trace from=".R1 > .pin1" to="net.GND" />
<trace from=".R1 > .pin2" to="net.VCC" />
</board>
)
Schematic Circuit Preview

Autorouting

Traces are automatically routed by tscircuit's autorouting system. The autorouter will:

  1. Find a path between components that doesn't intersect other traces
  2. Use vias to change layers when needed
  3. Respect any length constraints specified
  4. Try to minimize the number of vias used

You can customize the autorouting behavior by setting the autorouter property on the parent <board /> or <subcircuit />.

Length Constraints

Sometimes you need traces to be exactly a certain length, like for high-speed signals. You can use maxLength and minLength:

export default () => (
<board width="20mm" height="20mm">
<chip name="U1" footprint="soic8" pcbX={-5} />
<chip name="U2" footprint="soic8" pcbX={5} />
<trace
from=".U1 > .pin1"
to=".U2 > .pin1"
maxLength="15mm"
minLength="12mm"
/>
</board>
)
PCB Circuit Preview

Differential Pairs

For high-speed signals, you often need pairs of traces to have matched lengths. You can use the differentialPairKey property to group traces:

info

The differentialPairKey property is in beta and not available on all autorouters yet!

export default () => (
<board width="20mm" height="20mm">
<chip name="U1" footprint="soic8" pcbX={-5} />
<chip name="U2" footprint="soic8" pcbX={5} />
<trace
from=".U1 > .pin1"
to=".U2 > .pin1"
differentialPairKey="pair1"
/>
<trace
from=".U1 > .pin2"
to=".U2 > .pin2"
differentialPairKey="pair1"
/>
</board>
)
PCB Circuit Preview

The autorouter will ensure both traces in the pair have the same length.

Net vs Direct connections

There are generally two ways that traces are represented on a PCB "Rats Nest" or on a schematic and they have very different results:

  • Net - A trace that connects a net to a component pin.
    • <trace from="net.GND" to=".R1 > .pin1" />
  • Direct - A trace that connects two component pins directly.
    • <trace from=".R1 > .pin1" to=".C2 > .pin2" />

When you specify a trace with a net, the autorouter will look for the best place to tie into the net. This means you're not specifying the exact location where the trace will go.

When using net connections we use a Rats Nest on a PCB view or a net label on a schematic view. When you see a dotted line on a Rats Nest, you should think of it as a possible connection point, but not necessarily the final place where the autorouter will connect to the net.