Introducing KiVar: PCB Assembly Variants for KiCad

Hi KiCad community,

I’d like to take the release of series 0.2.x as an opportunity to introduce KiVar to this forum today.

As you know, one of the features still missing in KiCad is PCB assembly variant management.

If you want to switch variations and have the changes reflected directly in your PCB and schematic files, then using text callouts to describe which components have to be changed in which way for switching the behavior of the circuit is tedious, hard to maintain, inconvenient and error-prone.

So I came up with a method to (more or less formally) describe component variations, assign them to groups (called aspects) and a convenient and safe way to switch between these defined variation options (called choices) with a KiCad plugin or command-line application.

The plugin has been around for a while now, but I think with release series 0.2.x the expression syntax and features have matured to a point, where it could definitely be helpful for many KiCad users. The feedback I have received from users so far makes me optimistic.

In my experience, there is rarely a static PCB design that would not benefit from one or more - even small - variation options. Be it switching an I²C address, a maximum current, a voltage threshold, a few bootstrap pins, the MPNs of equivalent ICs - or of similar ICs and their respective peripheral ICs - or switching between already designed-in options to reduce costs.

For the complete feature set it’s best to consult the documentation. But as a short impression what KiVar can do for you:

Depending on the selected component variation choices, KiVar can assign component values, custom field content and attributes (i.e. DNP, Not in Pos. Files, Not in BoM).

Future versions may also support switching of component-specific solder paste application and of the visibility of individual 3D models of a component.

Setup is easy. You simply write your rule expressions into custom fields of the relevant components and you’re done. If you make the changes in the Schematic Editor, you will have to sync them to your PCB first. If you choose to add the expressions directly in the PCB (and sync them back to the schematic later), you’re already good to go. Simply click on the plugin icon and select a variation choice per aspect.

Following are two very simple examples to give you an impression how to use KiVar:

To switch a resistor between fitted and unfitted, add a custom field to this resistor, with the following content:

Var = Resistor_Fitted Yes(+!) No(-!)

This will create an aspect “Resistor_Fitted” (this is a random name and can be whatever you like to use as identifier), which can be used for this resistor only, or for other components as well. Also, these other components can add further variation choices, which will then be added to the possible choices for that aspect.

Syntax hint: Property ! stands for: fitted + in position files + in BoM.

Another example: To switch a resistor value between , 47kΩ and 100kΩ, use:

Var = Resistance Zero(0Ω) Medium(47kΩ) High(100kΩ)

Syntax hint: Any choice argument not starting with - or + is interpreted as part of the value (in the scope used here).

These as just two very basic examples. KiVar can also assign custom field content (such as MPN, datasheet URL, order info), use different expression notations (useful for making parts of your rules visible in your schematic for documentation purposes) and allows fine control over attributes.

For more examples take a look at the real-world examples in the documentation or check out the demo project.

KiVar is available as a KiCad Action Plugin, for seamless use directly inside the PCB Editor with immediate effect on your open PCB file, as well as a command line application to be used on *.kicad_pcb files, for analyzing and switching variations in command line and script environments.

KiVar 0.2.x requires KiCad version 8 or later.

The KiVar plugin can be installed from the official KiCad PCM repository.

The KiVar command-line app can be installed with pip install kivar.

More information can be found in the documentation.

I hope it’s useful for you.

Mark

4 Likes

Nice. This missing feature has indeed been badly needed. I am still on v7 until I wrap up a production project but hope to jump to v8 soon and will definitely check it out. Thanks Mark.

The previous release, version 0.1.2, is also still available for KiCad 7. You can install it via PCM.

That release still uses the older rule syntax dialect and does not yet provide custom field manipulation. But it’s useful nonetheless, and you’ll get a feeling of the general workflow.

If you want to use it, make sure to check out the matching documentation for the 0.1.2 release.

Also, when using KiCad 7, restrictions regarding back-annotation to your schematic apply (as listed in the documentation). These restrictions were resolved in KiCad 8.