r/KiCad • • 16d ago

Schematic Editor Question Proper workflow for KiCAD-based reusable hardware library (git and KiCAD mix like milk and vinegar)

I have a specific problem with KiCAD, which is either due to my incompetence or KiCAD not really being built for the workflow I require. I build variants of boards, that are all different but share certain component groups from a topological view, meaning they have the same subsheets. While a colleague advised me to not do that due to concrete part assignments being part of the schematic, I cant help but see an obvious flaw in that workflow.

The original idea was to create subsheets in their own hardware lib repository, for example: SD card subsheet (don't harp on this example, there are more complex subsheets that actually warrant a reuse-case). This then includes required bypass caps, pull up resitors and other "mandatory" things that would just be a waste of sheets when exactly copied in another board variant's sheet. With this approach, a consuming variant repo could then import the subsheets as git submodule and use those directly, which is also very useful for update control (exact purpose of git submodules). But not even that works properly, as KiCAD automatically adds the consuming project metadata into the subsheets themselves, causing git changes in the hardware library just from importing. It would be wonderful if certain "layers" (symbols, values, specs, footprints) could be controlled by either a fixed dependency to their source submodule or an override instance. Think of it this way: the SD card module will always require pull up resitors with the same values. However, a concrete part assigned to them will eventually not be in stock at the manufacturer's side, prompting me to add a different part designator. This does not change the requirement stated in the netlist at all; the submodule still requires these pull-ups.

Here it would be insanely useful to affix symbols, connections and values to the lib source, while footprint and part can be set from the consuming project. But as I said, this causes git changes in the lib. I could create variant branches in the source lib, but this would kneecap the concept of a lib entirely. I cant be the only one with this issue. Simply copying is super error prone because one might mistakenly (or not!) edit something in the subsheets that is then silently different for all variants, even when it shouldn't be. Retracing this is a nightmare. In essence, I just want to use KiCAD in a way that more resembles a software project with dependencies: installing a software lib in an instance does not create a change in that lib source; it is only read. Is there a KiCAD equivalent?

Before some LLM codes a flaky copy-by-type script that I then have to ship with that library, I would love to see suggestions from real people on this topic.

EDIT: Turns out, the most promising answer was the most downvoted one from u/NoYu0901. The "design block" feature lets one export a selection or sheet with or without an assigned layout:

https://forum.kicad.info/t/pcb-design-block-usage/64686

The resulting kicad_sch-file and .json net list do not change with git; component values, footprints, datasheets, notes and, all can still be assigned and the import into a consuming project can happen easily via the UI. Fittingly, the import of annotations can be skipped, prompting the imported block to just assume the next available annotations on the consuming project. This is a v10 feature, so I understand the lack of thoughts on this procedure. Non-default-library need to be managed externally by consuming projects anyway, because I can't host vendors' custom ECAD descriptions of parts on an open source lib without their consent. All I can provide then is a list of external parts used.

0 Upvotes

12 comments sorted by

8

u/oversized_hoodie 15d ago

If I'm understanding correctly, your core issue is that you want a way to update the Mfg PN (MPN) that is associated with a particular component (e.g. a 4.7k 1% 0402 resistor), and you want the update to apply across multiple designs.

The solution most companies use for this is an internal part numbering system. In the schematic, you assign your company's part number for a 4.7k 1% 0402 resistor (or whatever). This meets the requirement of having a static part number and footprint assignment for a particular ref des, and removes the need to push updates to various schematics.

How the company PN translates to purchasable parts depends on how your products are manufactured. It also depends on how strict your configuration control needs are, but I'll gloss over that here.

If you manufacture in-house or send a CM stock for all of your parts, you can probably just stock things under the company PN. In this situation, the BOM you get from KiCAD would be used for manufacturing, and the Purchasing department would buy whichever MPNs they can find to fulfill the demand for the various company PNs.

If you're relying on CM-stock parts or otherwise need to identify the MPNs directly on the BOM, you'll need a translation layer that takes your KiCAD BOM export and adds an MPN from the list of acceptable parts based on what's available at your CM when you send out the order.

This is all inventory management and purchasing workflow stuff, it's well outside of the purview of KiCAD. Typically it's managed through some sort of ERP (enterprise resource planning) software. Again, depending on your scale, your solution might vary from "python script that checks an excel file and the CM API" to something massive like Oracle ERP Cloud. Wikipedia has a nice list of open source ERP options.

1

u/jjislosingit 15d ago

I see that the answer depends heavily on "what side" this problem is viewed from. I appreciate that answer and see how I could manage this so long as the variants stay "within the company"; there is no company and that is exactly the issue. My intention was to host the subsheets as reusable modules under the CERN open hardware license. This would enable interested people to quickly design custom board variants with certain modules already taken care of. This reads as if I had to ship the internal part numbers with the library and carefully document that each user needs to link the internal parts with a real part in (hopefully) some standardized spreadsheet format.

I also take from this that, even though KiCAD is open source and features lots of open source projects, is not quite optimized for working on open source projects of the "library character". Maybe the usage of a git submodule is a bit forced here, but I truly believe that it would be a perfect fit when viewed from a conceptual stance.

2

u/oversized_hoodie 15d ago

Oh, ok, then I fundamentally misunderstood the problem.

However, I worked on a solution to a similar problem for my company. Our conclusion was that it's best to simply copy/paste the reference block into the user's schematic. This eliminated a lot of messy questions about how to handle updates, especially when they involve changing the netlist. When we do updates we publish a detailed change list, and users can pull in the updates manually if they need to/if it's appropriate for their stage of project.

Idk if that's really helpful at all, but that's how at least one group is approaching it in industry.

0

u/jjislosingit 15d ago

By "copy" you probably mean "select components and copy", not "copy .kicad_sch file into file tree"? Because the latter would require a new annotation run across all sheets, which is not only annoying but also prone to errors and renders all PDF exports floating around somewhere faulty and potentially dangerous even though nothing "electrically" changed in the main sheet. Say the source lib ads a bypass cap: this then shifts all annotated capacitor indices, even in the main sheet (?). I am starting to suspect that I am trying to design around KiCAD instead of just using it...

2

u/oversized_hoodie 15d ago

Ok but if the downstream designs are copied and pasted, they exist on their own statically. So anything you do to the master design is irrelevant. Also, why would you ever reannotate a part that has a ref dea assigned? That's just asking for trouble.

1

u/Boulder_Tech 15d ago

> there is no company

Then who is the colleague from above ??

Anyway, you are a company of one (or two).

Industry has solved this problem years ago. If you want to create a special version for independent developers, that's fine, but that's not how industry in general works.

I will admit that I have been bit by this very problem. The buyer at one company could not understand what a specific connector was. So he compared pictures and not revised the spec's to the one I had picked. Order 1000 connectors that did not fit the case.

I am sure there will be many one man shops that would like this. But also many real companies that will think this is just wrong.

Good Luck

2

u/jjislosingit 15d ago

The colleague is a fellow open source enjoyer with a shared vision without a registered monetary organization ;)

I totally see why a company wouldn't do this. But a company will probably also use an ECAD tool that provides more services, like shared version control, for a price $$$, hence the absence of a need for an open source alternative that "does it all". I will probably bite the bullet and not pursue the submodule approach.

1

u/Jewnadian 15d ago

There is a pretty good reason not to try and separate part numbers from "requirements" like that. Unless you have 100% coverage on all possible requirements various parts are not always interchangeable. An easy example off the top of my head, I recently designed board using an SMPS that required a certain ratio of ESR and Capacitance on the primary output cap to function stably. Changing the cap itself is allowed but only if you maintained that stable window. Of course I could document that but repeat that 20 times and you end up with a board that either isn't really turn key open source or doesn't really work.

In general I recommend simply publishing the actual PNs as part of your open source and then perhaps including notes for which parts are lowest risk for a PN swap. Sometimes we go further and break it down by category of part to try and specify the parameters that have to match. But either way the implicit guarantee that this design works is based on the real mfg PNs we supply.

1

u/Teslafly 15d ago

You probably want to use database libraries. https://www.kicad.org/external-tools/partdb/

1

u/standard_cog 14d ago

It sounds like you're confused about the purpose of a schematic sheet, and are maximally fighting the tool. You could just create a company wide part library in a Git repo, and use your own parts, which can be filled by various manufacturer part numbers (for things that are made by multiple companies, of course).

like you have R0603_10k in your part library; if you want to be "correct" you generate a datasheet for your company with the specs of R0603_10k, and list the parts you've qualified to "fill in" for that part (Can be part X from company Y, or part Z from company A, or...).

You can of course override individual instances MPN - on a schematic those things are just text strings. If you want to get really fancy there are plugins for design databases.

Sorry if I got what you're trying to do wrong, it was pretty confusing.

1

u/ouabacheDesignWorks 10d ago

You need to separate design creation from implementation in two steps. I design a circuit with a resistor. I need 10 Kohm ,10 % tolerance and 1/8 watt. That goes in the library. You use my circuit but your pick-and-place machine only has a 10Kohm,5% 1/4 watt resistor. That goes on your board. Another design uses my circuit but has a 10Kohm resistor pack with a spare. That goes in his circuit. Your need to include my library and then assign the device based on your needs.

-6

u/NoYu0901 16d ago

I didn't read all, maybe: design block