Circuit Board Case, a CAD Tutorial for Beginners
by amamitof7 in Design > Software
360 Views, 1 Favorites, 0 Comments
Circuit Board Case, a CAD Tutorial for Beginners
In this tutorial, we make a 3D printable case for a circuit board. The board slides into the case, and a separate front wall slides in too. The case also has a bracket to hold a 9V battery, a hole to insert a power switch, and rails to hold an optional top lid.
This tutorial is an introduction to CAD (computer aided design) software. It is for people with no, or very little, CAD or 3D printing experience. This is a good first project because everything is based on rectangles. CAD can handle complicated angles and curves, but they aren't needed in this project. Also, only a few of CAD's many features are used here.
The purpose of this tutorial is to introduce two very useful pieces of software, FreeCAD and PrusaSlicer. We'll use FreeCAD to draw the design, and we'll use PrusaSlicer to convert it into g-code which 3D printers interpret. FreeCAD may not be the most powerful CAD software, but it has one big advantage over some other options. It is openly available for computers of multiple operating systems. Because FreeCAD and PrusaSlicer are openly available, there are not obstacles to experimenting with them.
Another purpose of this tutorial is to show you how to draw a 3D case for a circuit board that is 3D printable. This design is sized to fit a standard solderable perfboard. However, the design can be modified to fit boards of other sizes.
Supplies
Before you begin, install both FreeCAD and PrusaSlicer. FreeCAD version 1.0.2 was used in developing this tutorial. (Hint for Ubuntu Linux users: install both with snap, not a apt. If you mistakenly try to install with apt, see here for undoing it.)
In this tutorial is for a CAD drawing, so no hardware is necessary. The design is made to fit the components listed below. If your circuit board, switch, or battery are a different size, modify the design as needed. This design is intended to be relatively simple, so add other features to fit your particular circuit too.
- Digikey solderable perfboard, 81.3 mm x 50.8 mm x 1.6 mm
- Switch, 30.5 mm x 13.5 mm x 28 mm
- 9V battery, 48.5 mm x 26.5 mm x 17.5 mm.
The back and bottom of the case have a wall thickness of 3 mm. The left and right of the case have a wall thickness of 5mm. These walls are a bit thicker to allow room for the circuit board and front piece to slide in. The separate front piece that slides in has a thickness of 2.5 mm. It also acts as a name plate. The optional top cover is assumed to have dimensions 81.3 mm x 50.8 mm x 3.2 mm. If you want to be able to view your circuit, try cutting it from a piece of transparent 1/8” Lexan.
Note: I made some minor changes between the design detailed above and the version I printed. I moved the switch to the opposite face, I changed the details of the rails for the lid, and I added the 2026 on the front wall.
The FreeCAD User Interface
To make a solid shape using CAD, you often start with a 2D sketch. Then, you extrude that sketch to make a Pad. Alternatively, start with a solid shape and a 2D sketch, and then you can make a Pocket by extending that shape into the solid thereby removing material.
When you first open FreeCAD and create a new Part, you end up in the Part Design Workbench. You can highlight a plane or surface and create a Sketch on it. You will then be in the Sketcher Workbench. You can tell which view you are in by looking at the Workbench Selector, illustrated in the figure above.
Let's look at some icons we'll use. FreeCAD is a powerful tool, and it has many more features and options than we'll use in this tutorial. If you start with a 2D sketch and want to extend it into a 3D solid, use the Pad icon. If you start with a solid and a 2D sketch and want to remove material, use the Pocket icon. If you start with a solid and a reference plane, the Mirrored icon will make a new version of that solid reflected over that reference plane. The Create Datum Plane icon makes reference planes.
You can zoom in and out using the scroll wheel on your mouse. You can change your viewpoint on the part either by clicking on the viewpoint tool in the upper right or by right clicking and selecting options under Standard Views. Notice the viewpoint tool on the upper right labels the top, bottom, front, back, left, and right faces.
Pads and Pockets
Let's start by making a solid part then hollowing it out with two pockets.
- Open FreeCAD. Go to File → New to create a new Part, and save your project.
- Next we'll create a solid rectangle of dimensions 63 mm x 90 mm x 75 mm.
- First create a sketch containing a 63 mm x 90 mm rectangle. Go to Sketch → Create New Sketch and position it on the XY plane.
- Select the Create Rectangle icon. Draw a rectangle with one corner on the origin. Notice that the cursor changes shape when you are near the origin or other reference point.
- Your rectangle should be 90 mm in the X direction and 63 mm in the Y direction. You can specify these dimensions by typing them in as you create the rectangle. Alternatively, you can make a rectangle of arbitrary size and adjust the length. To do so, select a horizontal edge of the rectangle, right click, select Constrain Horizontal, and specify the length. Repeat for a vertical edge by selecting Constrain Vertical too.
- Make sure you have specified enough information in your sketch. To do so, look at the top of the Tasks tab on the left. You should see a message that says your sketch is Fully Constrained. Close the Sketcher Workbench to return to the Part Design Workbench.
- Now, we'll use this 2D sketch to make a 3D solid. Click on the Pad icon. In the window that pops up, choose a length of 75 mm. Select OK, and you should see the 63 x 90 x 75 mm rectangular solid.
- Next, we'll create a pocket that hollows the solid out to form our shell-like case.
- Sketches are always specified with respect to some axis plane or other surface. We'll draw a sketch on the top surface of our solid. Click on the top face to highlight it. Then, choose Sketch → Create Sketch.
- Again we'll draw a rectangle. However, this time we don't want it touching the origin. Instead, we want a corner at X=5 mm and Y=87 mm. Select the Create Point icon, and put a point approximately at this location. Right click on the point, select Dimension → Constrain Horizontal Dimension, and set the value to 87 mm. Right click on the point again, select Dimension → Constrain Vertical Dimension, and set the value to 5 mm.
- Select the Create Rectangle icon. Then, draw a rectangle with one corner at this reference point and dimensions 53 mm x 87 mm. As above, you can specify the dimensions either as you draw the rectangle or by constraining the horizontal and vertical dimensions.
- Again look for the message Fully Constrained to ensure you have adequately specified the constraints of your sketch. Close the Sketcher Workbench to return to the Part Design Workbench.
- Select the Pocket icon, and create a pocket that is 72 mm deep. Our case is starting to take shape.
- Next we'll make a pocket for the front wall to slide in.
- Again highlight the top face, which now looks U-shaped. Choose Sketch → Create Sketch to create a a sketch on it.
- Create a reference point at x=2 mm, y=2 mm. Use the Create Point icon, put the point close to this location, then constrain its horizontal and vertical dimensions so that it is at the correct location.
- Choose the Create Rectangle icon. Use it to create a rectangle with one corner on this reference point and dimensions 59 mm x 3 mm. See the figure above. Again, you can define the size of the rectangle by typing lengths as you draw it or by right clicking and constraining the horizontal and vertical dimensions.
- Close the Sketcher Workbench to return to the Part Design Workbench.
- Create the pocket by selecting the Pocket icon and specifying a length of 73 mm.
Rails for the Circuit Board and Lid
A Datum Plane is a reference plane. We can use a datum plane when we want to draw a sketch on a surface other than an axis plane or a surface of our solid shape. This design uses two Datum Planes. The first plane is parallel to the front face but inset by 10 mm. We will use it when creating the rails that the circuit board and lid slide into. These rails do not extend the entire length from the front to back. Instead, they extend 10 mm from the front to 10 mm from the back. The second plane bisects the case. We can draw the rails on the left side then use this Datum Plane along with the Mirrored icon to quickly duplicate the rails on the right side.
- Define the first datum plane.
- Select the front face of the solid, which is U-shaped, so the plane will be created parallel to this face. Then, click on the Create Datum Plane icon.
- In the Datum Plane Parameters window on the left side, set the Attachment Offset in the z-direction to -10 mm.
- Select OK to finish creating your plane.
- Define the second datum plane.
- Select the right face of the solid. Then, click on the Create Datum Plane icon.
- In the Datum Plane Parameters window on the left side, set the Attachment Offset in the z-direction to -31.5 mm.
- Select OK to finish creating your plane.
- Now we'll make the rails to slide in the circuit board and lid.
- Highlight the first datum plane you just made and create a sketch on it.
- Create a point at x=5 mm and z=37 mm. Then, create a rectangle with one corner at that point and dimensions x=4 mm by z=3 mm. See the figure above for details.
- Create a point at x=5 mm and z=42 mm. Then, create a rectangle with one corner at that point and dimensions x=4 mm by z=3 mm.
- Create a point at x=5 mm and z=62 mm. Then, create a rectangle with one corner at that point and dimensions x=4 mm by z=3 mm.
- Create a point at x=5 mm and z=69 mm. Then, create a rectangle with one corner at that point and dimensions x=4 mm by z=3 mm.
- Close the Sketcher Workbench to return to the Part Design Workbench.
- Select the Pad icon and a length of 70 mm to create the rails. When creating the pad, check the Reverse Direction box so the rails stay inside the case.
- Next, we'll mirror these rails onto the right side. In the Model tab on the left of the screen, highlight the pad you just made. In my example, it is named Pad001. It should be at the bottom of the list. Then, select the Mirrored icon. In the Task tab on the left side, you will see a place to enter Mirrored Parameters. Under the Plane option, choose Select Plane, and then highlight the datum plane you made that bisects the case.
- Select OK to finish mirroring the shape.
Make the Switch Hole and Battery Bracket
No new techniques are introduced in this section. We just use Pad and Pocket to add some additional features to the design. Let's jump in.
- Let's make a hole to insert the switch.
- Select the right face and create a sketch on it.
- Create a point at y= 10 mm and z=10 mm.
- Create a rectangle with one corner at that reference point of dimensions y = 30 mm and z = 14 mm.
- Close the Sketcher Workbench to return to the Part Design Workbench.
- Select the Pocket icon with a length of 5 mm to create the hole.
- Next, let's make the bracket that holds the battery.
- This time, select the back face, and create a new sketch on it.
- Create a point at x= -32 mm and z=3 mm.
- Create a rectangle with one corner at that reference point of dimensions x=3 mm mm and z = 24 mm.
- Create a point at x= -27 mm and z=24 mm.
- Create a rectangle with one corner at that reference point of dimensions x=5 mm mm and z = 3 mm.
- Close the Sketcher Workbench to return to the Part Design Workbench.
- Select the Pad icon with a length of 35 mm.
Converting to STL Format
We have basically finished the case design. However, we have a few more steps. FreeCAD stores files in its own format, with extension .FCstd. The next step is to export the design to the more common .stl format which PrusaSlicer accepts.
- In the Model tab on the left, select Pad002, or whatever part the lowest in the list. You should see the entire case highlighted.
- Go to File → Export. Select .stl file format and save your file with a .stl extension.
Make the Front Wall
We're not quite done. Next, let's make the front wall that slides in to the case.
- Create a completely new part, and save it.
- Create a sketch in the XY plane. In that sketch, create a rectangle of dimensions 73 mm x 58.5 mm with one corner on the origin. Close the Sketcher Workbench to return to the Part Design Workbench.
- Select the Pad icon with a length of 2.5mm. This thickness should fit nicely into the 3 mm pocket of the case we created earlier.
- Let's add some text to it.
- Copy a font file into the same directory as your part. See here for operating system specific instructions on this step or download a font from here. (I used /usr/share/fonts/truetype/freefont/FreeSansBold.ttf, which I found on my Ubuntu Linux machine.)
- Select Draft in the Workbench Selector.
- Click on the Shape From Text icon.
- You will see a ShapeString Parameters window on the left. In the box labeled String, insert your text. I used 2026. Additionally, set x to 0 mm, y to 0 mm, z to 0 mm, height to 5mm, and select your font file. Click OK to create your ShapeString.
- Use the Workbench Selector to go back to the Part Design workbench.
- You should see a ShapeString in your Model tab on the left. In that tab, drag it under Body. You will see it indent in the list. Next still in the Model tab, click on the ShapeString to get more options for it.
- Click on MapMode to get to the Attachment Properties window. Click on the top face of your solid as the Attachment Mode. Also, set the Attachment Offset in the x direction to 10 mm and in the y direction to 10 mm. Select OK to finish.
- Select the Pocket icon and use a length of 1 mm to get your string into the solid. We have finished the design of the piece.
- As with the main case, export this design to .stl format.
Slicing With Prusa Slicer
PrusaSlicer accepts CAD designs in .stl and other formats and converts them to g-code which can be interpreted by a 3D printer. The resulting g-code is specific to a particular printer and for a particular filament.
- Determine the model of the 3D printer you intend to use, and determine the filament you will use. (I used an Original Prusa i3 MK3S printer with a 0.4 mm nozzle along with PLA filament. Use whatever matches your resources.)
- Open PrusaSlicer.
- On the right side, select your printer and filament. (I used the Generic PLA filament option.) Use the Printer → Add/Remove Presets to select your printer.
- Use the Add icon on the top ribbon to insert the case. Make sure the part has a logical location and orientation. To alter the location or orientation, click and drag it or use the icons on the left ribbon.
- Repeat the step above to insert front wall too.
- If you intend to use fill material, insert it now. Fill material is not necessary.
A 3D printer adds material in layers. For this reason, it has trouble printing overhangs, areas with no material vertically beneath. To prevent printing imperfections at overhangs, fill material is often added. PrusaSlicer is able to intelligently add fill material.
The front wall does not have any overhangs. The main case has some small overhangs, though. It has overhangs near the switch hole, beneath the rails for the circuit board and lid, and near the battery bracket. However, these overhangs are relatively small. For simplicity in this tutorial, I chose not to use fill material. The final print had some imperfections in these locations. However, the imperfections were quite minor and completely internal to the case.
- Select Slice Now, in the lower right.
- Select Export G-Code, also in the lower right.
- Transfer the file to your 3D printer. It is ready to print.