Template / Block designs with KiCad

I believe this is not possible with KiCad and I’m wondering if any other EDA tool supports it… ?

The idea is: design a schematic in a “block” that work as a template and can be replicated. Then it will automatically (internally) replicate the need components when it need to export to PCB.

The closest option in KiCad would be to create the schematic in a sheet and then replicate it… but if it need to change something, all others blocks need to be removed and replicated again.

Wondering also how it will global labels work… will it mix the same (duplicate) global names ?

Any more suggestions?

Eagle has such feature which is called “Design Blocks”. Since I’ve never liked Eagle, my team was using it :slight_smile: So I don’t know further details.

For KiCad, you can use Hierarchical sheets for this purpose. Imagine you have a design which has power circuit in it. This is a general switching regulator circuit which provides 3.3V. So probably you’ll use it for many of your designs. Your design could be very simple, yet if you use a hierarchical sheet for this design, you can move your power circuit into a sub circuit, which has d different schematic file.

After verifying your design, you can move this file into a global subcircuit repository and include them directly into your designs via referencing them.

One thing needs clarification for me. I don’t know whether a schematics file could be referenced outside of the project folder or not. Other than that, this would work just fine for all of the designs and will be updated in case of any improvements.

Also if you add this repository as a submodule in Git, then you’ll have full control of the sub circuit history (you might want to use an older revision for compatiblity reasons)

2 Likes

On my case, I’m just considering blocks on the same project.
I believe it needs a relation between a schematic and symbol libraries, otherwise, the schematic will be missing the symbols

That’s an easier case. In one of my last designs I had a sub-circuit which is used 8 times. So drawing them one by one was not a feasible choice. So I made them sub-sheets and like you expected every update was reflected on all of the sub-sheets.

Symbol library dependency is standard like without hierarchical sheets. So general Symbol Library methods could be easily applied.

2 Likes

But how do you made it update?
The only way I may see it is to manual remove the old design and copy new files and rename each one…?

The problem with referencing the same schematic file from multiple projects is not necessarily connected to the symbol libs. At least not if you use only global libraries then there is not really a problem.

One problem source can however be using the rescue dialog. If you allow KiCad to rescue such a sub circuit in one project then you might run into trouble in all other projects.

I am also not sure how annotation works as this is bound to the time stamp of the instance. I am not sure KiCad guarantees leaving the annotation information of other projects alone in such a case.

Full support for a central library of sub schematics is requested in https://gitlab.com/kicad/code/kicad/issues/2263

For the schematic side of things:

If you reference the same file (instantiate the same circuit multiple times) then changing the circuit will automatically be reflected in every instance.

The only thing that does not update is the sheet definition itself. (The arrangement of sheet pins for example as requested in https://gitlab.com/kicad/code/kicad/issues/2389)

See Hierarchical or flat schematic design, what is best for me? (How to deal with multi page schematics?) as a demonstration of this.

The layout side of your request is not supported at all right now. The closest options we have is by using the replicate layout plugin by @MitjaN Replicate layout: Action plugin

Full support for layout side design blocks is requested in https://gitlab.com/kicad/code/kicad/issues/2508

3 Likes

I also haven’t seen this officially documented but according to Wayne, KiCad supports this

Rene is not quite correct. I’ve implemented the layout side of this in Save/Restore action plugin. You might want to take a look. It is similar to Replicate layout plugin, but it works across projects.

The basic functionality works, but the propagation of changes from one project to other has not been tested (that I know of). Currently I copy the schematics files to other projects. I’d recommend against linking them as you will have to think hard when making changes in one project, what will happen to other project(s). Maybe you could store the .sch and exported layout (.pckl) files in dedicated git repo and then you can include them in various project as a git submodule. So git will offer you some tooling to help you how are the changes propagated to each project.

2 Likes

Just for reference, this topic comes up every now and then. Here are the previous discussions:



1 Like

Thanks @MitjaN I will need to read more carefully to understand the details…
But on my case, I’m just looking for the Schematic possibilities, I will not need the “PCB layout”.

Hopefully the coming new v6 schematic format with symbols embedded in the schematic file will make having a library of hierarchical sheets of subcircuits less annoying remapping symbols. Unless the new format also embeds sheets into one master schematic file… If so, might need to have a “save sheet to schematic file” feature then…

Sorry, for the late reply. As Rene pointed out, if you use the same schematics file with different references for all of your blocks, every update will reflect instantly to the others. You just need to take care of annotation since every blocks item must have different references. Otherwise the whole purpose would be gone.

Just be careful about global labels. Use as much as local ones and leave the outside connections to the hierarchical labels. They will be I/O’s of your module (design block).

I personally don’t look for PCB layout solution for design blocks, due to high possibility of physical changes. Honestly, for me PCB layout is much easier than designing it logically (schematics).

Thanks @MuratUrsavas !
I tested it on a new project and noticed that it works!

It actually looks like that KiCad could do what I was looking for.
I was thinking that a copy&paste or duplication was actually an hard copy/duplication of the data on the schematics, but it is actually a reference to the same file and it tracks only the differences related with the annotation.
Good job KiCad developers!
Solved!

1 Like

Well… actually there is a problem… that will not work on my case. Eg: if I have a Quad Opamp but will just use 1 opamp per sheet, it will not update or create U?A … U?B … U?C … etc
but anyway, I guess it still helps.

For multi unit parts the automatic selection works if you have it designed as a symbol where you allow kicad to exchange units (The annotation algorithm is then allowed to select the unit)

Most official symbols are however build with a separate power unit which makes the use of this feature an impossibility (We need to select “all units are not interchangeable” as there is no way to say units A to D are interchangeable but unit E is special)
We looked into the tradeoff regarding this and decided that the automatic annotation feature is less important than having the option to work without invisible power input pins.

2 Likes

Did you consider designating which units in a symbol were interchangeable with each other?

IE a logic IC with two nor gates, two nand gates and three power pins would designate the nor gates as belonging to group A (interchangeable with each other), the two nand gates would be designated as group B (interchangeable with each other) and the power pins as group C.

That gives you explicit power pins and interchangeable ‘gates’. I do think you probably need the ability to turn this off for specific instances. For example you might want to swap gates in most cases but not across power domains. I expect a full solution to this could be quite complex to make simple enough to use.

1 Like

Peanut gallery here… Do you mind explaining why that is?
I’m sure the Devs looked at every avenue and as I don’t code for KiCAD I will not object… but curiosity got the better part of me.
Same as @Robert1 above I guess :slight_smile:

The new file format will most likely support it

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.