KICAD 10: Hierarchical Sheets and Blocks: Lay 'Em Out Once, Use 'Em Over and Over

Readers: today's post assumes you have decent knowledge of Kicad, the incredible open source EDA program. If not, this post might be pea soup. Newbies: watch a great Kicad tutorial here.  Also--previous audioDiWHY posts focusing on Kicad are here, here, here and here


I have read that good engineering is modular engineering. Is good audio synthesis modular audio synthesis? Not sure.

Our beloved schematic capture/PCB layout/simulation software has added some great features in the last few revisions making bits of previous designs reusable--a huge timesaver.  

In this post (written right after the release of Kicad 10) I'll go over this.

"Hierarchical Sheets"

....let you put subcircuits into other designs, treating the subcircuit as a "black box"--don't worry what's in the box, just enjoy what it can do....you expose I/O between your black box and main design using "hierarchical labels."
  • Because I'm lazy, I will abbreviate hierarchical sheets going forward as "HS"
  • Create a new project, this will contain your HS.
  • In the schematic (.sch file), put whatever components you want in your HS--you are creating a normal schematic at this point
  • For any and all I/O you need to share outside your HS, with other Kicad files, issue the command: "Place" > "add hierarchical labels"
  • Put the hierarchical labels in your schematic where it makes sense to do so.


  • Save the schematic.
  • Create a new parent project, in the next few steps, we are going to embed the "HS" content into it.
  • In the parent's .sch file, click on this icon on the right:

  • using this tool, draw a box inside the parent schematic. 
  • You will see a blue box...this represents the HS:



  • A properties dialog appears (if you don't see it, select the "Untitled_Sheet" and then tap the letter "e".)
  • Give the HS a name
  •  in "sheetfile" click on the folder icon and navigate to the kicad_sch file you created initially, the one that contains your HS.

  • At this point you might see dialogs about using relative filenames and something about database tables being messed up (?).  
  • Pretend you didn't see any of that and click OK twice.
  • Still in the parent schematic file, click on this icon on the right:

  • Click on the HS box; the I/O pins ("hierarchical labels") created in the the source .sch file appear in the parent schematic--they are placed sequentially
  • Create the rest of the parent schematic and wire it to your HS.
In the screenshot below I ran a DC simulation on a "parent" schematic containing the hierarchical sheet; the "black box" HS contained a single 100k resistor with an "in" and "out" label. The simulated DC voltages in dark red show that this works--the 100K resistor in the HS is hidden from view but is part of the simualtion.
This is an OC simulation--DC values--not to be confused with "OCD"
 


DESIGN BLOCKS

....allow you to create a subcircuit, save it in its own library, and import it into future designs as a group. As of Kicad 10, you can put schematic and traces into a single block. MoreSee the video here.  

Blocks are organized into libraries, same as footprints.  

Double left click on a block, drag them into your schematic, creating a group of components and wires; optionally, left click on a part in the block, grouping > ungroup items to ungroup then  edit normally.

View your Design Blocks: from the schematic editor View > panels > make sure "design blocks" is checked.... you see something like this (your block names will be different....)



To create a new block: select some or all of your design, then right click on "blocks" 




From the drop down, choose "Save Selection as Design Block"





But! Be careful about "hide library tree", if you click that, the entire blocks user interface disappears, I had to go back to view > panels > design blocks to make it reappear.  This took me a few minutes to figure out the first time I accidently hit "Hide Library Tree".

Tidbit: By clicking "New Library" you can also choose if you want the block to be visible in the current project only or globally (all projects); the default is global:


AND NOW--IT'S A WORD FROM THIS BLOG'S SPONSOR


OK, I just created some cool new thing using these new Kicad 10 tools, and need to get some PCB's made then assembled.

For this, this blog's sponsor, PCBWAY, can fabricate the PCB's, do the component assembly, and everything else.
In addition to top shelf PCB fabrication they also do fantastic work with 3D printing, injection molding, and much more.  
As always--you can help this blog by checking out the PCBWAY site.  Thank you!

BLOCKS--SCHEMATICS AND FOOTPRINTS/TRACES IN ONE BLOCK

Super useful--capture the schematic and layout of a subcircuit in a single block. This feature is new to Kicad 10 and is one of those "miss any step and the whole damn thing won't work" situationship.  

The steps:

Creating the combo block--start with the schematic:
  • Create a schematic subcircuit with all the symbols, wires and values you want in your block.
  • Tool > create associations  
  • Make sure everything is OK, that all symbols have associated footprints and so on.
  • Create a block--for this let's call it europower w traces




Nothing new so far. Schematic blocks have been around since at least Kicad 9.

Next, create the associated traces.
  • Go to PCB and update the PCB from footprint
  • The footprint appears
  • Add traces. 
  • Highlight the footprint and draw in all traces you want to include in the combo block
  • Save the selected footprint and traces (you must select both!) as a block  (right click on block > save selection as block)
  • For the block name, type in the exact same name you used for the schematic block--this is case sensitive: europower w traces
  • Kicad 10 will ask "overwrite block"?  Say YES

To use it:
  • In Schematicland, pick the block europower w traces and put it on the schematic
  • In PCBland, pick the same block europower w traces and put it on the pcb
  • Hit F8.  
  • If all goes well you won't see a new footprint appear--the PCB and the schematic are "synced".
  • If you messed up, a new footprint will appear with no traces.  
  • Did you miss a step?




To edit it:
  • Select either PCB or Schematic version of the block
  • Right clock inside the block and say Grouping > ungroup
  • Edit.
Before



After: now it's editable components like everything else in the schematic.


Tidbit: I noticed when upgrading Kicad 9 > 10 I had to set the global blocks path manually.  Preferences > Manage Design Block libraries > global libraries must look like this:


For Kicad 10.0.1, I had to set the Nickname, the "Library Path" (where the global block libraries are stored--the local location might vary if you are using a cloud repo on different hosts), and the Library Format (pulldown to "Kicad") by hand for this to work. Not sure why I this didn't come over with the rest of my preferences.  

OUTTRO

Rapid 1/2" tape cut.  

No comments:

Post a Comment