3D modeling off-the-shelf PCBs in KiCAD and designing enclosures for them.

This is a writeup of an ongoing experiment.


  Usually when ordering ready PCB modules, we rarely want to use them as-is. That's why we design enclosures for them (or better yet, find it designed by someone else and just print - but I'm not going to cover it here). When designing an enclosure, it's immensely helpful to have a model of the board to do test fittings.

  My usual approach to this problem was:
  1. find or create a 3D board for the model. Creating a model for the PCB involves:
    • copying the board outline and every relevant part of its geometry,
    • for each component on it you search GrabCAD and the like, and in case of coming up short you DIY,
    • Align every single component to the board.
  2. load it into CAD software and design the enclosure around the model.
  At the end of this process you have the enclosure that's a 100% fit for your board, because in CAD software you can spin and modify and test fit those models all you want.

  The trouble is, each part of this process can be quite labor-intensive! For PCBs costing a buck, you might feel that it's not worth the effort, and you'd be right 😊.

  In today's post I'll be offering an alternative approach that can speed this up considerably:

Designing the "schematic" in Kicad

  Here's the subject of our experiments: boost DC-DC converter with a voltmeter [LM2577 DC-DC Boost Step Up Module blabla 3A Output 3-34V to 4-35V]


  So, instead of using generic CAD software to model this PCB, why not leverage electric CAD?

  Let's get started by downloading and installing KiCAD, creating a new project and switching to schematic editor.

  We are not going to prepare an actual schematic with connections and so on, rather just add the most relevant components to the sheet (for me, it meant the biggest ones that make up the bulk of the module).

  There was no footprint or 3d model for 3-digit 7-segment LED display that this module sports, so I'm joining 3 single 7-segs, each about the same size as 1/3 of the whole display on my PCB.

  This concludes the schematics chapter! Easy, wasn't it? Lets' switch to the PCB layout view now.

Laying out the PCB without a single trace

  This step is in the same vein as the one above - we only define the important things, everything that affects the final board look:

  1. Define the board outline on the Edge.Cuts layer. An ordinary run-of-the-mill ruler is more than enough for the rough measurements like the one we'll be doing.
  2. Arrange the components in roughly the same locations
  3. Don't forget about the mounting holes and additional silkscreen drawings.
  In between steps 1, 2 and 3 you'll be looking at 3D viewer (Alt+3) a lot, to get feedback and assess the quality and progress of your work.



  You might discover that some of the footprints you're using don't have 3D models associated with them. If that's a lot of components, it might not be worth your effort to keep modeling here - the whole advantage of modeling in KiCAD is that we get a lot of 3D models at no extra effort.

  For this boost converter, I only had to use one external 3D model for the screw terminal, but usually KiCAD is quite rich even when limited to the shipped 3D library.

Renders on top: with raytracing, bottom: no raytracing.
Which one do you like best?

Import to FreeCAD

  Now that you're satisfied with the looks of your model, it's time to import it somewhere for the more generic CAD work.

  This is where FreeCAD comes to rescue with its extremely helpful plugin called StepUp:



After installing them both, the only action that separates you from the beautiful and versatile model on the picture above is clicking the "Load KiCAD PCB" button! Having the PCB in the generic CAD software allows you to export it to any number of common formats, including but not limited to STEP and STL:



... and go from there!

Obviously that's not all - we went though all that trouble just to be able to design an enclosure for the damn thing, right?

I'd had very good results with the Ultimate Box Maker - you've probably seen a glimpse of it if you read Hackaday. It is a script for OpenSCAD that allows you generate a 3D printer-ready enclosure, and you do that simply by providing your parameters - box size, PCB size and so on (if you ever used Thingiverse Customizer, it's basically a frontend for OpenSCAD 😀 ) :


This enclosure can then be exported to STL file and test-fitted in FreeCAD before you print :

You might have noticed that the board is different from the one we started with. I'm using one of my projects for a test fit here, with a subtle difference that the PCB model comes from an actual PCB, not just a "dummy".


  If you need something more sophisticated than that - well, the remaining steps will depend on how comfortable you are with FreeCAD:

  a) Not at all: export the PCB model as STEP file, load it into your favorite CAD software and get cracking!

  b) Extremely comfortable: you don't even have to save the model you got from the .kicad_pcb file.   Just design the enclosure as you normally would, and for a test fit you just pull up the StepUp toolbar and load .kicad_pcb directly, then jiggle the board around with buttons on that same toolbar:


My take on completely designing enclosure in FreeCAD (and a first attempt at that, been using Inventor for this kind of task before):


Comparing to designing everything in general CAD software

Pros

  • Silkscreen, vias and all things inherent to PCBs - you get that for free at a single click with electric CAD.
  • KiCAD is free and does not require a license, so sharing the sources for the PCB lets everyone easily modify it - as opposed to STEP files (or, god forbid, some pricey professional software source files like SLDPRT or IPT. That bites even people with a license for one of these - suppose you have a license for Inventor but the sources are SolidWorks => hello, collection of vertices!)

Cons

  • You have to use KiCAD and FreeCAD, which might not be a con at all if you love FOSS
  • Approach might not be worth the hassle for exotic parts not included in standard KiCAD library. 

Project downloads:

  1. GrabCAD
  2. Google Drive backup

Comments