Skip to content

Route the connections ​

The schematic says which pins share a net. Routes put copper between those pins. Blinky combines copper drawn by hand with automatic legs, so you can control the important geometry without specifying every corner.

Manual routing ​

Find the VCC bus in pcb.tsx. route('3 10').net(VCC).width(0.3).H(9) draws a horizontal 0.3 mm track from (3, 10) to x = 9. Because both ends are geometric coordinates, .net(VCC) identifies the copper's net.

The next stroke at x = 9 runs vertically from y = 5 to y = 15, feeding the three channel rows. .H() and .V() take absolute coordinates. Their lowercase forms, .h() and .v(), take relative distances. .L() draws a straight segment to an x/y point.

For a route between two pads, .Z() draws the final straight segment to the destination. It does not search around obstacles, so you must leave a legal path.

Manual copperCompiled from the source below
Highlighted lines are this step’s focus
// Manual copper. Coordinates are millimetres, x right and y down.
import PCB, { route, pour, via } from '@pcbjs/core'
import { Brand, rect, roundedRect } from '@pcbjs/lib'
import * as sch from './blinky.sch'
import './blinky.sourcing'
import { layout as LedChannelRow } from './lib/led-channel'

const W = 30,
  H = 20

export default (
  <PCB name="Blinky" rev="0.1.0" schematic={sch} rules={{ clearance: 0.2, minTrackWidth: 0.2, requireSourcing: true }} autoroute={{ bend: '45', viaCost: 4 }}>
    <path layer="Edge.Cuts" d={roundedRect(W, H, 2)} />

    <J1 at="3 8" />
    <Q1 at="26 10" />
    <LedChannelRow g={CH1} at="16 5" label="LED1" />
    <LedChannelRow g={CH2} at="16 10" label="LED2" />
    <LedChannelRow g={CH3} at="16 15" label="LED3" />
    <C1 at="15 10" side="B" />

    {route('3 10').net(VCC).width(0.3).H(9)}
    {route('9 5').net(VCC).width(0.3).V(15)}
    {route('9 11.6').net(VCC).width(0.3).H(15.8)}
    {via(VCC, '15.8 11.6')}
    {route('15.8 11.6').net(VCC).layer('B.Cu').width(0.3).V(10)}
    {route('22.2 5').net(SW).width(0.3).V(16.5).H(27).V(10)}

  </PCB>
)
9 placed parts · 16 tracks

Automatic routing ​

A route between two pad handles can leave its entire path to the router. The following is an alternative to Blinky's existing SIG route, not an additional route to paste beside it:

Automatic SIG routeCompiled from the source below
Highlighted lines are this step’s focus
// Blinky: three LED channels switched by one transistor on a 30 x 20 mm two-layer board, in three files:
// blinky.sch.tsx has the nets, parts and schematic picture, blinky.sourcing.ts the part numbers, and this file the layout.
// Frame: millimetres, origin at the top-left corner of the outline, x right, y down (SVG).
// C1 sits on the back because CH2's led track runs over its spot on the front, and its chip footprint prints no ref.
// VCC runs from J1.2 to a bus at x = 9 where each channel row starts, then to a via and C1 on the back.
import PCB, { route, pour, via } from '@pcbjs/core'
import { Brand, rect, roundedRect } from '@pcbjs/lib'
import * as sch from './blinky.sch'
import './blinky.sourcing'
import { layout as LedChannelRow } from './lib/led-channel'

const W = 30,
  H = 20

export default (
  <PCB name="Blinky" rev="0.1.0" schematic={sch} rules={{ clearance: 0.2, minTrackWidth: 0.2, requireSourcing: true }} autoroute={{ bend: '45', viaCost: 4 }}>
    <path layer="Edge.Cuts" d={roundedRect(W, H, 2)} />

    {/* J1, Q1 and C1 by hand, each channel by its circuit's row layout */}
    <J1 at="3 8" />
    <Q1 at="26 10" />
    <LedChannelRow g={CH1} at="16 5" label="LED1" />
    <LedChannelRow g={CH2} at="16 10" label="LED2" />
    <LedChannelRow g={CH3} at="16 15" label="LED3" />
    <C1 at="15 10" side="B" />
    <text layer="B.SilkS" at="15 8.3" size={0.8}>
      C1
    </text>

    {/* tracks as path strings, a via, and a chain whose last hop .X() leaves to the autorouter */}
    {route('3 10').net(VCC).width(0.3).H(9)}
    {route('9 5').net(VCC).width(0.3).V(15)}
    {route('9 11.6').net(VCC).width(0.3).H(15.8)}
    {via(VCC, '15.8 11.6')}
    {route('15.8 11.6').net(VCC).layer('B.Cu').width(0.3).V(10)}
    {route('22.2 5').net(SW).width(0.3).V(16.5).H(27).V(10)}
    {route(J1[3], Q1[1]).width(0.25)}

    {/* GND: a pour over the back, Q1.2 autorouted into it */}
    {route(Q1[2], '25 12.5 B.Cu').width(0.3)}
    {pour(GND, 'B.Cu', rect(W, H))}

    <text layer="F.SilkS" at="3 4.3" size={0.8}>
      GND
    </text>
    <text layer="F.SilkS" at="15 18.5" size={1}>
      Blinky · pcbjs
    </text>
    <Brand at="15 4" height={5} layer="B.SilkS" />
  </PCB>
)
9 placed parts · 19 tracks

The pads supply the net. With no manual chain, the compiler chooses the path using the board's layers, obstacles and rules. In JSX, place the route expression inside braces, as the existing calls in pcb.tsx do.

Hybrid routing ​

Blinky uses a manual chain for that same SIG connection. It travels to y = 14, then (5, 16), changes to B.Cu, continues across the back, and returns to F.Cu. The chain stops short of Q1, so the compiler automatically finishes the last leg. The .X('24 16') in the middle requests an automatic leg to that point; the remaining .V() and layer change constrain the approach before the automatic final connection.

This division gives the route a deliberate corridor while leaving its final approach to the router. .via('B.Cu') changes layers at the current point; the following segments use that layer until another change.

Hybrid SIG routeCompiled from the source below
Highlighted lines are this step’s focus
// Blinky: three LED channels switched by one transistor on a 30 x 20 mm two-layer board, in three files:
// blinky.sch.tsx has the nets, parts and schematic picture, blinky.sourcing.ts the part numbers, and this file the layout.
// Frame: millimetres, origin at the top-left corner of the outline, x right, y down (SVG).
// C1 sits on the back because CH2's led track runs over its spot on the front, and its chip footprint prints no ref.
// VCC runs from J1.2 to a bus at x = 9 where each channel row starts, then to a via and C1 on the back.
import PCB, { route, pour, via } from '@pcbjs/core'
import { Brand, rect, roundedRect } from '@pcbjs/lib'
import * as sch from './blinky.sch'
import './blinky.sourcing'
import { layout as LedChannelRow } from './lib/led-channel'

const W = 30,
  H = 20

export default (
  <PCB name="Blinky" rev="0.1.0" schematic={sch} rules={{ clearance: 0.2, minTrackWidth: 0.2, requireSourcing: true }} autoroute={{ bend: '45', viaCost: 4 }}>
    <path layer="Edge.Cuts" d={roundedRect(W, H, 2)} />

    {/* J1, Q1 and C1 by hand, each channel by its circuit's row layout */}
    <J1 at="3 8" />
    <Q1 at="26 10" />
    <LedChannelRow g={CH1} at="16 5" label="LED1" />
    <LedChannelRow g={CH2} at="16 10" label="LED2" />
    <LedChannelRow g={CH3} at="16 15" label="LED3" />
    <C1 at="15 10" side="B" />
    <text layer="B.SilkS" at="15 8.3" size={0.8}>
      C1
    </text>

    {/* tracks as path strings, a via, and a chain whose last hop .X() leaves to the autorouter */}
    {route('3 10').net(VCC).width(0.3).H(9)}
    {route('9 5').net(VCC).width(0.3).V(15)}
    {route('9 11.6').net(VCC).width(0.3).H(15.8)}
    {via(VCC, '15.8 11.6')}
    {route('15.8 11.6').net(VCC).layer('B.Cu').width(0.3).V(10)}
    {route('22.2 5').net(SW).width(0.3).V(16.5).H(27).V(10)}
    {route(J1[3], Q1[1]).width(0.25).V(14).L(5, 16).via('B.Cu').X('24 16').V(7.5).via('F.Cu')}

    {/* GND: a pour over the back, Q1.2 autorouted into it */}
    {route(Q1[2], '25 12.5 B.Cu').width(0.3)}
    {pour(GND, 'B.Cu', rect(W, H))}

    <text layer="F.SilkS" at="3 4.3" size={0.8}>
      GND
    </text>
    <text layer="F.SilkS" at="15 18.5" size={1}>
      Blinky · pcbjs
    </text>
    <Brand at="15 4" height={5} layer="B.SilkS" />
  </PCB>
)
9 placed parts · 23 tracks

Copper can also be an area ​

Blinky calls pour(GND, 'B.Cu', rect(W, H)) to fill the back with ground copper. A route brings Q1's ground pad toward that layer. The compiler clears the pour from other nets and checks whether the ground connection is complete.

Try it: follow SIG from J1 pin 3 to Q1 pin 1 in 2D, switching copper layers at its vias. Then inspect the route's endpoints:

sh
npx pcbjs inspect J1/3
npx pcbjs inspect Q1/1
npx pcbjs check

Next: Check the result. The Routing reference lists the chain commands; Autorouter explains route failures and the routing controls.

MIT licensed. A proof of concept, pre 0.1.