Skip to content

Instantly share code, notes, and snippets.

@pulsar256
Last active April 30, 2016 10:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pulsar256/48123988da60936c7ff81d3742b472ab to your computer and use it in GitHub Desktop.
Save pulsar256/48123988da60936c7ff81d3742b472ab to your computer and use it in GitHub Desktop.
semi-parametric 3d printed case for a 50x50 PCB
$fn=100;
// Enclosure for
// http://blog.kehribar.me/build/2015/12/06/polyphonic-fm-synthesizer-with-stm32f031.html
case(drawPart=0); // 0=box, 1=lid, 2==both
module case (
wall=1.5, // wall thickness
boardWidth=50, // board width
boardLength=50, // board length
boardHeight=1.4, // board height
holePadding=2.5, // center of the drill hole relative to the board edges
holeRadius=1.4, // drill hole radius
innerMargin=0.5, // margin, added to board dimensions, makes the inner dimensions larger * 2 in x/y
innerHeight=29, // inner height of the box, no margins or compensation for standoff heights / board height is added
standoffR=3, // standoff radius
standoffH=2, // standoff height
drawPart=0 // 0=box, 1=lid, 2==both
) {
module box() {
difference(){
// walls
translate([-(wall+innerMargin),-(wall+innerMargin),-wall]) {
cube ([
boardWidth+(2*wall)+(innerMargin*2),
boardLength+(2*wall)+(innerMargin*2),
innerHeight+1*wall]);
}
translate([-(innerMargin),-(innerMargin),0]) {
cube ([boardWidth+(innerMargin*2),boardLength+(innerMargin*2),innerHeight+1]);
}
/**
* Holes for MIDI, Power and Jacks are hardcoded, it will depend on the socket types you use
* and the general design.
*/
// midi socket
translate([6.5+innerMargin,-(innerMargin+wall+1),boardHeight+standoffH+1]) cube([19,25,19]);
// usb socket
translate([35+innerMargin,-(innerMargin+wall+1),innerHeight-5]) cube([9,10,6]);
// jacks
translate([boardLength-1,boardWidth/1.5,innerHeight-innerHeight/3]) {
rotate([90,0,90]) {
translate([-8,0,0])cylinder(h=10,r=4.5);
translate([8,0,0]) cylinder(h=10,r=4.5);
}
}
}
// standoffs
translate([holePadding+innerMargin, holePadding+innerMargin,0])
standoff(standoffH, standoffR, holeRadius);
translate([boardWidth-holePadding-innerMargin, holePadding+innerMargin,0])
standoff(standoffH, standoffR, holeRadius);
translate([holePadding+innerMargin, boardLength-holePadding-innerMargin,0])
standoff(standoffH, standoffR, holeRadius);
translate([boardWidth-holePadding-innerMargin, boardLength-holePadding-innerMargin,0])
standoff(standoffH, standoffR, holeRadius);
}
module lid() {
translate([+ boardWidth + innerMargin*2 + wall * 2 + 5,0,0]) {
translate([-(wall+innerMargin),-(wall+innerMargin),-wall]) {
cube ([boardWidth+(2*wall)+(innerMargin*2),boardLength+(2*wall)+(innerMargin*2),wall]);
}
translate([-innerMargin,-innerMargin,0])
cube ([boardWidth+(innerMargin*2),boardLength+(innerMargin*2),wall]);
}
}
if (drawPart == 0 || drawPart == 2) box();
if (drawPart == 1 || drawPart == 2) lid();
}
module standoff(standoffH, standoffR, holeRadius) {
difference(){
cylinder(h=standoffH,r=standoffR);
cylinder(h=standoffH,r=holeRadius);
}
}
@pulsar256
Copy link
Author

2016-04-29 21_04_26-case scad - openscad

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment