ERC

typeCAD provides a built in ERC function.

Electrical Rules Checker

typeCAD 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 KiCAD includes a lot of other rules, but the majority of them are not relevant to typeCAD.


Here’s a simple example.

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.

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 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.