1
0

SpHEAR_common.scad 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. //
  2. // Spherical Harmonics Ear Project (*SpHEAR)
  3. //
  4. // Common Modules and Variables
  5. //
  6. // Copyright 2015-2016, Fernando Lopez-Lezcano, All Rights Reserved
  7. // nando@ccrma.stanford.edu
  8. //
  9. // This program is free software: you can redistribute it and/or modify
  10. // it under the terms of the GNU General Public License as published by
  11. // the Free Software Foundation, either version 3 of the License, or
  12. // (at your option) any later version.
  13. //
  14. // This program is distributed in the hope that it will be useful,
  15. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. // GNU General Public License for more details.
  18. //
  19. // You should have received a copy of the GNU General Public License
  20. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. //
  22. // 3d Models released under the Creative Commons license as follows:
  23. // Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)
  24. // http://creativecommons.org/licenses/by-nc-sa/4.0/
  25. ////
  26. //// default model parameters
  27. ////
  28. // microphone capsule array
  29. //
  30. // dimensions of the electret microphone capsule
  31. capsule_radius = 5;
  32. capsule_height = 4.5;
  33. // wall thickness of the capsule holder
  34. wall = 1;
  35. // distance between the face of a capsule and the center of array
  36. mic_radius = 9.6;
  37. // dimensions of the capsule holder connection legs
  38. // a width of 4mm is too thin, 5mm prints better
  39. leg_width = 5;
  40. leg_thick = 1.75;
  41. // width of the ridge that connects to the mount
  42. ridge_width = 2.0;
  43. ridge_slot_width = 2.0;
  44. // depth of the connector mount ridge
  45. ridge_depth = 3.0;
  46. // add to the thickness of ridges
  47. ridge_wfit = 0.1;
  48. ridge_hfit = 3;
  49. // microphone mount
  50. //
  51. mount_radius = 3.5;
  52. mount_wall = 0.75;
  53. // height and eccentricity of top connector
  54. mount_top_height = 10.0;
  55. mount_top_eccentricity = 1.3;
  56. // height of mount
  57. mount_height = 40;
  58. // microphone stand mount
  59. //
  60. // diameter of existing shielded wires (x 4)
  61. mic_wire_diam = 1.5;
  62. mic_wire_fit = 0.8;
  63. mic_wire_hole_radius = 3.0;
  64. mic_wire_hole_offset = 5;
  65. // standard microphone stand
  66. // measured diameter = 13.5, inside diameter of sleeve = 13.79 (
  67. mic_mount_radius = 13.50 / 2;
  68. // add this to inside diameter
  69. mic_mount_fit = 0.2;
  70. mic_mount_slot_height = 11.5;
  71. mic_mount_slot_width = 4.25;
  72. mic_mount_slot_radius = 6.25 / 2;
  73. mic_mount_wall = 1.5;
  74. mic_mount_height = 35.0 + mic_wire_hole_offset + mic_wire_hole_radius + 2 * mic_mount_wall;
  75. //// end of model parameters
  76. ////
  77. //// rendering control
  78. // what type of connection to use between capsule holders:
  79. // 0 -> original cylindrical angled legs
  80. // 1 -> interlocking horizontal legs with triangular top (only works with small radius)
  81. // 2 -> interlocking horizontal legs
  82. // 3 -> interlocking vertical legs
  83. connect = 1;
  84. // how many mount ridges to create
  85. // 0 -> no ridges
  86. // 1 -> 1 ridge
  87. // 2 -> 2 ridges
  88. ridges = 1;
  89. //// end of rendering control
  90. ////
  91. // adjustment for the inner radius of the capsule holder
  92. // measured inside diameter of a trial print was around 7.5 to 8.2
  93. // instead of 10, capsule diameter was 9.99)
  94. fudge = 0.12;
  95. // adjustment for fit of slots in connection legs and mount
  96. // 0.1: initial setting
  97. // 0.1 ->0.15: Ultimaker 2 + Extended plus APL (2016.06.17)
  98. // 0.15->0.10 (2017.01.21)
  99. fit = 0.10;
  100. // number of facets for rendering cylinders
  101. facets = 64;
  102. // render capsule holders with better resolution
  103. cfacets = 128;
  104. // "a wafer-thin mint..."
  105. // something to use when we need tiny 3d slivers
  106. thin_mint = 0.001;
  107. ////////
  108. // microphone capsule holder
  109. // mounts: vectors containing the angle of the mount and the angle to the adjacent capsule
  110. // twist: rotate the whole capsule to match mounting legs
  111. // ridge: add 0, 1 or 2 ridges for attaching the structure to the mount
  112. // ridge_wfit: tune the fit, used for carving slots in mount
  113. // ridge_hfit: adjust height of ridges when carving out the capsule rests
  114. // solid: make the capsule holder solid, used in the mount code to carve the capsule rests
  115. module capsule (mounts, twist, ridge, ridge_wfit = 0.0, ridge_hfit = 0.0, solid = 0) {
  116. difference () {
  117. union () {
  118. // main capsule holder
  119. cylinder(r = capsule_radius + wall, h = capsule_height, $fn = cfacets);
  120. // the mounting legs
  121. for (angles = mounts) {
  122. rotate([0, 0, angles[0] + twist]) {
  123. // disable rendering of the connection legs if the array radius is too
  124. // small and components of adyacent capsule holders touch each other
  125. //
  126. leg_height = leg_thick;
  127. // make sure capsule holders do not touch
  128. render_legs = ((mic_radius - capsule_height) / tan(angles[1])) - capsule_radius - wall -
  129. // and make sure connection leg does not touch adyacent capsule holder
  130. (angles[1] > 45 ? leg_height * tan(2 * angles[1] - 90) + 2 * fit : 0.0);
  131. //
  132. // connect with cylindrical beams, very pretty, not printable
  133. if (connect == 0 && render_legs >= 0) {
  134. leg_length = mic_radius * cos(angles[1]) - capsule_radius * sin(angles[1]);
  135. translate([capsule_radius - wall, 0, capsule_height - wall]) {
  136. rotate([0, 180 - angles[1], 0]) {
  137. cylinder(d = leg_width, h = leg_length - 0.3, center = false, $fn = facets);
  138. }
  139. }
  140. }
  141. // connect with horizontal legs with triangular top (the best by far)
  142. if (connect == 1 && render_legs >= 0) {
  143. leg_length = capsule_radius + wall + capsule_height * tan(angles[1]) - fit;
  144. leg_w = (solid != 0)? leg_width + fit : leg_width;
  145. slot_radius = (mic_radius - capsule_height) / tan(angles[1]);
  146. translate([0, 2 * (- leg_w / 3), 0]) {
  147. difference() {
  148. cube([leg_length, leg_w + leg_w / 3, capsule_height]);
  149. // cut slots that lock with adyacent leg
  150. if (solid == 0) {
  151. for (offset = [1, 3]) {
  152. translate([slot_radius - 1 * fit, leg_w / offset - fit / 2, 0]) {
  153. rotate([0, 90 - angles[1] * 2, 0]) translate([0, 0, - capsule_height])
  154. cube([leg_length, leg_w / 3 + fit, capsule_height * 2]);
  155. }
  156. }
  157. }
  158. // shave triangular slice of fingers, starts at edge of capsule holder
  159. translate([capsule_radius + wall, 0, leg_height]) {
  160. rotate([0, 90 - angles[1], 0]) {
  161. cube([leg_length, leg_w + leg_w / 3, capsule_height]);
  162. }
  163. }
  164. // and remove the rest when the leg height is less than the capsule height
  165. translate([0, - 2 * (- leg_w / 3), leg_height]) {
  166. difference() {
  167. cylinder(r = capsule_radius + leg_length, h = capsule_height, $fn = facets);
  168. cylinder(r = capsule_radius + wall, h = capsule_height, $fn = facets);
  169. }
  170. }
  171. }
  172. }
  173. }
  174. // connect with horizontal legs
  175. if (connect == 2 && render_legs >= 0) {
  176. leg_length = (mic_radius - capsule_height + leg_thick) * tan(90 - angles[1]);
  177. slot_depth = leg_thick / cos(90 - 2 * angles[1]);
  178. slot_xtra_depth = (angles[1] < 45) ? (leg_thick * tan(90 - 2 * angles[1])) : 0.0;
  179. translate([0, - leg_width / 3, 0]) {
  180. difference() {
  181. cube([leg_length, leg_width, leg_thick]);
  182. // cut slot in connector
  183. translate([leg_length - slot_depth - slot_xtra_depth - fit, leg_width / 3 - (fit / 2), 0]) {
  184. cube([slot_depth + slot_xtra_depth + fit, leg_width / 3 + fit, leg_thick]);
  185. }
  186. }
  187. }
  188. }
  189. // connect with vertical legs
  190. if (connect == 3 && render_legs >= 0) {
  191. // fix this 0.2 == (2 * fudge?)
  192. leg_length = (mic_radius * tan(90 - angles[1]) - capsule_radius) * tan(angles[1]) - 0.2;
  193. slot_depth = leg_thick * cos (90 - (2 * angles[1]));
  194. translate([capsule_radius - leg_thick / 2 + fudge, - leg_width / 3,
  195. - leg_length + capsule_height]) {
  196. difference() {
  197. // the connection
  198. difference() {
  199. cube([leg_thick + leg_thick / 2, leg_width, leg_length]);
  200. translate([-leg_thick + wall - fudge, 0, - capsule_height + fudge]) {
  201. cube([leg_thick, leg_width, leg_length]);
  202. }
  203. }
  204. // cut slot in connector
  205. translate([0, leg_width / 3 - (fit / 2), 0]) {
  206. cube([leg_thick + leg_thick / 2, leg_width / 3 + fit, slot_depth]);
  207. }
  208. }
  209. }
  210. }
  211. }
  212. }
  213. // add ridges for microphone mount
  214. ridge_length = (mic_radius - capsule_height) / tan(elev_angle) - (capsule_radius + wall);
  215. if (ridge == 2) {
  216. rotate([0, 0, twist]) {
  217. translate([capsule_radius + wall - ridge_length / 2, (ridge_width + ridge_wfit) / 2, 0]) {
  218. cube([ridge_length * 3 / 2, ridge_width + ridge_wfit, capsule_height + ridge_hfit], center = false);
  219. }
  220. translate([capsule_radius + wall - ridge_length / 2, - (ridge_width + ridge_wfit) * 3 / 2, 0]) {
  221. cube([ridge_length * 3 / 2, ridge_width + ridge_wfit, capsule_height + ridge_hfit], center = false);
  222. }
  223. }
  224. }
  225. if (ridge == 1) {
  226. rotate([0, 0, twist]) {
  227. difference() {
  228. translate([capsule_radius + wall / 2, - (ridge_width + ridge_wfit) / 2, 0]) {
  229. cube([ridge_depth + wall / 2, ridge_width + ridge_wfit, capsule_height + ridge_hfit], center = false);
  230. }
  231. translate([capsule_radius + wall + ridge_length, - (ridge_width + ridge_wfit) / 2, 0]) {
  232. rotate([0, elev_angle, 0]) {
  233. cube([ridge_depth, ridge_width + ridge_wfit, capsule_height * 2], center = false);
  234. }
  235. }
  236. }
  237. }
  238. }
  239. }
  240. // make the hole for the capsule (also cuts leg overhang for vertical connectors)
  241. if (solid != 1) {
  242. translate ([0, 0, -capsule_height]) {
  243. cylinder(r = capsule_radius + fudge, h = capsule_height * 2, $fn = cfacets);
  244. }
  245. }
  246. // remove any extra connecting beam material from the face of the holder
  247. if (connect == 0) {
  248. translate ([0, 0, capsule_height]) {
  249. cylinder(r = capsule_radius + wall * 2, h = 2, $fn = cfacets);
  250. }
  251. }
  252. }
  253. }
  254. //// shared modules for zapnspark printed circuit board
  255. // one printed circuit board
  256. module pcb(length, width, thick) {
  257. translate([-width/2, 0, 0]) {
  258. cube([width, thick, length]);
  259. }
  260. }
  261. // one printed circuit board with space in the front and back for components
  262. module pcb_clear(length, width, thick, slot_depth, front, back) {
  263. translate([0, - (thick + front)]) {
  264. pcb(length, width, thick);
  265. // clear space in the front
  266. translate([- (width/2 - slot_depth), thick, 0]) {
  267. cube([width - 2 * slot_depth, front, length]);
  268. }
  269. // clear space in the back
  270. translate([- (width/2 - slot_depth), - back, 0]) {
  271. cube([width - 2 * slot_depth, back, length]);
  272. }
  273. }
  274. }
  275. //// shared modules for mount
  276. // rectangular block with rounded corners
  277. module rounded_block(height, width, depth, radius) {
  278. dw = width - radius;
  279. dd = depth - radius;
  280. minkowski() {
  281. translate([-dw, -dd, 0]) {
  282. cube([dw * 2, dd * 2, height / 2]);
  283. }
  284. cylinder(r = radius, h = height / 2, $fn = facets);
  285. }
  286. }
  287. // rectangular inset block with rounded corners
  288. module rounded_block_relative(height, ref_width, ref_depth, ref_corner, radius_inc) {
  289. corner = ref_corner * ((ref_width + radius_inc) / ref_width);
  290. rounded_block(height, ref_width + radius_inc, ref_depth + radius_inc, corner);
  291. }
  292. // box with rounded corners
  293. module rounded_box(height, width, depth, radius, wall) {
  294. iradius = radius * ((width - wall) / width);
  295. difference() {
  296. rounded_block(height, width, depth, radius);
  297. rounded_block(height, width - wall, depth - wall, iradius);
  298. }
  299. }
  300. //// shared modules for shock mount
  301. // eyelet for connecting the external ring to the stand mount
  302. module shock_mount_ring(outside_radius, inside_radius, thickness) {
  303. difference() {
  304. union() {
  305. cylinder(r = outside_radius, h = thickness, $fn = facets);
  306. translate([0, -outside_radius, 0]) {
  307. cube([outside_radius, outside_radius, thickness]);
  308. }
  309. }
  310. cylinder(r = inside_radius, h = thickness, $fn = facets);
  311. }
  312. }
  313. // internal ring of shock mount
  314. module shock_mount_internal_ring(height, xradius, yradius, corner, gap, lip) {
  315. slot_sep = xradius * 2 / 2.5;
  316. slot_w = 5;
  317. slot_o = height / 3;
  318. difference() {
  319. union() {
  320. // base ring
  321. difference() {
  322. rounded_block_relative(slot_o, xradius + gap, yradius + gap, corner, 3 * wall);
  323. rounded_block(slot_o, xradius + gap, yradius + gap, corner);
  324. }
  325. // upper ring with slots for rubber bands
  326. difference() {
  327. rounded_block_relative(height, xradius + gap + 2 * wall, yradius + gap + 2 * wall, corner, 2 * wall);
  328. rounded_block_relative(height, xradius + gap + wall, yradius + gap + wall, corner, 1 * wall);
  329. for (rot = [0, 90, 180, 270]) rotate([0, 0, rot]) {
  330. // slots for rubber bands
  331. minkr = 1.5;
  332. for (m = [0, 1]) mirror([0, m, 0]) {
  333. translate([-slot_w / 2 + slot_sep, ((rot % 180) ? xradius : yradius) + gap, slot_o + minkr]) {
  334. minkowski() {
  335. cube([slot_w - minkr, 10, slot_o - minkr]);
  336. rotate([90, 0, 0]) cylinder(r = minkr, h = 1, $fn = facets);
  337. }
  338. }
  339. }
  340. // cut holes in slots
  341. rotate([0, 0, -45]) {
  342. translate([-thin_mint, 0, slot_o]) {
  343. for (m = [0, 1]) mirror([0, m, 0]) {
  344. // this should be a pizza slice, not a cube
  345. cube([6.0, xradius + gap + 3 * wall + 5.0, height]);
  346. }
  347. }
  348. }
  349. }
  350. }
  351. // body for bars that connect both rings together
  352. for (rot = [0, 90, 180, 270]) rotate([0, 0, rot]) {
  353. translate([((rot % 180) ? yradius : xradius) + gap + 3 * wall, -(connector_w/2 + wall), 0]) {
  354. cube([connector_d + wall, connector_w + 2 * wall, height]);
  355. }
  356. for (m = [0, 1]) mirror([0, m, 0]) {
  357. translate([((rot % 180) ? yradius : xradius) + gap + 4 * wall, -(connector_w/2 + wall), 0]) {
  358. cylinder(r = wall * 2, h = height, $fn = 3);
  359. }
  360. }
  361. }
  362. }
  363. // carve holes for bars that connect both rings
  364. for (rot = [0, 90, 180, 270]) rotate([0, 0, rot]) {
  365. translate([((rot % 180) ? yradius : xradius) + gap + 3 * wall, -connector_w/2, 0]) {
  366. cube([connector_d, connector_w, height - 2.75 * wall]);
  367. translate([connector_d / 2, 0, height - 3 * wall]) {
  368. rotate([-90, 0, 0]) {
  369. cylinder(r = connector_d / 2, h = connector_w, $fn = facets);
  370. }
  371. }
  372. }
  373. }
  374. }
  375. for (rot = [0, 90, 180, 270]) rotate([0, 0, rot]) {
  376. // lip to support microphone on lower ring only
  377. if (lip == 1) {
  378. lip_w = 10;
  379. translate([((rot % 180) ? yradius : xradius) + gap + 2.5 * wall, -lip_w/2, height]) {
  380. rotate([90, 90, 180]) {
  381. linear_extrude(height = lip_w) {
  382. polygon([[0, 0], [0, 4], [1, 4], [height * 2/3, 0]]);
  383. }
  384. }
  385. }
  386. }
  387. }
  388. }
  389. // external ring of shock mount (connects to stand mount)
  390. module shock_mount_external_ring(height, xradius, yradius, corner, gap, lip) {
  391. difference() {
  392. rounded_block_relative(ring_ext_height, xradius, yradius, mount_corner, gap);
  393. rounded_block_relative(ring_ext_height, xradius, yradius, mount_corner, gap - ring_wall);
  394. }
  395. for (rot = [0, 90, 180, 270]) {
  396. rotate([0, 0, rot]) {
  397. translate([((rot % 180) ? yradius : xradius) + gap + ring_wall, -7.5, 0]) {
  398. cube([4, 15, ring_ext_height]);
  399. }
  400. translate([((rot % 180) ? yradius : xradius) + gap, -2, 0]) {
  401. cube([7, 4, ring_ext_height]);
  402. }
  403. }
  404. }
  405. // connection to stand mount
  406. intersection() {
  407. translate([ring_arm_gap, 0, 0]) {
  408. difference() {
  409. rounded_block_relative(ring_ext_height, xradius, yradius, mount_corner, gap);
  410. rounded_block_relative(ring_ext_height, xradius, yradius, mount_corner, gap - ring_wall);
  411. }
  412. }
  413. translate([ring_arm_gap / 2, -(yradius + 2 * mount_corner), 0]) {
  414. cube([(xradius + 2 * mount_corner) + ring_arm_gap, 2 * (yradius + 2 * mount_corner), ring_ext_height]);
  415. }
  416. }
  417. // connection to hub
  418. translate([xradius + mount_corner + ring_arm_gap, -2, 0]) {
  419. cube([8, 4, ring_ext_height]);
  420. }
  421. // rotating mount
  422. o_rad = 8;
  423. i_rad = 3;
  424. rotate([0, 90, -90]) {
  425. translate([-o_rad, xradius + mount_corner + ring_arm_gap + o_rad + ring_wall / 2 + 4, -2]) {
  426. shock_mount_ring(o_rad, i_rad, ring_wall);
  427. }
  428. }
  429. }
  430. // connector that joins the two internal rings
  431. module shock_mount_connector(length, lip, width, thickness, fit) {
  432. cube([length + 2 * lip , width - 2 * fit, thickness - 2 * fit]);
  433. translate([lip, -(thickness / 2), 0])
  434. cube([length , width + thickness, thickness * 3 / 2]);
  435. }
  436. // mount to standard microphone clip stand mount
  437. module shock_mount_stand(height, wall, stand_wall) {
  438. // stand mount
  439. translate([0, 0, 0]) {
  440. difference() {
  441. union() {
  442. // main mount cylinder
  443. translate([0, 0, 0]) {
  444. difference() {
  445. cylinder(r = mic_mount_radius + mic_mount_fit + stand_wall,
  446. h = height, $fn = facets);
  447. // make the hole for the mount (* 1.5 to cut the ridge as well)
  448. cylinder(r = mic_mount_radius + mic_mount_fit, h = height, $fn = facets);
  449. }
  450. }
  451. }
  452. // slot for fitting into microphone stand
  453. translate([mic_mount_radius - stand_wall / 2, - mic_mount_slot_width / 2, 0]) {
  454. cube([2 * stand_wall, mic_mount_slot_width, mic_mount_slot_height]);
  455. }
  456. // eyelet for microphone stand
  457. translate([mic_mount_radius - stand_wall / 2, 0, mic_mount_slot_height]) {
  458. rotate([0, 90, 0]) {
  459. cylinder(r = mic_mount_slot_radius, h = 2 * stand_wall, $fn = facets);
  460. }
  461. }
  462. }
  463. // top of mount
  464. translate([0, 0, height]) {
  465. difference() {
  466. cylinder(h = mic_mount_radius,
  467. r1 = mic_mount_radius + mount_wall + wall + mic_mount_fit, r2 = 6.5, $fn = facets);
  468. cylinder(h = mic_mount_radius,
  469. r1 = mic_mount_radius + mount_wall + mic_mount_fit, r2 = 0.1, $fn = facets);
  470. }
  471. *translate([0, 0, mic_mount_radius - 1]) {
  472. cylinder(h = 1, r = 5, $fn = facets);
  473. }
  474. }
  475. // eyelets
  476. o_rad = 8;
  477. i_rad = 3;
  478. thk = 4;
  479. // screw head dimensions
  480. head_thick = 3.0;
  481. head_diam = 9.2;
  482. for (m = [0, 1]) mirror([0, m, 0]) {
  483. rotate([90, 90, 0]) {
  484. translate([-(height + o_rad + 6), 0, thk/2 + fit]) {
  485. rotate([0, 0, 45]) {
  486. if (m == 0) {
  487. difference() {
  488. shock_mount_ring(o_rad, i_rad, thk + head_thick / 3);
  489. // recessed hexagonal screw head
  490. translate([0, 0, thk - head_thick + head_thick / 2]) {
  491. rotate([0, 0, 15]) cylinder(h = head_thick, r = head_diam / 2, $fn = 6);
  492. }
  493. }
  494. } else {
  495. shock_mount_ring(o_rad, i_rad, thk + head_thick / 3);
  496. }
  497. }
  498. }
  499. }
  500. }
  501. }
  502. }