ERC

typeCAD provides ERC via the typecad erc CLI command and the runERC() programmatic API.

Electrical Rules Checker

typeCAD runs KiCAD’s ERC via kicad-cli sch erc. After typecad build has been run, you can run typecad erc to check your schematic for any connection errors.

It uses the same KiCAD rules as shown in this picture.

KiCAD ERC KiCAD includes a lot of other rules, but the majority of them are not relevant to typeCAD.


Here’s how to run ERC from the command line:

typecad build
typecad erc
Assuming no errors, it will show `ERC passed. No errors or warnings.` in the output.

You can also run ERC programmatically:

import { runERC } from '@typecad/typecad';

let report = await runERC('./build/erc.kicad_sch');
console.log(report);


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 files, generated by typeCAD 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:

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.