//What entities do you need? Render_now = "both"; // [both, box_only, cap_only] // PCB Dimensions PCB_X_Dimension = 55.30;// mm [1:200] PCB_Y_Dimension = 39.70;// mm [1:200] PCB_Width = 1.6; // mm [0.4:0.1:4] // Extra space around PCB in X and Y PCB_Extra_Space = 0.6; // mm [0.4:0.1:2] // Space below the PCB, left it as 0 if you don't need PCB holder PCB_Bottom_Space = 4; // mm [1:10] // Space above the PCB inside the box PCB_Top_Space = 18; // mm [1:60] // Box wall width in bottom and sides Wall_Width = 2.0; // [1:0.1:4] // Box wall width in cap Cap_Width = 1.5; // [1:0.1:4] /* [ PCB Holder pads ] */ // Set true if you need cap holder With_PCB_Holder = true; // PCB holders size in corners, X and Y too PCB_Holder_Size = 6.35; // mm [1:20] // PCB holder's screw diameter PCB_Holder_Hole_Diameter = 2.7; // mm [2:0.5:4] /* [ Cap Holder ] */ // Set true if you need cap holder With_Cap_Holder = true; // Cap holder's screw diameter in box Cap_Holder_Hole_Diameter = 2.7; // mm [2:0.5:4] // Cap holder's screw diameter in cap Cap_Holder_Hole_Diameter_Cap = 3.7; // mm [2:0.5:4] // How many bigger the cap holder than the screw in it Cap_Holder_Size_Multipleter = 4.0; // mm [2:0.5:6] /* [ Wall Mount Points ] */ // Set true if you need 2 wall mount points With_Double_Wall_Mount_Points = true; // Set true if you need 4 wall mount points With_Quad_Wall_Mount_Points = false; // Wall mount point's screw diameter Wall_Mount_Hole_Diameter = 4.0; // mm [2:0.5:4] // Wall mount point height (thickness) Wall_Mount_Height = 4; // mm 1 to 10 // How many bigger the wall mount point than the screw in it Wall_Mount_Size_Multipleter = 3.5; // mm [2:0.5:4] /* [ Hexa ventilation holes ] */ Hexa_Hole_Diameter = 2; // mm [1:10] Hexa_Hole_In_X = 10; // mm [1:10] Hexa_Hole_In_Y = 8; // mm [1:10] Hexa_Hole_Wall = 2.4; // mm [1:0.2:5] /* [ cut-outs ] */ // settings of types of cut-outs // Height , width , extra // RJ12 connector 15.5 , 14.5 , 0 // USB-B connector 6.5 , 10.5 , 0 // Power connector 11.5 , 9.5 , 0 // Terminal 2 pol. 10.5 , 10.7 , 0 // Terminal 3 pol. 10.5 , 15.8 , 0 // Terminal 4 pol. 10.5 , 20.9 , 0 // Terminal 6 pol. 10.5 , 32.5 , 0 // cut-out Example // use_cut_out_x = True is use cutout // cut_x_split = True is hole till top, extra blok on cap // cut_x_position = position of cut-out from the middle // cut_x_side = side of the box // 1= front, 2=right, 3=back, 4= left // cut_x_height = height of the cut-out // cut_x_width = width of the cut-out // cut_x_extra = extra space above pcb, 0 is direct on the pcb // cut-out 1 Power connector use_cut_out_1 = false; cut_1_type = "square"; //[square, round] cut_1_split = true; cut_1_position = 15.56; cut_1_side = 1; cut_1_height = 11.5; cut_1_width = 9.5; cut_1_extra = 0; cut_1_cap = PCB_Top_Space - cut_1_height; // cut-out 2 Terminal 2 polig use_cut_out_2 = true; cut_2_type = "square"; //[square, round] cut_2_split = true; cut_2_position = 2.22; cut_2_side = 1; cut_2_height = 10.5; cut_2_width = 10.7; cut_2_extra = 0; cut_2_cap = PCB_Top_Space - cut_2_height; // cut-out 3 RJ12 Connector use_cut_out_3 = true; cut_3_type = "square"; //[square, round] cut_3_split = true; cut_3_position = -13.02; cut_3_side = 1; cut_3_height = 15.5; cut_3_width = 14.5; cut_3_extra = 0; cut_3_cap = PCB_Top_Space - cut_3_height; // cut-out 4 Temp Sensor use_cut_out_4 = true; cut_4_type = "round"; //[square, round] cut_4_split = false; cut_4_position = 20; cut_4_side = 1; cut_4_height = 3.5; cut_4_width = 3.5; cut_4_extra = 10; cut_4_cap = PCB_Top_Space - cut_4_height; // cut-out 5 use_cut_out_5 = false; cut_5_type = "square"; //[square, round] cut_5_split = false; cut_5_position = 0; cut_5_side = 1; cut_5_height = 0; cut_5_width = 0; cut_5_extra = 0; cut_5_cap = PCB_Top_Space - cut_5_height; module hide() {} // With this extra space you can be sure there is // no space between different elements, and your // slicer will be work properly Fix_STL_Build_Issue = .05; // If you want render the two object in one step // how many distance should be keep between them Spacer_between_objects = 10; // Precounted value // Outside of the Box X Outside_X = PCB_X_Dimension + 2 * (PCB_Extra_Space + Wall_Width); // Outside of the Box Y Outside_Y = PCB_Y_Dimension + 2 * (PCB_Extra_Space + Wall_Width); // Outside of the Box Z Outside_Z = Wall_Width + PCB_Bottom_Space + PCB_Width + PCB_Top_Space; // Inside of the Box X Inside_X = PCB_X_Dimension + 2 * PCB_Extra_Space; // Inside of the Box Y Inside_Y = PCB_Y_Dimension + 2 * PCB_Extra_Space; // Inside of the Box Z Inside_Z = PCB_Bottom_Space + PCB_Width + PCB_Top_Space; //Module Base Box module BaseBox() { difference() { translate([ 0, 0, Outside_Z/2]) cube([Outside_X, Outside_Y, Outside_Z], true); translate([ 0, 0, Outside_Z/2 + Wall_Width]) cube([Inside_X, Inside_Y, Inside_Z], true); } } // Module Base top Box module TopBox() { translate([ 0, 0, Cap_Width/2]) cube([Outside_X, Outside_Y, Cap_Width], true); translate([ 0, 0, Cap_Width/2 + 1]) cube([Inside_X - 0.5, Inside_Y - 0.5, 1], true); } // cut-outs module to make cut-out module cut_out(cut_width, cut_height, cut_extra, cut_position, cut_side, cut_split, cut_cap) { if (!cut_split) { if (cut_side == 1) { translate ([ cut_position , PCB_Y_Dimension / 2 + PCB_Extra_Space , PCB_Width + PCB_Bottom_Space + Wall_Width + cut_extra + cut_height / 2 ]) cube ([ cut_width, Wall_Width * 2 , cut_height ], center = true); }; if (cut_side == 2) { translate ([ -(PCB_X_Dimension / 2 + PCB_Extra_Space) , cut_position , PCB_Width + PCB_Bottom_Space + Wall_Width + cut_extra + cut_height / 2 ]) rotate ([0,0,90]) cube ([ cut_width, Wall_Width * 2 , cut_height ], center = true); }; if (cut_side == 3) { translate ([ cut_position , -(PCB_Y_Dimension / 2 + PCB_Extra_Space) , PCB_Width + PCB_Bottom_Space + Wall_Width + cut_extra + cut_height / 2 ]) cube ([ cut_width, Wall_Width * 2 , cut_height ], center = true); }; if (cut_side == 4) { translate ([ PCB_X_Dimension / 2 + PCB_Extra_Space , cut_position , PCB_Width + PCB_Bottom_Space + Wall_Width + cut_1_extra + cut_height / 2 ]) rotate ([0,0,90]) cube ([ cut_width, Wall_Width * 2 , cut_height ], center = true); }; } if (cut_split) { if (cut_side == 1) { translate ([ cut_position , PCB_Y_Dimension / 2 + PCB_Extra_Space , PCB_Width + PCB_Bottom_Space + Wall_Width + cut_extra + PCB_Top_Space / 2 ]) cube ([ cut_width, Wall_Width * 2 , PCB_Top_Space ], center = true); }; if (cut_side == 2) { translate ([ -(PCB_X_Dimension / 2 + PCB_Extra_Space) , cut_position , PCB_Width + PCB_Bottom_Space + Wall_Width + cut_extra + PCB_Top_Space / 2 ]) rotate ([0,0,90]) cube ([ cut_width, Wall_Width * 2 , PCB_Top_Space ], center = true); }; if (cut_side == 3) { translate ([ cut_position , -(PCB_Y_Dimension / 2 + PCB_Extra_Space) , PCB_Width + PCB_Bottom_Space + Wall_Width + cut_extra + PCB_Top_Space / 2 ]) cube ([ cut_width, Wall_Width * 2 , PCB_Top_Space ], center = true); }; if (cut_side == 4) { translate ([ PCB_X_Dimension / 2 + PCB_Extra_Space , cut_position , PCB_Width + PCB_Bottom_Space + Wall_Width + cut_1_extra + PCB_Top_Space / 2 ]) rotate ([0,0,90]) cube ([ cut_width, Wall_Width * 2 , PCB_Top_Space ], center = true); }; } } module cut_round (cut_width, cut_extra, cut_position, cut_side) { if (cut_side == 1) { translate ([ cut_position , PCB_Y_Dimension / 2 + PCB_Extra_Space + Wall_Width/2, PCB_Width + PCB_Bottom_Space + Wall_Width + cut_extra]) rotate ([90, 0, 0]) cylinder ( h = Wall_Width, d = cut_width, $fn = 50, center = true); }; if (cut_side == 2) { translate ([ PCB_X_Dimension / -2 - PCB_Extra_Space - Wall_Width/2, cut_position, PCB_Width + PCB_Bottom_Space + Wall_Width + cut_extra]) rotate ([90, 0, 90]) cylinder ( h = Wall_Width, d = cut_width, $fn = 50, center = true); }; if (cut_side == 3) { translate ([ cut_position , PCB_Y_Dimension / -2 - PCB_Extra_Space - Wall_Width/2, PCB_Width + PCB_Bottom_Space + Wall_Width + cut_extra]) rotate ([90, 0, 0]) cylinder ( h = Wall_Width, d = cut_width, $fn = 50, center = true); }; if (cut_side == 4) { translate ([ PCB_X_Dimension / 2 + PCB_Extra_Space + Wall_Width/2, cut_position, PCB_Width + PCB_Bottom_Space + Wall_Width + cut_extra]) rotate ([90, 0, 90]) cylinder ( h = Wall_Width, d = cut_width, $fn = 50, center = true); }; } module cutouts() { // module to select witch cut-outs if ((use_cut_out_1) && (cut_1_type == "square")) { cut_out ( cut_1_width, cut_1_height, cut_1_extra, cut_1_position, cut_1_side, cut_1_split, cut_1_cap); } if ((use_cut_out_1) && (cut_1_type == "round")) { cut_round ( cut_1_width, cut_1_extra, cut_1_position, cut_1_side); } if ((use_cut_out_2) && (cut_2_type == "square")) { cut_out ( cut_2_width, cut_2_height, cut_2_extra, cut_2_position, cut_2_side, cut_2_split, cut_2_cap); } if ((use_cut_out_2) && (cut_1_type == "round")) { cut_round ( cut_2_width, cut_2_extra, cut_2_position, cut_2_side); } if ((use_cut_out_3) && (cut_3_type == "square")){ cut_out ( cut_3_width, cut_3_height, cut_3_extra, cut_3_position, cut_3_side, cut_3_split, cut_3_cap); } if ((use_cut_out_1) && (cut_3_type == "round")) { cut_round ( cut_3_width, cut_3_extra, cut_3_position, cut_3_side); } if ((use_cut_out_4) && (cut_4_type == "square")){ cut_out ( cut_4_width, cut_4_height, cut_4_extra, cut_4_position, cut_4_side, cut_4_split, cut_4_cap); } if ((use_cut_out_4) && (cut_4_type == "round")) { cut_round ( cut_4_width, cut_4_extra, cut_4_position, cut_4_side); } if ((use_cut_out_5) && (cut_5_type == "square")) { cut_out ( cut_5_width, cut_5_height, cut_5_extra, cut_5_position, cut_5_side, cut_5_split, cut_5_cap); } if ((use_cut_out_5) && (cut_5_type == "round")) { cut_round ( cut_5_width, cut_5_extra, cut_5_position, cut_5_side); } } module cap_stand(cut_width, cut_height, cut_extra, cut_position, cut_side, cut_cap) { if (cut_side == 1) { translate ([ cut_position , -(PCB_Y_Dimension / 2 + PCB_Extra_Space) , Cap_Width + cut_cap / 2 ]) cube ([ cut_width, Wall_Width * 2 , cut_cap ], center = true); } if (cut_side == 2) { translate ([ -(PCB_X_Dimension / 2 + PCB_Extra_Space) , cut_position , Cap_Width + cut_cap / 2 ]) rotate ([0,0,90]) cube ([ cut_width, Wall_Width * 2 , cut_cap ], center = true); }; if (cut_side == 3) { translate ([ cut_position , PCB_Y_Dimension / 2 + PCB_Extra_Space , Cap_Width + cut_cap / 2 ]) cube ([ cut_width, Wall_Width * 2 , cut_cap ], center = true); }; if (cut_side == 4) { translate ([ PCB_X_Dimension / 2 + PCB_Extra_Space , cut_position , Cap_Width + cut_cap / 2 ]) rotate ([0,0,90]) cube ([ cut_width, Wall_Width * 2 , cut_cap ], center = true); }; } module capstands() { // module to select witch cap stands if ((use_cut_out_1) && (cut_1_split)) { cap_stand ( cut_1_width, cut_1_height, cut_1_extra, cut_1_position, cut_1_side, cut_1_cap); } if ((use_cut_out_2) && (cut_2_split)) { cap_stand ( cut_2_width, cut_2_height, cut_2_extra, cut_2_position, cut_2_side, cut_2_cap); } if ((use_cut_out_3) && (cut_3_split)) { cap_stand ( cut_3_width, cut_3_height, cut_3_extra, cut_3_position, cut_3_side, cut_3_cap); } if ((use_cut_out_4) && (cut_4_split)) { cap_stand ( cut_4_width, cut_4_height, cut_4_extra, cut_4_position, cut_4_side, cut_4_cap); } if ((use_cut_out_5) && (cut_5_split)) { cap_stand ( cut_5_width, cut_5_height, cut_5_extra, cut_5_position, cut_5_side, cut_5_cap); } } // PCB holders in corners module PCBHolders() { module PCBHolder() { difference() { cube([ PCB_Holder_Size + PCB_Extra_Space, PCB_Holder_Size + PCB_Extra_Space, PCB_Bottom_Space + Wall_Width ]); translate([ PCB_Holder_Size / 2 + PCB_Extra_Space, PCB_Holder_Size / 2 + PCB_Extra_Space, Wall_Width ]) cylinder( d = PCB_Holder_Hole_Diameter, h = PCB_Bottom_Space + 1, $fn = 50 ); } } translate([ PCB_X_Dimension / 2 + PCB_Extra_Space, PCB_Y_Dimension / 2 + PCB_Extra_Space, 0 ]) rotate([0, 0, 180]) PCBHolder(); translate([ -PCB_X_Dimension / 2 - PCB_Extra_Space, PCB_Y_Dimension / 2 + PCB_Extra_Space, 0 ]) rotate([0, 0, 270]) PCBHolder(); translate([ PCB_X_Dimension / 2 + PCB_Extra_Space, -PCB_Y_Dimension / 2 - PCB_Extra_Space, 0 ]) rotate([0, 0, 90]) PCBHolder(); translate([ -PCB_X_Dimension / 2 - PCB_Extra_Space, -PCB_Y_Dimension / 2 - PCB_Extra_Space, 0 ]) PCBHolder(); } // Cap holders Box module CapHolders_Box(height, hole_bottom_space) { cap_holder_size = Cap_Holder_Hole_Diameter * Cap_Holder_Size_Multipleter; module CapHolder(block_size, hole_bottom_space) { difference() { intersection() { cube([ block_size, block_size, height ]); translate([ 0, block_size / 2, 0 ]) cylinder( d = block_size, h = height, $fn = 50 ); } translate([ Cap_Holder_Hole_Diameter / 2, block_size / 2, hole_bottom_space ]) cylinder( d = Cap_Holder_Hole_Diameter, h = height, $fn = 50 ); } } translate([ Outside_X / 2 - Fix_STL_Build_Issue, Outside_Y / 2 - cap_holder_size, 0 ]) CapHolder(cap_holder_size, hole_bottom_space); translate([ Outside_X / 2 - Fix_STL_Build_Issue, -Outside_Y / 2, 0 ]) CapHolder(cap_holder_size, hole_bottom_space); translate([ -Outside_X / 2 + Fix_STL_Build_Issue, -Outside_Y / 2, 0 ]) mirror([1, 0, 0]) CapHolder(cap_holder_size, hole_bottom_space); translate([ -Outside_X / 2 + Fix_STL_Build_Issue, Outside_Y / 2 - cap_holder_size, 0 ]) mirror([1, 0, 0]) CapHolder(cap_holder_size, hole_bottom_space); } // Cap holders Cap module CapHolders_Cap(height, hole_bottom_space) { cap_holder_size = Cap_Holder_Hole_Diameter_Cap * Cap_Holder_Size_Multipleter; module CapHolder_Cap(block_size, hole_bottom_space) { difference() { intersection() { cube([ block_size, block_size, height ]); translate([ 0, block_size / 2, 0 ]) cylinder( d = block_size, h = height, $fn = 50 ); } translate([ Cap_Holder_Hole_Diameter_Cap / 2, block_size / 2, hole_bottom_space ]) cylinder( d = Cap_Holder_Hole_Diameter_Cap, h = height, $fn = 50 ); } } translate([ Outside_X / 2 - Fix_STL_Build_Issue, Outside_Y / 2 - cap_holder_size, 0 ]) CapHolder_Cap(cap_holder_size, hole_bottom_space); translate([ Outside_X / 2 - Fix_STL_Build_Issue, -Outside_Y / 2, 0 ]) CapHolder_Cap(cap_holder_size, hole_bottom_space); translate([ -Outside_X / 2 + Fix_STL_Build_Issue, -Outside_Y / 2, 0 ]) mirror([1, 0, 0]) CapHolder_Cap(cap_holder_size, hole_bottom_space); translate([ -Outside_X / 2 + Fix_STL_Build_Issue, Outside_Y / 2 - cap_holder_size, 0 ]) mirror([1, 0, 0]) CapHolder_Cap(cap_holder_size, hole_bottom_space); } // Wall mount points module WallMountPoints() { wall_mount_point_size = Wall_Mount_Hole_Diameter * Wall_Mount_Size_Multipleter; module WallMountPoint(block_size) { difference() { intersection() { cube([ block_size, block_size, Outside_Z ]); translate([ block_size / 4, block_size / 2, 0 ]) cylinder( d = block_size, h = Wall_Mount_Height, $fn = 50 ); } translate([ block_size / 4, block_size / 2, 0 ]) cylinder( d = Wall_Mount_Hole_Diameter, h = Wall_Mount_Height, $fn = 50 ); } } if (With_Quad_Wall_Mount_Points) { cap_holder_size = Cap_Holder_Hole_Diameter * Cap_Holder_Size_Multipleter; translate([ Outside_X / 2, Outside_Y / 2 - cap_holder_size / 4 * 3 - wall_mount_point_size, 0 ]) WallMountPoint(wall_mount_point_size); translate([ Outside_X / 2, -Outside_Y / 2 - cap_holder_size / 4 * 3 + wall_mount_point_size, 0 ]) WallMountPoint(wall_mount_point_size); translate([ -Outside_X / 2, Outside_Y / 2 - cap_holder_size / 4 * 3 - wall_mount_point_size, 0 ]) mirror([1, 0, 0]) WallMountPoint(wall_mount_point_size); translate([ -Outside_X / 2, -Outside_Y / 2 - cap_holder_size / 4 * 3 + wall_mount_point_size, 0 ]) mirror([1, 0, 0]) WallMountPoint(wall_mount_point_size); } if (With_Double_Wall_Mount_Points) { translate([ Outside_X / 2, -wall_mount_point_size / 2, 0 ]) WallMountPoint(wall_mount_point_size); translate([ -Outside_X / 2, -wall_mount_point_size / 2, 0 ]) mirror([1, 0, 0]) WallMountPoint(wall_mount_point_size); } } // Hexa holes module HexaHole() { rotate([0, 0, 30]) cylinder( d = Hexa_Hole_Diameter, h = Wall_Width + 2, $fn = 6 ); } module HexaHoles() { hole_space_x = Hexa_Hole_Diameter / 2 * sqrt(3) + Hexa_Hole_Wall; hole_space_y = Hexa_Hole_Diameter * 2 / 3 + Hexa_Hole_Wall; for (x = [1:Hexa_Hole_In_X]) { for (y = [1:Hexa_Hole_In_Y]) { translate([ -hole_space_x * ((Hexa_Hole_In_X - 1) / 2) + (x - 1) * hole_space_x + ((y/2==round(y/2)) ? hole_space_x / 2 : 0), -hole_space_y * ((Hexa_Hole_In_Y - 1) / 2) + (y - 1) * hole_space_y, 0 ]) HexaHole(); } } } // The objects module PCB_box() { difference () { BaseBox(); cutouts(); } if (With_Cap_Holder) { CapHolders_Box(Outside_Z, Wall_Width); } WallMountPoints(); if (With_PCB_Holder) { PCBHolders(); } } module PCB_cap() { difference() { union() { TopBox(); if (With_Cap_Holder) { CapHolders_Cap(Cap_Width, 0); } } if (Hexa_Hole_In_X > 0 && Hexa_Hole_In_Y > 0) HexaHoles(); } capstands(); } if (Render_now == "both") { PCB_box(); translate([0, Outside_Y + Spacer_between_objects, 0]) PCB_cap(); } if (Render_now == "box_only") { PCB_box(); } if (Render_now == "cap_only") { PCB_cap(); }