Auto Router

typeCAD includes an auto router that generates tracks between connected pins.

Usage

Call route() on the PCB instance with a net definition:

import { PCB } from '@typecad/typecad';
import { Resistor } from '@typecad/passives/0805';

let typecad = new PCB('autoroute_example');

let r1 = new Resistor({ value: '1kohm', reference: 'R1' });
let r2 = new Resistor({ value: '1kohm', reference: 'R2' });

r1.pcb = { x: 10, y: 10, rotation: 0 };
r2.pcb = { x: 20, y: 10, rotation: 0 };

const signal_net = typecad.named('signal').net(r1.pin(1), r2.pin(1));

typecad.route(signal_net);

typecad.create(r1, r2);

You can also route directly between pins without a named net:

let tracks = await typecad.route({
  from: r1.pin(1),
  to: r2.pin(1),
});

typecad.create(r1, r2, ...tracks);

Configuration

The route method accepts an optional configuration object:

typecad.route(signal_net, {
    gridResolution: 0.15,
    debug: false,
});

By default, the router uses a resolution derived from the trace width and clearance settings. Decreasing the resolution value increases the search space and memory usage but may help find paths in congested layouts.

The router’s fallback trace width and clearance come from the board’s design rules (JLCPCB no-surcharge standard by default), or from the net’s net class if it has been assigned one. Per-route width and clearance options override them for an individual trace.

By default the router uses every copper layer the board declares, minus layers dedicated as planes; pass layers to restrict a route (e.g. layers: ['In3.Cu']). Pass an impedance constraint (impedance: { target: 50, tolerance: 5 }) and the trace widens to hit the target computed from the board’s stackup — see controlled impedance. Router-placed vias follow the board’s via policy.