/* [Rendering options] */ // Show placeholder PCB in OpenSCAD preview show_pcb = false; // Lid mounting method lid_model = "cap"; // [cap, inner-fit] // Conditional rendering render = "case"; // [all, case, lid] /* [Dimensions] */ // Height of the PCB mounting stand-offs between the bottom of the case and the PCB standoff_height = 5.0; // PCB thickness pcb_thickness = 1.6; // Bottom layer thickness floor_height = 1.2; // Case wall thickness wall_thickness = 1.2; // Space between the top of the PCB and the top of the case headroom = 8.5; /* [M3 screws] */ // Outer diameter for the insert insert_M3_diameter = 3.77; // Depth of the insert insert_M3_depth = 4.5; /* [Hidden] */ $fa=$preview ? 10 : 4; $fs=0.2; inner_height = floor_height + standoff_height + pcb_thickness + headroom; module wall (thickness, height) { linear_extrude(height, convexity=10) { difference() { offset(r=thickness) children(); children(); } } } module bottom(thickness, height) { linear_extrude(height, convexity=3) { offset(r=thickness) children(); } } module lid(thickness, height, edge) { linear_extrude(height, convexity=10) { offset(r=thickness) children(); } translate([0,0,-edge]) difference() { linear_extrude(edge, convexity=10) { offset(r=-0.2) children(); } translate([0,0, -0.5]) linear_extrude(edge+1, convexity=10) { offset(r=-1.2) children(); } } } module box(wall_thick, bottom_layers, height) { if (render == "all" || render == "case") { translate([0,0, bottom_layers]) wall(wall_thick, height) children(); bottom(wall_thick, bottom_layers) children(); } if (render == "all" || render == "lid") { translate([0, 0, height+bottom_layers+0.1]) lid(wall_thick, bottom_layers, lid_model == "inner-fit" ? headroom-2.5: bottom_layers) children(); } } module mount(drill, space, height) { translate([0,0,height/2]) difference() { cylinder(h=height, r=(space/2), center=true); cylinder(h=(height*2), r=(drill/2), center=true); translate([0, 0, height/2+0.01]) children(); } } module connector(min_x, min_y, max_x, max_y, height) { size_x = max_x - min_x; size_y = max_y - min_y; translate([(min_x + max_x)/2, (min_y + max_y)/2, height/2]) cube([size_x, size_y, height], center=true); } module Cutout_TypeC_substract() { width = 10; length = 10; height = 3.5; translate([-length/2, 0, height/2]) rotate([0,90,0]) union() { translate([0, -(width/2 - height/2), 0]) cylinder(length, height/2, height/2); translate([0, (width/2 - height/2), 0]) cylinder(length, height/2, height/2); translate([0, 0, length/2]) cube([height, width-height, length], center=true); } } module pcb() { thickness = 1.6; color("#009900") difference() { linear_extrude(thickness) { polygon(points = [[0.0,0.0], [102.7,0.0], [102.7,91.4], [0.0,91.4], [0.0,0.0]]); } translate([1.6, 1.6, -1]) cylinder(thickness+2, 1.6, 1.6); translate([101.1, 1.6, -1]) cylinder(thickness+2, 1.6, 1.6); translate([1.6, 89.8, -1]) cylinder(thickness+2, 1.5999999999999943, 1.5999999999999943); translate([101.1, 89.8, -1]) cylinder(thickness+2, 1.5999999999999943, 1.5999999999999943); } } module case_outline() { polygon(points = [[-5.0,-5.0], [107.7,-5.0], [107.7,96.4], [-5.0,96.4]]); } module Insert_M3() { translate([0, 0, -insert_M3_depth]) cylinder(insert_M3_depth, insert_M3_diameter/2, insert_M3_diameter/2); translate([0, 0, -0.3]) cylinder(0.3, insert_M3_diameter/2, insert_M3_diameter/2+0.3); } rotate([render == "lid" ? 180 : 0, 0, 0]) scale([1, -1, 1]) translate([-51.35, -45.7, 0]) { pcb_top = floor_height + standoff_height + pcb_thickness; difference() { box(wall_thickness, floor_height, inner_height) { case_outline(); } // J10 Hirose_FH12-15S-0.5SH_1x15-1MP_P0.50mm_Horizontal Hirose_FH12-15S-0.5SH_1x15-1MP_P0.50mm_Horizontal translate([9.5, 88.7, pcb_top]) rotate([0, 0, 0]) #connector(-6.81,-3,6.81,13.9,2.7); // J5 PinHeader_2x05_P2.54mm_Vertical PinHeader_2x05_P2.54mm_Vertical translate([45.5, 80.19, pcb_top]) rotate([0, 0, 0]) #connector(-1.77,-1.77,4.32,20.93,8.7); // J6 HDMI_A_Amphenol_10029449-x01xLF_Horizontal translate([9.5, 5.495, pcb_top]) rotate([0, 0, -180.0]) #connector(-9.25,-6.45,9.25,14.0,6.2); // J8 USB_C_Receptacle_HRO_TYPE-C-31-M-12 translate([45.5, 2.05, pcb_top]) rotate([0, 0, -180.0]) #connector(-5.32,-5.27,5.32,13.15,3.7); // Substract: Hole to fit the plug of a Type-C connector translate([45.5, -5.0, pcb_top]) rotate([0, 0, -270.0]) Cutout_TypeC_substract(); } if (show_pcb && $preview) { translate([0, 0, floor_height + standoff_height]) pcb(); } if (render == "all" || render == "case") { // TC_MH1 [('M3', 3)] translate([1.6, 1.6, floor_height]) mount(3.2, 8.0, standoff_height) Insert_M3(); // TC_MH2 [('M3', 3)] translate([101.1, 1.6, floor_height]) mount(3.2, 8.0, standoff_height) Insert_M3(); // TC_MH3 [('M3', 3)] translate([1.6, 89.8, floor_height]) mount(3.2, 8.0, standoff_height) Insert_M3(); // TC_MH4 [('M3', 3)] translate([101.1, 89.8, floor_height]) mount(3.2, 8.0, standoff_height) Insert_M3(); } }