# typeCAD - Complete Documentation --- ## Docs *๐Ÿ“— **type**CAD Documentation* These pages show **type**CAD in a user-focused way, without getting into the details of class properties and methods and less-used options. The Docs section focuses on learning the basics. You'll probably want to start there. After that, have a look at the Packages section to learn how to fully use **type**CAD. Requirements --- ## Board Layout *Board Layout* **type**CAD can help with board layout. Component locations can be set in code and then reused. ## Recommended workflow 1. If you're using a **type**CAD package that includes a board layout 2. `import` and configure as usual 3. At the end of the main file, include the package's components in `PCB::create(...package.components)`. 4. Call `PCB::create();` to generate the KiCAD board file. When you open the board in KiCAD, you'll see the components placed. ## `PCB` Here is the minimal code to create a PCB. ```ts import { PCB } from '@typecad/typecad'; let pcb = new PCB('typecad_docs'); // add components to the PCB pcb.create(); ``` After running the code, there will be a `typecad_docs.kicad_pcb` file in `./build`. ## PCB Coordinates Each `Component` has a `pcb` property that contains `{x, y, rotation}`. That's how the component's location is specified. You can take them directly from KiCAD when you're finished laying out the components. ```ts import { PCB } from '@typecad/typecad'; import { Resistor } from '@typecad/passives/0805'; let pcb = new PCB('typecad_docs'); let r1 = new Resistor({ value: '1kohm', reference: 'R1' }); r1.pcb = { x: 10, y: 10, rotation: 0 }; // [!code highlight] pcb.create(); ``` ## Group or Place Components In KiCAD, you can group components together. They will move around together when you click and drag anywhere in the group. There is also a labeled box around the components. To accomplish this for a group of related components: ```ts import { PCB } from '@typecad/typecad'; import { Resistor } from '@typecad/passives/0805'; let r1 = new Resistor({ value: '1kohm', reference: 'R1' }); let pcb = new PCB('typecad_docs'); r1.pcb = { x: 10, y: 10, rotation: 0 }; pcb.group('typecad_docs', r1); // [!code highlight] pcb.create(); ``` Or to place them: ```ts import { PCB } from '@typecad/typecad'; import { Resistor } from '@typecad/passives/0805'; let r1 = new Resistor({ value: '1kohm', reference: 'R1' }); let pcb = new PCB('typecad_docs'); r1.pcb = { x: 10, y: 10, rotation: 0 }; pcb.group('typecad_docs', r1); // [!code --] pcb.place(r1); // [!code ++] pcb.create(); ``` ## Vias Vias can be created, placed and connected like any other component. Vias are connected through `pin(1)`. ```ts import { PCB } from '@typecad/typecad'; import { Resistor } from '@typecad/passives/0805'; let typecad = new PCB('typecad_docs'); let r1 = new Resistor({ value: '1kohm' }); // create a via with a diameter of 0.6mm and a drill size of 0.3mm let via = typecad.via({ at: { x: 10, y: 10 }, size: 0.6, drill: 0.3, powerInfo: { current: 1, maxTempRise: 5, thickness: 35 }, }); // connect the resistor and via together typecad.net(r1.pin(1), via.pin(1)); // group it typecad.group('typecad_docs', r1, via); // create it like any other component typecad.create(r1, via); ``` ### Power aware Vias can be created with the optional `powerInfo` object. This allows **type**CAD to check that the current draw through the via is within the limits of the via's rating using the IPC-2221 standard. `maxTempRise` is the maximum wanted rise in temperature of the via, default is 10 C. `thickness` is the thickness of the via's copper in microns. 35 is the default (1 oz). ## Outlines Board outlines can be created. ```ts import { PCB } from '@typecad/typecad'; let pcb = new PCB('typecad_docs'); // create an outline x=100, y=100, width=50, height=50, with a corner fillet of 1mm pcb.outline(100, 100, 50, 50, 1); pcb.create(); ``` _The corner fillet is optional and can be omitted._ ## Tracks Tracks are created using the `TrackBuilder` object. ```ts import { PCB, TrackBuilder } from '@typecad/typecad'; let pcb = new PCB('typecad_docs'); let power_track: TrackBuilder = this.pcb .track() .powerInfo({ current: 1.0, maxTempRise: 10, thickness: 35 }) // optional power information .from({ x: 100, y: 100 }, 'F.Cu', 0.2) // Start on F.Cu, 0.2mm wide (these are the defaults and can be omitted) .to({ x: 110, y: 100 }) // go to 110, 100 .via({ size: 0.8, drill: 0.4 }) // create a via at 110, 100 .to({ x: 110, y: 120, layer: 'B.Cu' }); // Continues on B.Cu pcb.group('typecad_docs', power_track); // add the TrackBuilder to the group pcb.create(); ``` Using the above method, tracks can be created by going from point to point, using vias to transition between layers. Nets and connections are not required to be specified. KiCAD will connect any track that touches an element with a net, ie. a track that touches a pad connected to the 'gnd' net will make the entire track also connected to the 'gnd' net. ### Power aware `TrackBuilder` objects can be created with the optional `powerInfo` object. This allows **type**CAD to check that the current draw through the track is within the limits of the track's rating using the IPC-2221 standard. `maxTempRise` is the maximum wanted rise in temperature of the track, default is 10 C. `thickness` is the thickness of the track's copper in microns. 35 is the default (1 oz). > [!note] There is an easier way > [@typecad/kicad2typecad](https://www.npmjs.com/package/@typecad/kicad2typecad) is a command-line tool that can be used to convert a KiCAD board file into **type**CAD code snippets. It will give component locations, TrackBuilder objects and vias. > This is particularly useful for [package](/docs/package/overview) creation. You can lay out the entire package in KiCAD; components placed, tracks drawn, and vias added. Then use `kicad2typecad` to generate the code snippets to create them programmatically in the package. --- ## Classes *Classes* ## `PCB` The main class that represents the entire circuit. ```ts import { PCB } from '@typecad/typecad'; let typecad = new PCB('typecad_concepts', {thickness: 1.6, copper_thickness: 35 }); ``` The only required option is the name. The name determines the name of the resulting KiCAD files (.net and .kicad_pcb). Optional properties are: `{thickness: 1.6, copper_thickness: 35 }` - thickness โ€” board thickness in mm - copper_thickness โ€” copper thickness in microns (1 oz = 35 microns) These are used in power-aware calculations. The `PCB` class is where: - Components are added - Connections are made between components - utility functions like ERC and BOM ## `Component` The `Component` class represents individual parts like resistors, capacitors, ICs, etc. You add a `Component` to your `PCB`. ```ts import { Component } from '@typecad/typecad'; let R1 = new Component({ value: '1kohm' }); ``` Options for the `Component` class are: - _reference_ โ€” reference designator - _value_ โ€” value of component - _footprint_ โ€” footprint - _prefix_ โ€” prefix for reference designator - _datasheet_ โ€” link to component datasheet - _description_ โ€” description of component - _voltage_ โ€” voltage rating of component - _wattage_ โ€” wattage rating of component - _mpn_ โ€” Manufacturer Part Number - _dnp_ โ€” true if component is Do Not Populate, false to place component - _simulation_ โ€” an object with simulation data `{ include: true, model: 'ngspice-model' }` > [!note] Syntax > **type**CAD makes use of the above syntax style for many of its classes, ie. passing an object of optional properties. *Optional* in terms of TypeScript code, if a particular property isn't passed and **type**CAD requires it, it will throw an error during build. ## `Power` Represents a power source like a battery or voltage regulator. ```ts import { Power } from '@typecad/typecad'; let coin_cell = new Power({ power: holder.pin(1), gnd: holder.pin(2), voltage: 3.7 }); ``` Options are: - _power_ โ€” pin on a component that supplies power - _gnd_ โ€” pin on a component that supplies ground - _voltage_ โ€” voltage of power source Passives --- ## Components *Components* In the [passives](https://www.npmjs.com/package/@typecad/passives) package, components are created with a couple properties that have been predetermined: - footprint - prefix Doing that takes some of the effort out of creating common components. But all it was really doing was calling the `Component` class with a few properties already set. ## `Component` The `Component` class is the base class for all components in **type**CAD. A component is anything added to the board. In KiCAD, it would be anything that has a footprint file associated with it. ```ts import { Component } from '@typecad/typecad'; let u1 = new Component({ footprint: 'Package_SO:SOIC-8_5.3x5.3mm_P1.27mm' }); ``` The above creates a SOIC-8 component. `footprint` is the KiCAD footprint path and split into two strings. That method works well for simple components, but there is a better way using the `add-component` tool. ## `npx @typecad/add-component` **type**CAD has a command line tool that can be used to create a component. It is in your project's `package.json` file, you can simply click the `Add Component` button in the VSCode GUI under `NPM Scripts`. If you're not using VSCode, you can run `npx @typecad/add-component --folder=./src` from the `./hw` directory of your project. The script will ask where the component is coming from, either the KiCAD library, a local file, or an EasyEDA/JLCPCB component. If you're using the KiCAD library, you'll be asked for the symbol library and name. Paste it in, press enter and it should automatically figure out which footprint to use. If it can't, it will ask you for a footprint library name and footprint name (library.kicad_mod:footprint). If you're using a local file, you'll be asked for the path to the symbol file and footprint file. If it's an [EasyEDA/JLCPCB component](https://jlcpcb.com/parts), you'll be asked for the `C###` number. ### KiCAD Library Components If you'll be creating a component that is in the KiCAD library, you need two pieces of information: - footprint library name - component footprint name Right now, the easiest way to get that information is to add the part you want to a schematic. For this example, we'll make an ATtiny85 MCU so add it to a KiCAD schematic. Select it and press `e`. You should see a dialog that looks like this: ![KiCAD Symbol Properties](/docs/attiny85.png) The highlighted `Library link` text on the bottom has the information you need. The first part, before the `:` is the symbol library name (`MCU_Microchip_ATtiny`), the second part is the symbol name (`ATtiny85-20S`). > [!important] > Making components is the only point in **type**CAD where you need to deal with KiCAD symbols. It uses the information in them to create some boilerplate code for you. ### Local File Components If you're creating a component that is not in the KiCAD library, you need the symbol file (.kicad_sym) and footprint file (.kicad_mod) for the component. It is easiest to copy the files to your project directory. They can be deleted after the component is created. ### EasyEDA/JLCPCB Component If you are working within JLC's ecosystem for design or assembly, you can use the `C###` numbers of their parts to create a component. The footprint and 3d model will be downloaded and a **type**CAD component will be created. > [!WARNING] > The parts are converted from EasyEDA's format to KiCAD's footprint. The conversion isn't always perfect. The most common issue is pin types being `unspecified` rather than what they should actually be. ### Component Use After the component is created, they'll be some code in the terminal that tells you how to `import` it and declare a `new` instance of it. For the ATtiny85, it will look like this: ```bash # [!code word:import] # [!code word:new] ๐Ÿงฉ typeCAD Create Component โœ” Component source? KiCAD โœ” Symbol name? MCU_Microchip_ATtiny:ATtiny3227-M โœ” Footprint name? Package_DFN_QFN:QFN-24-1EP_4x4mm_P0.5mm_EP2.6x2.6mm Finished component creation, use it with: import { ATtiny85_20S } from './ATtiny85_20S'; let u1 = new ATtiny85_20S(); ``` Let's look at what's in the `ATtiny85_20S.ts` file that was created to get a better idea of what is going on. ### `ATtiny85_20S.ts` ```ts import { Component, Pin } from '@typecad/typecad'; /** | Pin # | Name | Type | | --: | :-- | :-- | | 8 | VCC | power_in | | 4 | GND | power_in | | 5 | AREF_PB0 | bidirectional | | 6 | PB1 | bidirectional | | 7 | PB2 | bidirectional | | 2 | XTAL1_PB3 | bidirectional | | 3 | XTAL2_PB4 | bidirectional | | 1 | _RESET_PB5 | bidirectional | */ export class ATtiny85_20S extends Component { VCC = new Pin(this.reference, 8, 'power_in', this, { minimum_voltage: -0.5, maximum_voltage: 6, current: 0.2, }); GND = new Pin(this.reference, 4, 'power_in', this, { minimum_voltage: -0.5, maximum_voltage: 6, current: 0.2, }); AREF_PB0 = new Pin(this.reference, 5, 'bidirectional', this, { minimum_voltage: -0.5, maximum_voltage: 6, current: 0.04, }); PB1 = new Pin(this.reference, 6, 'bidirectional', this, { minimum_voltage: -0.5, maximum_voltage: 6, current: 0.04, }); PB2 = new Pin(this.reference, 7, 'bidirectional', this, { minimum_voltage: -0.5, maximum_voltage: 6, current: 0.04, }); XTAL1_PB3 = new Pin(this.reference, 2, 'bidirectional', this, { minimum_voltage: -0.5, maximum_voltage: 6, current: 0.04, }); XTAL2_PB4 = new Pin(this.reference, 3, 'bidirectional', this, { minimum_voltage: -0.5, maximum_voltage: 6, current: 0.04, }); _RESET_PB5 = new Pin(this.reference, 1, 'bidirectional', this, { minimum_voltage: -0.5, maximum_voltage: 13, current: 0.04, }); constructor(reference?: string | undefined) { super({ reference, footprint: 'Package_SO:SOIC-8_5.3x5.3mm_P1.27mm' }); } } ``` It is a bit more involved than the simple TypeScript we've been using so far (that's why it was auto-generated). But it helps to explain what is going on. The file `extends` the `Component` by adding some extras to it. In particular, it adds `Pin` objects to the component. Rather than using the pins like `u1.pin(1)`, we can use `u1.VCC` for the VCC pin, or `u1.GND` for the GND pin. This makes the code much easier to read and understand. `minimum_voltage`, `maximum_voltage`, and `current` are optional and provide additional information for the power-aware system to check trace widths, and ensure voltage/current restrictions are met. ## `add` After a `Component` has been created and modified, call `add` to include it in the schematic and netlist. ```ts import { PCB } from '@typecad/typecad'; import { ATtiny85_20S } from './ATtiny85_20S'; let typecad = new PCB('typecad_docs'); let u1 = new ATtiny85_20S(); typecad.add(u1); // method 1 // --or-- typecad.create(u1, ...); // method 2 ``` The `add` method adds the component explicitly and the `::create(...)` method adds them all at once just prior to building. Functionally, there is no difference, but if a components are being created dynamically, it is useful to have a method to add them. Pins --- ## Concepts *Concepts* Instead of using the KiCAD schematic editor, you write code and then build it into a KiCAD schematic. **type**CAD uses TypeScript. You don't need an extensive knowledge of TypeScript to get started. If you're familiar with any programming language, you can pick up the basics of TypeScript pretty quickly. > [!faq]- Why TypeScript? > One of the long-term goals of **type**CAD was to integrate hardware design into the realm of AI. Most AI-based tools understand TypeScript very well and don't need special training to use it effectively. > TypeScript is also relatively simple to learn and use. ## KiCAD The normal flow in KiCAD is: 1. Create a project with a schematic and board 2. Add components 3. Make connections 4. Layout the board ## **type**CAD **type**CAD replaces steps 1-3. Instead of clicking and dragging to place components and make connections, TypeScript code is used. This is how a PCB is created. ```ts import { PCB } from '@typecad/typecad'; let typecad = new PCB('typecad'); typecad.create(); ``` That code will create a KiCAD board file in `./build/typecad.kicad_pcb`. ### Build **type**CAD projects have a build process. It takes the TypeScript code and turns it into a KiCAD project. The code you write, plus the **type**CAD API simply runs itself and the result is the KiCAD project. ### Workflow The new layout becomes: 1. Create a **type**CAD project 2. Edit the code to add components and make connections 3. Build it 4. Open the board in KiCAD to layout Tooling --- ## Connections *Connections* In **type**CAD, connections are created by calling the `Schematric::net()` function. Connections are made between components in the same `Schematic`. The `net()` function takes a list of `Pin` objects. ## Connecting Pins Let's add a decoupling capacitor to the ATtiny85 example we've been working with. ```ts import { Capacitor } from '@typecad/passives/0805'// [!code highlight] import { ATtiny85_20S } from './ATtiny85_20S'; import { PCB } from '@typecad/typecad'; let typecad = new PCB('typecad_docs'); let u1 = new ATtiny85_20S(); let c1 = new Capacitor({ value: '1uF' });// [!code highlight] typecad.net(u1.VCC, c1.pin(1)); // power [!code highlight] typecad.net(u1.GND, c1.pin(2)); // ground [!code highlight] ``` We've connected pin 1 of the capacitor to the VCC pin of the ATtiny85 and pin 2 to the GND pin. `::net()` takes any number of `Pin` objects, so you can connect multiple pins at once. ### Named Connections Sometimes it is useful to name the connection. The net name will be visible in KiCAD, it can be useful when laying out the board. Some **type**CAD utility functions will only pay attention to named connections as well. If you don't name the connection, it will be `net#`. ```ts typecad.net(u1.VCC, c1.pin(1)); // [!code --] typecad.named('power').net(u1.VCC, c1.pin(1)); // [!code ++] ``` The connection in KiCAD will now be labled `power`. > [!WARNING] > **type**CAD merges nets with similar `Pin` connections. If you make a connection to an already connected pin, that newer net will be merged into the existing net. This will mean your `named` net may not keep the name you give it if it is merged with another net later. You'll see a warning in the build output if this happens. Board Layout --- ## Package Code *Code* Now that we've created a package, we need to know how to use it. ## Self-documenting A benefit of TypeScript is that you can write a lot of documentation in the code itself. You'll notice the JSDoc comments in the package code. This will result in VSCode hints and tips as you write the code, explaining parameters and providing examples if fully implemented. ## Copying files Refer to the [structure](../package/structure) section for the file structure of a package, particularly the `postinstall.js` file. KiCAD expects symbols and footprints to be in the `./build` directory, but we haven't actually `npm install`ed the package, so those files will need to be manually copied there. ## `import` The tooling gave us the `import` statement for the package. ```ts import { typecad_package } from "./typecad_package"; ``` ## `new` Now create a new instance of the package. ```ts import { PCB } from '@typecad/typecad'; import { typecad_package } from "./typecad_package"; import * as _0805 from '@typecad/passives/0805' let typecad = new PCB('typecad_docs'); let u1 = new typecad_package({ pcb: typecad }); // pcb is required let u1 = new typecad_package({ pcb: typecad, reference: 'U1' }); // specify the reference designator let u1 = new typecad_package({ pcb: typecad, passives: _0805 }); // change passives to 0805 ``` ## Connections After creating the instance, you'll probably want to connect the package's components to something. You can access the pins of any component in the package. ```ts u1.U1.GND // the ground pin of the ATtiny3227 u1.U1.VCC // the power pin of the ATtiny3227 ``` ## Include the package After the package has been pulled in with an `import` and a `new` instance created, configuration is done, and connections made, you `create` it to the schematic. ```ts import { PCB } from '@typecad/typecad'; import { typecad_package } from "./typecad_package"; let typecad = new PCB('typecad_docs'); let u1 = new typecad_package({ pcb: typecad }); typecad.create(...u1.components); ``` The package's components will be added to the PCB. ## Do Not Populate If a package includes a component you don't want included in the netlist or layout: ```ts let u1 = new typecad_package({ schematic: typecad }); u1.U1.dnp = true; ``` --- ## Passives *Passives* To simplify adding components, the most common components: resistors, capacitors, etc, have been packaged into [@typecad/passives](https://www.npmjs.com/package/@typecad/passives). It is automatically installed when a project is created. ## Sizes The [@typecad/passives](https://www.npmjs.com/package/@typecad/passives) package is organized by component size. ```ts 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: ```ts import { Resistor, LED, Capacitor, Diode, Inductor, Fuse } from '@typecad/passives/0603'// [!code word:0603:1] ``` 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: ```ts // [!code word:* as _0603] // [!code word:* as _0805] 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' }); ``` > [!tip] > `_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 `reference` is 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 `reference` is not passed, it will create one using the `prefix` property and an internal counter by type of component. ie the first resistor will be `R1`, the second resistor will be `R2`, etc. - if the `prefix` property is not passed, it will be `R` by default for resistors, `C` for capacitors, `L` for inductors, etc. > [!warning] > Because ultimately, KiCAD is tracking components by reference designator, components will sometimes swap reference designators with eachother based on when the **type**CAD 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: 1. copy the footprint file (.kicad_mod) into ./hw/src/build/lib/footprints 2. use it in your `new` component: ```ts import { Inductor } from '@typecad/passives/0805' let l1 = new Inductor({ value: '1uH', footprint: 'unique_inductor_footprint' }); ``` Components --- ## Pins *Pins* In **type**CAD, the `Pin` object represents the pin/leg/lead/ball etc. of a component. ## `Pin` All `Component` objects have a `::pin()` function that returns a `Pin` object for the number passed. ```ts import { Resistor } from '@typecad/passives/0805' let r1 = new Resistor({ value: '1kohm' }); r1.pin(1); // to get the pin object for the first pin r1.pin(2); // and the second ``` Using `::pin()` like that is the simplest way, but for more complex components, it can become unwieldy remembering which pin is which. A more declarative way to use/create `Pin` objects is described in the [components](/docs/components) page. Using the **type**CAD tooling, any given component can be created giving access to `Pin` objects that allow them to be used with a descriptive name. ```ts import { ATtiny85_20S } from './ATtiny85_20S'; let u1 = new ATtiny85_20S(); u1.VCC // for this particular component, the VCC pin is pin 8 u1.GND // GND is pin 4 ``` ## Power aware Each `Pin` object has a `powerInfo` object that can be optionally passed when creating the `Pin`. It has the following properties: - `minimum_voltage` โ€” minimum voltage the pin can tolerate - `maximum_voltage` โ€” maximum voltage the pin can tolerate - `current` โ€” maximum current the pin can handle When pins have the object passed with data, **type**CAD can check that the voltage levels and current draw are compatible with each other. ```ts VCC = new Pin(this.reference, 8, 'power_in', this, { minimum_voltage: -0.5, maximum_voltage: 6, current: 0.2, }); ``` `VCC` can accept -0.5 to 6 volts and supply up to 0.2 amps. When connected to other pins, **type**CAD can check that the voltage and current levels are compatible and issue error or warning messages if the voltage is too high or the current draw is too much. Power --- ## Power *Power* A `Power` object is extra information that is used for: - ERC: by setting `Pin` types to `power_out` or `power_in` - voltage compatibility checks Another thing that is important to know is that `Power` is not the equivalent of a power or ground symbol on a schematic. A `Power` object represents a physical set of pins, not an abstract concept of power or ground. ## Output `Power` An output `Power` object defines a source of electrical power within your design. ```ts import { Component, Power } from '@typecad/typecad'; let bt1 = new Component({ footprint: 'Battery:BatteryHolder_Keystone_3008_1x2450' }); // bt1 represents a coin cell battery holder. // The following Power object defines its output characteristics: let coin_cell = new Power({ power: bt1.pin(1), // Pin 1 is the positive terminal gnd: bt1.pin(2), // Pin 2 is the ground terminal voltage: 3.7, // Nominal voltage of 3.7V direction: 'output' // Indicates this is a power source }); ``` In this example, `coin_cell` configures `bt1` (a coin cell battery holder) as a power source. - It specifies `bt1.pin(1)` as the positive terminal and `bt1.pin(2)` as the ground. - It declares that this source provides a nominal 3.7 volts. - Because `direction` is set to `output`, typeCAD automatically sets the `type` of `bt1.pin(1)` and `bt1.pin(2)` to `power_out`. This is important for Electrical Rules Checking (ERC). ### Handling `output` and `input` `Power` in Components Components like voltage regulators often have both power inputs and outputs. For instance, a voltage regulator takes an input voltage and produces a different output voltage. A common scenario is when the input and output sides of such a component share the same ground pin. If you define separate `Power` objects for the input and output, and both reference the same physical pin as ground, this can lead to ERC conflicts because a pin would be assigned as `power_out` (from the output `Power` object) and potentially `power_in` or another type (from the input `Power` object). To avoid such ERC errors for a shared ground pin, you can manually set the pin's type to `passive` after the `Power` objects have been defined: ```ts // Assuming U1 is a voltage regulator component // and U1.pin(2) is the shared ground pin. 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' }); // Manually set the shared ground pin to passive to avoid ERC conflicts U1.pin(2).type = 'passive'; ``` This tells typeCAD that the pin is a common connection point not actively sourcing or sinking power in a way that conflicts with its dual role. ## Input `Power` Just as components can source power, they often need to receive it. An input `Power` object is used to specify the power requirements for a component or a part of your circuit. When creating reusable typeCAD packages (e.g., a module for a specific sensor that requires power), you can define a constructor parameter for a `Power` object. This allows users of your package to easily connect a suitable power source. Inside your package's code, you can then use the properties of this input `Power` object to make connections. For example, if `vin` is an input `Power` object passed to your component, and `U1` is an internal part that needs power: ```ts // Assuming 'vin' is a Power object passed as a parameter (direction: 'input') // and U1 is a component within your design that needs power. // Connect the power line from the input Power object to U1's VCC pin typecad.net(vin.power, U1.VCC); // Connect the ground line from the input Power object to U1's GND pin typecad.net(vin.gnd, U1.GND); ``` By using `vin.power` and `vin.gnd`, you are connecting to the pins that were defined when the input `Power` object (`vin`) was created. This ensures that your component correctly receives power according to its design. If `direction` is set to `input`, typeCAD will automatically set the `type` of the associated pins to `power_in` for ERC purposes. ### Voltage checks A package can check that the voltage levels coming in are correct as well. ```ts if (vin.voltage != 3.3) { throw new Error('Voltage must be 3.3v'); } ``` Connections --- ## Project Structure *Project Structure* A **type**CAD project is self-contained and looks like this: ```bash project โ”œโ”€โ”€ fw โ”œโ”€โ”€ hw โ”‚ โ””โ”€โ”€ build โ”‚ โ””โ”€โ”€ lib โ”‚ โ””โ”€โ”€ footprints โ””โ”€โ”€ src ``` ## `fw` Intended for firmware. If a PlatformIO project is created when you run `npx @typecad/create-typecad`, you can open the `workspace` file to open both the firmware and hardware projects in the same VSCode and have access to their respective build tools. ## `hw` All the hardware-related files are here. - `build` holds all the KiCAD files - `./build/lib` is where KiCAD symbols are stored - `./build/footprints` is where KiCAD footprints are stored - `src` is where the TypeScript files are stored ## Self-contained The entire project is contained in the project folder. Symbols, footprints, 3d files, source files, etc. are all in this project folder. Classes --- ## Requirements *Requirements* Make sure your system has the required software to get started. - [KiCAD](https://kicad.org/download/) - version **8.0** or later - [npm/Node.js](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) - version **20** or later - [Visual Studio Code](https://code.visualstudio.com/) - *not required, but highly recommended and used throughout this website* - [PlatformIO](https://docs.platformio.org/en/latest/core/installation/index.html) - *mentioned, but not required* - [git](https://git-scm.com/downloads) - *mentioned, but not required* --- > [!WARNING] pio and git in your PATH > Ensure that `pio` and `git` are in your PATH. **type**CAD optionally uses these commands in its tooling Concepts --- ## Tooling *Tooling* **type**CAD provides a collection of tools to make the development process easier. ## Project Creation To create a new project enter the following command in your terminal: ```bash npx @typecad/create-typecad ``` The first time, `npx` will ask you to download the script so it can run it. Then you'll be prompted to enter project details: - name for the project - if you want to create a PlatformIO project and if so, the [board ID](https://docs.platformio.org/en/latest/boards/index.html) - if you want to create a `git` repository - install optional utility packages A project will be created in the current directory. Inside the project directory, there will be a VSCode `workspace` file that will open the project in VSCode. ### Non-interactive mode All the information can be passed by command-line arguments and the script will automatically create a project. `--help` will show all the parameters. ```bash npx @typecad/create-typecad --name=typecad_project --git=false --pio=false ``` The above is the minimum to run automatically. --- ### Project Use A **type**CAD project is just an npm package. All the normal npm-based tools are available to you. A `package.json` file is created with access to the following scripts: - Project Building - Adding Components - Opening the `kicad_pcb` file in KiCAD > [!tip] > In VSCode, there's a sidebar that allows you to just click the various scripts to run them ### Project Building Click the `Build` script in VSCode's `NPM Scripts` sidebar. To build the project in a terminal, run the following command: ```bash npx tsx [path/to/file.ts] ``` The outputs will be in `./build/`. ## Adding Components Components are discussed in the [Components](/docs/components) page. But for now, they are anything with a footprint that you'd add to your PCB like MCUs and resistors. To add a component to the project: ```bash npx @typecad/add-component --folder=./src ``` When the script runs, you'll be asked the source for the symbol and footprint files. You can mix any of the sources ie. a KiCAD symbol, but a local file. - If it's a KiCAD library component, you'll be prompted to enter the symbol and footprint names - If it's a local file, you'll be prompted to enter the path to the file - If it's an EasyEDA/JLCPCB component, you'll be asked for the `C###` number A `[component].ts` file will be generated along with instructions on how to use it. Files will also be copied into the `./build/` directory. ### Non-interactive mode All the information can be passed by command-line arguments and the script will automatically create a component. `--help` will show all the parameters. ```bash npx @typecad/add-component --symbol_source=kicad --footprint_source=local --symbol=MCU_Microchip_ATtiny:ATtiny3227-M --footprint=MyLib:MyFootprint npx @typecad/add-component --symbol_source=jlcpcb --footprint_source=kicad --c=C3217148 --footprint=Package_QFN:QFN-32-1EP_5x5mm_P0.5mm_EP3.45x3.45mm ``` The above is the minimum to run automatically. > [!important] > There's no need to add passives (resistors, capacitors etc.) this way. See the [Passives](/docs/passives) page for more information. ## Package Creation typeCAD has a command-line tool to generate all the boilerplate code for a package. It sets up the package for easy publishing and reuse. It is discussed in more detail in the [Package Overview](/docs/package/overview) page. Execute the following command in `./hw` of an already existing **type**CAD project. ```bash npx @typecad/add-package --folder=./src ``` Project Structure --- ## What Is Typecad *What is typeCAD* ## KiCAD + TypeScript + npm = **type**CAD > typeCAD is a way to programmatically create hardware designs. It's done with TypeScript and all the awesomeness of the npm/Node.js ecosystem. - npm packages can be imported into your projects - create portable/importable/shareable packages - semantic version control The schematic portion of hardware design is replaced with a few simple TypeScript classes. Rather than clicking and dragging, a line of code creates a component, and another line connects it. Sections of code can be turned into reusable modules and those modules can be turned into reusable packages, layout included. Code can be version controlled, status tracked, git push/pull/PR/issues can be used, and all the typical tools for software design can be used for hardware design now ## Example This **type**CAD code... ```ts import { Schematic, Component } from '@typecad/typecad' import { Resistor, LED } from '@typecad/passives/0805' let typecad = new Schematic('typecad'); let bt1 = new Component({ footprint: 'BatteryHolder_Keystone_500' }); let r1 = new Resistor({ value: "1 kOhm" }); let d1 = new LED(); typecad.named('vin').net(bt1.pin(1), r1.pin(1)); typecad.net(r1.pin(2), d1.pin(2)); typecad.named('gnd').net(d1.pin(1), bt1.pin(2)); typecad.create(r1, d1, bt1); ``` ...is the same as this schematic. ![simple led circuit](https://typecad.net/led-circuit.png) >The difference is that code can be copied, turned into reusable packages, version controlled, and used within the npm/Node.js system. ## Get started Read through the [walkthrough](https://typecad.net/docs/walkthrough/get-started) for a quick introduction to the basics. Wouldn't testing and CI be nice for hardware designs? Code can be version controlled, status tracked, git push/pull/PR/issues can be used, and all the typical tools for software design can be used for hardware design now. ```ts expect(power.minimum).to.be.at.least(3.0); // check voltage levels expect(power.maximum).to.be.at.most(3.6); typecad.erc(); // run ERC on every build ``` --> --- ## Examples *Examples* ### Tutorial | | | | :------------------------------------------------------------------ | ------------------------------- | | [Creating a project](/getting-started) | creating and building a project | | [Add/connect passives](/examples/voltage-divider) | make a voltage divider | | [Add KiCAD Components](/examples/attiny85) | Add an MCU to your project | ### Examples A list of small examples to show how to use **type**CAD | | | | :---------------------------------------- | -------------------------------------------------- | | [ERC](/examples/erc) | run an electrical rule check on your schematic | | [BOM](/examples/bom) | export a bill-of-material file from your schematic | | [ngspice](/examples/ngspice) | run a simulation with your **type**CAD code | | [JLCPCB-Export](/examples/jlcpcb-export) | export all the assembly files for JLCPCB | | [Jig/Multi-boards](/examples/jig) | Create a test jig/multi-board with one codebase | --- ## Attiny85 *Adding KiCAD Library Components* **type**CAD is tightly integrated with KiCAD, that means easy access to the installed KiCAD library of parts it comes with. ### Video ## `add-component` Using the `Add Component ๐Ÿงฉ` NPM script to add a new component is the easiest way. It should be available to just click in the NPM Scripts section in VS Code. Click it and you should see something like the following: ``` ๐Ÿงฉ typeCAD Create Component ? Component source? (Use arrow keys) โฏ KiCAD local file EasyEDA/JLCPCB A symbol from the installed KiCAD library ``` Choose `KiCAD`. The next thing it asks is the `Symbol name`. Right now, the easiest way to get that information is to add the part you want to a schematic. For this example, we'll make an ATtiny85 MCU. Open KiCAD's schematic editor and add it to a KiCAD schematic. Select it and press `e`. You should see a dialog that looks like this: ![KiCAD Symbol Properties](/docs/attiny85.png) The highlighted `Library link` text on the bottom has the information you need. The first part, before the `:` is the symbol library name (`MCU_Microchip_ATtiny`), the second part is the symbol name (`ATtiny85-20S`). KiCAD conveniently lets you copy this text, so copy it and paste it into our terminal. ``` ๐Ÿงฉ typeCAD Create Component โœ” Component source? KiCAD โœ” Symbol name? MCU_Microchip_ATtiny:ATtiny85-20M ? Footprint name? (Package_DFN_QFN:QFN-20-1EP_4x4mm_P0.5mm_EP2.6x2.6mm) ``` The next question asks for the `Footprint name`. For all KiCAD components, the default text will contain the symbol-specified footprint file. For some components this might not be what you want, but for this particular component, `Package_DFN_QFN:QFN-20-1EP_4x4mm_P0.5mm_EP2.6x2.6mm` is the right one. Hit enter. ``` ๐Ÿงฉ typeCAD Create Component โœ” Component source? KiCAD โœ” Symbol name? MCU_Microchip_ATtiny:ATtiny85-20M โœ” Footprint name? Package_DFN_QFN:QFN-20-1EP_4x4mm_P0.5mm_EP2.6x2.6mm Finished component creation, use it with: import { ATtiny85_20M } from './ATtiny85_20M'; let u1 = new ATtiny85_20M(); ``` There will be a little implementation code that shows how to `import` the code and create a `new` instance of it. ## `import` The minimal code to use this new component looks like this: ```ts import { PCB } from '@typecad/typecad' import { ATtiny85_20M } from './ATtiny85_20M'; let typecad = new PCB('attiny85'); let u1 = new ATtiny85_20M(); typecad.create(u1); ``` --- ## Bom *BOM* **type**CAD provides a built in BOM export function. ## Bill-of-Material **type**CAD can export a CSV file from a `Schematic` object. ```ts import { Component, PCB, Power } from '@typecad/typecad'; let typecad = new pcb('bom'); // add components typecad.create(); typecad.bom(); ``` The output will be a `bom.csv` in the `./build` folder and will look something like this: ```csv Reference,Value,Datasheet,Footprint,MPN U1,,,lib:ESP32S3MINI1N8,C2913206 C3,22uF,,Capacitor_SMD:C_0603_1608Metric, C4,0.1uF,,Capacitor_SMD:C_0603_1608Metric, C6,1uF,,Capacitor_SMD:C_0603_1608Metric, R2,10kฮฉ,,Resistor_SMD:R_0603_1608Metric, C1,22uF,,Capacitor_SMD:C_0603_1608Metric, C2,10uF,,Capacitor_SMD:C_0603_1608Metric, VR1,,https://www.mouser.com/datasheet/2/698/REN_isl9120ir_DST_20050421-1998698.pdf,lib:QFN50P300X300X75-13N-D,ISL9120IRTNZ L1,1uH,https://www.mouser.com/datasheet/2/281/1/J_E_TE243A_0011-2303275.pdf,lib:1285ASH1R0MP2,1285AS-H-1R0M=P2 BT1,,,Battery:BatteryHolder_Keystone_3008_1x2450,3008TR ``` Each field, `value`, `datasheet`, `footprint`, and `MPN` can all be set for each `Component` object. ## Extending BOM **type**CAD is entirely TypeScript, so you can extending or changing the function is simple. You'll want to look at how the BOM function is implemented in [schematic.ts](https://github.com/typecad/typecad/blob/1a63964eece0fc98053e426192e770c35577a14d/schematic.ts#L96). This is the bulk of the function and is simple to change. ```ts bom += 'Reference,Value,Datasheet,Footprint,MPN\n'; this.Components.forEach(component => { bom += `${component.reference},${component.value},${component.datasheet},${component.footprint},${component.mpn}\n`; }); ``` --- ## Erc *ERC* **type**CAD provides a built in ERC function. ## Electrical Rules Checker **type**CAD replicates the functionality of the KiCAD ERC. After `Schematic::create()` has been called, you can call `Schematic::erc()` and it will check your schematic for any connection errors. It uses the same KiCAD basic rules as shown in this picture. ![KiCAD ERC](/examples/erc/kicad-erc.png) KiCAD includes a lot of other rules, but the majority of them are not relevant to **type**CAD. Here's a simple example. ```ts import { PCB } from '@typecad/typecad' let typecad = new PCB('erc'); typecad.create(); typecad.erc(); ``` Assuming no errors, it will show `ERC 0 errors, 0 warnings` in the build output. ```bash ERC error: power_in pin VR1:5 not driven by a power_out pin. Use [pin].type = 'power_out' to designate a power_out pin ERC 1 errors, 0 warnings ``` If an error is found, there will be an error message in the output: > [!WARNING] > If ERC returns an error, the build process is stopped. The code under `::erc` will not be executed. ## Pin Types ERC works primarily by checking pin type against each other. The types are the standard KiCAD pin types: `power_in`, `power_out`, `passive` etc. A `power_in` pin must be connected to a `power_out` pin, for example. Pin type are typically set in [component](/docs/components) files, generated by **type**CAD tooling. The information for pin types is taken from the symbol files, but the files are not always correct. Many symbols that come from outside the KiCAD library will have all the types set to `passive`. Pin types can be corrected manually in the component files, or they can be set in code like this: ```ts import { Component } from '@typecad/typecad'; let bt1 = new Component({ footprint: 'Battery:BatteryHolder_Keystone_3008_1x2450', prefix: 'BT', mpn: '3008TR' }); bt1.pin(1).type = 'power_out'; bt1.pin(2).type = 'power_out'; ``` This example shows changing a battery holder's pins to `power_out` since they were set to `passive` originally. --- ## Jig *Test jig/multi-board creation* Making a test jig is a common activity when developing a PCB. Using **type**CAD, you can create a test jig and the board you're developing in a single codebase. This is also a demonstration of how multiple PCBs can be created from code as well. ## Testing jigs For this example, our board and jig will be: 1. a board with test points on the bottom 2. another board with pogo pins that connect to the test points 3. the boards will connect with standoffs and mounting holes There's obviously a lot of options here and this is just a simple example of one way it could be done. ## Make a **type**CAD project From a terminal, run: ```bash npx @typecad/create-typecad ``` Call this project `jig`. No need to make a PlatformIO project or initialize a git repo unless you want to. No extra packages are needed either, but feel free to add them later if you want. ## Code Add some code which will: - create a board with two test points and two mounting holes - create a jig board with two pogo pins and two mounting holes - add a resistor to pretend to be testing something ```ts import { PCB } from "@typecad/typecad" import { Resistor } from '@typecad/passives/0603'; import { MountingHole } from '@typecad/passives/mounting_hole'; import { Testpoint } from '@typecad/passives/testpoint'; import { P70_5000045R } from './P70_5000045R'; let typecad = new PCB('main'); let r1 = new Resistor({ value: '1kohm', pcb: {x: 166.815, y: 86.36, rotation: 0} }); let mh1 = new MountingHole({ size: 'M2.5', pcb: {x: 152.4, y: 76.2, rotation: 0} }); let mh2 = new MountingHole({ size: 'M2.5', pcb: {x: 177.8, y: 101.6, rotation: 0} }); let tp1 = new Testpoint({ pcb: {x: 165.1, y: 81.28, rotation: 0} }); let tp2 = new Testpoint({ pcb: {x: 168.04, y: 93.98, rotation: 0} }); typecad.create(r1, mh1, mh2, tp1, tp2); let jig = new PCB('jig'); let pogo1 = new P70_5000045R({ pcb: {x: 165.1, y: 81.28, rotation: 0} }); let pogo2 = new P70_5000045R({ pcb: {x: 168.04, y: 93.98, rotation: 0} }); jig.create(mh1, mh2, pogo1, pogo2); ``` ## Code walkthrough ### `import` ```ts import { PCB } from "@typecad/typecad" import { Resistor } from '@typecad/passives/0603'; import { MountingHole } from '@typecad/passives/mounting_hole'; import { Testpoint } from '@typecad/passives/testpoint'; import { P70_5000045R } from './P70_5000045R'; ``` We import the usual classes, plus a pogo pin from a custom package (_there's a downlink link at the bottom for this whole project_). `MountingHole`, `Testpoint` and `Resistor` are all from the `@typecad/passives` package which should already be installed. ### `PCB` Now create the two PCBs. ```ts let typecad = new PCB('main'); let jig = new PCB('jig'); ``` Here, we create the main board, and also the jig board. ### Components Then all the components are created. `mh1`, `mh2` are mounting holes. `tp1`, `tp2` are test points and will go on the main PCB. `pogo1`, `pogo2` are pogo pins and will go on the jig board. One important point to see is that the locations are being specified. This will come in handy when we reuse the mounting holes on the jig board. Now create the components on the main board. ```ts pcb.create(r1, mh1, mh2, tp1, tp2); ``` ### Jig board components The last thing to do will be to add the mounting holes and pogo pins to the jig board. Notice that we've copied the xy locations of the test points to the pogo pins. This will ensure that the pogo pins line up with the test points. ```ts let pogo1 = new P70_5000045R({ pcb: {x: 165.1, y: 81.28, rotation: 0} }); let pogo2 = new P70_5000045R({ pcb: {x: 168.04, y: 93.98, rotation: 0} }); jig.create(mh1, mh2, pogo1, pogo2); ``` ## Build Build the code and there will be two PCB files created; `main.kicad_pcb` and `jig.kicad_pcb`. You'll see that the mounting holes, testpoints/pogo pins all line up. From here you can add additional functionality as needed. Changes made to one board can be programmatically applied to the other board with just a little bit of code. ## Downlink [jig project source](/examples/jig/jig.zip) Extract the zip file and open `jig.code-workspace` in VSCode. `npm i` to install dependencies. --- ## Jlcpcb Export *JLCPCB-Export* The [@typecad/jlcpcb-export](https://www.npmjs.com/package/@typecad/jlcpcb-export) package exports all the assembly files for JLCPCB. Install the package in a **type**CAD project: ```ts npm i @typecad/jlcpcb-export ``` Then `import` it and use it: ```ts import { PCB } from '@typecad/typecad'; import { jlcpcb_export } from '@typecad/jlcpcb-export';// [!code highlight] let typecad = new PCB('project'); // all your code jlcpcb_export(typecad, pcb);// [!code highlight] ``` ## Pre-checks The most appropriate place to run `jlcpcb_export` may not be at the bottom of your code. This would work nicely in a Github CI/CD setup. When an update is pushed, the build files are created. Another option would be running it as a git hook. Regardless of where you run it, it will check: - that the board passes KiCAD's DRC - that the git repo is clean If you don't care, you can disable these checks: `jlcpcb_export(typecad, pcb, true);` ## Output Several files will be created, with a single zip file ready to upload to JLCPCB. --- ## Ngspice *ngspice* One of the benefits of PCB-as-code is it avoids the tediousness of drag-and-drop GUIs. The various spice simulations often require the same drag-and-drop steps and maybe even recreating the PCB. **type**CAD lets you use your code with only very minor changes. ## Voltage Divider This example will use the [voltage divider](/examples/voltage-divider) example as a starting point. This is the circuit: ![Voltage Divider](/examples/voltage-divider/voltage-divider.png) And this is the code: ```ts import { PCB } from "@typecad/typecad" import { Resistor } from '@typecad/passives/0603'; let typecad = new PCB('voltage_divider'); let r1 = new Resistor({ value: '10kohm' }); let r2 = new Resistor({ value: '10kohm' }); typecad.named('vdiv').net(r1.pin(2), r2.pin(1)); typecad.create(r1, r2); ``` ## Install `@typecad/ngspice` First, make sure you have `@typecad/ngspice` installed in your project. From the `./hw` directory, run: ```bash npm install @typecad/ngspice ``` Then you'll need [ngspice](https://ngspice.sourceforge.io/download.html) installed and ensure the binaries are in your `PATH`. ### `Power` Next, we need to add a `Power` component. In addition to helping with simulation, they assist with ERC (electrical rule checking) by ensuring pins are connected as they should be and packages can use it to determine the power supply voltage is correct. ```ts import { PCB } from "@typecad/typecad" // [!code --] import { PCB, Power } from "@typecad/typecad" // [!code ++][!code word:Power] import { Resistor } from '@typecad/passives/0603'; let typecad = new PCB('voltage_divider'); let r1 = new Resistor({ value: '10kohm' }); let r2 = new Resistor({ value: '10kohm' }); let vin = new Power({ power: r1.pin(1), gnd: r2.pin(2), voltage: 3.3 }); // [!code highlight] typecad.named('in').net(r1.pin(1)); // [!code highlight] typecad.named('vdiv').net(r1.pin(2), r2.pin(1)); typecad.named('gnd').net(r2.pin(2)); // [!code highlight] typecad.create(r1, r2); ``` In the code above, we added a `Power` object called `vin`. Power is coming in from the top of `R1` and going to the bottom of `R2`. The `voltage` is 3.3 volts. A more practical example would be a battery holder with the pins corresponding to the positive and negative terminals, but for this example, we'll use the resistor legs as the power terminals. > [!tip] > `Power` objects represent a physical component like the pins of a battery holder or a voltage regulator. It is not the same as a PCB `VCC` or `GND` symbol that is more abstract. Look at lines 10 and 12. You'll see that `vin.power` is connected to `r1.pin(1)` by itself and it is `::named`. `@typecad/ngspice` only pays attention to `::named` nets that have components used in the simulation. nspice will treat each `::named` net as a node and give voltage/power/current measurements for each. ## Import `ngspice` Now we need to add the `ngspice` related code. ```ts // [!code word:simulation] import { PCB, Power } from "@typecad/typecad" import { Resistor } from '@typecad/passives/0603'; import { ngspiceSimulator } from '@typecad/ngspice'; // [!code highlight] let typecad = new PCB('voltage_divider'); let r1 = new Resistor({ value: '10kohm', simulation: { include: true } }); let r2 = new Resistor({ value: '10kohm', simulation: { include: true } }); let vin = new Power({ power: r1.pin(1), gnd: r2.pin(2), voltage: 3.3 }); let ngspice = new ngspiceSimulator(typecad, vin); // [!code highlight] typecad.named('vdiv').net(r1.pin(2), r2.pin(1)); typecad.create(r1, r2); ``` This code imports the package. It also adds a `simulation` property to the resistors. This tells `@typecad/ngspice` to include the component in the simulation. Every component has a `simulation` property, setting `include` to `true` will include the component in the simulation. There is an additional property, `model`, that can be used to specify an ngspice model: `{model: '.model Dled D (IS=1a RS=3.3 N=1.8)'`. The last thing is to create a `ngspiceSimulator` object. It takes the `PCB` object and all the `Power` objects. In this example, we only have one `Power` object, but if you have multiple, you can pass them all. ## Simulate Now that our circuit is created, nets are named, we can run the simulation. Currently, there are two simulation modes available in the library: DC and transient analysis. ```ts import { PCB, Power } from "@typecad/typecad" import { Resistor } from '@typecad/passives/0603'; import { ngspiceSimulator } from '@typecad/ngspice'; let typecad = new PCB('voltage_divider'); let r1 = new Resistor({ value: '10kohm', simulation: { include: true } }); let r2 = new Resistor({ value: '10kohm', simulation: { include: true } }); let vin = new Power({ power: r1.pin(1), gnd: r2.pin(2), voltage: 3.3 }); let ngspice = new ngspiceSimulator(typecad, vin); typecad.named('vdiv').net(r1.pin(2), r2.pin(1)); typecad.create(r1, r2); ngspice.op(); // [!code highlight] ``` When the project is built, the output will be in the console: ```bash ๐ŸŒถ๏ธ Running ngspice โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ Variable โ”‚ Type โ”‚ Value โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ r1:power โ”‚ power โ”‚ 2.7225 mW โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ v(in) โ”‚ voltage โ”‚ 3.3000 V โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ i(r1) โ”‚ current โ”‚ 1.6500 mA โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ i(r2) โ”‚ current โ”‚ 1.6500 mA โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ r2:power โ”‚ power โ”‚ 2.7225 mW โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ i(v1) โ”‚ current โ”‚ -1.6500 mA โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ v(vdiv) โ”‚ voltage โ”‚ 1.6500 V โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ ``` Each node will be displayed with calculated voltage. ngspice doesn't list ground nodes. Each included component will be displayed with power and current. The final bit will be information about the power supply. In this example, `v1` supplies 1.65 mA of current to the circuit. ### Transient This example won't show any variance, but you can run a transient analysis. Add `ngspice.tran('1us', '100ms');` to the end of the file and ngspice's graphing windows will open for all the nodes and components when the project is built. `tran` takes all the same arguments as ngspice's `tran` command, as described in the [ngspice documentation](https://ngspice.sourceforge.io/docs/ngspice-manual.pdf), section 11.3.10. ## Continuing development This package covers the basic functionality of basic components. Future development will include the ability to use ngspice library files, additional power source options, and more analysis types. --- ## Voltage Divider *Make a Voltage Divider in **type**CAD* In this example, we will make a voltage divider. This is the equivalent circuit: ![Voltage Divider](/examples/voltage-divider/voltage-divider.png) Very simple, just two resistors. Voltage on the top, ground on the bottom, with half the voltage in the middle. ### Video ## Make a **type**CAD project From a terminal, run: ```bash npx @typecad/create-typecad ``` Call this project `voltage_divider`. No need to make a PlatformIO project or initialize a git repo unless you want to. No extra packages are needed either, but feel free to add them later if you want. Like the output said, open `voltage_divider.code-workspace` in VSCode to get started. You should see `NPM Scripts` in the sidebar with a few scripts. If you don't, click `View > Open View >` and enter `NPM Scripts`. ### Test build Click the `๐Ÿค– Build` script and you should see some build output in a terminal. If everything is [installed](/docs/requirements) correctly, you should be able to build the project without any errors. The `r1` resistor is there as test code. It, and the rest of the code, is contained in `./src/voltage-divider.ts`. ## Making resistors You can delete most of the starter code in `voltage_divider.ts` so you're left with this: ```ts import { PCB } from '@typecad/typecad' import { Resistor } from '@typecad/passives/0603'; let typecad = new PCB('voltage_divider'); let r1 = new Resistor({ value: '1kohm' }); typecad.create(r1); ``` This code creates a `PCB` object called `typecad` and a `Resistor` object called `r1`. We need two resistors, so let's make another. ```ts import { PCB } from '@typecad/typecad' import { Resistor } from '@typecad/passives/0603'; let typecad = new PCB('voltage_divider'); let r1 = new Resistor({ value: '1kohm' }); let r2 = new Resistor({ value: '1kohm' }); // [!code ++] typecad.create(r1, r2); // [!code ++] ``` Don't forget to add `r2` to the `create` method. ### `@typecad/passives` Most passives can be added in this way. For all the documentation, visit the [package](https://www.npmjs.com/package/@typecad/passives) page. Resistors, capacitors, inductors, fuses, diodes and LEDs in various sizes can be made this way. Connectors and testpoints are also in the package. ### Resistor properties Components have several properties, the one we're concerned with here is `value` (VSCode tooltips will tell you all the other properties). Our example schematic used 10kOhm resistors, so let's change that. ```ts import { PCB } from '@typecad/typecad' import { Resistor } from '@typecad/passives/0603'; let typecad = new PCB('voltage_divider'); let r1 = new Resistor({ value: '10kohm' }); // [!code ++] let r2 = new Resistor({ value: '10kohm' }); // [!code ++] typecad.create(r1, r2); ``` ## Build Build the schematic again. Click the `โœณ๏ธ Open Board` script. When KiCAD opens you should see two resistors on the board. > [!TIP] > To see the changes in your code in KiCAD, use the `Revert` menu item in `File`. You may want to hotkey this function since you'll be using it a lot with typeCAD. ## Connections To create our voltage divider, we need to connect our two resistors together. For passive components, it is typical to just use a `r1.pin(x)` method to get a `Pin` object. ```ts import { PCB } from '@typecad/typecad' import { Resistor } from '@typecad/passives/0603'; let typecad = new PCB('voltage_divider'); let r1 = new Resistor({ value: '10kohm' }); let r2 = new Resistor({ value: '10kohm' }); typecad.net(r1.pin(2), r2.pin(1));// [!code ++] typecad.create(r1, r2); ``` If we want, we can give this connection a name so it is clearer in KiCAD. ```ts typecad.net(r1.pin(2), r2.pin(1));// [!code --] typecad.named('vdiv').net(r1.pin(2), r2.pin(1));// [!code ++] ``` ## Build again When you build again, you'll see the connection we just made inside KiCAD. ## Power We need to add a power source to make something happen. A `Power` object represents a physical source of power in **type**CAD. Don't think of it like the VCC or GND symbol in a schematic, but more like a power regulator or battery as it would be in your PCB; it has pins and is an actual component. For this simple example, the pins will be the top of `R1` and the bottom of `R2`. In a more practical example, the pins of a `Power` object would be a voltage regulator, battery holder, or similar source. ```ts import { PCB, Power } from "@typecad/typecad" // [!code ++] import { Resistor } from '@typecad/passives/0603'; let typecad = new PCB('voltage_divider'); let r1 = new Resistor({ value: '10kohm' }); let r2 = new Resistor({ value: '10kohm' }); let vcc = new Power({ power: r1.pin(1), gnd: r2.pin(2), voltage: 5.0 }); // [!code ++] typecad.named('vdiv').net(r1.pin(2), r2.pin(1)); typecad.create(r1, r2); ``` There won't be anything to see after this change from with KiCAD. --- ## Getting Started *Getting Started with typeCAD* Welcome to typeCAD! This guide will help you get started with our hardware design platform. ## What is typeCAD? typeCAD is a modern hardware design platform that brings the power of TypeScript to electronic design. It allows you to: - Create modular, reusable hardware designs - Version control your hardware designs using git - Generate production-ready outputs for manufacturing - Collaborate with other designers using familiar development tools ## Quick Start 1. **Install Node.js** - Download and install [Node.js](https://nodejs.org/) (LTS version recommended) - Verify installation by running `node --version` in your terminal 2. **Create Your First Project** ```bash npx @typecad/create-typecad ``` 3. **Start Designing** - Open the project in VS Code - Begin creating your hardware design using TypeScript - `build` your code to generate outputs ## Next Steps - Start with making a simple [voltage divider circuit](/examples/voltage-divider) - Check out our [Documentation](/docs) for detailed guides - Explore [Examples](/examples) to see typeCAD in action - Join our [Reddit community](https://www.reddit.com/r/typecad/) for support and discussions --- ## Ai *Hardware Design with AI* --- title: Hardware Design with AI description: Use AI to create reference designs from a datasheet date: '2025-4-8' categories: - tools - command-line - git - wiring - code-as-schematic published: true cover: https://unsplash.com/photos/XJuogr6jhv8/download?ixid=M3wxMjA3fDB8MXxzZWFyY2h8Mnx8YWklMjBoYXJkd2FyZXxlbnwwfHx8fDE3NDQ1NjU1ODZ8MA&force=true&w=640 --- **typeCAD-prompt** is a specialized tool designed to integrate **typeCAD** with AI coding models, enabling users to generate detailed prompts for transforming IC reference designs into typeCAD packages. Leverage AI capabilities, such as those provided by Gemini 2.5, to help with the hardware design process. ### Key Features - **Automated Component Analysis**: The tool identifies components from schematics and cross-references datasheets to ensure accurate selection. - **Interactive Refinement**: Users can interact with the AI to confirm component details, adjust configurations, and resolve ambiguities during the design process. ### Workflow Overview 1. **Input Preparation**: Provide an IC datasheet (PDF or plaintext) and a schematic image. The tool generates a structured prompt for the AI model. 2. **Prompt Execution**: Use an AI platform like Cursor to execute the prompt. The AI analyzes the schematic, references the datasheet, and creates a typeCAD package. ### Installation and Usage Install **typeCAD-prompt** globally using the following command: ```bash npm i -g @typecad/typecad-prompt ``` Read more about using it [here](https://www.npmjs.com/package/@typecad/typecad-prompt). --- ## Command Line Suite *A suite of command-line tools* --- title: Command Line Suite description: Create schematics, wiring diagrams, and documentation, all from the terminal date: '2025-4-8' categories: - tools - command-line - git - wiring - code-as-schematic published: true cover: https://unsplash.com/photos/6EsIiLE3VCs/download?ixid=M3wxMjA3fDB8MXxzZWFyY2h8NzB8fHdvcmtiZW5jaCUyMGVsZWN0cm9uaWNzfGVufDB8fHx8MTc0NDEyNjM2OHww&force=true&w=640 --- We've just released [typecad-docgen](https://www.npmjs.com/package/@typecad/typecad-docgen) to automate the generation of KiCAD documentation from markdown files. This works nicely with the other command-line tools we've released. - [wiring](https://www.npmjs.com/package/@typecad/wiring) - Programmatically create wiring diagrams - [typecad-gitdiff](https://www.npmjs.com/package/@typecad/typecad-gitdiff) - See the differences between KiCAD PCB files Using those tools along with typeCAD means a huge portion of the workflow can be automated and also easily integrated into your CI/CD pipeline. --- ## Jlcpcb Parts *JLCPCB Parts* --- title: JLCPCB Parts description: An easy way to search for basic and preferred components from JLCPCB's catalog date: '2025-7-22' categories: - tools - command-line - jlcpcb - parts published: true cover: https://unsplash.com/photos/bByhWydZLW0/download?ixid=M3wxMjA3fDB8MXxzZWFyY2h8MjB8fGxpYnJhcnl8ZW58MHwwfHx8MTc1MzE5NjEyNnww&force=true&w=640 --- Intelligent fuzzy search for JLCPCB basic and preferred electrical components with CLI interface. This TypeScript-based npm package provides smart component search capabilities by automatically managing a local database of JLCPCB parts and offering natural language search with intelligent parameter matching. ### Dependencies This package uses [CDFER/jlcpcb-parts-database](https://github.com/CDFER/jlcpcb-parts-database) which provides a daily CSV download of all basic and preferred parts. That project depends on [yaqwsx/jlcparts](https://github.com/yaqwsx/jlcparts). Please consider supporting them. ## Features - ๐Ÿ” **Intelligent Fuzzy Search**: Find components using natural language descriptions - ๐Ÿ“ฆ **Automatic Database Management**: Downloads and caches JLCPCB components database - โšก **Fast CLI Interface**: Quick command-line searches with formatted output - ๐ŸŽฏ **Smart Parameter Parsing**: Recognizes electrical values, packages, tolerances, and more - ๐Ÿ“Š **Scored Results**: Get ranked results with match explanations - ๐Ÿ”„ **Auto-Updates**: Keeps component database fresh (24-hour cache) - ๐ŸŽจ **Multiple Output Formats**: Detailed, compact, table, or JSON display options - ๐Ÿ”ง **Programmatic Integration**: JSON output for scripting and automation ## Installation ### Global Installation ```bash npm install -g @typecad/jlcpcb-parts ``` After global installation, you can use the `jlcpcb-search` command from anywhere: ```bash jlcpcb-search "10k resistor 0603" ``` ### Local Installation ```bash npm install @typecad/jlcpcb-parts ``` ## Quick Start ### Basic Search ```bash # Search for a 10kฮฉ resistor in 0603 package jlcpcb-search "10k resistor 0603" # Search for a 100ยตF capacitor rated for 16V jlcpcb-search "100uF capacitor 16V" # Search for buttons jlcpcb-search "SPST button" ``` [Read the full documentation here](https://www.npmjs.com/package/@typecad/jlcpcb-parts) --- ## Kicad Typecad Sync *Code and KiCAD* --- title: Syncing KiCAD and typeCAD description: Getting KiCAD and typeCAD to play nice together date: '2025-6-5' categories: - typecad - kicad - editing - sync - code-as-schematic published: true cover: https://unsplash.com/photos/-_yJPCofxYQ/download?ixid=M3wxMjA3fDB8MXxzZWFyY2h8NzZ8fGZyaWVuZHMlMjBwZXRzfGVufDB8MHx8fDE3NDkxNTM3NjF8MA&force=true&w=640 --- **type**CAD is meant to work closely with KiCAD, essentially replacing the schematic editor. But **type**CAD can do a lot more than the schematic editor so the best way to go about things was getting a bit hazy. ## The Problem The vast majority of PCB design and layout can be done with **type**CAD now. But there are still some things that KiCAD is better at and the best way to sync changes between moving parts in the editor versus what's generated by code wasn't clear. ## The Solution Nearly everything can have its state saved and **type**CAD is smart enough to figure out what needs to be updated and what should be left as you manually edited it. ## Some Improvements ### Saving over KiCAD changes **type**CAD used to check for a lock file to see if the PCB file was open in KiCAD. It worked, but it wasn't great. Now, it does some fancy window title checking, finds the open KiCAD window and checks for unsaved changes. The build process will stop and let you know and let you save (or not) before proceeding. If you're on a system that doesn't support this (Mac?), it will just check for the lock file. ### Tracks Tracks can have their widths changed in KiCAD, but not deleted. **type**CAD will recreate deleted tracks, so if you want to modify a track, if it it created in code, it needs to be deleted in code (delete the line). Preserved track changes are displayed during the build process, so you are made aware of any deviations from what the code as supposed to make. ### Components Components can be moved and rotated in KiCAD. **type**CAD will preserve those changes. Nearly anything you can do with components in KiCAD will be preserved. ### Vias Vias can be created in **type**CAD, so if you make any in KiCAD, the build process will let you know about them and give the coordinates so you can add them to your code. ## The End Result The goal is to have a smooth workflow between KiCAD and **type**CAD. You should be able to make changes in either if you choose, while nudging in the direction of **type**CAD for declaratively creating a PCB. --- ## Layout Improvements *Major improvements in typeCAD PCB layout* --- title: Layout Improvements description: Major improvements in typeCAD PCB layout date: '2025-4-19' categories: - layout - pcb published: true cover: https://unsplash.com/photos/T_l246EK19I/download?ixid=M3wxMjA3fDB8MXxzZWFyY2h8Mnx8bGV2ZWwlMjB1cHxlbnwwfHx8fDE3NDUxMjUzMTl8MA&force=true&w=640 --- Version 0.1.2 of [typeCAD](https://www.npmjs.com/package/@typecad/typecad) was just released with major layout improvements. Before there were significant limitations on what was possible with it. Before, when a layout was applied, it moved all the components to whatever location specified in the typeCAD code. This worked well enough as an MVP, but wasn't a great developer experience. Now with this new release, that has been fixed. To keep the components from moving around, they just need to be given a UUID: ```ts this.C1 = new Capacitor({ value: '10uF', uuid: '6d588378-32ea-4e85-a943-d9b373a3d454' }); ``` There are several VS Code extensions that can help with the generation. [Here's one](https://marketplace.visualstudio.com/items?itemName=netcorext.uuid-generator). ## Other improvements There were also improvements in BOM generation. Fields can be customized in typeCAD code. --- ## Llms Txt *The llms.txt standard* --- title: typeCAD has an /llms.txt file description: Use AI to create reference designs from a datasheet date: '2025-7-6' categories: - tools - llm - ai published: true cover: https://unsplash.com/photos/OPpCbAAKWv8/download?ixid=M3wxMjA3fDB8MXxzZWFyY2h8MjJ8fGNoYWxrYm9hcmQlMjB3aXRoJTIwYSUyMGxvdCUyMG9mJTIwdGV4dHxlbnwwfDB8fHwxNzUxODI0NzE5fDA&force=true&w=640 --- The standard is defined at at their website: [llms-txt](https://llmstxt.org/). Basically, it is a way to document projects for easy use with AI. ## Example use Most any LLM model allows file usage; download [`/llms-full.txt`](/llms-full.txt), provide it to your LLM, then ask it anything about **type**CAD. It should have the entire website and API available as a source of information. Embed [`/llms-full.txt`](/llms-full.txt) into a vector database and create your own agents. [Langflow](https://www.langflow.org/) or [Flowise](https://flowiseai.com/) work well for this. A scraper could also be used to download all the markdown files for more specific or fine-tuned approaches. --- ## Mcp *typeCAD MCP Server* --- title: typeCAD MCP Server description: Install our MCP server for a much smoother AI experience date: '2025-7-17' categories: - tools - command-line - git - ai - llm - mcp published: true cover: hhttps://unsplash.com/photos/M5tzZtFCOfs/download?ixid=M3wxMjA3fDB8MXxzZWFyY2h8Mnx8bmV0d29yayUyMHNlcnZlcnxlbnwwfDB8fHwxNzUyNzYxNDM1fDA&force=true&w=640 --- An MCP (Model Context Protocol) server that provides AI assistants with direct access to typeCAD tools and workflows. This enables seamless integration between AI coding assistants and typeCAD's electronic design automation capabilities. ## What is MCP? MCP (Model Context Protocol) is a standard that allows AI assistants to connect to external tools and data sources. This server exposes typeCAD's functionality as MCP tools, letting AI assistants create projects, add components, validate designs, and more. ## Features The server provides these typeCAD tools to AI assistants: - **๐Ÿ—๏ธ Create Project** - Initialize new typeCAD projects with optional PlatformIO support - **๐Ÿงฉ Add Component** - Add components from KiCAD libraries or JLCPCB catalog - **๐Ÿ“„ PDF to Text** - Convert component datasheets from PDF to text format - **๐Ÿ“š Download Docs** - Fetch the latest typeCAD documentation - **โœ… Validate Component** - Verify component definitions against datasheets - **๐Ÿ“ฆ Create Package** - Generate complete IC packages from datasheets and schematics > [!tip] > `PDF to Text` is a very naive conversion tool. A far more robust tool can be found at [Datalab](https://www.datalab.to/playground). Their site provides a free option and it can also be installed locally for free. LLMs can't read PDFs, but they can read text. The better the conversion, the better the LLM can understand the datasheet and extract the relevant information. ### Passive Components Quick access to common passive components using the @typecad/passives package: - **๐Ÿ’ˆ Add Resistor** - Create resistors with value, wattage, voltage rating options - **๐Ÿชซ Add Capacitor** - Create capacitors with value, voltage rating options - **๐Ÿ’ก Add LED** - Create LEDs with voltage and brightness specifications - **๐Ÿ”Œ Add Diode** - Create diodes with voltage and efficiency specifications - **๐ŸŒ€ Add Inductor** - Create inductors with inductance value specifications - **๐Ÿ”’ Add Fuse** - Create fuses with current and voltage ratings - **๐Ÿ”— Add Connector** - Create connectors with pin count and footprint options - **๐ŸŽฏ Add Testpoint** - Create testpoints with custom footprint options ### Power Management Tools for defining and managing power in your designs: - **๐Ÿ”‹ Add Power Source** - Define power sources like batteries and regulators with voltage specs - **โšก Add Power Input** - Define power input requirements for components and modules ### PCB Layout & Routing Advanced PCB design tools for layout and routing: - **๐Ÿ”— Add Via** - Create vias for layer transitions with size, drill, and power specifications - **๐Ÿ›ค๏ธ Add Track** - Create PCB tracks with power-aware routing and layer management ### Connections & Networking Tools for managing electrical connections between components: - **๐Ÿท๏ธ Create Named Net** - Create named connections between pins for better organization - **๐Ÿ”Œ Connect Pins** - Connect multiple pins together in electrical networks ### Component Management Advanced component creation and modification tools: - **๐Ÿงฉ Create Custom Component** - Create custom components with named pins and power specs - **โš™๏ธ Set Component Properties** - Modify component properties like DNP, reference, value, etc. ### Design Validation Comprehensive design checking and validation tools: - **โœ… Validate Design** - Run comprehensive design validation including power and ERC checks - **๐Ÿ” Run ERC** - Run Electrical Rules Check to validate pin connections and compatibility ## Installation Install globally via npm: ```bash npm install -g @typecad/typecad-mcp ``` ## Configuration Add this to your MCP configuration file: ``` { "mcpServers": { "typecad-mcp": { "command": "npx", "args": ["-y", "@typecad/typecad-mcp" ], "env": {} } } } ``` ## Usage Once configured, AI assistants can use typeCAD tools directly in conversation: - "Create a new typeCAD project called 'sensor-board'" - "Add the ESP32-S3 microcontroller to my project" - "Validate this component against its datasheet" - "Create a package for this voltage regulator IC" - "Add a resistor/capacitor/inductor/diode/LED/fuse/testpoint/connector" - "Add a power source" The AI assistant will automatically call the appropriate MCP tools and guide you through any required inputs. --- ## New Site *cover: https://unsplash.com/photos/b0p818k8Ok8/download?ixid=M3wxMjA3fDB8MXxjb2xsZWN0aW9ufDh8MjU1MTgzMXx8fHx8Mnx8MTcyNTU0MDM2N3w&force=true&w=640* --- title: New Site description: Welcome to our new site date: '2025-3-10' categories: - website published: true --- # New Site We switched to a new site, so watch here for updates on **type**CAD. --- ## Power Aware *Building power aware circuits with typeCAD* --- title: Power aware design description: typeCAD can check for power compatibility between components now date: '2025-6-12' categories: - typecad - kicad - editing - sync - code-as-schematic published: true cover: https://unsplash.com/photos/SG9Ycz2uqGs/download?ixid=M3wxMjA3fDB8MXxzZWFyY2h8NDR8fGRvJTIwbm90JTIwdG91Y2h8ZW58MHwwfHx8MTc0OTc0NTg2M3ww&force=true&w=640 --- **type**CAD can now check for power issues as you develop your circuits. ## Current carrying tracks When creating tracks, you can pass a `powerInfo` object that includes the current the track will carry. **type**CAD will check that the track is wide enough to handle the current. ```ts let track = pcb.track() .powerInfo({ current: 1.0, maxTempRise: 10, thickness: 35 }); .from({x: 100, y: 100}, "F.Cu", 0.2) .to({x: 110, y: 100}) .to({x: 110, y: 120, layer: "B.Cu"}) ``` Using the above code, **type**CAD will check that the track is wide enough to handle 1 amp of current for the specified temperature rise and copper thickness. If not, it will throw an error during build. Like this: ``` [TrackBuilder] ERROR: Track width 0.2mm is too narrow for 1A current on F.Cu. Minimum width should be 0.300mm. ``` This works for any segment of track and it is automatically done during every build. You don't need to have a separate calculator and manually check each track segment. ## Current carrying vias Vias can be created with the optional `powerInfo` object. This allows **type**CAD to check that the current draw through the via is within the limits of the via's rating using the IPC-2221 standard. `maxTempRise` is the maximum wanted rise in temperature of the via, default is 10 C. `thickness` is the thickness of the via's copper in microns. 35 is the default (1 oz). ```ts let via = pcb.via({ at: { x: 10, y: 10 }, size: 0.6, drill: 0.3, powerInfo: { current: 3, maxTempRise: 10, thickness: 35 }, }); ``` Using the above code, **type**CAD will check that the via is large enough to handle 1 amp of current for the specified temperature rise and copper thickness. If not, it will throw an error during build. Like this: ``` [PCB VIA] ERROR: Via size 0.6mm (drill 0.3mm) is too small for 3A current. Maximum capacity is 2.75A @ 10ยฐC rise ``` This also works automatically during every build. ## Connecting power aware tracks, vias and pins **type**CAD also now allows for `powerInfo` objects to be attached to pins of components. This allows for checking proper voltage levels and current draw between components and the nets they are connected to. - If you try to connect a device that draws 1 Amp, but only power it with a 0.8 Amp power supply, you'll see an error. - If you try to connect a 5V device to a 3.3V power supply, you'll see an error. - and many more issues are detected This all happens automatically during every build. ## Taking advantage of programmatic circuit design This is a good example of taking full advantage of programming concepts for circuit design. --- ## Private Npm Packages *Keeping your work private* --- title: Private npm Packages description: Host your own npm packages date: '2025-3-17' categories: - website published: true cover: https://unsplash.com/photos/f3Ug9b50KwI/download?ixid=M3wxMjA3fDB8MXxhbGx8fHx8fHx8fHwxNzQyMjQzNzYxfA&force=true&w=640 --- [npm](https://www.npmjs.com/) is a great way to share your work with the world, but sometimes you may want to keep your work private or have more control over it. In those case, you can use [npm private packages](https://docs.npmjs.com/about-private-packages). You have to pay $7 per month per user. You can create private packages and publish them to your own private registry. ## Private Registry Maybe you have a server that you can use. If so, you can use [verdaccio](https://verdaccio.org/) to create your own private registry. It's just a single command to install and run. And using it is equally simple, just add a `--registry [server address]` to your `npm install` or `npm publish` command. --- ## Schematics *Make a schematic file in typeCAD* --- title: Schematics description: Generate a schematic file from typeCAD projects date: '2025-5-13' categories: - tools - command-line - schematic - code-as-schematic published: true cover: https://unsplash.com/photos/QCOg4dicY74/download?ixid=M3wxMjA3fDB8MXxzZWFyY2h8N3x8ZWxlY3RyaWNhbCUyMHNjaGVtYXRpY3xlbnwwfHx8fDE3NDcxNDE4OTB8MA&force=true&w=640 --- A schematic file isn't needed since typeCAD code takes the place of it, but it can be useful to have one available. People will likely still want to look at a schematic rather than code. To provide a starting point for that, we've developed a package to do that. Read more about using it [here](https://www.npmjs.com/package/@typecad/schematic). --- ## Simplification *Simplification* --- title: typeCAD Simplification description: The entire typeCAD API has been simplified and interaction between KiCAD and typeCAD has been improved. date: '2025-5-30' categories: - tools - command-line - git - wiring - code-as-schematic published: true cover: https://unsplash.com/photos/_SEbdtH4ZLM/download?ixid=M3wxMjA3fDB8MXxzZWFyY2h8MjN8fGVhc2llcnxlbnwwfDB8fHwxNzQ4NjY4MzA0fDA&force=true&w=640 --- **type**CAD was growing in features at the expense of simplicity. The entire API has been simplified and the interaction between KiCAD and typeCAD has been improved while also maintaining backwards compatibility. ## `Schematic` and `PCB` The `Schematic` and `PCB` classes have been merged into a single `PCB` class. The `PCB` class now has a `schematic` property that contains the schematic data. The `PCB` class also has a `create` method that takes a list of components and adds them to the schematic and board. This change was made because the schematic and board are always created together and there was no need to have two separate classes. Also, **type**CAD was the schematic, so why put any mental effort into another 'Schematic'? Now the bare minimum code to create a board is: ```ts import { PCB } from '@typecad/typecad'; let typecad = new PCB('typecad'); typecad.create(); ``` There's no need to think about `Schematic` anymore. All the functionality is still there, but it's stubbed out in the `PCB` class. `::net` and `::named` are called from `PCB` now. So is `::bom` and `::erc`. ## KiCAD The interaction between **type**CAD and KiCAD was getting unintuitive. Wondering if you needed to Revert to see component location changes or reimport the netlist to see other updates was confusing. Now, **type**CAD will automatically import the netlist after running `PCB::create()`. That means you never have to interact with the netlist file again. Any changes made to the board will be reflected in their entirety when you run `PCB::create()` and use the Revert function (or just reopen) the board in KiCAD. ### More KiCAD integration to come Soon, we'll be releasing a new version that will check for a dirty .kicad_pcb file and prompt you to revert before running `PCB::create()`. This will prevent any changes you've made in KiCAD from being lost. It will be more robust and useful that the current method which just checks for the existence of a lock file. ## Package improvement We've tweaked things to make packages easier to create and use. They are now created similarly to other components, and also used the same as well. Before, our example packages had `add` and `place` methods. Now, they have a property that holds everything in a `components` array. That array is passed to `PCB::create()` as a spread operator. The result is a much simpler and more intuitive package creation and use. ## `npm update` Update your projects and packages to the latest version to get the latest features and improvements. --- ## Tracks *Create tracks with typeCAD* --- title: Route your boards description: Use AI to create reference designs from a datasheet date: '2025-5-25' categories: - tools - routing - tracks - board - pcb - code-as-schematic published: true cover: https://unsplash.com/photos/FwzhysPCQZc/download?ixid=M3wxMjA3fDB8MXxzZWFyY2h8MzF8fHdpcmVzfGVufDB8MHx8fDE3NDgxODk5OTh8MA&force=true&w=640 --- One of the last parts of board design was routing and that is largely accomplished now with the newest release. ## `TrackBuilder` The `TrackBuilder` object lets you create tracks with a fluent API. ```ts import { PCB, TrackBuilder } from '@typecad/typecad'; let pcb = new PCB('typecad_docs'); let power_track: TrackBuilder = this.pcb.track() .from({x: 100, y: 100}, "F.Cu", 0.2) // Start on F.Cu, 0.2mm wide (these are the defaults and can be omitted) .to({x: 110, y: 100}) // go to 110, 100 .via({size: 0.8, drill: 0.4}) // create a via at the 110, 100 .to({x: 110, y: 120, layer: "B.Cu"}); // Continues on B.Cu pcb.group('typecad_docs', power_track); // add the TrackBuilder to the group pcb.create(); ``` This method fits in nicely with the rest of the **type**CAD API. ### Connections `TrackBuilder` objects don't take any connection information. This is because KiCAD will connect any track that touches an element with a net, ie. a track that touches a pad connected to the 'gnd' net will make the entire track also connected to the 'gnd' net. Since there's no use for an unconnected track, this simplifies to process. ## typecad/kicad2typecad [@typecad/kicad2typecad](https://www.npmjs.com/package/@typecad/kicad2typecad) is a package to simplify making tracks. This is particularly useful for making packages. You can lay out the entire package in KiCAD; components placed, tracks drawn, and vias added. Then use `kicad2typecad` to generate the code snippets to create them programmatically in the package. ### Making a package The workflow for creating a reusable package is: 1. Create a package, add components and connections 2. Layout the board in KiCAD using tracks and vias 3. Use `kicad2typecad` to generate the code snippets 4. Add the code snippets to the package An example output for a small package looks like this: ```bash Reading from File: .\typecad_docs.kicad_pcb Found 6 segments. Generating TrackBuilder chains from File: .\Reading from File: .\typecad_docs.kicad_pcb. --- Generated typeCAD TrackBuilder Code from File: .\typecad_docs.kicad_pcb --- this.pcb.track().from({ x: 152.05, y: 96.87 }, "F.Cu", 0.2) .to({ x: 152.4, y: 96.52, layer: "F.Cu", width: 0.2 }); this.pcb.track().from({ x: 151.1, y: 99.665 }, "F.Cu", 0.2) .to({ x: 151.765, y: 100.33, layer: "F.Cu", width: 0.2 }) .to({ x: 152.273, y: 99.822, layer: "F.Cu", width: 0.2 }) .to({ x: 153.67, y: 99.822, layer: "F.Cu", width: 0.2 }); this.pcb.track().from({ x: 150.6, y: 99.175 }, "F.Cu", 0.2) .to({ x: 151.1, y: 99.175, layer: "F.Cu", width: 0.2 }) .to({ x: 151.1, y: 99.665, layer: "F.Cu", width: 0.2 }); --------------------------------------------------------- Found 4 footprints. Generating placement code from File: .\typecad_docs.kicad_pcb. --- Generated Component Placement Code from File: .\typecad_docs.kicad_pcb --- this.C1.pcb = { x: 153.67, y: 99.047, rotation: -90 }; this.C2.pcb = { x: 153.67, y: 95.986, rotation: -90 }; this.VR1.pcb = { x: 150.6, y: 97.725, rotation: 0 }; this.L1.pcb = { x: 147.32, y: 97.828, rotation: 90 }; ------------------------------------------------------------- Found 3 vias. Generating typeCAD code from File: .\typecad_docs.kicad_pcb. --- Generated typeCAD Via Code from File: .\typecad_docs.kicad_pcb --- this.v1 = this.pcb.via({ at: { x: 110, y: 100 }, size: 0.8, drill: 0.4 }); this.v2 = this.pcb.via({ at: { x: 152.4, y: 96.52 }, size: 0.6, drill: 0.3 }); this.v3 = this.pcb.via({ at: { x: 151.765, y: 100.33 }, size: 0.6, drill: 0.3 }); ----------------------------------------------------- ``` ### Using the code The `TrackBuilder` objects can be used within a package directly. That's why they are prefixed with `this`. One modification would be to place the return value of each `this.pcb.track` into a `TrackBuilder` object which can then be used to place in a package group. The vias can also be used directly, or you can just take their location data. For `Component` objects, the package doesn't read your code so it doesn't know what the variable names for your components are. It just uses the reference to show the code snippet. --- ## Packages *Packages* ## Reference Designs | | | | :-----------------------------------------------------------------: | ------------------------------------------------------------------------------------------------------------------------------------ | | [rd-ESP32S3](https://www.npmjs.com/package/@typecad/rd_esp32s3) | reference design for the ESP32-S3-MINI-1-N8. A module that provides 2.4 GHz b/g/n WiFi and BLE 5 connectivity, MCU, and PCB antenna | | [rd-ISL9120IR](https://www.npmjs.com/package/@typecad/rd_isl9120ir) | reference design for the ISL9120IR. A Compact High Efficiency Low Power Buck-Boost Regulator | | [rd-bq24210](https://www.npmjs.com/package/@typecad/rd-bq24210) | reference design for the bq24210 800-mA, Single-Input, Single-Cell Li-Ion Battery Solar Charger | ## Utility packages | | | | :-----------------------------------------------------------------------: | --------------------------------------------------------------------------------------------------- | | [graphviz](https://www.npmjs.com/package/@typecad/graphviz) | view connections in your typeCAD project | | [ngspice](https://www.npmjs.com/package/@typecad/ngspice) | ngspice Simulation for typeCAD | | [wiring](https://www.npmjs.com/package/@typecad/wiring) | Programmatically Create Wiring Diagrams | | [jlcpcb-export](https://www.npmjs.com/package/@typecad/jlcpcb-export) | export all the required files for JLCPCB assembly from a typeCAD project | | [typecad-docgen](https://www.npmjs.com/package/@typecad/typecad-docgen) | convert markdown files and KiCAD PCBs into documentation with support for layer exports and renders | | [typecad-gitdiff](https://www.npmjs.com/package/@typecad/typecad-gitdiff) | See the differences between KiCAD PCB files | | [schematic](https://www.npmjs.com/package/@typecad/schematic) | Generate KiCAD schematics from your typeCAD project | | [kicad2typecad](https://www.npmjs.com/package/@typecad/kicad2typecad) | Parse KiCad PCB board files and generate typeCAD code | --- ## API Reference --- ## passives *typeCAD Passives* This is a typeCAD package that includes simple access to many passive components. ## Resistors, capacitors, LEDs, diodes, fuses, and inductors This package uses an options interface. Any parameter can be included or left out. They can be accessed and modified later in code. ```ts import { Schematic } from '@typecad/typecad' import { Resistor, LED, Capacitor, Diode, Inductor, Fuse } from '@typecad/passives/0805' import * as _0603 from '@typecad/passives/0603' let typecad = new Schematic('passives'); let resistor = new Resistor({ reference: "R1", value: "4.7 kOhm" }); let capacitor = new Capacitor({value: "100 nF", voltage: "6 V"}); let diode = new Diode(); let inductor = new Inductor({ value: "2.2 uH"}); let fuse = new Fuse({ reference: "F1" }); let led = new _0603.LED(); // a 0603 instead of 0805 typecad.create(resistor, led, capacitor, inductor, diode, fuse); ``` 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* ### Auto designation If `{ reference }` is not included, the component will be auto-numbered. If there are any name collisions, the new name will be suffixed with a `_1`, ie `R1_1`. ## Connectors Connectors can be created similarly. ```ts import { Connector } from './module/passives/connector' // create a 10-pin connector using the JST footprint passed in the last parameter let j1 = new Connector({ number: 10, footprint:"Connector_JST:JST_SH_SM10B-SRSS-TB_1x10-1MP_P1.00mm_Horizontal" }); // create a 5-pin connector using a default 2.54 mm pin-header let j2 = new Connector({ number: 5 }); ``` ## Testpoints Testpoints can be created: ```ts import { Testpoint } from '@typecad/passives/testpoint'; let tp = new Testpoint(); ``` Will create a testpoint with a default footprint of `TestPoint:TestPoint_Pad_D1.0mm`. Specific footprints can be chosen: ```ts let tp = new Testpoint({ footprint: 'TestPoint:TestPoint_Keystone_5015_Micro_Mini'}); ``` Connect a testpoint using `tp.pin(1)` in the `::net()` method. --- ## Globals *@typecad/typecad* [**@typecad/typecad**](README.md) *** ## Classes - [Component](Class.Component.md) - [ComponentRegistry](Class.ComponentRegistry.md) - [I2C](Class.I2C.md) - [KiCAD](Class.KiCAD.md) - [PCB](Class.PCB.md) - [Pin](Class.Pin.md) - [Power](Class.Power.md) - [Schematic](Class.Schematic.md) - [TrackBuilder](Class.TrackBuilder.md) - [UART](Class.UART.md) - [USB](Class.USB.md) ## Interfaces - [IComponent](Interface.IComponent.md) - [IPinPowerInfo](Interface.IPinPowerInfo.md) ## Variables - [kicad\_cli\_path](Variable.kicad_cli_path.md) - [kicad\_path](Variable.kicad_path.md) --- ## PCB *Class: PCB* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / PCB Defined in: [pcb.ts:46](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/pcb.ts#L46) Represents a printed circuit board (PCB). ## Constructors ### Constructor > **new PCB**(`Boardname`, `options?`): `PCB` Defined in: [pcb.ts:66](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/pcb.ts#L66) Initializes a new PCB. #### Parameters ##### Boardname `string` Name and filename of generated files. ##### options? `IPcbOptions` #### Returns `PCB` ## Properties ### Boardname > **Boardname**: `string` Defined in: [pcb.ts:47](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/pcb.ts#L47) *** ### copper\_thickness > **copper\_thickness**: `number` Defined in: [pcb.ts:50](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/pcb.ts#L50) *** ### Schematic > **Schematic**: [`Schematic`](Class.Schematic.md) Defined in: [pcb.ts:48](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/pcb.ts#L48) *** ### thickness > **thickness**: `number` Defined in: [pcb.ts:49](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/pcb.ts#L49) ## Accessors ### option #### Get Signature > **get** **option**(): `IPcbOptions` Defined in: [pcb.ts:113](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/pcb.ts#L113) Getter for PCB options. ##### Returns `IPcbOptions` ## Methods ### \_track() > **\_track**(`start`, `end`, `width`, `layer`, `locked`, `uuid?`): `string` Defined in: [pcb.ts:2410](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/pcb.ts#L2410) #### Parameters ##### start ###### x `number` ###### y `number` ##### end ###### x `number` ###### y `number` ##### width `number` = `0.05` ##### layer `string` = `"F.Cu"` ##### locked `boolean` = `false` ##### uuid? `string` #### Returns `string` *** ### add() > **add**(...`components`): `void` Defined in: [pcb.ts:2605](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/pcb.ts#L2605) Adds components to the associated schematic. This is a pass-through to the Schematic.add() method. #### Parameters ##### components ...[`Component`](Class.Component.md)[] Components to add to the schematic. #### Returns `void` *** ### bom() > **bom**(`output_folder?`): `void` Defined in: [pcb.ts:2588](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/pcb.ts#L2588) Generates a Bill of Materials (BOM) for the associated schematic. This is a pass-through to the Schematic.bom() method. #### Parameters ##### output\_folder? `string` The folder to output the BOM to. #### Returns `void` *** ### create() > **create**(...`items`): `Promise`\ Defined in: [pcb.ts:1123](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/pcb.ts#L1123) Creates and saves the board to a file. #### Parameters ##### items ...([`Component`](Class.Component.md) \| [`TrackBuilder`](Class.TrackBuilder.md))[] Components and TrackBuilder instances to add to the board before creating. #### Returns `Promise`\ *** ### erc() > **erc**(): `void` Defined in: [pcb.ts:2596](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/pcb.ts#L2596) Performs electrical rule checks on the associated schematic. This is a pass-through to the Schematic.erc() method. #### Returns `void` *** ### group() > **group**(`group_name`, ...`items`): `void` Defined in: [pcb.ts:299](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/pcb.ts#L299) Groups components and/or elements from a TrackBuilder together on the board. #### Parameters ##### group\_name `string` Name of the group. ##### items ...([`Component`](Class.Component.md) \| [`TrackBuilder`](Class.TrackBuilder.md))[] A list of Component instances or TrackBuilder instances. #### Returns `void` *** ### named() > **named**(`name`): `this` Defined in: [pcb.ts:2578](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/pcb.ts#L2578) Sets a name for a net in the associated schematic. This is a pass-through to the Schematic.named() method. #### Parameters ##### name `string` The name to set for the net. #### Returns `this` The PCB instance for chaining. *** ### net() > **net**(...`pins`): `void` Defined in: [pcb.ts:2562](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/pcb.ts#L2562) Connects a group of pins together in the associated schematic. This is a pass-through to the Schematic.net() method. #### Parameters ##### pins ...[`Pin`](Class.Pin.md)[] Pins to connect in the net. #### Returns `void` *** ### outline() > **outline**(`x`, `y`, `width`, `height`, `filletRadius`, `conceptualUuidFromUser?`): `void` Defined in: [pcb.ts:2265](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/pcb.ts#L2265) Creates a rectangular outline on the Edge.Cuts layer. #### Parameters ##### x `number` The x-coordinate of the rectangle's start point. ##### y `number` The y-coordinate of the rectangle's start point. ##### width `number` The width of the rectangle. ##### height `number` The height of the rectangle. ##### filletRadius `number` = `0` The radius for filleted corners (0 for sharp). ##### conceptualUuidFromUser? `string` Optional UUID for the conceptual outline. #### Returns `void` *** ### place() > **place**(...`components`): `void` Defined in: [pcb.ts:256](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/pcb.ts#L256) Places components on the board. #### Parameters ##### components ...[`Component`](Class.Component.md)[] List of components to place. #### Returns `void` *** ### track() > **track**(): [`TrackBuilder`](Class.TrackBuilder.md) Defined in: [pcb.ts:2553](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/pcb.ts#L2553) Begins a fluent interface for creating connected tracks and vias. #### Returns [`TrackBuilder`](Class.TrackBuilder.md) A TrackBuilder instance. Example: ``` let power_track_elements = pcb.connect() .from({x: 100, y: 100}, "F.Cu", 0.2) .to({x: 110, y: 100}) .via({size: 0.8, drill: 0.4}) // Transitions to B.Cu (or other side of via) .to({x: 110, y: 120, layer: "B.Cu"}) // Continues on B.Cu ``` *** ### via() > **via**(`via`): [`Component`](Class.Component.md) Defined in: [pcb.ts:2206](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/pcb.ts#L2206) Handles via-related operations. #### Parameters ##### via `Omit`\ = `{}` The via details. #### Returns [`Component`](Class.Component.md) The component representing the via. --- ## Schematic *Class: Schematic* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / Schematic Defined in: [schematic.ts:114](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/schematic.ts#L114) The main class for typeCAD. Holds all [Component](Class.Component.md) classes, creates work files, and creates nets. ## Export Schematic ## Constructors ### Constructor > **new Schematic**(`Sheetname`): `Schematic` Defined in: [schematic.ts:203](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/schematic.ts#L203) Initializes a new schematic with a given sheet name. #### Parameters ##### Sheetname `string` Name and filename of generated files. #### Returns `Schematic` #### Example ```ts let typecad = new Schematic('sheetname'); ``` ## Properties ### Components > **Components**: [`Component`](Class.Component.md)[] = `[]` Defined in: [schematic.ts:115](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/schematic.ts#L115) *** ### merged\_nets > **merged\_nets**: `object`[] = `[]` Defined in: [schematic.ts:122](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/schematic.ts#L122) #### merged\_to\_number > **merged\_to\_number**: `number` #### old\_name > **old\_name**: `string` *** ### Nodes > **Nodes**: `object`[] = `[]` Defined in: [schematic.ts:121](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/schematic.ts#L121) #### code > **code**: `number` #### name > **name**: `string` #### nodes > **nodes**: [`Pin`](Class.Pin.md)[] #### owner > **owner**: `null` \| [`Component`](Class.Component.md) *** ### Sheetname > **Sheetname**: `string` = `''` Defined in: [schematic.ts:116](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/schematic.ts#L116) *** ### uuid > **uuid**: `` `${string}-${string}-${string}-${string}-${string}` `` Defined in: [schematic.ts:117](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/schematic.ts#L117) ## Accessors ### option #### Get Signature > **get** **option**(): `ISchematicOptions` Defined in: [schematic.ts:141](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/schematic.ts#L141) Getter for Schematic options. ##### Example ```ts let schematic = new Schematic('sheetname'); schematic.option.safe_write = false; schematic.option.build_dir = './custom_build/'; ``` ##### Returns `ISchematicOptions` ## Methods ### add() > **add**(...`components`): `void` Defined in: [schematic.ts:219](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/schematic.ts#L219) Adds components to the schematic. #### Parameters ##### components ...[`Component`](Class.Component.md)[] Components to add to the schematic. #### Returns `void` #### Example ```ts let typecad = new Schematic('sheetname'); let r1 = new Component({}); let r2 = new Component({}); typecad.add(r1, r2); ``` *** ### bom() > **bom**(`output_folder?`): `undefined` \| `false` Defined in: [schematic.ts:153](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/schematic.ts#L153) #### Parameters ##### output\_folder? `string` #### Returns `undefined` \| `false` *** ### create() > **create**(...`component`): `undefined` \| `false` Defined in: [schematic.ts:490](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/schematic.ts#L490) Creates schematic files. #### Parameters ##### component ...[`Component`](Class.Component.md)[] #### Returns `undefined` \| `false` #### Example ```ts let typecad = new Schematic('sheetname'); let r1 = new Component({}); let r2 = new Component({}); typecad.create(r1, r2); ``` *** ### dnc() > **dnc**(...`pins`): `void` Defined in: [schematic.ts:309](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/schematic.ts#L309) Adds a no-connection flag to a pin. #### Parameters ##### pins ...[`Pin`](Class.Pin.md)[] Pins to mark as no-connect. #### Returns `void` #### Example ```ts let typecad = new Schematic('sheetname'); let r1 = new Resistor({ symbol: "Device:R_Small", reference: 'R1' }); typecad.dnc(r1.pin(1)); ``` *** ### erc() > **erc**(): `void` Defined in: [schematic.ts:519](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/schematic.ts#L519) Performs electrical rule checks. #### Returns `void` *** ### error() > **error**(`error`): `void` Defined in: [schematic.ts:528](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/schematic.ts#L528) Logs an error message and exits. #### Parameters ##### error `string` The error message to log. #### Returns `void` *** ### named() > **named**(`name`): `Schematic` Defined in: [schematic.ts:333](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/schematic.ts#L333) Sets a name for a net. #### Parameters ##### name `string` #### Returns `Schematic` #### Example ```ts let typecad = new Schematic('sheetname'); let r1 = new Component({}); let r2 = new Component({}); // named net typecad.named('vin').net(r1.pin(1), r2.pin(1)); // unnamed net typecad.net(r1.pin(1), r2.pin(1)); ``` *** ### net() > **net**(...`pins`): `void` Defined in: [schematic.ts:355](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/schematic.ts#L355) Connects a group of pins together. #### Parameters ##### pins ...[`Pin`](Class.Pin.md)[] Pins to connect. #### Returns `void` #### Example ```ts let typecad = new Schematic('sheetname'); let r1 = new Component({}); let r2 = new Component({}); // named net typecad.named('vin').net(r1.pin(1), r2.pin(1)); // unnamed net typecad.net(r1.pin(1), r2.pin(1)); ``` *** ### warn() > **warn**(`warning`): `void` Defined in: [schematic.ts:538](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/schematic.ts#L538) Logs a warning message. #### Parameters ##### warning `string` The warning message to log. #### Returns `void` --- ## Component *Class: Component* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / Component Defined in: [component.ts:45](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L45) Represents a component in an electronic circuit. ## Constructors ### Constructor > **new Component**(`options?`): `Component` Defined in: [component.ts:74](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L74) Creates an instance of Component. #### Parameters ##### options? [`IComponent`](Interface.IComponent.md) = `{}` The component options. #### Returns `Component` ## Properties ### datasheet > **datasheet**: `string` = `''` Defined in: [component.ts:49](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L49) Link to component datasheet. *** ### description > **description**: `string` = `''` Defined in: [component.ts:50](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L50) Description of the component. *** ### dnp > **dnp**: `boolean` = `false` Defined in: [component.ts:55](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L55) True if Do Not Place. *** ### footprint > **footprint**: `string` = `''` Defined in: [component.ts:48](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L48) Component footprint (e.g., Resistor_SMD:R_0603_1608Metric). *** ### groups > **groups**: `string`[] = `[]` Defined in: [component.ts:63](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L63) *** ### mpn > **mpn**: `string` = `''` Defined in: [component.ts:53](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L53) Manufacturer Part Number. *** ### pcb > **pcb**: `object` Defined in: [component.ts:54](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L54) PCB placement details (x, y, rotation). #### rotation? > `optional` **rotation**: `number` #### side? > `optional` **side**: `"front"` \| `"back"` #### x > **x**: `number` #### y > **y**: `number` *** ### pins > **pins**: [`Pin`](Class.Pin.md)[] = `[]` Defined in: [component.ts:57](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L57) Array of component pins. *** ### reference > **reference**: `string` = `''` Defined in: [component.ts:46](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L46) Reference designator (e.g., R1). *** ### sch > **sch**: `object` Defined in: [component.ts:62](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L62) #### rotation? > `optional` **rotation**: `number` #### x > **x**: `number` #### y > **y**: `number` *** ### simulation > **simulation**: `object` Defined in: [component.ts:60](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L60) Simulation details. #### include > **include**: `boolean` #### model > **model**: `string` *** ### symbol? > `optional` **symbol**: `string` = `''` Defined in: [component.ts:61](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L61) *** ### value > **value**: `string` = `''` Defined in: [component.ts:47](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L47) Component value (e.g., 1 kOhm). *** ### via > **via**: `boolean` = `false` Defined in: [component.ts:58](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L58) True if the component is a via. *** ### viaData? > `optional` **viaData**: `IVia` Defined in: [component.ts:59](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L59) *** ### voltage > **voltage**: `string` = `''` Defined in: [component.ts:51](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L51) *** ### wattage > **wattage**: `string` = `''` Defined in: [component.ts:52](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L52) ## Accessors ### uuid #### Get Signature > **get** **uuid**(): `string` Defined in: [component.ts:127](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L127) Get the UUID for this component. If not explicitly set, it will be generated consistently based on component properties. ##### Returns `string` #### Set Signature > **set** **uuid**(`value`): `void` Defined in: [component.ts:150](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L150) Set the UUID for this component ##### Parameters ###### value `string` ##### Returns `void` Unique identifier. ## Methods ### getGroups() > **getGroups**(): `string`[] Defined in: [component.ts:197](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L197) Get all groups this component belongs to. #### Returns `string`[] Array of group names this component is a member of. *** ### isInGroup() > **isInGroup**(`groupName`): `boolean` Defined in: [component.ts:189](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L189) Check if this component belongs to a specific group. #### Parameters ##### groupName `string` The name of the group to check. #### Returns `boolean` True if the component is in the specified group. *** ### pin() > **pin**(`number`): [`Pin`](Class.Pin.md) Defined in: [component.ts:159](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L159) Returns a [Pin](Class.Pin.md) object from the component. #### Parameters ##### number The pin number or identifier. `string` | `number` #### Returns [`Pin`](Class.Pin.md) The pin object. --- ## ComponentRegistry *Class: ComponentRegistry* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / ComponentRegistry Defined in: [component\_registry.ts:10](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component_registry.ts#L10) Registry for managing component UUIDs and reusing them across builds ## Methods ### clear() > **clear**(): `void` Defined in: [component\_registry.ts:205](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component_registry.ts#L205) Clear the registry Use with caution as this will invalidate all component UUIDs #### Returns `void` *** ### findComponentHashByUUID() > **findComponentHashByUUID**(`uuid`): `undefined` \| `string` Defined in: [component\_registry.ts:189](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component_registry.ts#L189) Find a component by UUID Useful for cross-referencing components #### Parameters ##### uuid `string` UUID to lookup #### Returns `undefined` \| `string` The component hash or undefined if not found *** ### getAllUUIDs() > **getAllUUIDs**(): `string`[] Defined in: [component\_registry.ts:197](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component_registry.ts#L197) Get all registered UUIDs #### Returns `string`[] Array of UUIDs *** ### getComponentCount() > **getComponentCount**(): `number` Defined in: [component\_registry.ts:17](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component_registry.ts#L17) Get the number of components in the registry #### Returns `number` *** ### getUUID() > **getUUID**(`component`): `string` Defined in: [component\_registry.ts:160](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component_registry.ts#L160) Get or create a UUID for the given component Will reuse existing UUID if a similar component is found #### Parameters ##### component `any` The component to get a UUID for #### Returns `string` A UUID string *** ### getUuidToHashCount() > **getUuidToHashCount**(): `number` Defined in: [component\_registry.ts:24](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component_registry.ts#L24) Get the number of UUID to hash mappings in the registry #### Returns `number` *** ### getInstance() > `static` **getInstance**(): `ComponentRegistry` Defined in: [component\_registry.ts:37](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component_registry.ts#L37) Get the singleton instance of the registry #### Returns `ComponentRegistry` --- ## Pin *Class: Pin* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / Pin Defined in: [pin.ts:16](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/pin.ts#L16) Class representing a pin in a schematic. Pin ## Constructors ### Constructor > **new Pin**(`reference`, `number`, `type?`, `owner?`, `powerInfo?`): `Pin` Defined in: [pin.ts:37](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/pin.ts#L37) Initializes a new pin with a given reference, number, and optional type. #### Parameters ##### reference `string` The reference identifier for the pin. ##### number The pin number or identifier. `string` | `number` ##### type? `TPinType` The type of the pin. Defaults to 'passive'. ##### owner? [`Component`](Class.Component.md) The owner component of this pin. ##### powerInfo? [`IPinPowerInfo`](Interface.IPinPowerInfo.md) Power characteristics of the pin. #### Returns `Pin` #### Example ```ts let pin = new Pin('R1', 1, 'input'); let powerPin = new Pin('U1', 5, 'power_in', this, { minimum_voltage: -0.3, maximum_voltage: 6.5, current: 2 }); ``` ## Properties ### number > **number**: `string` \| `number` = `''` Defined in: [pin.ts:17](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/pin.ts#L17) *** ### owner > **owner**: `null` \| [`Component`](Class.Component.md) Defined in: [pin.ts:20](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/pin.ts#L20) *** ### powerInfo? > `optional` **powerInfo**: [`IPinPowerInfo`](Interface.IPinPowerInfo.md) Defined in: [pin.ts:21](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/pin.ts#L21) *** ### reference > **reference**: `string` = `''` Defined in: [pin.ts:18](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/pin.ts#L18) *** ### type > **type**: `TPinType` Defined in: [pin.ts:19](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/pin.ts#L19) --- ## Power *Class: Power* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / Power Defined in: [buses.ts:68](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/buses.ts#L68) ## Constructors ### Constructor > **new Power**(`__namedParameters`): `Power` Defined in: [buses.ts:73](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/buses.ts#L73) #### Parameters ##### \_\_namedParameters `IPower` = `{}` #### Returns `Power` ## Properties ### current? > `optional` **current**: `number` Defined in: [buses.ts:72](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/buses.ts#L72) *** ### gnd > **gnd**: [`Pin`](Class.Pin.md) Defined in: [buses.ts:70](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/buses.ts#L70) *** ### power > **power**: [`Pin`](Class.Pin.md) Defined in: [buses.ts:69](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/buses.ts#L69) *** ### voltage? > `optional` **voltage**: `number` Defined in: [buses.ts:71](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/buses.ts#L71) --- ## TrackBuilder *Class: TrackBuilder* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / TrackBuilder Defined in: [pcb\_track\_builder.ts:5](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/pcb_track_builder.ts#L5) ## Constructors ### Constructor > **new TrackBuilder**(`pcb`): `TrackBuilder` Defined in: [pcb\_track\_builder.ts:14](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/pcb_track_builder.ts#L14) #### Parameters ##### pcb [`PCB`](Class.PCB.md) #### Returns `TrackBuilder` ## Methods ### from() > **from**(`startPos`, `layer?`, `width?`): `this` Defined in: [pcb\_track\_builder.ts:18](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/pcb_track_builder.ts#L18) #### Parameters ##### startPos ###### x `number` ###### y `number` ##### layer? `string` ##### width? `number` #### Returns `this` *** ### getElements() > **getElements**(): `IGeneratedElement`[] Defined in: [pcb\_track\_builder.ts:331](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/pcb_track_builder.ts#L331) #### Returns `IGeneratedElement`[] *** ### powerInfo() > **powerInfo**(`info`): `this` Defined in: [pcb\_track\_builder.ts:28](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/pcb_track_builder.ts#L28) #### Parameters ##### info `IPowerInfo` #### Returns `this` *** ### to() > **to**(`endPos`): `this` Defined in: [pcb\_track\_builder.ts:75](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/pcb_track_builder.ts#L75) #### Parameters ##### endPos ###### layer? `string` ###### width? `number` ###### x `number` ###### y `number` #### Returns `this` *** ### via() > **via**(`params`): `this` Defined in: [pcb\_track\_builder.ts:246](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/pcb_track_builder.ts#L246) #### Parameters ##### params ###### drill? `number` ###### layers? `string`[] ###### net? `string` ###### powerInfo? `IViaPowerInfo` ###### size? `number` #### Returns `this` --- ## KiCAD *Class: KiCAD* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / KiCAD Defined in: [kicad.ts:10](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/kicad.ts#L10) ## Constructors ### Constructor > **new KiCAD**(): `KiCAD` Defined in: [kicad.ts:19](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/kicad.ts#L19) #### Returns `KiCAD` --- ## I2C *Class: I2C* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / I2C Defined in: [buses.ts:4](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/buses.ts#L4) ## Constructors ### Constructor > **new I2C**(`sda`, `scl`): `I2C` Defined in: [buses.ts:7](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/buses.ts#L7) #### Parameters ##### sda [`Pin`](Class.Pin.md) ##### scl [`Pin`](Class.Pin.md) #### Returns `I2C` ## Properties ### scl > **scl**: [`Pin`](Class.Pin.md) Defined in: [buses.ts:6](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/buses.ts#L6) *** ### sda > **sda**: [`Pin`](Class.Pin.md) Defined in: [buses.ts:5](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/buses.ts#L5) --- ## UART *Class: UART* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / UART Defined in: [buses.ts:13](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/buses.ts#L13) ## Constructors ### Constructor > **new UART**(`rx`, `tx`, `rts?`, `cts?`): `UART` Defined in: [buses.ts:18](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/buses.ts#L18) #### Parameters ##### rx [`Pin`](Class.Pin.md) ##### tx [`Pin`](Class.Pin.md) ##### rts? [`Pin`](Class.Pin.md) ##### cts? [`Pin`](Class.Pin.md) #### Returns `UART` ## Properties ### cts? > `optional` **cts**: [`Pin`](Class.Pin.md) Defined in: [buses.ts:17](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/buses.ts#L17) *** ### rts? > `optional` **rts**: [`Pin`](Class.Pin.md) Defined in: [buses.ts:16](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/buses.ts#L16) *** ### rx > **rx**: [`Pin`](Class.Pin.md) Defined in: [buses.ts:15](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/buses.ts#L15) *** ### tx > **tx**: [`Pin`](Class.Pin.md) Defined in: [buses.ts:14](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/buses.ts#L14) --- ## USB *Class: USB* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / USB Defined in: [buses.ts:26](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/buses.ts#L26) ## Constructors ### Constructor > **new USB**(`DP`, `DN`): `USB` Defined in: [buses.ts:29](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/buses.ts#L29) #### Parameters ##### DP [`Pin`](Class.Pin.md) ##### DN [`Pin`](Class.Pin.md) #### Returns `USB` ## Properties ### dn > **dn**: [`Pin`](Class.Pin.md) Defined in: [buses.ts:28](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/buses.ts#L28) *** ### dp > **dp**: [`Pin`](Class.Pin.md) Defined in: [buses.ts:27](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/buses.ts#L27) --- ## IComponent *Interface: IComponent* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / IComponent Defined in: [component.ts:21](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L21) ## Properties ### datasheet? > `optional` **datasheet**: `string` Defined in: [component.ts:23](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L23) *** ### description? > `optional` **description**: `string` Defined in: [component.ts:23](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L23) *** ### dnp? > `optional` **dnp**: `boolean` Defined in: [component.ts:24](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L24) *** ### footprint? > `optional` **footprint**: `string` Defined in: [component.ts:22](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L22) *** ### mpn? > `optional` **mpn**: `string` Defined in: [component.ts:24](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L24) *** ### pcb? > `optional` **pcb**: `object` Defined in: [component.ts:25](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L25) #### rotation? > `optional` **rotation**: `number` #### side? > `optional` **side**: `"front"` \| `"back"` #### x > **x**: `number` #### y > **y**: `number` *** ### pins? > `optional` **pins**: [`Pin`](Class.Pin.md)[] Defined in: [component.ts:25](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L25) *** ### prefix? > `optional` **prefix**: `string` Defined in: [component.ts:23](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L23) *** ### reference? > `optional` **reference**: `string` Defined in: [component.ts:22](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L22) *** ### sch? > `optional` **sch**: `object` Defined in: [component.ts:26](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L26) #### rotation > **rotation**: `number` #### x > **x**: `number` #### y > **y**: `number` *** ### simulation? > `optional` **simulation**: `object` Defined in: [component.ts:26](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L26) #### include > **include**: `boolean` #### model? > `optional` **model**: `string` *** ### symbol? > `optional` **symbol**: `string` Defined in: [component.ts:22](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L22) *** ### uuid? > `optional` **uuid**: `string` Defined in: [component.ts:24](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L24) *** ### value? > `optional` **value**: `string` Defined in: [component.ts:22](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L22) *** ### via? > `optional` **via**: `boolean` Defined in: [component.ts:25](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L25) *** ### viaData? > `optional` **viaData**: `IVia` Defined in: [component.ts:27](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L27) *** ### voltage? > `optional` **voltage**: `string` Defined in: [component.ts:23](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L23) *** ### wattage? > `optional` **wattage**: `string` Defined in: [component.ts:24](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/component.ts#L24) --- ## IPinPowerInfo *Interface: IPinPowerInfo* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / IPinPowerInfo Defined in: [pcb\_interfaces.ts:79](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/pcb_interfaces.ts#L79) ## Properties ### current? > `optional` **current**: `number` Defined in: [pcb\_interfaces.ts:82](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/pcb_interfaces.ts#L82) *** ### maximum\_voltage? > `optional` **maximum\_voltage**: `number` Defined in: [pcb\_interfaces.ts:81](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/pcb_interfaces.ts#L81) *** ### minimum\_voltage? > `optional` **minimum\_voltage**: `number` Defined in: [pcb\_interfaces.ts:80](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/pcb_interfaces.ts#L80) --- ## kicad_path *Variable: kicad\_path* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / kicad\_path > **kicad\_path**: `string` \| `undefined` Defined in: [kicad.ts:7](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/kicad.ts#L7) --- ## kicad_cli_path *Variable: kicad\_cli\_path* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / kicad\_cli\_path > **kicad\_cli\_path**: `string` \| `undefined` Defined in: [kicad.ts:8](https://github.com/typecad/typecad/blob/1cc6b22dbd0361f12767bd5b33367d9ef04cbbfe/kicad.ts#L8)