Guest User

Untitled

a guest
Nov 21st, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.28 KB | None | 0 0
  1. // Test support frame for proto boards
  2. // Ed Nisley KE4ZNU - Jan 2017
  3. // June 2017 - Add side-mount bracket, inserts into bottom
  4. // 2017-11 - Selectable board sizes, chassis mounting holes
  5.  
  6. /* [Options] */
  7.  
  8. PCBSelect = "ArdUno"; // ["20x80","40x60","30x70","50x70","70x90","80x120","ArdDuemil","ArdMega","ArdPro","ArdUno","ProtoneerCNC"]
  9.  
  10. Layout = "Frame"; // [Frame, Bracket]
  11.  
  12. ClampFlange = true; // external flange
  13.  
  14. Mounts = true; // frame to chassis screw holes
  15.  
  16. Channel = false; // wiring channel cutout
  17.  
  18. WasherRecess = false; // cutout around screw head
  19.  
  20. /* [Extrusion parameters] */
  21.  
  22. ThreadThick = 0.25; // [0.15, 0.20, 0.25]
  23. ThreadWidth = 0.40;
  24.  
  25. function IntegerMultiple(Size,Unit) = Unit * ceil(Size / Unit);
  26.  
  27. /* [Hidden] */
  28.  
  29. Protrusion = 0.1;
  30.  
  31. HoleWindage = 0.2;
  32.  
  33. inch = 25.4;
  34.  
  35. Tap4_40 = 0.089 * inch;
  36. Clear4_40 = 0.110 * inch;
  37. Head4_40 = 0.211 * inch;
  38. Head4_40Thick = 0.065 * inch;
  39. Nut4_40Dia = 0.228 * inch;
  40. Nut4_40Thick = 0.086 * inch;
  41. Washer4_40OD = 0.270 * inch;
  42. Washer4_40ID = 0.123 * inch;
  43.  
  44. Tap6_32 = 0.106 * inch;
  45. Clear6_32 = 0.166 * inch;
  46. Head6_32 = 0.251 * inch;
  47. Head6_32Thick = 0.097 * inch;
  48. Nut6_32Dia = 0.312 * inch;
  49. Nut6_32Thick = 0.109 * inch;
  50. Washer6_32OD = 0.361 * inch;
  51. Washer6_32ID = 0.156 * inch;
  52.  
  53. ID = 0;
  54. OD = 1;
  55. LENGTH = 2;
  56.  
  57. //- PCB sizes
  58. // the list must contain all the selection names as above
  59.  
  60. //* [Hidden] */
  61. PCB_NAME = 0;
  62. PCB_DIMENSION = 1;
  63.  
  64. PCBSizes = [
  65. ["40x60",[40,60,1.6]],
  66. ["30x70",[30,70,1.6]],
  67. ["50x70",[50,70,1.6]],
  68. ["20x80",[20,80,1.6]],
  69. ["70x90",[70,90,1.6]],
  70. ["80x120",[80,120,1.6]],
  71. ["ArdDuemil",[69,84,1.6]],
  72. ["ArdMega",[102,53.5,1.6]],
  73. ["ArdPro",[53,53.5,1.6]],
  74. ["ArdUno",[69,53.1,1.6]],
  75. ["ProtoneerCNC",[69,53.1,1.6]],
  76. ];
  77.  
  78. PCBIndex = search([PCBSelect],PCBSizes)[0];
  79. PCBSize = PCBSizes[PCBIndex][PCB_DIMENSION];
  80.  
  81. //echo(str("PCB Size Table: ",PCBSizes));
  82. //echo(str("PCB Select: ",PCBSelect));
  83. //echo(str("PCB Index: ",PCBIndex));
  84. echo(str("PCB Size: ",PCBSize));
  85.  
  86. /* [Sizes] */
  87.  
  88. WallThick = 4.0; // basic frame structure
  89.  
  90. FrameHeight = 10.0;
  91.  
  92. /* [Hidden] */
  93.  
  94. Insert = [3.9,4.6,5.8];
  95.  
  96. PCBShelf = 1.0; // width of support rim under PCB
  97.  
  98. Clearance = 1*[ThreadWidth,ThreadWidth,0]; // around PCB on all sides
  99.  
  100. ScrewOffset = ThreadWidth + Insert[OD]/2; // beyond PCB edges
  101. echo(str("Screw offset: ",ScrewOffset));
  102.  
  103. /* [Screw Selectors] */
  104.  
  105. // ij selectors for PCB clamp screw holes: -1/0/1 = left/center/right , bottom/center/top
  106.  
  107. ScrewSites = [
  108. // [-1,1],[1,1],[1,-1],[-1,-1], // corners
  109. // [-1,0],[1,0],[0,1],[0,-1] // middles
  110. [-1,1],[-1,-1],[1,0] // Arduinos
  111. ];
  112.  
  113. // ij selectors for frame mounting holes
  114.  
  115. MountSites = [
  116. [0,-1],[0,1],
  117. // [-1,0],[1,0]
  118. ];
  119.  
  120. function ScrewAngle(ij) = (ij[0]*ij[1]) ? ij[0]*ij[1]*15 : ((!ij[1]) ? 30 : 0); // align screw sides
  121.  
  122. OAHeight = FrameHeight + Clearance[2] + PCBSize[2]; // total frame height
  123. echo(str("OAH: ",OAHeight));
  124.  
  125. BossOD = 2*Washer4_40OD; // make bosses oversized for washers
  126.  
  127. FlangeExtension = 4.0 + Washer6_32OD/2 - WallThick; // beyond frame structure
  128.  
  129. FlangeThick = IntegerMultiple(2.0,ThreadThick); // plate under frame
  130.  
  131. Flange = PCBSize
  132. + 2*[ScrewOffset,ScrewOffset,0]
  133. + [BossOD,BossOD,0]
  134. + [2*FlangeExtension,2*FlangeExtension,(FlangeThick - PCBSize[2])]
  135. ;
  136.  
  137. FlangeRadius = BossOD/4;
  138.  
  139. echo(str("Flange: ",Flange));
  140. NumSides = 4*5;
  141.  
  142. WireChannel = [Flange[0],15.0,3.0 + PCBSize[2]]; // ad-hoc wiring cutout
  143. WireChannelOffset = [
  144. Flange[0]/2,0,(FrameHeight + PCBSize[2] - WireChannel[2]/2)
  145. ];
  146.  
  147. //- Adjust hole diameter to make the size come out right
  148.  
  149. module PolyCyl(Dia,Height,ForceSides=0) { // based on nophead's polyholes
  150.  
  151. Sides = (ForceSides != 0) ? ForceSides : (ceil(Dia) + 2);
  152.  
  153. FiiDia = Dia / cos(180/Sides);
  154.  
  155. cylinder(r=(FiiDia + HoleWindage)/2,h=Height,$fn=Sides);
  156. }
  157.  
  158. //- Build things
  159.  
  160. if (Layout == "Frame")
  161. difference() {
  162. union() { // body block
  163. translate([0,0,OAHeight/2])
  164. cube(PCBSize + Clearance + [2*WallThick,2*WallThick,FrameHeight],center=true);
  165.  
  166. for (ij = ScrewSites) // screw bosses
  167. if (ij[0] != 0 || ij[1] != 0)
  168. translate([ij[0]*(PCBSize[0]/2 + ScrewOffset),
  169. ij[1]*(PCBSize[1]/2 + ScrewOffset),
  170. 0])
  171. cylinder(d=BossOD,h=OAHeight,$fn=NumSides);
  172.  
  173. if (ClampFlange) // flange for work holder & mounting screw holes
  174. linear_extrude(height=Flange[2])
  175. hull()
  176. for (i=[-1,1], j=[-1,1]) {
  177. translate([i*(Flange[0]/2 - FlangeRadius),j*(Flange[1]/2 - FlangeRadius)])
  178. circle(r=FlangeRadius,$fn=NumSides); // convenient rounding size
  179. }
  180. }
  181.  
  182. for (ij = ScrewSites) { // screw position indeies
  183. if (ij[0] != 0 || ij[1] != 0) {
  184. translate([ij[0]*(PCBSize[0]/2 + ScrewOffset),
  185. ij[1]*(PCBSize[1]/2 + ScrewOffset),
  186. -Protrusion])
  187. rotate(ScrewAngle(ij))
  188. PolyCyl(Clear4_40,(OAHeight + 2*Protrusion),6); // screw clearance holes
  189.  
  190. translate([ij[0]*(PCBSize[0]/2 + ScrewOffset),
  191. ij[1]*(PCBSize[1]/2 + ScrewOffset),
  192. -Protrusion])
  193. rotate(ScrewAngle(ij))
  194. PolyCyl(Insert[OD],OAHeight - PCBSize[2] - 3*ThreadThick + Protrusion,6); // inserts
  195.  
  196. if (WasherRecess)
  197. translate([ij[0]*(PCBSize[0]/2 + ScrewOffset),
  198. ij[1]*(PCBSize[1]/2 + ScrewOffset),
  199. OAHeight - PCBSize[2]])
  200. PolyCyl(1.2*Washer4_40OD,(PCBSize[2] + Protrusion),NumSides); // optional washer recess
  201. }
  202. }
  203.  
  204. if (Mounts)
  205. for (ij = MountSites)
  206. translate([ij[0]*(Flange[0]/2 - Washer6_32OD/2),ij[1]*(Flange[1]/2 - Washer6_32OD/2),-Protrusion])
  207. rotate(ScrewAngle(ij))
  208. PolyCyl(Clear6_32,(Flange[2] + 2*Protrusion),6);
  209.  
  210. translate([0,0,OAHeight/2]) // through hole below PCB
  211. cube(PCBSize - 2*[PCBShelf,PCBShelf,0] + [0,0,2*OAHeight],center=true);
  212.  
  213. translate([0,0,(OAHeight - (PCBSize[2] + Clearance[2])/2 + Protrusion/2)]) // PCB pocket on top
  214. cube(PCBSize + Clearance + [0,0,Protrusion],center=true);
  215.  
  216. if (Channel)
  217. translate(WireChannelOffset) // opening for wires from bottom side
  218. cube(WireChannel + [0,0,Protrusion],center=true);
  219. }
  220.  
  221. // Add-on bracket to hold smaller PCB upright at edge
  222.  
  223. PCB2Insert = [3.0,4.9,4.1];
  224. PCB2OC = 45.0;
  225.  
  226. if (Layout == "Bracket")
  227. difference() {
  228. hull() // frame body block
  229. for (i=[-1,1]) // bosses around screws
  230. translate([i*(PCBSize[0]/2 + ScrewOffset),0,0])
  231. cylinder(r=Washer4_40OD,h=OAHeight,$fn=NumSides);
  232.  
  233. for (i=[-1,1]) // frame screw holes
  234. translate([i*(PCBSize[0]/2 + ScrewOffset),0,-Protrusion])
  235. rotate(i*180/(2*6))
  236. PolyCyl(Clear4_40,(OAHeight + 2*Protrusion),6);
  237.  
  238. for (i=[-1,1]) // PCB insert holes
  239. translate([i*PCB2OC/2,(Washer4_40OD + Protrusion),OAHeight/2])
  240. rotate([90,0,0])
  241. cylinder(d=PCB2Insert[OD],h=2*(Washer4_40OD + Protrusion),$fn=6);
  242.  
  243. }
Add Comment
Please, Sign In to add comment