TinySpHEAR_common.scad 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  1. //
  2. // Spherical Harmonics Ear Project (*SpHEAR)
  3. //
  4. // TinySpHEAR, First Order (B-format) Ambisonics Microphone
  5. // Common Modules and Variables
  6. //
  7. // Copyright 2015-2016, Fernando Lopez-Lezcano, All Rights Reserved
  8. // nando@ccrma.stanford.edu
  9. //
  10. // This program is free software: you can redistribute it and/or modify
  11. // it under the terms of the GNU General Public License as published by
  12. // the Free Software Foundation, either version 3 of the License, or
  13. // (at your option) any later version.
  14. //
  15. // This program is distributed in the hope that it will be useful,
  16. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. // GNU General Public License for more details.
  19. //
  20. // You should have received a copy of the GNU General Public License
  21. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. //
  23. // 3d Models released under the Creative Commons license as follows:
  24. // Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)
  25. // http://creativecommons.org/licenses/by-nc-sa/4.0/
  26. // https://en.wikipedia.org/wiki/Tetrahedron
  27. // angle of capsule to vertical axis = atan(sqrt(2)) = 54.7356103172
  28. ////
  29. //// default model parameters
  30. ////
  31. // microphone capsule array
  32. //
  33. // dimensions of the electret microphone capsule
  34. capsule_radius = 5;
  35. capsule_height = 4.5;
  36. // distance between the face of a capsule and the center of array
  37. mic_radius = 9.6;
  38. // dimensions of the capsule holder connection legs
  39. // a width of 4mm is too thin, 5mm prints better
  40. leg_width = 5;
  41. leg_thick = 1.75;
  42. // width of the ridge that connects to the mount
  43. ridge_width = 2.0;
  44. ridge_slot_width = 2.0;
  45. // depth of the connector mount ridge
  46. ridge_depth = 3.0;
  47. // add to the thickness of ridges
  48. ridge_wfit = 0.1;
  49. ridge_hfit = 3;
  50. // wall thickness of the capsule holder
  51. wall = 1;
  52. // microphone mount
  53. //
  54. mount_radius = 3.5;
  55. mount_wall = 0.75;
  56. // height and eccentricity of top connector
  57. mount_top_height = 15.0;
  58. mount_top_eccentricity = 1.3;
  59. // height of mount
  60. mount_height = 40;
  61. // microphone stand mount
  62. //
  63. // diameter of existing shielded wires (x 4)
  64. mic_wire_diam = 1.5;
  65. mic_wire_hole_radius = 3.0;
  66. mic_wire_hole_offset = 5;
  67. // standard microphone stand
  68. // measured diameter = 13.5, inside diameter of sleeve = 13.79 (
  69. mic_mount_radius = 13.50 / 2;
  70. // add this to inside diameter
  71. mic_mount_fit = 0.2;
  72. mic_mount_slot_height = 11.5;
  73. mic_mount_slot_width = 4.25;
  74. mic_mount_slot_radius = 6.25 / 2;
  75. mic_mount_wall = 1.5;
  76. mic_mount_height = 20.0 + mic_wire_hole_offset + mic_wire_hole_radius + 2 * mic_mount_wall;
  77. //// end of model parameters
  78. ////
  79. //// rendering control
  80. // what type of connection to use between capsule holders:
  81. // 0 -> original cylindrical angled legs
  82. // 1 -> interlocking horizontal legs
  83. // 2 -> interlocking vertical legs
  84. connect = 1;
  85. // how many mount ridges to create
  86. // 0 -> no ridges
  87. // 1 -> 1 ridge
  88. // 2 -> 2 ridges
  89. ridges = 1;
  90. //// end of rendering control
  91. ////
  92. // elevation angle for the capsule holders (fixed for this microphone)
  93. elev_angle = atan(sqrt(1/2));
  94. // angles of the connection legs and adjacent capsule holders
  95. leg_angles_top =
  96. [
  97. [-120, elev_angle],
  98. [0, elev_angle],
  99. [120, elev_angle]
  100. ];
  101. leg_angles_bot =
  102. [
  103. [-120, elev_angle],
  104. [120, elev_angle]
  105. ];
  106. // adjustment for the inner radius of the capsule holder
  107. // measured inside diameter of a trial print was around 7.5 to 8.2
  108. // instead of 10, capsule diameter was 9.99)
  109. fudge = 0.12;
  110. // adjustment for fit of slots in connection legs and mount
  111. // 0.1: initial setting
  112. // 0.1 ->0.15: Ultimaker 2 + Extended plus APL (2016.06.17)
  113. fit = 0.15;
  114. // number of facets for rendering cylinders
  115. facets = 64;
  116. // render capsule holders with better resolution
  117. cfacets = 128;
  118. // microphone structure geometry
  119. capsule_sep_min = (mic_radius - capsule_height) * cos(elev_angle) - (capsule_radius + wall) * sin(elev_angle);
  120. capsule_sep_max = mic_radius * cos(elev_angle) - (capsule_radius + wall) * sin(elev_angle);
  121. capsule_bottom = mic_radius * sin(elev_angle) + (capsule_radius + wall) * cos(elev_angle);
  122. mount_radius_capsule = capsule_sep_max;
  123. // simple microphone mount, clips into standard microphone stand
  124. //
  125. // angles: angles for mount slots
  126. // wall: thickness of cylinder wall
  127. // stand_wall: thickness of stand mount wall
  128. // separation: height of mount with respect of the microphone assembly (for display)
  129. module ellipsoid(height, rad_bot, rad_top, eccentricity) {
  130. linear_extrude(height = height, scale = [eccentricity, rad_top / rad_bot]) {
  131. circle(r = rad_bot, $fn = facets);
  132. }
  133. }
  134. module mount (angles, wall, stand_wall, separation) {
  135. translate([0, 0, -separation]) {
  136. difference() {
  137. union() {
  138. // conic section
  139. translate([0, 0, mic_mount_height + mount_height]) {
  140. rotate([0, 0, 45]) {
  141. difference() {
  142. ellipsoid(mount_top_height, mount_radius + wall, mount_radius_capsule, mount_top_eccentricity);
  143. ellipsoid(mount_top_height, mount_radius, mount_radius_capsule * 0.5, mount_top_eccentricity * 1.05);
  144. }
  145. }
  146. }
  147. // stalk
  148. translate([0, 0, mic_mount_height + mount_height * 2/3]) {
  149. difference() {
  150. cylinder(r = mount_radius + wall, h = mount_height / 3, $fn = facets);
  151. // make the hole for the mount
  152. cylinder(r = mount_radius, h = mount_height / 3, $fn = facets);
  153. }
  154. }
  155. // transition to stand mount
  156. translate([0, 0, mic_mount_height]) {
  157. difference() {
  158. cylinder(r2 = mount_radius + wall, r1 = mic_mount_radius + mic_mount_fit + stand_wall,
  159. h = mount_height * 2 / 3, $fn = facets);
  160. // make the hole for the mount
  161. cylinder(r2 = mount_radius, r1 = mic_mount_radius + mic_mount_fit,
  162. h = mount_height * 2 / 3, $fn = facets);
  163. }
  164. }
  165. // stand mount
  166. translate([0, 0, 0]) {
  167. difference() {
  168. union() {
  169. // main mount cylinder
  170. translate([0, 0, 0]) {
  171. difference() {
  172. cylinder(r = mic_mount_radius + mic_mount_fit + stand_wall, h = mic_mount_height, $fn = facets);
  173. // make the hole for the mount (* 1.5 to cut the ridge as well)
  174. cylinder(r = mic_mount_radius + mic_mount_fit, h = mic_mount_height, $fn = facets);
  175. }
  176. }
  177. }
  178. // slot for fitting into microphone stand
  179. translate([mic_mount_radius - stand_wall / 2, - mic_mount_slot_width / 2, 0]) {
  180. cube([2 * stand_wall, mic_mount_slot_width, mic_mount_slot_height]);
  181. }
  182. // eyelet for microphone stand
  183. translate([mic_mount_radius - stand_wall / 2, 0, mic_mount_slot_height]) {
  184. rotate([0, 90, 0]) {
  185. cylinder(r = mic_mount_slot_radius, h = 2 * stand_wall, $fn = facets);
  186. }
  187. }
  188. // hole for microphone wiring
  189. translate([mic_mount_radius - stand_wall / 2, 0, mic_mount_height - mic_wire_hole_offset]) {
  190. rotate([0, 90, 0]) {
  191. cylinder(r = mic_wire_hole_radius, h = 2 * stand_wall, $fn = facets);
  192. }
  193. }
  194. }
  195. }
  196. }
  197. // indentations that match the two lower capsule holders
  198. translate([0, 0, mic_mount_height + mount_height + mount_top_height +
  199. (mic_radius - capsule_height) + capsule_height * cos(elev_angle)]) {
  200. rotate([0, (90 + elev_angle), angles[0]]) {
  201. translate([0, 0, mic_radius - capsule_height]) {
  202. capsule([], 0, 1, ridge_wfit, ridge_hfit, 1);
  203. }
  204. }
  205. rotate([0, (90 + elev_angle), angles[1]]) {
  206. translate([0, 0, mic_radius - capsule_height]) {
  207. capsule([], 0, 1, ridge_wfit, ridge_hfit, 1);
  208. }
  209. }
  210. }
  211. }
  212. }
  213. }
  214. // render a tetrahedral capsule array
  215. //
  216. module render_tetra_capsule_array_old(z_offset) {
  217. translate([0, 0, z_offset]) {
  218. // all four capsules
  219. rotate([0, (90 - elev_angle), 45]) {
  220. translate([0, 0, mic_radius - capsule_height]) {
  221. capsule(leg_angles_top, 60, 0, 0.0, 0.0, 0);
  222. }
  223. }
  224. rotate([0, (90 - elev_angle), -135]) {
  225. translate([0, 0, mic_radius - capsule_height]) {
  226. capsule(leg_angles_top, 60, 0, 0.0, 0.0, 0);
  227. }
  228. }
  229. rotate([0, (90 + elev_angle), -45]) {
  230. translate([0, 0, mic_radius - capsule_height]) {
  231. capsule(leg_angles_bot, 0, 1, 0.0, 0.0, 0);
  232. }
  233. }
  234. rotate([0, (90 + elev_angle), 135]) {
  235. translate([0, 0, mic_radius - capsule_height]) {
  236. capsule(leg_angles_bot, 0, 1, 0.0, 0.0, 0);
  237. }
  238. }
  239. }
  240. }
  241. module render_tetra_capsule_array(z_offset, r_offset) {
  242. translate([0, 0, z_offset]) {
  243. // all four capsules
  244. rotate([0, (90 - elev_angle), 45]) {
  245. translate([0, 0, mic_radius - capsule_height + r_offset]) {
  246. capsule(leg_angles_top, 60, 0, 0.0, 0.0, 0);
  247. }
  248. }
  249. rotate([0, (90 - elev_angle), -135]) {
  250. translate([0, 0, mic_radius - capsule_height + r_offset]) {
  251. capsule(leg_angles_top, 60, 0, 0.0, 0.0, 0);
  252. }
  253. }
  254. rotate([0, (90 + elev_angle), -45]) {
  255. translate([0, 0, mic_radius - capsule_height + r_offset]) {
  256. capsule(leg_angles_top, 0, 0, 0.0, 0.0, 0);
  257. }
  258. }
  259. rotate([0, (90 + elev_angle), 135]) {
  260. translate([0, 0, mic_radius - capsule_height + r_offset]) {
  261. capsule(leg_angles_top, 0, 0, 0.0, 0.0, 0);
  262. }
  263. }
  264. }
  265. }
  266. // render individual capsules
  267. //
  268. module render_tetra_capsule_top() {
  269. capsule(leg_angles_top, 60, 0, 0.0, 0.0, 0);
  270. }
  271. module render_tetra_capsule_bot() {
  272. capsule(leg_angles_bot, 0, 1, 0.0, 0.0, 0);
  273. }
  274. // render simple microphone stand mount
  275. //
  276. module render_simple_stand_mount(z_offset) {
  277. translate([0, 0, z_offset]) {
  278. mount([-45, 135], mount_wall, mic_mount_wall, mic_mount_height + mount_top_height + mount_height + capsule_bottom);
  279. }
  280. }
  281. // capsule holder with conical mount
  282. //
  283. // ratio of capsule radius to transition length
  284. transition_ratio = 1.0;
  285. // ratio of capsule radius to bottom radius of holder
  286. holder_ratio = 0.4;
  287. // diameter of microphone capsule cable (Mogami 2490)
  288. capsule_cable_diam = 1.7;
  289. module capsule_holder(ratio, transition, hollow = true) {
  290. capsule_h = capsule_height;
  291. difference() {
  292. // main capsule holder, use a conical bore to press fit the capsule
  293. f = 0.05;
  294. cylinder(r = capsule_radius + fudge + wall, h = capsule_h, $fn = cfacets);
  295. if (hollow) cylinder(r1 = capsule_radius + fudge - f, r2 = capsule_radius + fudge, h = capsule_h + thin_mint, $fn = cfacets);
  296. }
  297. // conical transition into core sphere
  298. transition_h = transition * capsule_radius;
  299. translate([0, 0, - transition_h]) {
  300. difference() {
  301. cylinder(r2 = capsule_radius + fudge + wall, r1 = (capsule_radius) * ratio + wall, h = transition_h, $fn = facets);
  302. // add overhang so that we have a stop when inserting the capsule
  303. overhang = 0.2;
  304. if (hollow) cylinder(r2 = capsule_radius + fudge - overhang, r1 = (capsule_radius) * ratio, h = transition_h, $fn = facets);
  305. // add holes in the walls of the conical transition
  306. if (hollow) {
  307. for (r = [0:36:179]) {
  308. rotate([0, 90, r]) {
  309. translate([-transition_h, 0, -capsule_radius - 2 * wall])
  310. scale([3.5, 1.25, 1]) cylinder(r = 1.0, h = (capsule_radius + 2 * wall) * 2, $fn = facets);
  311. }
  312. }
  313. }
  314. }
  315. // lip to insert holder into core
  316. lip_d = 1.4 * wall;
  317. translate([0, 0, hollow == false ? -3 : -lip_d]) {
  318. difference() {
  319. // if not hollow make the ring longer to cut into core
  320. // cylinder(r = (capsule_radius) * ratio + wall + (hollow == true ? 0 : fit/2),
  321. cylinder(r = (capsule_radius) * ratio + wall + (hollow == true ? 0 : 0),
  322. h = hollow == true ? lip_d : 4.0, $fn = facets);
  323. if (hollow) { cylinder(r = capsule_cable_diam/2 * 1.4, h = lip_d + thin_mint, $fn = facets); }
  324. }
  325. }
  326. }
  327. }
  328. // new stype capsule array
  329. // the spherical core and mounting stalk
  330. //
  331. // render = 0: the full sphere (for visualization)
  332. // render = 1: upper half
  333. // render = -1: lower half with stalk
  334. // thickness of ring that connects both halves of the core sphere
  335. core_ring_height = 5.0;
  336. // holes for screws that hold together both halves of the sphere
  337. module capsule_holder_screws(radius, wall, screw_r, shift = 0) {
  338. h_offset = 1.2;
  339. for (r = [90, 270]) {
  340. for (t = [0, 45]) {
  341. m = t > 0 ? 1 : 0;
  342. // 11.5 matches the angle for the flat shaves in the core
  343. mirror([0, 0, m]) rotate([0, 11.5, r + t]) translate([-(radius + 2 * wall), 0, shift]) {
  344. rotate([0, 90, 0]) {
  345. cylinder(r = screw_r, h = radius, $fn = facets);
  346. }
  347. }
  348. }
  349. }
  350. }
  351. // ring that connects the two halves of the core sphere
  352. module capsule_holder_ring(offset = 3.5, shift = 0) {
  353. s_radius = mic_radius - capsule_radius * (1 + transition_ratio) + offset;
  354. ring_h = core_ring_height - 0.2;
  355. translate([0, 0, -ring_h/2]) difference() {
  356. cylinder(r = s_radius - 2.5 * wall - fit, h = ring_h, $fn = facets);
  357. cylinder(r = s_radius - 4 * wall - fit, h = ring_h, $fn = facets);
  358. // shift the holes slightly so the two halves are pressed together
  359. translate([0, 0, ring_h/2]) capsule_holder_screws(s_radius, wall, 0.65, shift);
  360. }
  361. }
  362. // spherical core
  363. module capsule_holder_core(top_radius, render = 0, offset = 3.5) {
  364. s_radius = mic_radius - capsule_radius * (1 + transition_ratio) + offset;
  365. difference() {
  366. union() {
  367. difference() {
  368. // core
  369. sphere(r = s_radius, $fn = facets);
  370. sphere(r = s_radius - 2.5 * wall, $fn = facets);
  371. // shave sides as well (cosmetic, really)
  372. for (az = [-45, 135]) rotate([0, -elev_angle, az]) {
  373. translate([s_radius - 0.5 * wall, -s_radius/2, -s_radius/2]) {
  374. cube([s_radius, s_radius, s_radius]);
  375. }
  376. }
  377. for (az = [45, -135]) rotate([0, elev_angle, az]) {
  378. translate([s_radius - 0.5 * wall, -s_radius/2, -s_radius/2]) {
  379. cube([s_radius, s_radius, s_radius]);
  380. }
  381. }
  382. // remove one half of the sphere
  383. if (render == 1) {
  384. translate([-mic_radius, -mic_radius, -mic_radius * 2]) cube([mic_radius * 2, mic_radius * 2, mic_radius * 2]);
  385. }
  386. if (render == -1) {
  387. translate([-mic_radius, -mic_radius, 0]) cube([mic_radius * 2, mic_radius * 2, mic_radius * 2]);
  388. }
  389. // make space for connection ring
  390. ring_h = core_ring_height;
  391. translate([0, 0, -ring_h/2]) {
  392. cylinder(r = s_radius - 2.5 * wall, h = ring_h, $fn = facets);
  393. }
  394. // hole for stalk
  395. if (render == -1) {
  396. translate([0, 0, -mic_radius]) cylinder(r = mount_radius - 2*wall, h = mic_radius, $fn = facets);
  397. }
  398. }
  399. // stalk that transitions into flare
  400. if (render == -1) {
  401. //stalk_len = 15.0;
  402. // normal length plus 10 to insert into flare
  403. stalk_len = stalk_height + 10.0 + 10.0;
  404. inset = wall;
  405. translate([0, 0, - (stalk_len - inset + s_radius)]) {
  406. difference() {
  407. cylinder(r = top_radius, h = stalk_len + inset, $fn = facets);
  408. cylinder(r = top_radius - wall, h = stalk_len + inset + thin_mint, $fn = facets);
  409. }
  410. }
  411. // add flange for coupling into flare
  412. translate([0, 0, - (stalk_height - inset - 0.5 + 10.0 + 10.0)]) {
  413. difference() {
  414. cylinder(r2 = top_radius, r1 = top_radius + wall, h = 10.0, $fn = facets);
  415. cylinder(r2 = top_radius - wall, r1 = top_radius, h = 10.0, $fn = facets);
  416. }
  417. }
  418. translate([top_radius, 0, - (stalk_height - inset - 0.5 + 10.0 + 10.0 + 10.0)]) {
  419. // add key to stalk so orientation is always correct
  420. difference() {
  421. cylinder(r = 0.4, h = 10.0, $fn = facets);
  422. }
  423. }
  424. }
  425. }
  426. // make holes for capsule holders
  427. render_tetra_capsule_holder_array(false);
  428. }
  429. // index for aligning the two halves of core sphere
  430. rotate([0, 0, 0]) translate([s_radius, 0, 0]) {
  431. difference() {
  432. scale([1, 1, 2]) sphere(r = 0.5, $fn = facets);
  433. translate([-2.2, -1, -4]) cube([2, 2, 8]);
  434. if (render == 1) {
  435. translate([-2, -1, -8]) cube([4, 2, 8]);
  436. }
  437. if (render == -1) {
  438. translate([-2, -1, 0]) cube([4, 2, 8]);
  439. }
  440. }
  441. }
  442. }
  443. holder_ratio = 0.4;
  444. transition_ratio = 0.8;
  445. module render_tetra_capsule_holder_array(hollow = true) {
  446. // all four capsules
  447. rotate([0, (90 - elev_angle), 45]) {
  448. translate([0, 0, mic_radius - capsule_height]) {
  449. capsule_holder(holder_ratio, transition_ratio, hollow);
  450. }
  451. }
  452. rotate([0, (90 - elev_angle), -135]) {
  453. translate([0, 0, mic_radius - capsule_height]) {
  454. capsule_holder(holder_ratio, transition_ratio, hollow);
  455. }
  456. }
  457. rotate([0, (90 + elev_angle), -45]) {
  458. translate([0, 0, mic_radius - capsule_height]) {
  459. capsule_holder(holder_ratio, transition_ratio, hollow);
  460. }
  461. }
  462. rotate([0, (90 + elev_angle), 135]) {
  463. translate([0, 0, mic_radius - capsule_height]) {
  464. capsule_holder(holder_ratio, transition_ratio, hollow);
  465. }
  466. }
  467. }