/* [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 = 10.0; /* [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 pcb() { thickness = 1.6; color("#009900") difference() { linear_extrude(thickness) { polygon(points = [[0.0,0.0], [80.0,0.0], [80.0,100.0], [0.0,100.0], [0.0,0.0]]); } translate([8.5, 12, -1]) cylinder(thickness+2, 1.5999999999999996, 1.5999999999999996); translate([71.5, 5, -1]) cylinder(thickness+2, 1.5999999999999996, 1.5999999999999996); translate([5, 95, -1]) cylinder(thickness+2, 1.5999999999999943, 1.5999999999999943); translate([71.5, 70, -1]) cylinder(thickness+2, 1.5999999999999943, 1.5999999999999943); } } module case_outline() { polygon(points = [[-4.0,-4.0], [84.0,-4.0], [84.0,104.0], [-4.0,104.0]]); } 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([-40.0, -50.0, 0]) { pcb_top = floor_height + standoff_height + pcb_thickness; difference() { box(wall_thickness, floor_height, inner_height) { case_outline(); } // J5 TerminalBlock_Phoenix_MPT-0,5-2-2.54_1x02_P2.54mm_Horizontal TerminalBlock_Phoenix_MPT-0,5-2-2.54_1x02_P2.54mm_Horizontal translate([38.73, 95.9, pcb_top]) rotate([0, 0, 0]) #connector(-2,-3.6,4.54,11.6,10.2); } if (show_pcb && $preview) { translate([0, 0, floor_height + standoff_height]) pcb(); } if (render == "all" || render == "case") { // MH1 [('M3', 3)] translate([8.5, 12, floor_height]) mount(3.2, 5.2, standoff_height) Insert_M3(); // MH2 [('M3', 3)] translate([71.5, 5, floor_height]) mount(3.2, 5.2, standoff_height) Insert_M3(); // MH3 [('M3', 3)] translate([5, 95, floor_height]) mount(3.2, 5.2, standoff_height) Insert_M3(); // MH4 [('M3', 3)] translate([71.5, 70, floor_height]) mount(3.2, 5.2, standoff_height) Insert_M3(); } }