Passives
To simplify adding components, the most common components: resistors, capacitors, etc, have been packaged into @typecad/passives. It is automatically installed when a project is created.
Sizes
The @typecad/passives package is organized by component size.
import { Resistor, LED, Capacitor, Diode, Inductor, Fuse } from '@typecad/passives/0805'
let r1 = new Resistor({ value: '1kohm', reference: 'R1' });Will import all the components in the 0805 size.
To import 0603 components, use:
import { Resistor, LED, Capacitor, Diode, Inductor, Fuse } from '@typecad/passives/0603'All of the sizes are:
- @typecad/passives/1210
- @typecad/passives/1206
- @typecad/passives/0805
- @typecad/passives/0603
- @typecad/passives/0402
- @typecad/passives/0201 *no fuses
Multi-sizes
To import multiple sizes, use this import statement syntax:
import * as _0603 from '@typecad/passives/0603'
import * as _0805 from '@typecad/passives/0805'
let r1 = new _0603.Resistor({ value: '1kohm' });
let c2 = new _0805.Capacitor({ value: '1uF' });_0603 and _0805 can be changed to any TypeScript-legal name.
Reference Designators
KiCAD tracks components by their reference designator. This is the name that appears on the schematic and the PCB. In the passives package, the reference property is how components are referenced. It is not a required property of any passives component, if it is not passed, one will automatically generated.
Auto-generation works as follows:
- if
referenceis passed, it will be used. If there is a name conflict, it will be renamed and a warning will be logged in the build output. - if
referenceis not passed, it will create one using theprefixproperty and an internal counter by type of component. ie the first resistor will beR1, the second resistor will beR2, etc. - if the
prefixproperty is not passed, it will beRby default for resistors,Cfor capacitors,Lfor inductors, etc.
Because ultimately, KiCAD is tracking components by reference designator, components will sometimes swap reference designators with eachother based on when the typeCAD build process encounters it during the build process. This only happens when a similar component is created before an already laid-out component.
Unique Footprints
Sometimes, passive components will have a unique footprint. To use that footprint with this package:
- copy the footprint file (.kicad_mod) into ./hw/src/build/lib/footprints
- use it in your
newcomponent:
import { Inductor } from '@typecad/passives/0805'
let l1 = new Inductor({ value: '1uH', footprint: 'unique_inductor_footprint' });On This Page