omdl  v0.9.5
OpenSCAD Mechanical Design Library
pci_bracket.scad
Go to the documentation of this file.
1 //! A PCI slot cover and adapter card bracket generator.
2 /***************************************************************************//**
3  \file
4  \author Roy Allen Sutton
5  \date 2018-2024
6 
7  \copyright
8 
9  This file is part of [omdl] (https://github.com/royasutton/omdl),
10  an OpenSCAD mechanical design library.
11 
12  The \em omdl is free software; you can redistribute it and/or modify
13  it under the terms of the [GNU Lesser General Public License]
14  (http://www.gnu.org/licenses/lgpl.html) as published by the Free
15  Software Foundation; either version 2.1 of the License, or (at
16  your option) any later version.
17 
18  The \em omdl is distributed in the hope that it will be useful,
19  but WITHOUT ANY WARRANTY; without even the implied warranty of
20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21  Lesser General Public License for more details.
22 
23  You should have received a copy of the GNU Lesser General Public
24  License along with the \em omdl; if not, write to the Free Software
25  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26  02110-1301, USA; or see <http://www.gnu.org/licenses/>.
27 
28  \details
29 
30  \amu_define group_name (PCI bracket)
31  \amu_define group_brief (PCI slot cover bracket generator.)
32 
33  \amu_include (include/amu/pgid_path_pstem_pg.amu)
34 *******************************************************************************/
35 
36 //----------------------------------------------------------------------------//
37 // group and macros.
38 //----------------------------------------------------------------------------//
39 
40 /***************************************************************************//**
41  \amu_include (include/amu/group_in_parent_start.amu)
42  \amu_include (include/amu/includes_required.amu)
43 *******************************************************************************/
44 
45 //----------------------------------------------------------------------------//
46 
47 //! PCI slot cover and adapter card bracket generator.
48 /***************************************************************************//**
49  \param form <integer> bracket form factor
50  (0=standard, 1=low profile).
51 
52  \param fins <integer> fin placements
53  (0=none, 1=side one, 2=side two, 3=both sides).
54 
55  \param vents <data-list-2> vent specification.
56 
57  \param ribs <data-list-4> rib specification.
58 
59  \param tabs <list-list-n> tab specification.
60 
61  \param align <integer-list-3> part alignment.
62 
63  \details
64 
65  This module generates customized PCI brackets that can be used to
66  create simple PCI slot covers and PCI adapter card brackets in both
67  full and half-height formats. All parameters are optional. Default
68  values are used for all unspecified parameters. Default values are
69  also used for unspecified elements positions for parameter that
70  accepts a list of values.
71 
72  Multi-value parameters
73  ----------------------
74 
75  \b vents
76 
77  e | data type | default value | parameter description
78  ---:|:-----------------:|:-----------------:|:------------------------------------
79  0 | <integer> | 0 | vent hole count
80  1 | <decimal> | 3.0 | vent hole radius
81 
82  \b ribs
83 
84  e | data type | default value | parameter description
85  ---:|:-----------------:|:-----------------:|:------------------------------------
86  0 | <integer> | 3 | location (0=top, 1=none, 2=bottom, 3=both)
87  1 | <integer> | 1 | shape (0=cylinder, 1=ellipse)
88  2 | <integer> | 10 | number of divisions
89  3 | <decimal-list-n> | [3, 7] | division positions list [p1, p2, ..., pn]
90 
91  \b tabs
92 
93  e | data type | default value | parameter description
94  ---:|:-----------------:|:-----------------:|:------------------------------------
95  0 | <decimal-list-3> | | tab-0: [offset-y, offset-x, hole-diameter]
96  ...| ... | | ...
97  n | <decimal-list-3> | | tab-n: [offset-y, offset-x, hole-diameter]
98 
99  \b align
100 
101  e | data type | default value | parameter description
102  ---:|:-----------------:|:-----------------:|:------------------------------------
103  0 | <integer> | 0 | align-x
104  1 | <integer> | 0 | align-y
105  2 | <integer> | 0 | align-z
106 
107  The possible x, y, and z alignment locations and configuration
108  values are described in the following table:
109 
110  | parameter | value | value description
111  |:---------:|:---------:|:--------------------------------------------------------
112  | align-x | 0 | bracket outside
113  | | 1 | bracket center
114  | | 2 | bracket inside
115  | | 3 | bracket tab screw center-x
116  | | 4 | back of tab
117  | | 5 | pci connector alignment slot
118  | align-y | 0 | bracket edge away from circuit board
119  | | 1 | bracket tab edge away from circuit board
120  | | 2 | circuit board bottom edge
121  | | 3 | bracket tab screw center-y
122  | | 4 | bracket edge near circuit board
123  | | 5 | connectors window edge away from circuit board
124  | | 6 | connectors window center
125  | | 7 | connectors window edge near circuit board
126  | align-z | 0 | bracket bottom
127  | | 1 | top of pci connector
128  | | 2 | bottom of board / board stop
129  | | 3 | bottom of bracket tab
130  | | 4 | top of bracket tab
131  | | 5 | connectors window bottom
132  | | 6 | connectors window center
133  | | 7 | connectors window top
134 
135  \amu_define title (PCI bracket example)
136  \amu_define image_views (left right back diag)
137  \amu_define image_size (sxga)
138  \amu_define image_columns (4)
139 
140  \amu_include (include/amu/scope_diagrams_3d.amu)
141 *******************************************************************************/
142 module pci_bracket
143 (
144  form = 0,
145  fins = 1,
146  vents,
147  ribs,
148  tabs,
149  align
150 )
151 {
152  bff = defined_or(form, 0);
153 
154  mth = 0.86; // 20 GA
155 
156  sv01 = select_ci( [112.75, 71.46], bff);
157  sv02 = select_ci( [ 2.54, -2.14], bff); // bff1: 20.73 - 18.59
158  sv03 = select_ci( [ 21.59, 20.73], bff); // bff1: 17.15 + 3.58
159  sv04 = select_ci( [ 11.43, 11.84], bff);
160  sv05 = 18.42;
161  sv06 = select_ci( [ 5.08, 6.35], bff);
162  sv07 = 4.42;
163  sv08 = select_ci( [ 89.90, 54.53], bff);
164  sv09 = select_ci( [ 10.16, 9.04], bff);
165  sv10 = select_ci( [ 4.56, 0.00], bff);
166  sv11 = 4.11;
167  sv12 = select_ci( [120.02, 79.20], bff);
168 
169  sv13 = 59.05;
170  sv14 = select_ci( [100.36, 63.58], bff);
171  sv15 = select_ci( [111.15, 68.90], bff);
172  sv16 = select_ci( [106.65, 64.40], bff);
173  sv17 = select_ci( [ 12.06, 12.07], bff);
174 
175  sv18 = select_ci( [ 2.54, -3.58], bff);
176 
177  sv19 = 5.07;
178  sv20 = 5.00;
179 
180  // configuration and defaults
181  brm = defined_e_or(ribs, 0, 3);
182  brs = defined_e_or(ribs, 1, 1);
183  brd = sv05/defined_e_or(ribs, 2, 10);
184  brc = defined_e_or(ribs, 3, [3,7]);
185 
186  bfc = defined_or(fins, 0);
187 
188  vhc = defined_e_or(vents, 0, 0);
189  vhr = defined_e_or(vents, 1, 3);
190  vhs = vhr*4;
191 
192  mtt = 2.00 * mth;
193  tbf = 1.25;
194 
195  // alignment offsets
196  bax = select_ci(
197  [
198  0,
199  -mth/2,
200  -mth,
201  sv06,
202  sv04,
203  -sv13,
204  0
205  ]
206  , defined_e_or(align, 0, 0) );
207 
208  bay = select_ci(
209  [
210  0,
211  select_ci([-sv02, -sv18], bff),
212  -sv05+mtt,
213  select_ci([-sv05, 0], bff),
214  select_ci([-sv03, -sv05], bff),
215  -sv05/2+sv17/2,
216  -sv05/2,
217  -sv05/2-sv17/2,
218  0
219  ]
220  , defined_e_or(align, 1, 0) );
221 
222  baz = select_ci(
223  [
224  sv12-sv01,
225  -sv01+sv14+sv15-sv16,
226  -sv01+sv14,
227  -sv01,
228  -sv01-mth,
229  -sv01+sv08+sv09,
230  -sv01+sv08/2+sv09,
231  -sv01+sv09,
232  0
233  ]
234  , defined_e_or(align, 2, 0) );
235 
236  //
237  // bracket
238  //
239 
240  translate([bax,bay,baz])
241  rotate([90,0,90])
242  difference()
243  {
244  // connector opening
245  col = sv08;
246  coo = sv01-col-sv09;
247 
248  union()
249  {
250  // top tab
251  translate([0,sv01,eps])
252  rotate([270,0,0])
253  difference()
254  {
255  vrf = select_ci( [[0,0,1.5,1.5], [1.5,0,1.5,1.5]], bff);
256  translate([sv18,0,0])
257  extrude_linear_mss(h=mth)
258  rectangle(size=[sv03-abs(sv02), sv04], vr=vrf, center=false);
259 
260  if ( bff == 0 )
261  {
262  translate([sv05,sv06,-mth/2])
263  union()
264  {
265  cylinder(d=sv07, h=mth*2);
266  translate([0,-sv07/2,0])
267  cube([sv07,sv07,mth*2]);
268  }
269  }
270  else
271  {
272  translate([0,sv06,-mth/2])
273  union()
274  {
275  cylinder(d=sv07, h=mth*2);
276  translate([-sv07,-sv07/2,0])
277  cube([sv07,sv07,mth*2]);
278  }
279  }
280  }
281 
282  // tab to bracket offset
283  toh = sv10;
284  translate([sv02,sv01-toh+mth,0])
285  extrude_linear_mss(h=mth)
286  rectangle(size=[sv03-abs(sv02), toh], vr=[0,toh/1.75,0,0], vrm=2, center=false);
287 
288  // tab fillet
289  tbfl = select_ci( [sv03-sv02, sv03+sv02+sv18], bff);
290  tbfo = select_ci( [sv02, 0], bff);
291  translate([tbfo,sv01-tbf,0])
292  mirror([0,1,1])
293  rotate([0,90,0])
294  extrude_linear_mss(h=tbfl)
295  polygon([[tbf,tbf], [tbf,0], [0,0]]);
296 
297  // bracket
298  vrf = select_ci( [[4.00,4.00,0,2.5], [4.00,4.00,1.5,0]], bff);
299  vrmf = select_ci( [15, 3], bff);
300  extrude_linear_mss(h=mth)
301  rectangle(size=[sv05, sv01-toh+mth+eps*4], vr=vrf, vrm=vrmf, center=false);
302 
303  // bottom tab with bend
304  btx = sv05-sv11*2;
305  bty1 = sv12-sv01-sv20;
306  bty2 = sv20;
307 
308  translate([sv11,-bty1-eps*2,0])
309  extrude_linear_mss(h=mth)
310  rectangle(size=[btx, bty1 + eps*4], center=false);
311 
312  translate([sv11,-bty1-bty2-mth*sin(sv19),-bty2*sin(sv19)])
313  rotate([sv19, 0, 0])
314  union()
315  {
316  extrude_linear_mss(h=mth)
317  rectangle(size=[btx, bty2], vr=[1.5,1.5,0,0], vrm=0, center=false);
318  translate([0,bty2,mth/2]) rotate([0,90,0]) cylinder(d=mth, h=btx);
319  }
320 
321  // ribs
322  for (x=brc)
323  {
324  translate([x*brd, coo, mth/2])
325  rotate([270,0,0])
326  difference()
327  {
328  if (brs == 0)
329  {
330  union()
331  {
332  cylinder(d=brd, h=col-brd);
333  sphere(d=brd);
334  translate([0,0,col-brd])
335  sphere(d=brd);
336  }
337  }
338  else
339  {
340  union()
341  {
342  extrude_linear_mss(h=col-brd)
343  ellipse(size=[1,1/2]*brd);
344  rotate([0,90,0])
345  ellipsoid([1,2]*brd);
346  translate([0,0,col-brd])
347  rotate([0,90,0])
348  ellipsoid([1,2]*brd);
349  }
350  }
351 
352 
353  translate([-brd*2,-brd*brm,-brd]/2)
354  cube([brd*2,brd,col+brd]*(1+eps));
355  }
356  }
357 
358  // board mount tabs
359  for (n = tabs)
360  {
361  ty = defined_e_or(n, 0, n); // y-offset vector[0] or scalar
362  tx = defined_e_or(n, 1, 9.40); // x-offset or standard
363  hd = defined_e_or(n, 2, 4); // hole diameter or standard
364 
365  tt = mtt;
366  tl = tx+hd;
367  tw = hd*2;
368 
369  translate([sv05, sv01-tw/2-ty, -eps])
370  rotate([0,-90,0])
371  difference()
372  {
373  union()
374  {
375  extrude_linear_mss(h=tt)
376  rectangle(size=[tl, tw], vr=[0,hd/2,hd/2,0], center=false);
377  translate([tbf+mth,0,tt])
378  rotate([270,180,0])
379  mirror([0,0,0])
380  extrude_linear_mss(h=tw)
381  polygon([[tbf,tbf], [tbf,0], [0,0]]);
382  }
383  translate([tx, tw/2, -tt/2])
384  cylinder(d=hd, h=tt*2);
385  }
386  }
387 
388  // edge fins
389  for (x = [[0,0], [1,sv05-mth]])
390  {
391  if ( binary_bit_is(fins, first(x), 1) )
392  translate([second(x),coo-mth,mth*3-eps])
393  rotate([0,90,0])
394  extrude_linear_mss(h=mth)
395  rectangle(size=[mth*2, sv08], vr=[1,0,0,1]*mth*1.5, center=false);
396  }
397  }
398 
399  // vent holes
400  vho = coo + col/2 - (vhc-1)*vhs/2;
401  if (vhc > 0)
402  {
403  for (y=[1:vhc])
404  {
405  translate([sv05/2, vho + (y-1)*vhs, -mth/2-mth])
406  extrude_linear_mss(h=mth*4)
407  ngon(n=6, r=vhr, vr=vhr/2);
408  }
409  }
410  }
411 }
412 
413 //! @}
414 //! @}
415 
416 
417 //----------------------------------------------------------------------------//
418 // openscad-amu auxiliary scripts
419 //----------------------------------------------------------------------------//
420 
421 /*
422 BEGIN_SCOPE example;
423  BEGIN_OPENSCAD;
424  include <omdl-base.scad>;
425  include <tools/operation_cs.scad>;
426  include <parts/3d/computer/pci_bracket.scad>;
427 
428  pci_bracket
429  (
430  form = 1,
431  fins = 3,
432  vents = [4],
433  ribs = [3,1,8, [2,3,4,5,6]],
434  tabs = [55, [20,undef,5.5]],
435  align = [1,6,6],
436  $fn = 36
437  );
438 
439  // end_include
440  END_OPENSCAD;
441 
442  BEGIN_MFSCRIPT;
443  include --path "${INCLUDE_PATH}" {var_init,var_gen_png2eps}.mfs;
444  table_unset_all sizes;
445 
446  images name "sizes" types "sxga";
447  views name "views" views "left right back diag";
448 
449  variables set_opts_combine "sizes views";
450  variables add_opts "--viewall --autocenter --view=axes";
451 
452  include --path "${INCLUDE_PATH}" scr_make_mf.mfs;
453  END_MFSCRIPT;
454 END_SCOPE;
455 */
456 
457 //----------------------------------------------------------------------------//
458 // end of file
459 //----------------------------------------------------------------------------//
460 
eps
<decimal> Epsilon, small distance to deal with overlapping shapes.
Definition: constants.scad:195
function binary_bit_is(v, b, t=1)
Test if a binary bit position of an integer value equals a test bit.
function defined_e_or(v, i, d)
Return an element of an iterable when it exists or a default value otherwise.
function second(v)
Return the second element of an iterable value.
function first(v)
Return the first element of an iterable value.
function select_ci(v, i, l=true)
Select specified element from list or return a default.
function defined_or(v, d)
Return given value, if defined, or a secondary value, if primary is not defined.
module pci_bracket(form=0, fins=1, vents, ribs, tabs, align)
PCI slot cover and adapter card bracket generator.
module ngon(n, r, vr)
An n-sided equiangular/equilateral regular polygon.
Definition: basic_2d.scad:760
module ellipse(size)
An ellipse.
Definition: basic_2d.scad:798
module rectangle(size, vr, vrm=0, center=false)
A rectangle with corner rounds or chamfers.
Definition: basic_2d.scad:471
module ellipsoid(size)
An ellipsoid.
Definition: basic_3d.scad:622
module extrude_linear_mss(h, center=false, c=true)
Linearly extrude a 2d shape with multi-segment uniformly-spaced profile scaling.
Definition: extrude.scad:748