Object oriented project

Hi everyone
just started working with kicad to try a little project but am unsure about how to go about organizing the project itself. I basically want to try to build some “complex logic” using only basic components (bjt, cmos etc) as a fun experiment. My approach was to create simple logic gates in hierarchical sheets to then reference to make more complex logics and so on. I saw there is a plugin to then reorganize the pcb layout for all instances of a sheet, so that would solve that problem as well. My problem is that when i create a hiararchical sheet i actually have to place it in the schema, which would basically mean i would have a copy of each of the basic components “on the side” with no real use, or create them the first time I use them, but then have no real organization in my project. I know this is not a real world project but is it possible to do something like this in kicad or is it just too unrealistic? is there a completely different approach i should take (multi unit symbols?)
thanks for your help

This looks like an ideal case for hierarchical sheets.

Mmm. not very sure what you mean with this.
Maybe this link will help: Hierarchical or flat schematic design, what is best for me? (How to deal with multi page schematics?)

Thanks for the super quick reply. I had actually read the page you linked and it’s what gave me the idea to use hirarchical sheets, but i think i didn’t get in the right mindset, and I thought that when I defined a subsheet it was somehow “in the sheet” it was defined. But rereading the link and trying it out I need to reorganize my . Thanks for the tip

Hierarchical sheets are not a good fit for this.

A much better way would be a “true hierarchy”, where a new schematic sheet could be attached to a schematic symbol, but that is not (yet?) supported by KiCad. It’s a quite common idea, just yesterday for example someone else posted the same idea on Hackaday.

I’ve heard some rumors that the next KiCad version is going to have some support for “design blocks”, or “modules”. (I don’t know if there already is a name for it). The Idea is that a partial design (for example schematic and PCB layout of an SMPS circuit) can be re-used in another project.

KiCad is one of the most active Open Source projects i know, and it’s doing quite well. But it still has a finite amount of development hours to divide over many parts of the software, and people are free (within limits) on what part of KiCad they want to work on.

Coming from a CS background that is more what a had in mind. However it looks like the different files created when defining a sub sheet basically work in a similar way, and that this is in fact the correct way to do it, even though a bit cumbersome in some regards, but as you say it’s open source and free I’m not complaining :slight_smile: just making sure it’s the correct way to proceed and there isn’t a better tool

If you’re thinking in CS terms, the child sheet is more like an instantiated macro with parameter substitution.

You can approach the hierarchical sheets like OOP objects, especially if you don’t use any global labels (including power symbols) inside your sub sheets. You can reference the same schematic file multiple times with different sheet objects just like you can call the same object multiple times in OOP. KiCad will keep track of the different reference designator sets for the different sheet objects that point to the same schematic file.

Though sheets might be better analogous to function calls than object calls since sheets don’t have the extra flexibility of methods that objects do. Though, unlike functions in programming, you can’t (for example) change a resistor value by passing an attribute to a sheet object. All component values on your sheets that point the same schematic file must be the same.

Wrong! It’s possible in v6 using sheet properties as text variables with ${property_name} syntax.

1 Like

I’ll have to play with that. This is a new feature that I haven’t played with (didn’t remember it), and if it works as expected I’ll certainly be glad to be wrong. :smiley:

You can find a test project in Eeschema: Hierarchical sheet parameters (Parametric Hierarchical Design) (lp:#1838072) (#2466) · Issues · KiCad / KiCad Source Code / kicad · GitLab, but it was made with 5.99, I haven’t tested it recently. (EDIT: tested, and works with v6.)

I just played a little bit with my hierarchical test project (converting it from v5 to v6 and including some v6 features). It seems to work. For others watching, here are some screenshots with explanations:

Parent sheet with two sheet objects. The text in blue is manually added schematic text. The text in magenta is the sheet property.
2022-01-31 17_40_15-Window

Here are the properties for both sheets. Note how I also have the part number of the variable part, but have them invisible.
2022-01-31 17_41_36-Window

2022-01-31 17_42_06-Window

When looking at either sheet, here are the properties for the potentiometer:
2022-01-31 17_42_30-Window

And here are how the pots are shown in the two sheets:
2022-01-31 17_40_47-Window

2022-01-31 17_41_08-Window

And, finally, here are how the two pots show in the generated BOM (note, I haven’t checked iBOM yet…):

"Item","Qty","Reference(s)","Value","LibPart","Footprint","Datasheet","Characteristics","Manf","Manf#"
"4","1","R1","20k","Device:R_Potentiometer_US","Potentiometer_THT:Potentiometer_Bourns_PTV09A-1_Single_Vertical","~","Audio Taper","Bourns Inc.","PTV09A-4025F-A203"
"7","1","R4","5k0","Device:R_Potentiometer_US","Potentiometer_THT:Potentiometer_Bourns_PTV09A-1_Single_Vertical","~","Audio Taper","Bourns Inc.","PTV09A-4020F-A502"

So, It can be done, and works well. The implementation is clumsy enough that one might want to restrict the usage to something simple like 1 or 2 value changes. @eelik, Thanx for the heads up on this feature.

2 Likes

Thanks for the tips. I mean think I’m getting the hang of it, my only annoyance for now is that all the tutorials show that subsheets are created when they ate needed rather than beforehand. Whereas in OOP might create a class or a function beforehand just to have a library to use. But it’s merely a workflow change

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