diff --git a/readme.md b/readme.md index d8372dc..7a258d8 100644 --- a/readme.md +++ b/readme.md @@ -2846,6 +2846,7 @@ Face order is bottom, top, left, right, front, back. |:--- |:--- | | `atx_psu(type)` | True if an ATX style PSU | | `psu_accessories(type)` | Accessories to add to BOM, e.g. mains lead | +| `psu_face_cutout(type)` | Panel cutout to accommodate this face, e.g. for ATX | | `psu_face_cutouts(type)` | List of polygons to remove | | `psu_face_fan(type)` | Fan x,y position and type | | `psu_face_grill(type)` | Is this face a grill | @@ -2881,7 +2882,7 @@ Face order is bottom, top, left, right, front, back. ### Modules | Module | Description | |:--- |:--- | -| `atx_psu_cutout(type)` | Cut out for the rear of an ATX | +| `atx_psu_cutout(type, face = f_front)` | Cut out for the rear of an ATX, which is actually f_front! | | `psu(type)` | Draw a power supply | | `psu_screw_positions(type, face = undef)` | Position children at the screw positions on the preferred mounting face, which can be overridden. | | `terminal_block(type, ways)` | Draw a power supply terminal block | diff --git a/tests/PSUs.scad b/tests/PSUs.scad index 3704ac7..ec24c55 100644 --- a/tests/PSUs.scad +++ b/tests/PSUs.scad @@ -16,11 +16,15 @@ // You should have received a copy of the GNU General Public License along with NopSCADlib. // If not, see . // +show_cutout = false; + include <../core.scad> include <../vitamins/psus.scad> use <../utils/layout.scad> + + module psus() layout([for(p = psus) atx_psu(p) ? psu_length(p) : psu_width(p)], 10) let(p = psus[$i]) rotate(atx_psu(p) ? 0 : 90) { @@ -29,6 +33,9 @@ module psus() psu_screw_positions(p) translate_z(3) screw_and_washer(psu_screw(p), 8); + + if(show_cutout && atx_psu(p)) + #atx_psu_cutout(p); } if($preview) { diff --git a/tests/png/psus.png b/tests/png/psus.png index 081d2ce..aa5293a 100644 Binary files a/tests/png/psus.png and b/tests/png/psus.png differ diff --git a/vitamins/psu.scad b/vitamins/psu.scad index 81a010f..9a58a08 100644 --- a/vitamins/psu.scad +++ b/vitamins/psu.scad @@ -39,6 +39,7 @@ function psu_face_fan(type) = type[4]; //! Fan x,y position and typ function psu_face_iec(type) = type[5]; //! IEC connector x,y, rotation and type function psu_face_switch(type) = type[6]; //! Rocker switch x,y, rotation and type function psu_face_vents(type) = type[7]; //! Vents array position x,y, rotation, size and corner radius +function psu_face_cutout(type) = type[8]; //! Panel cutout to accommodate this face, e.g. for ATX function psu_name(type) = type[1]; //! The part name function psu_length(type) = type[2]; //! Length @@ -125,9 +126,9 @@ function psu_face_transform(type, face) = //! Returns a transformation ) translate([0, 0, h / 2]) * rotate(rotations[face]) * translate([0, 0, translations[face]]); module psu_grill(width, height, grill_hole = 4.5, grill_gap = 1.5, fn = 0, avoid = []) { - nx = floor(width / (grill_hole + grill_gap)); + nx = floor(width / (grill_hole + grill_gap)) + 1; xpitch = width / nx; - ny = floor(height / ((grill_hole + grill_gap) * cos(30))); + ny = floor(height / ((grill_hole + grill_gap) * cos(30))) + 1; ypitch = height / ny; r = grill_hole / 2; avoid = avoid ? [for(p = avoid) [[p.x - p[2] / 2 - r, p.y - p[3] / 2 - r], [p.x + p[2] / 2 + r, p.y + p[3] / 2 + r]]] : false; @@ -192,15 +193,17 @@ module psu(type) { //! Draw a power supply g = psu_face_grill(f); if(g) { list = is_list(g); - fn = list ? g[2] : 0; hole = list ? g[0] : 4.5; gap = list ? g[1] : 1.5; - avoid = list ? g[3] : []; - mx = 6; - my1 = i == f_top && psu_face_grill(faces[f_back]) ? 0 : 6; - my2 = i == f_back && psu_face_grill(faces[f_top]) ? 0 : 6; - translate([0, (my2 - my1) / 2]) - psu_grill(xw - 2 * mx, yw - my1 - my2, grill_hole = hole, grill_gap = gap, fn = fn, avoid = avoid); + fn = list ? g[2] : 0; + margins = list ? g[3] : [6, 6, 6, 6]; + avoid = list ? g[4] : []; + mx1 = margins[0]; + mx2 = margins[1]; + my1 = i == f_top && psu_face_grill(faces[f_back]) ? 0 : margins[2]; + my2 = i == f_back && psu_face_grill(faces[f_top]) ? 0 : margins[3]; + translate([(mx1 - mx2) / 2, (my2 - my1) / 2]) + psu_grill(xw - mx1 - mx2, yw - my1 - my2, grill_hole = hole, grill_gap = gap, fn = fn, avoid = avoid); } if(fan) translate([fan.x, fan.y]) intersection() { @@ -343,22 +346,9 @@ module psu_screw_positions(type, face = undef) { //! Position children at the sc children(); } -module atx_psu_cutout(type) { //! Cut out for the rear of an ATX - holes = psu_face_holes(psu_faces(type)[f_front]); - translate([holes[0].x, -psu_width(type) / 2, psu_height(type) / 2 + holes[0].y]) - rotate([90, 0, 0]) - linear_extrude(100, center = true) - round(5) - polygon([ // https://www.techpowerup.com/forums/threads/pc-component-dimensions.157239, tweaked - [18.7, -13], - [ 5.7, 0], - [ 5.7, 54], - [18.7, 67], - [127, 67], - [140, 67 - 13 / tan(52)], - [140, -5 + 11 / tan(52)], - [129, -5], - [81.3, -5], - [73.3, -13], - ]); +module atx_psu_cutout(type, face = f_front) { //! Cut out for the rear of an ATX, which is actually f_front! + multmatrix(psu_face_transform(type, face)) + linear_extrude(100, center = true) + round(5) + polygon(psu_face_cutout(psu_faces(type)[face])); } diff --git a/vitamins/psus.scad b/vitamins/psus.scad index 2d6ce64..c991c1d 100644 --- a/vitamins/psus.scad +++ b/vitamins/psus.scad @@ -62,29 +62,58 @@ ATX500 = [[], 0.8, []], [[], 0.8, []], [[], 0.8, []], - [[[-69, -27], [-69, 37], [69, 37], [45, -37]], 0.8, [], false, [-25, 0, fan80x25], [45, -19.6, 180, IEC_inlet_atx], [45, 23, 90, small_rocker]], + [[[-69, -27], [-69, 37], [69, 37], [45, -37]], 0.8, [], false, [-25, 0, fan80x25], [45, -19.6, 180, IEC_inlet_atx], [45, 23, 90, small_rocker], false, + let(h0 = [-69, -27]) [ // https://www.techpowerup.com/forums/threads/pc-component-dimensions.157239, tweaked + [18.7, -13] + h0, + [ 5.7, 0] + h0, + [ 5.7, 54] + h0, + [18.7, 67] + h0, + [127, 67] + h0, + [140, 67 - 13 / tan(52)] + h0, + [140, -5 + 11 / tan(52)] + h0, + [129, -5] + h0, + [81.3, -5] + h0, + [73.3, -13] + h0, + ] + ], [[], 0.8, [], true], ], [": IEC mains lead"] ]; // Single fan in the top, wires exit opposite side from mains in -ATX300 = let(p = [113 / 2, 51 / 2], iec = [35.5, 6], sw = [6.5, 7]) - ["ATX300", "FSP300-60GHX", 125, 100, 64, No632_pan_screw, 5/2, true, 0, 0, [], +ATX300 = let(p = [113 / 2, 51.5 / 2], s = [125, 100, 64], iec = [35.5, 6], sw = [6.5, 7]) + ["ATX300", "FSP300-60GHX", s.x, s.y, s.z, No632_pan_screw, No6_clearance_radius, true, 0, 0, [], [ [[], 0.5, []], [[], 0.5, [], false, [0, 8, fan80x25]], [[], 0.5, []], [[], 0.5, []], - [[-p, p, [-p.x, p.y], [p.x, -p.y], [p.x, 0]], 0.5, [], [3, 0.35, 6, [ + [[-p, p, [-p.x, p.y], [p.x, -p.y], [p.x, 0]], 0.5, [], [3, 0.6, 6, [6.3, 7, 6.4, 5.5], [ [-p.x, -p.y, 5, 5], [-p.x, p.y, 5, 5], - [p.x, 0, 9, 100], - [p.x, -p.y, 17, 6], + [p.x, 0, 5, 100], + [p.x, p.y, 12, 6], + [p.x, -p.y, 12, 6], [iec.x, iec.y, 32, 22], - [sw.x, sw.y, 23, 20], - [sw.x, sw.y, 28, 12], - ]], false, [iec.x, iec.y, 180, IEC_inlet_atx2], [sw.x, sw.y, 90, small_rocker]], + [sw.x, sw.y, 20, 20], + [sw.x, sw.y, 27, 12], + ]], false, [iec.x, iec.y, 180, IEC_inlet_atx2], [sw.x, sw.y, 90, small_rocker], false, [ + [-s.x / 2 + 11.5, -s.z / 2 + 4.5], + [-s.x / 2 + 5.5, -s.z / 2 + 4.5 + 6 * tan(60)], + + [-s.x / 2 + 5.5, s.z / 2 - 5.4 - 6 * tan(60)], + [-s.x / 2 + 11.5, s.z / 2 - 5.4], + + [ s.x / 2 - 14, s.z / 2 - 5.4], + [ s.x / 2 - 10.5, s.z / 2 - 5.4 - 3.5 * tan(60)], + [ s.x / 2 - 10.5, -6], + [ s.x / 2 - 8, -8.5], + + [ s.x / 2 - 8, -s.z / 2 + 4.5 + 6 * tan(60)], + [ s.x / 2 - 14, -s.z / 2 + 4.5], + ] + ], [[], 0.5, []], ], [": IEC mains lead"]