TinySphEAR.scad 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  1. //
  2. // TinySphEAR, Tiny Spherical Ear, First Order (B-format) Ambisonics Microphone
  3. //
  4. // Copyright 2015, Fernando Lopez-Lezcano, All Rights Reserved
  5. // nando@ccrma.stanford.edu
  6. //
  7. //
  8. // This program is free software: you can redistribute it and/or modify
  9. // it under the terms of the GNU General Public License as published by
  10. // the Free Software Foundation, either version 3 of the License, or
  11. // (at your option) any later version.
  12. //
  13. // This program is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. // GNU General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU General Public License
  19. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. //
  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. // https://en.wikipedia.org/wiki/Tetrahedron
  26. // angle of capsule to vertical axis = atan(sqrt(2)) = 54.7356103172
  27. ////
  28. //// model parameters
  29. // dimensions of the EM182 electret microphone
  30. capsule_radius = 5;
  31. capsule_height = 4.5;
  32. // distance between face of capsule and center of array
  33. mic_radius = 10;
  34. // dimensions of capsule holder connection legs
  35. // 4mm is too thin for the width, 5mm works better
  36. leg_width = 5;
  37. leg_thick = 2.5;
  38. // width of the ridge that connects to the mount
  39. ridge_width = 2.0;
  40. ridge_slot_width = 2;
  41. // wall thickness of capsule holder
  42. wall = 1;
  43. // dimensions of microphone holder
  44. mount_radius = 2.5;
  45. // height of mount
  46. mount_height = 30;
  47. // height of sleeve
  48. sleeve_height = 20;
  49. sleeve_wall = 0.75;
  50. //// end of model parameters
  51. ////
  52. //// rendering control
  53. // what to render:
  54. // 0 -> ready to print
  55. // set = 0 -> one capsule, set = 1 -> four capsules
  56. // 1 -> the whole microhone with four capsules
  57. rendermic = 1;
  58. renderset = 0;
  59. // what type of connection to use between capsule holders:
  60. // 0 -> original cylinder beams
  61. // 1 -> interlocking beams (out)
  62. // 2 -> interlocking beams (in)
  63. connect = 2;
  64. // what type of mount ridges to use
  65. // 0 -> nothing
  66. // 1 -> 1 ridge
  67. // 2 -> 2 ridges
  68. ridges = 1;
  69. //// end of rendering control
  70. ////
  71. // elevation angle for the capsule holders (fixed for this microphone)
  72. elev_angle = atan(sqrt(1/2));
  73. // angles of the connection legs and adjacent capsule holders
  74. leg_angles_top =
  75. [
  76. [-120, elev_angle],
  77. [0, elev_angle],
  78. [120, elev_angle]
  79. ];
  80. leg_angles_bot =
  81. [
  82. [-120, elev_angle],
  83. [120, elev_angle]
  84. ];
  85. // adjustment for the inner radius of the capsule holder
  86. // measured inside diameter of a trial print was around 7.5 to 8.2
  87. // instead of 10, capsule diameter was 9.99)
  88. fudge = 0.15;
  89. // adjustment for fit of slots in connection legs and mount
  90. fit = 0.2;
  91. // number of facets for rendering cylinders
  92. facets = 64;
  93. // microphone holder geometry
  94. capsule_sep_min = (mic_radius - capsule_height) * cos(elev_angle) - (capsule_radius + wall) * sin(elev_angle);
  95. capsule_sep_max = mic_radius * cos(elev_angle) - (capsule_radius + wall) * sin(elev_angle);
  96. capsule_bottom = mic_radius * sin(elev_angle) + (capsule_radius + wall) * cos(elev_angle);
  97. mount_slot_depth = ridge_length * sin(elev_angle);
  98. mount_radius_capsule = capsule_sep_max;
  99. ////////
  100. // microphone capsule holder
  101. // azimuth: horizontal orientation of the capsule
  102. // elevation: vertical orientation of the capsure
  103. // mounts: vectors containing the angle of the mount and the angle to the adjacent capsule
  104. // twist: rotate the whole capsule to match mounting legs
  105. // ridge: 1 -> print ridge for mount
  106. // solid: make the capsule holder solid, used in the mount to carve the capsule rests
  107. module capsule (azimuth, elevation, mounts, twist, ridge, solid = 0) {
  108. rotate([0, 0, azimuth]) {
  109. rotate([0, (90 - elevation), 0]) {
  110. translate([0, 0, rendermic == 0 ? 0 : mic_radius - capsule_height]) {
  111. difference () {
  112. union () {
  113. // main capsule holder
  114. cylinder(r = capsule_radius + wall, h = capsule_height, $fn = facets);
  115. // the mounting legs
  116. for (angles = mounts) {
  117. rotate([0, 0, angles[0] + twist]) {
  118. // connect with cylindrical beams, very pretty
  119. if (connect == 0) {
  120. leg_length = mic_radius * cos(angles[1]) - capsule_radius * sin(angles[1]);
  121. translate([capsule_radius - wall, 0, capsule_height - wall]) {
  122. rotate([0, 180 - angles[1], 0]) {
  123. cylinder(d = leg_width, h = leg_length - 0.3, center = false, $fn = facets);
  124. }
  125. }
  126. }
  127. // connect with horizontal legs
  128. if (connect == 1) {
  129. leg_length = (mic_radius - capsule_height + leg_thick) * tan(90 - angles[1]) - capsule_radius;
  130. slot_depth = leg_thick * cos(90 - 2 * angles[1]) + wall + fit;
  131. translate([capsule_radius + leg_length + fudge, - leg_width / 3, 0]) {
  132. rotate([0, -90, 0]) {
  133. difference() {
  134. // thickness, width
  135. cube([leg_thick, leg_width, leg_length]);
  136. // cut slot in connector
  137. translate([0, leg_width / 3 - (fit / 2), 0]) {
  138. cube([leg_thick, leg_width / 3 + fit, slot_depth]);
  139. }
  140. }
  141. }
  142. }
  143. }
  144. // connect with vertical legs
  145. if (connect == 2) {
  146. // fix this 0.2 == (2 * fudge?)
  147. leg_length = (mic_radius * tan(90 - angles[1]) - capsule_radius) * tan(angles[1]) - 0.2;
  148. slot_depth = leg_thick * cos (90 - (2 * angles[1]));
  149. translate([capsule_radius - leg_thick / 2 + fudge, - leg_width / 3,
  150. - leg_length + capsule_height]) {
  151. difference() {
  152. // thickness, width
  153. difference() {
  154. cube([leg_thick + leg_thick / 2, leg_width, leg_length]);
  155. translate([-leg_thick / 2 + wall - fudge, 0, - capsule_height + fudge]) {
  156. cube([leg_thick, leg_width, leg_length]);
  157. }
  158. }
  159. // cut slot in connector
  160. translate([0, leg_width / 3 - (fit / 2), 0]) {
  161. cube([leg_thick + leg_thick / 2, leg_width / 3 + fit, slot_depth]);
  162. }
  163. }
  164. }
  165. }
  166. }
  167. }
  168. // add ridges for microphone mount
  169. ridge_length = (mic_radius - capsule_height) / tan(elev_angle) - (capsule_radius + wall);
  170. if (ridge == 2) {
  171. rotate([0, 0, twist]) {
  172. translate([capsule_radius + wall - ridge_length / 2, ridge_slot_width / 2, 0]) {
  173. cube([ridge_length * 3 / 2, ridge_width, capsule_height], center = false);
  174. }
  175. translate([capsule_radius + wall - ridge_length / 2, -ridge_width - ridge_slot_width / 2, 0]) {
  176. cube([ridge_length * 3 / 2, ridge_width, capsule_height], center = false);
  177. }
  178. }
  179. }
  180. if (ridge == 1) {
  181. rotate([0, 0, twist]) {
  182. translate([capsule_radius + wall - ridge_length / 2, -ridge_width / 2, 0]) {
  183. cube([ridge_length * 3 / 2, ridge_width, capsule_height], center = false);
  184. }
  185. }
  186. }
  187. }
  188. // make the hole for the capsule
  189. if (solid != 1) {
  190. translate ([0, 0, 0]) {
  191. cylinder(r = capsule_radius + fudge, h = capsule_height, $fn = facets);
  192. }
  193. }
  194. // remove any extra connecting beam material from the face of the holder
  195. if (connect == 0) {
  196. translate ([0, 0, capsule_height]) {
  197. cylinder(r = capsule_radius + wall * 2, h = 2, $fn = facets);
  198. }
  199. }
  200. }
  201. }
  202. }
  203. }
  204. }
  205. // microphone mount
  206. //
  207. // angles: angles for mount slots
  208. // wall: thickness of cylinder wall
  209. // separation: height of mount with respect of the microphone assembly
  210. module mount (angles, wall, separation) {
  211. capsule_indent = (capsule_radius * cos(elev_angle)) * 1.25;
  212. cone_height = 5;
  213. translate([0, 0, -(separation - 0)]) {
  214. difference() {
  215. union() {
  216. // conic section
  217. translate([0, 0, -cone_height]) {
  218. difference() {
  219. cylinder(r2 = mount_radius_capsule, r1 = mount_radius + wall, h = cone_height, $fn = facets);
  220. // make the hole for the mount (* 1.5 to cut the ridge as well)
  221. cylinder(r2 = mount_radius_capsule - wall, r1 = mount_radius, h = cone_height * 1.5, $fn = facets);
  222. }
  223. }
  224. translate([0, 0, -mount_height]) {
  225. difference() {
  226. cylinder(r = mount_radius + wall, h = mount_height - cone_height, $fn = facets);
  227. // make the hole for the mount (* 1.5 to cut the ridge as well)
  228. cylinder(r = mount_radius, h = (mount_height - cone_height) * 1.5, $fn = facets);
  229. }
  230. }
  231. }
  232. // indentations that match the lower capsule holders
  233. translate([0, 0, separation - capsule_height * cos (elev_angle)]) {
  234. capsule(-45, -elev_angle, [], 0, 1);
  235. capsule(135, -elev_angle, [], 0, 1);
  236. }
  237. // %for (rot = angles) {
  238. // rotate([0, 0, rot]) {
  239. // translate([mount_radius_capsule, 0, capsule_indent]) {
  240. // rotate([0, 90 + elev_angle, 0]) {
  241. // cylinder(r = capsule_radius + wall, h = capsule_height * 2, $fn = facets);
  242. // }
  243. // }
  244. // }
  245. // }
  246. // slots for the mounting ridges
  247. // for (rot = angles) {
  248. // rotate([0, -elev_angle, rot]) {
  249. // translate([-capsule_sep_max * 2, -ridge_width / 2, mount_slot_depth - 2 * wall]) {
  250. // cube([capsule_sep_max * 2, ridge_width + fit, mount_height]);
  251. // }
  252. // }
  253. // }
  254. // slice it open so we can pop in cables
  255. rotate([0, 0, 45]) {
  256. translate([mount_radius - fudge, - wall / 2, -mount_height]) {
  257. cube([mount_radius_capsule - mount_radius + fudge, wall, mount_height]);
  258. }
  259. }
  260. }
  261. }
  262. }
  263. module mount_sleeve (wall, separation) {
  264. translate([0, 0, -(separation + 0.0)]) {
  265. difference() {
  266. union() {
  267. // main mount cylinder
  268. translate([0, 0, -mount_height]) {
  269. difference() {
  270. cylinder(r = mount_radius + 2 * wall, h = sleeve_height, $fn = facets);
  271. // make the hole for the mount (* 1.5 to cut the ridge as well)
  272. cylinder(r = mount_radius + wall, h = sleeve_height * 1.5, $fn = facets);
  273. }
  274. }
  275. // spine that fits into slice of mount body
  276. rotate([0, 0, 45]) {
  277. translate([mount_radius - wall, - wall / 2, -mount_height]) {
  278. cube([2 * wall, wall, sleeve_height]);
  279. }
  280. }
  281. }
  282. // cut a bit less that one half of the sleeve so it fits around the body
  283. rotate([0, 0, 45]) {
  284. translate([-mount_radius - 3 * wall, - (mount_radius + wall) * 1.5, -mount_height]) {
  285. cube([mount_radius + wall, (mount_radius + wall) * 3, sleeve_height]);
  286. }
  287. }
  288. }
  289. }
  290. }
  291. box_height = 4.0;
  292. module mount_cube_2 (angles, wall, separation) {
  293. translate([0, 0, -separation]) {
  294. rotate([0, 0, 45]) {
  295. difference() {
  296. int_width = leg_width * 4 / 3;
  297. translate([-(int_width) / 2, -(capsule_sep_max - 2.1), - box_height]) {
  298. difference() {
  299. translate([-wall, -wall, 0]) {
  300. cube([int_width + 2 * wall, (capsule_sep_max - 2.1) * 2 + 2 * wall, box_height]);
  301. }
  302. cube([int_width, (capsule_sep_max - 2.1) * 2, box_height]);
  303. }
  304. }
  305. }
  306. }
  307. }
  308. }
  309. mount_top_depth = 2.0;
  310. mount_stalk_radius = 1.5;
  311. mount_stalk_length = 8;
  312. module mount_cube (angles, wall, separation) {
  313. translate([0, 0, -separation]) {
  314. rotate([0, 0, 45]) {
  315. difference() {
  316. translate([-(ridge_slot_width + 2 * ridge_width) / 2, -capsule_sep_max, - mount_top_depth]) {
  317. cube([ridge_slot_width + 2 * ridge_width, capsule_sep_max * 2, mount_top_depth]);
  318. }
  319. // cut a slot for the ridges in the mount
  320. for (rot = angles) {
  321. rotate([0, -elev_angle, -45 + rot]) {
  322. translate([-capsule_sep_max * 2, 0.5 * ridge_slot_width - fit / 2, mount_slot_depth - 0.6 * wall]) {
  323. cube([capsule_sep_max * 2, ridge_slot_width + fit, mount_height]);
  324. }
  325. translate([-capsule_sep_max * 2, - 1.5 * ridge_slot_width - fit / 2, mount_slot_depth - 0.6 * wall]) {
  326. cube([capsule_sep_max * 2, ridge_slot_width + fit, mount_height]);
  327. }
  328. // top of the ridge
  329. translate([-capsule_sep_max * 2, -ridge_slot_width, mount_slot_depth + wall]) {
  330. cube([capsule_sep_max * 2, 2 * ridge_slot_width + fit, mount_height]);
  331. }
  332. }
  333. }
  334. // cut a hole for the mounting stalk
  335. translate([0, 0, -mount_top_depth]) {
  336. cylinder(r = mount_stalk_radius, h = mount_top_depth, $fn = facets);
  337. }
  338. }
  339. }
  340. }
  341. }
  342. module mount_cylinder (angles, wall, separation) {
  343. translate([0, 0, -(separation + 0.0)]) {
  344. difference() {
  345. union() {
  346. // main mount cylinder
  347. translate([0, 0, -mount_height]) {
  348. difference() {
  349. cylinder(r = mount_radius + wall, h = mount_height, $fn = facets);
  350. // make the hole for the mount (* 1.5 to cut the ridge as well)
  351. cylinder(r = mount_radius, h = mount_height * 1.5, $fn = facets);
  352. }
  353. }
  354. // make rests for microphone ridges thicker
  355. rotate([0, 0, 45]) {
  356. for (move = [- (ridge_slot_width / 2 + ridge_width), (ridge_slot_width / 2 + ridge_width) - 2 * wall]) {
  357. translate([move, -mount_radius, -mount_height]) {
  358. cube([2 * wall, mount_radius * 2, mount_height]);
  359. }
  360. }
  361. }
  362. }
  363. // shave exterior of the cylinder, erases extensions that protrude
  364. translate([0, 0, -mount_height]) {
  365. difference() {
  366. cylinder(r = mount_radius + 2 * wall, h = mount_height, $fn = facets);
  367. cylinder(r = mount_radius + wall, h = mount_height, $fn = facets);
  368. }
  369. }
  370. // cut a slot for the ridges in the wall of the cylinder
  371. for (rot = angles) {
  372. rotate([0, -elev_angle, rot]) {
  373. translate([-capsule_sep_max * 2, 0.5 * ridge_slot_width - fit / 2, mount_slot_depth - wall]) {
  374. cube([capsule_sep_max * 2, ridge_slot_width + fit, mount_height]);
  375. }
  376. translate([-capsule_sep_max * 2, - 1.5 * ridge_slot_width - fit / 2, mount_slot_depth - wall]) {
  377. cube([capsule_sep_max * 2, ridge_slot_width + fit, mount_height]);
  378. }
  379. // top of the ridge
  380. // translate([-capsule_sep_max * 2, -ridge_slot_width, mount_slot_depth]) {
  381. // cube([capsule_sep_max * 2, 2 * ridge_slot_width + fit, mount_height]);
  382. // }
  383. }
  384. }
  385. // lower the top of theo mount ridges (we have to do the geometry of all this...)
  386. rotate([0, 0, -45]) {
  387. translate([- capsule_sep_max, -ridge_slot_width / 2, -0.4]) {
  388. cube([capsule_sep_max * 2, ridge_slot_width, 2]);
  389. }
  390. }
  391. }
  392. }
  393. }
  394. // render a complete microphone
  395. if (rendermic == 1) {
  396. capsule(45, elev_angle, leg_angles_top, 60, 0);
  397. capsule(-135, elev_angle, leg_angles_top, 60, 0);
  398. capsule(-45, -elev_angle, leg_angles_bot, 0, 1);
  399. capsule(135, -elev_angle, leg_angles_bot, 0, 1);
  400. // the mount
  401. mount([-45, 135], wall, capsule_bottom);
  402. // the sleeve closing it
  403. mount_sleeve(sleeve_wall, capsule_bottom);
  404. }
  405. // print all the parts separately
  406. if (rendermic == 0) {
  407. if (connect == 1) {
  408. part_rot = 90;
  409. part_height = 0;
  410. part_sep = capsule_radius * 2.5;
  411. // #3
  412. translate([part_sep, -part_sep, part_height]) { capsule(0, part_rot, leg_angles_top, 60, 0); }
  413. if (renderset != 0) {
  414. // #4
  415. translate([part_sep, part_sep, part_height]) { capsule(0, part_rot, leg_angles_top, 60, 0); }
  416. // #2
  417. translate([-part_sep, part_sep, part_height]) { capsule(0, part_rot, leg_angles_bot, -90, 1); }
  418. // #1
  419. translate([-part_sep, -part_sep, part_height]) { capsule(0, part_rot, leg_angles_bot, 90, 1); }
  420. // mount body
  421. translate([0, 0, mount_height]) { mount([-45, 135], 1, 0); }
  422. // mount sleeve
  423. translate([mount_radius * 8, 0, mount_height]) { mount_sleeve(1, 0); }
  424. // add connecting ridges to make it all one part
  425. difference() {
  426. for (rot_a = [-45, 45]) {
  427. rotate([0, 0, rot_a]) {
  428. translate([-wall / 2, -part_sep, 0]) {
  429. cube([wall, part_sep * 2, wall / 2]);
  430. }
  431. }
  432. }
  433. // remove them in the inside of the mount
  434. cylinder(r = mount_radius + wall / 2, h = wall / 2);
  435. }
  436. }
  437. } else {
  438. // connect == 2
  439. part_rot = -90;
  440. part_height = capsule_height;
  441. part_sep = capsule_radius * 2;
  442. // #3
  443. translate([part_sep, -part_sep, part_height]) { capsule(0, part_rot, leg_angles_top, 0, 0); }
  444. if (renderset != 0) {
  445. // #4
  446. *translate([part_sep, part_sep, part_height]) { capsule(0, part_rot, leg_angles_top, 0, 0); }
  447. // #2
  448. *translate([-part_sep, part_sep, part_height]) { capsule(0, part_rot, leg_angles_bot, -90, 1); }
  449. // #1
  450. *translate([-part_sep, -part_sep, part_height]) { capsule(0, part_rot, leg_angles_bot, 90, 1); }
  451. // mount
  452. *translate([0, 0, mount_height]) { mount([-45, 135], 1, 0); }
  453. // add connecting ridges to make it all one part
  454. *difference() {
  455. for (rot_a = [-45, 45]) {
  456. rotate([0, 0, rot_a]) {
  457. translate([-wall / 2, -part_sep * 0.85, 0]) {
  458. cube([wall, part_sep * 1.75, wall / 2]);
  459. }
  460. }
  461. }
  462. // remove them in the inside of the mount
  463. cylinder(r = mount_radius + wall / 2, h = wall / 2);
  464. }
  465. }
  466. }
  467. }