Changing a flat schematic to hierarchical

I’ve done hierarchical schematics without problems in the past, but I’m an old guy and I forget things. I started a project as a flat schematic, but realized I would need more than one page. So I started over, creating a root sheet. Now I need to bring my original schematic into the hierarchy, and nothing I’ve tried works. I must be missing something.

TIA
bdh

Hi,

on your root page, go to the right side of the eeschema window and click on “Add a hierarchical sheet” (hotkey is [S]).
image

Draw a rectangle and left klick. In the dialog box for “Sheet file” enter the name of the schematic sheet you want to import.
image

1 Like

The method fox describes works reasonably well, but there are a few things I have to add. The “root” sheet in a KiCad project is the schematic file with the same name as the project. So if you want to move that sheet to somewhere else in the hierarchy you have to rename the actual file first.

The most intuitive method would be to just use the regular cut and paste method to move parts from one schematic sheet to another, and I assume you already tried this. Copying parts between sheets has been a gap in KiCad’s functionality for a long time, but it has also been (partially) fixed in KiCad V5.1.x some time ago. If copy and paste does not work Within a Project, then you probably have some older version of KiCad and you should update to the latest stable version (V5.1.10)

If you have already made the PCB (or at least partly) then you still have a problem in KiCad V5.1.x. Copy & Paste throws away the RefDes (a.k.a “Reference” in KiCad). and it also generates new “Timestamp” values. The result is that the links between the schematic and the PCB are lost. Even if you rename the schematic, and then directly use it in another place in the hierarchy these links get lost. KiCad does something complex in the background to make it possible to include multiple instances of the same hierarchical sheet as a way to make it easy to insert a part of the schematic multiple times, and this interferes with moving parts from one sheet to another. You can move / copy the symbols and the graphics in the schematic, but not the links that maintain the connection with the footprints on the PCB. The only way I know of is to repair this manually for each schematic symbol / footprint combination.

So in the end you might as well use the regular cut and paste to move parts of a schematic through the hierarchy.

In KiCad-nightly V5.99 this has also been fixed. It has a “paste special” operation that can preserve the RefDes (a.k.a "Reference in KiCad) and then you can use the Schematic Editor / Tools / Update PCB from Schematic [F8] / Match Method: Re-associate footprints by reference during the update of the PCB.

Hello Fox and paulvdh

I had tried Fox’s method before I wrote to Forum. I tried it again. It did not work either time.

I am using 5.1.10. Upon creating the root sheet, my dialog box looks completely different from Fox’s, but the info is the same. Where does the sheet name come from? The sheet file names are the same in my root as my original flat schematic.

I tried copy and paste without success.

At this point, in the time I have spent trying to get this to work, I could have redrawn the entire schematic, and now I think that’s the solution.

Thanks to both of you for your help.

Bruce

The closest analogy (although not perfect) that I can think of off the top of my head is:
Compared to schematic symbols, the sheet name is similar to a symbol’s value. Call it what makes sense for the understanding of the circuit. The sheet file name is similar to a symbol’s asset in the library. This will point to the specific file. Multiple sheets can point to the same file like multiple symbols can point to the same asset in a library.

I’ve never tried giving two sheets the same name, but I suspect it would break. So maybe the sheet name is similar to a Ref’d in that it should be unique, but similar to a value in that it should be descriptive.

The first time you create a hierarchical sheet, you get this dialog:
image

If you enter a filename here (there is no button for a file browser) that already exists then, that file is used as the hierarchical sheet. The filename should not be the same as your project, as that is the “main” schematic file of the project.
Also note this window has a “timestamp” value. This is a unique value to identify an item in KiCad V5.1.x As a result it should not matter if you change the sheet name or the file it links to, KiCad sees it as the same hierarchical sheet if this timestamp value does not change.

The screenshot fox posted is made from KiCad-nightly V5.99, and it’s a bit naughty to do so without disclosing it. This version also defaults to the “Unknown” file and sheet names, instead of the numbers.

I do not know why it does not work for you.
As I wrote before, renaming a sheet, and then including it as a hierarchical sheet breaks the links between the schematic and the PCB, so you may as well create new sheets for your hierarchy, and then just cut a block from you main sheet, and paste it in a hierarchical sheet. It is the simplest method.

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