Skip to main content

Generate clearance rules for KiCAD by a table.

Project description

This Python program converts a given table of voltage distances into KiCad design rules.

docs/source/figures/overview.png

1 Installation

Install KiClearance directly from pyPI:

pip install kiclearance

2 Usage

2.1 Create a table ‘clearance.ods/xls/csv’ containing clearance distances

Create a table (name it clearance.ods/xls/csv) in your KiCad project directory with voltage clearances defined by your requirements (e.g. standards). Download and use this template as a guide: clearance.ods.

The table contains the distances from a potential to another in mm. The same net distance is optional. The default distance is 0.15 mm.

docs/source/figures/table.png

2.2 Define net classes in your KiCad project

Add the net classes to each connection in the circuit diagram.

docs/source/figures/net_class_directive_labels.png

Add the same net classes in the net classes of the PCB editor: KiCad PCB Editor: File -> Board Setup -> Design Rules -> Net classes

docs/source/figures/board_setup.png

2.3 Run KiClearance

Navigate to the project folder with the KiCad project and the clearance.ods/.xls/.csv file. Open a terminal and execute :

python -m kiclearance

Now a file yourprojectname.kicad_dru is generated, which contains the rule sets.

Open your KiCad project, the rule sets are now stored and you can start the routing.

As the inner layers are exposed to less dirt and no air, the distance in the inner layers is halved by default. If this factor is to be set differently, this can be set with the following command (in the example: distance to 75%):

python -m kiclearance -i 0.75

To see help and options, run

python -m kiclearance --help
The following arguments are possible:
-h, --help: Prints this information,
-f, --project_folder (Optional): Path to the folder in which the project is located. Default: Folder in which this python script is located.
-n, --project_name (Optional): Name of the kicad project (file prefix). Default: Script will look for a file with .kicad_pro in the set folder.
-t, --table_file (Optional): Name (and ending) of the file containing the distance values. Default name: 'clearance'.
-i, --factor_inner_layers (Optional): Reduced factor for the inner layers. Default: 0.5
-d, --min_track_distance (Optional): minimum track distance between two tracks on the same potential. Default: 0.15 mm.

3 Tips and tricks

If two network classes are assigned to a connection by mistake, this is displayed as an error in the Electrical Rules Checker (Inspect -> Electrical Rules Checker).

KiCad works through the rules from bottom to top: Once an applicable rule has been found, KiCad will not search for further rules. Keep this in mind when adding more own rules except from this script here.

4 Example

A complete example can be found here.

5 Documentation

Find the documentation here.

6 Troubleshooting

This program has so far been tested only on Linux and Windows.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kiclearance-0.1.2.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

kiclearance-0.1.2-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file kiclearance-0.1.2.tar.gz.

File metadata

  • Download URL: kiclearance-0.1.2.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.19

File hashes

Hashes for kiclearance-0.1.2.tar.gz
Algorithm Hash digest
SHA256 710497fa9359dfe79e47f6f95994e8f8e21313017db9917a452da9ae21c1b968
MD5 c95bda05fae13c2b4bafe9f9a3f14b5c
BLAKE2b-256 811b87c8d71c7b2978c945f2522d54b5f5dddbcb406409d99d2beac5984b6c6c

See more details on using hashes here.

File details

Details for the file kiclearance-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: kiclearance-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.19

File hashes

Hashes for kiclearance-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0a2d7767d52e2f004ebeb4519e97b74e93183176175db0baa093de6bcbec44d1
MD5 2c142649525c0a3d5018c5dd0fc6b1ba
BLAKE2b-256 75ab67f85e036eb514f1f1ab6490a0131fe00ac0904a6b5852e630b01d29b017

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page