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

Readers: today's post assumes you have a working knowledge of Kicad, an incredible open source EDA program. If not, this post might be pea soup. Newbies: watch a great Kicad tutorial here.  And--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.

Kicad--our beloved schematic capture/PCB layout/simulation software--has recently added some great features in making bits of your previous designs reusable--a huge timesaver.  

Let's 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 I/O you need to share outside your HS issue the command: "Place" > "add hierarchical labels"


  • Save the schematic.
Next--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, 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 a hierarchical sheet; the HS contained a single 100k resistor with "in" and "out" labels. 

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. 

This feature showed up in Kicad 9 (See the video here). 

With Kicad 10, you can put schematic symbols/wires and PCB traces into a single design block.

And--again, due to indolence/laziness, I will call "design blocks" going forward "blocks". Have a nice day.  

Organizing blocks: Blocks are organized into libraries, same idea as Kicad symbols.  Each block is a folder containing a json description file and file(s) for the .sch and/or .pcb components.  

For both the people out there who are interested--get a zip of my custom blocks from Github, here.

Creating a 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 block's user interface section disappears. This threw me at first. I had to go back to view > panels > design blocks to make it reappear.  
 
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:


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


Using existing blocksDouble left click on a block, drag it into your schematic, creating a group of components and wires.

Editing blocks:

  • Select either PCB 
  • Right clock inside the block and say Grouping > ungroup
  • Edit.

Before



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


NOW: A WORD FROM THIS BLOG'S SPONSOR

OK, you just created something awesome using these new Kicad 10 tools and need to get some PCB's, then get them assembled.

For this, check out this blog's sponsor, PCBWAY, who can fabricate the PCB's, do the component assembly, and then, do everything else.

In addition to top shelf PCB fabrication they also do fantastic work with 3D printing, injection molding, and much more. 

And!!! Kicad Mavens (you must be if you've made it this far?): run, don't walk, and submit your Kicad masterpiece to PCBWAY'S Kicad PCB Design Contest--winners get cash and/or RPi goodies. Check out the contest here.

As always--you can help this blog by checking out the PCBWAY site.  Thank you!


SCHEMATICS AND FOOTPRINTS/TRACES IN ONE BLOCK--New to Kicad 10--How To Do This

Super useful--capture the schematic and layout of a subcircuit in a single block. However--work slowly and carefully. This feature is one of those "miss any step and the whole damn thing won't work" situation.  

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




Next, create the associated traces.
  • Go to PCB and update the PCB from footprint
  • The footprint appears
  • 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: in this case, "europower w traces"
  • Kicad 10 will ask "overwrite block"?  Say YES

To use it:
  • In your schematic, pick the block europower w traces and put it on the schematic
  • In your PCB, pick the same block europower w traces and put it on the pcb
  • Hit F8.  
  • If all goes well you will see a footprint with traces appear--the PCB and the schematic are "synced"--it's all wired up.
  • If you messed up, a new footprint will appear with no traces. Fiddlesticks! Try again, make sure to follow each step.
  • You can now grouping > ungroup your Schematic or PCB block and change things.  





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


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 this didn't come over with the rest of my preferences.  

OUTTRO

Think "She's so Heavy": another brilliant John Lennon time signature change, with rapid master tape cut.  

No comments:

Post a Comment