Pins & Power
The Pin object represents the pin/leg/lead/ball of a component. When pins carry
power information, typeCAD checks voltage levels and current draw for compatibility — that's the
power-aware system, and Power is how a source or consumer enters it.
Pin
One pin of a component. Two access styles: numeric for simple parts, named for complex ones. An optional powerInfo object makes the pin power-aware.
Example first
import { Resistor } from '@typecad/pcb';
let r1 = new Resistor({ value: '1kohm' });
r1.pin(1); // first pin
r1.pin(2); // second pinNumeric access — component.pin(n)
Use for simple components like passives where pin numbers are straightforward.
Named access — component.PINNAME
Use for complex components (ICs, connectors) with a generated .ts file where Pin objects are defined:
import { ATtiny85_20S } from './ATtiny85_20S';
let u1 = new ATtiny85_20S();
u1.VCC // power pin (internally pin 8)
u1.GND // ground pin (internally pin 4)
u1.PB0 // GPIO pin PB0pin (config) this.pin(number, { type, powerInfo }): Pin
| Parameter | Type | Units / values | Description |
|---|---|---|---|
| type | string | KiCAD type | e.g. 'power_in', 'power_out', 'bidirectional' — used by ERC |
| powerInfo | object | — | Optional — enables voltage and current compatibility checks |
The powerInfo properties:
| Property | Meaning |
|---|---|
| minimum_voltage | Volts the pin can tolerate (minimum) |
| maximum_voltage | Volts the pin can tolerate (maximum) |
| current | Maximum current the pin can handle (A) |
With data present, typeCAD checks that connected pins have compatible voltage levels and current draw — errors or warnings when the voltage is too high or the draw too much:
VCC = this.pin(8, { type: 'power_in', powerInfo: {
minimum_voltage: -0.5,
maximum_voltage: 6,
current: 0.2,
}});Power
Extra information used for ERC (pin types), voltage compatibility checks, and automatic trace width calculation. A Power object represents a physical set of pins, not an abstract concept of power or ground.
Example first
import { Component, Power } from '@typecad/pcb';
let bt1 = new Component({ footprint: 'Battery:BatteryHolder_Keystone_3008_1x2450' });
let coin_cell = new Power({
power: bt1.pin(1), // Pin 1 is the positive terminal → type set to 'power_out'
gnd: bt1.pin(2), // Pin 2 is the ground terminal → type set to 'power_in'
voltage: 3.7, // Nominal voltage
current: 0.5, // Current capacity
direction: 'output' // This is a power source (default)
});Options
| Option | Type | Description |
|---|---|---|
| power | Pin | Pin that supplies power |
| gnd | Pin | Pin that supplies ground |
| voltage | number | Volts |
| current | number | Current capacity |
| direction | 'output' | 'input' | 'output' (default) for power sources, 'input' for power consumers |
How pin types are set
When a Power object is created, pin types are set automatically for ERC — the gnd pin is always power_in, regardless of direction:
| direction | power pin type | gnd pin type |
|---|---|---|
| direction: output | power_out | power_in |
| direction: input | power_in | power_in |
voltage and current propagate to the pins' powerInfo,
used by ERC for voltage checks and by the routing system for trace width calculation.
Shared ground pins
Voltage regulators often have power inputs and outputs sharing one ground pin. Since gnd is always power_in, this typically works without conflict; override
the pin type manually if ERC needs it:
// U1 is a voltage regulator, pin 2 is shared ground
let vin = new Power({ power: U1.pin(1), gnd: U1.pin(2), voltage: 5, direction: 'input' });
let vout = new Power({ power: U1.pin(3), gnd: U1.pin(2), voltage: 3.3, direction: 'output' });Input Power
An input Power specifies the power requirements of a component or sub-circuit —
commonly passed into reusable packages so users can connect a suitable source:
// 'vin' is an input Power object passed as a parameter
typecad.net(vin.power, U1.VCC);
typecad.net(vin.gnd, U1.GND);A package can check the incoming voltage as well:
if (vin.voltage != 3.3) {
throw new Error('Voltage must be 3.3v');
}