Parameterized component values (using expressions for component values)

When simulating analog circuits and experimenting with feedback compensation, I often need to change multiple component values (resistors and capacitors) at the same time.
It would be really useful to be able to define component values using an expression with parameters, e.g. resistor R1 value being defined as (1000 + ra) * rf where ra and rf are parameters that can be set independently and cause several components to change value.

Does such a feature exist in KiCad or in any plugin/extension?

Would it be possible to implement this type of in a (Python) plugin that iterates over all components, and if a certain custom field (e.g. value_expression) exists, calculating the value of the expression resolving values of any embedded named parameters as well as references to other component values (e.g. R2 value being defined as R1*2.5+100, and subsequently update the component value with the computed value (possibly formatting the value into a human readable form usiing SI units: p, n, µ, m, k, M, G).

If no such feature exists, I’ll create a repo on GitHub and make an attempt developing the plugin myself. I naively think that it shouldn’t be that difficult to implement, and even automatically triggering a recalculation of componentr values when referenced parameters or component values change.

EDIT
With a working IPC API for the schematic editor still being way off, I think I will make an attempt to solve this feature by parsing/modifying the underlying s-expressions in the <project>.kicad_sch file using KiCad-Skip.

References

Similar feature request

About contents of symbol value field and simulation

Example of Python plugin modifying schematic field values

KiCad-skip

I responded to your Personal Message…

1 Like

An example project (but also see various projects at Simulation examples for KiCad/Eeschema/ngspice ).


params.7z (4.8 KB)

1 Like

Thanks for the hint of using variables and expressions in NGSpice. But I would like to move the expressions and dependencies to the schematic editor itself so the actual component values will be plainly visible in the schematic, and the underlying parameters and expressions will be somewhat hidden in a user-defined field. That way, a BOM will not contain “unresolvable” values. But simulations will happily use the computed component value.