1
0

TinySphEAR.scad 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  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. ridge_length = 2.5;
  42. // wall thickness of capsule holder
  43. wall = 1;
  44. // dimensions of microphone holder
  45. mount_radius = 3.5;
  46. // height of mount
  47. mount_height = 30;
  48. // height of sleeve
  49. sleeve_height = 25;
  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 = 1;
  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. ////////
  99. // microphone capsule holder
  100. // azimuth: horizontal orientation of the capsule
  101. // elevation: vertical orientation of the capsure
  102. // mounts: vectors containing the angle of the mount and the angle to the adjacent capsule
  103. // twist: rotate the whole capsule to match mounting legs
  104. // ridge: 1 -> print ridge for mount
  105. module capsule (azimuth, elevation, mounts, twist, ridge) {
  106. rotate([0, 0, azimuth]) {
  107. rotate([0, (90 - elevation), 0]) {
  108. translate([0, 0, rendermic == 0 ? 0 : mic_radius - capsule_height]) {
  109. difference () {
  110. union () {
  111. // main capsule holder
  112. cylinder(r = capsule_radius + wall, h = capsule_height, $fn = facets);
  113. // the mounting legs
  114. for (angles = mounts) {
  115. rotate([0, 0, angles[0] + twist]) {
  116. // connect with cylindrical beams, very pretty
  117. if (connect == 0) {
  118. leg_length = mic_radius * cos(angles[1]) - capsule_radius * sin(angles[1]);
  119. translate([capsule_radius - wall, 0, capsule_height - wall]) {
  120. rotate([0, 180 - angles[1], 0]) {
  121. cylinder(d = leg_width, h = leg_length - 0.3, center = false, $fn = facets);
  122. }
  123. }
  124. }
  125. // connect with horizontal legs
  126. if (connect == 1) {
  127. leg_length = (mic_radius - capsule_height + leg_thick) * tan(90 - angles[1]) - capsule_radius;
  128. slot_depth = leg_thick * cos(90 - 2 * angles[1]) + wall + fit;
  129. translate([capsule_radius + leg_length + fudge, - leg_width / 3, 0]) {
  130. rotate([0, -90, 0]) {
  131. difference() {
  132. // thickness, width
  133. cube([leg_thick, leg_width, leg_length]);
  134. // cut slot in connector
  135. translate([0, leg_width / 3 - (fit / 2), 0]) {
  136. cube([leg_thick, leg_width / 3 + fit, slot_depth]);
  137. }
  138. }
  139. }
  140. }
  141. }
  142. // connect with vertical legs
  143. if (connect == 2) {
  144. // fix this 0.2 == (2 * fudge?)
  145. leg_length = (mic_radius * tan(90 - angles[1]) - capsule_radius) * tan(angles[1]) - 0.2;
  146. slot_depth = leg_thick * cos (90 - (2 * angles[1]));
  147. translate([capsule_radius - leg_thick / 2 + fudge, - leg_width / 3,
  148. - leg_length + capsule_height]) {
  149. difference() {
  150. // thickness, width
  151. difference() {
  152. cube([leg_thick + leg_thick / 2, leg_width, leg_length]);
  153. translate([0, 0, -capsule_height + fudge]) {
  154. cube([leg_thick / 2, leg_width, leg_length]);
  155. }
  156. }
  157. // cut slot in connector
  158. translate([0, leg_width / 3 - (fit / 2), 0]) {
  159. cube([leg_thick + leg_thick / 2, leg_width / 3 + fit, slot_depth]);
  160. }
  161. }
  162. }
  163. }
  164. }
  165. }
  166. // add ridges for microphone mount
  167. if (ridge == 2) {
  168. rotate([0, 0, twist]) {
  169. translate([capsule_radius - ridge_length / 2 + fudge, ridge_slot_width / 2, 0]) {
  170. cube([ridge_length * 3 / 2, ridge_width, capsule_height], center = false);
  171. }
  172. translate([capsule_radius - ridge_length / 2 + fudge, -ridge_width - ridge_slot_width / 2, 0]) {
  173. cube([ridge_length * 3 / 2, ridge_width, capsule_height], center = false);
  174. }
  175. }
  176. }
  177. if (ridge == 1) {
  178. rotate([0, 0, twist]) {
  179. translate([capsule_radius - ridge_length / 2 + fudge, -ridge_width / 2, 0]) {
  180. cube([ridge_length * 3 / 2, ridge_width, capsule_height], center = false);
  181. }
  182. }
  183. }
  184. }
  185. // make the hole for the capsule
  186. translate ([0, 0, 0]) {
  187. cylinder(r = capsule_radius + fudge, h = capsule_height, $fn = facets);
  188. }
  189. // remove any extra connecting beam material from the face of the holder
  190. if (connect == 0) {
  191. translate ([0, 0, capsule_height]) {
  192. cylinder(r = capsule_radius + wall * 2, h = 2, $fn = facets);
  193. }
  194. }
  195. }
  196. }
  197. }
  198. }
  199. }
  200. // microphone mount
  201. //
  202. // angles: angles for mount slots
  203. // wall: thickness of cylinder wall
  204. // separation: height of mount with respect of the microphone assembly
  205. module mount (angles, wall, separation) {
  206. translate([0, 0, -(separation + 0.0)]) {
  207. difference() {
  208. union() {
  209. // main mount cylinder
  210. translate([0, 0, -mount_height]) {
  211. difference() {
  212. cylinder(r = mount_radius + wall, h = mount_height, $fn = facets);
  213. // make the hole for the mount (* 1.5 to cut the ridge as well)
  214. cylinder(r = mount_radius, h = mount_height * 1.5, $fn = facets);
  215. }
  216. }
  217. }
  218. // indentations that match the lower capsule holders
  219. for (rot = angles) {
  220. rotate([0, 0, rot + 45]) {
  221. translate([-mount_radius * 1.6, mount_radius * 1.6, 8.0 / 3]) {
  222. rotate([0, 90 - elev_angle, -45]) {
  223. cylinder(r = capsule_radius + wall, h = capsule_height * 2, $fn = facets);
  224. }
  225. }
  226. }
  227. }
  228. // slots for the mounting ridges
  229. for (rot = angles) {
  230. rotate([0, -elev_angle, rot]) {
  231. translate([-capsule_sep_max * 2, -ridge_width / 2, mount_slot_depth - 2 * wall]) {
  232. cube([capsule_sep_max * 2, ridge_width + fit, mount_height]);
  233. }
  234. }
  235. }
  236. // slice it open so we can pop in cables
  237. rotate([0, 0, 45]) {
  238. translate([mount_radius - wall / 2, - wall / 2, -mount_height]) {
  239. cube([2 * wall, wall, mount_height]);
  240. }
  241. }
  242. }
  243. }
  244. }
  245. module mount_sleeve (wall, separation) {
  246. translate([0, 0, -(separation + 0.0)]) {
  247. difference() {
  248. union() {
  249. // main mount cylinder
  250. translate([0, 0, -mount_height]) {
  251. difference() {
  252. cylinder(r = mount_radius + 2 * wall, h = sleeve_height, $fn = facets);
  253. // make the hole for the mount (* 1.5 to cut the ridge as well)
  254. cylinder(r = mount_radius + wall, h = sleeve_height * 1.5, $fn = facets);
  255. }
  256. }
  257. // spine that fits into slice of mount body
  258. rotate([0, 0, 45]) {
  259. translate([mount_radius - wall, - wall / 2, -mount_height]) {
  260. cube([2 * wall, wall, sleeve_height]);
  261. }
  262. }
  263. }
  264. // cut a bit less that one half of the sleeve so it fits around the body
  265. rotate([0, 0, 45]) {
  266. translate([-mount_radius - 3 * wall, - (mount_radius + wall) * 1.5, -mount_height]) {
  267. cube([mount_radius + wall, (mount_radius + wall) * 3, sleeve_height]);
  268. }
  269. }
  270. }
  271. }
  272. }
  273. box_height = 4.0;
  274. module mount_cube_2 (angles, wall, separation) {
  275. translate([0, 0, -separation]) {
  276. rotate([0, 0, 45]) {
  277. difference() {
  278. int_width = leg_width * 4 / 3;
  279. translate([-(int_width) / 2, -(capsule_sep_max - 2.1), - box_height]) {
  280. difference() {
  281. translate([-wall, -wall, 0]) {
  282. cube([int_width + 2 * wall, (capsule_sep_max - 2.1) * 2 + 2 * wall, box_height]);
  283. }
  284. cube([int_width, (capsule_sep_max - 2.1) * 2, box_height]);
  285. }
  286. }
  287. }
  288. }
  289. }
  290. }
  291. mount_top_depth = 2.0;
  292. mount_stalk_radius = 1.5;
  293. mount_stalk_length = 8;
  294. module mount_cube (angles, wall, separation) {
  295. translate([0, 0, -separation]) {
  296. rotate([0, 0, 45]) {
  297. difference() {
  298. translate([-(ridge_slot_width + 2 * ridge_width) / 2, -capsule_sep_max, - mount_top_depth]) {
  299. cube([ridge_slot_width + 2 * ridge_width, capsule_sep_max * 2, mount_top_depth]);
  300. }
  301. // cut a slot for the ridges in the mount
  302. for (rot = angles) {
  303. rotate([0, -elev_angle, -45 + rot]) {
  304. translate([-capsule_sep_max * 2, 0.5 * ridge_slot_width - fit / 2, mount_slot_depth - 0.6 * wall]) {
  305. cube([capsule_sep_max * 2, ridge_slot_width + fit, mount_height]);
  306. }
  307. translate([-capsule_sep_max * 2, - 1.5 * ridge_slot_width - fit / 2, mount_slot_depth - 0.6 * wall]) {
  308. cube([capsule_sep_max * 2, ridge_slot_width + fit, mount_height]);
  309. }
  310. // top of the ridge
  311. translate([-capsule_sep_max * 2, -ridge_slot_width, mount_slot_depth + wall]) {
  312. cube([capsule_sep_max * 2, 2 * ridge_slot_width + fit, mount_height]);
  313. }
  314. }
  315. }
  316. // cut a hole for the mounting stalk
  317. translate([0, 0, -mount_top_depth]) {
  318. cylinder(r = mount_stalk_radius, h = mount_top_depth, $fn = facets);
  319. }
  320. }
  321. }
  322. }
  323. }
  324. module mount_cylinder (angles, wall, separation) {
  325. translate([0, 0, -(separation + 0.0)]) {
  326. difference() {
  327. union() {
  328. // main mount cylinder
  329. translate([0, 0, -mount_height]) {
  330. difference() {
  331. cylinder(r = mount_radius + wall, h = mount_height, $fn = facets);
  332. // make the hole for the mount (* 1.5 to cut the ridge as well)
  333. cylinder(r = mount_radius, h = mount_height * 1.5, $fn = facets);
  334. }
  335. }
  336. // make rests for microphone ridges thicker
  337. rotate([0, 0, 45]) {
  338. for (move = [- (ridge_slot_width / 2 + ridge_width), (ridge_slot_width / 2 + ridge_width) - 2 * wall]) {
  339. translate([move, -mount_radius, -mount_height]) {
  340. cube([2 * wall, mount_radius * 2, mount_height]);
  341. }
  342. }
  343. }
  344. }
  345. // shave exterior of the cylinder, erases extensions that protrude
  346. translate([0, 0, -mount_height]) {
  347. difference() {
  348. cylinder(r = mount_radius + 2 * wall, h = mount_height, $fn = facets);
  349. cylinder(r = mount_radius + wall, h = mount_height, $fn = facets);
  350. }
  351. }
  352. // cut a slot for the ridges in the wall of the cylinder
  353. for (rot = angles) {
  354. rotate([0, -elev_angle, rot]) {
  355. translate([-capsule_sep_max * 2, 0.5 * ridge_slot_width - fit / 2, mount_slot_depth - wall]) {
  356. cube([capsule_sep_max * 2, ridge_slot_width + fit, mount_height]);
  357. }
  358. translate([-capsule_sep_max * 2, - 1.5 * ridge_slot_width - fit / 2, mount_slot_depth - wall]) {
  359. cube([capsule_sep_max * 2, ridge_slot_width + fit, mount_height]);
  360. }
  361. // top of the ridge
  362. // translate([-capsule_sep_max * 2, -ridge_slot_width, mount_slot_depth]) {
  363. // cube([capsule_sep_max * 2, 2 * ridge_slot_width + fit, mount_height]);
  364. // }
  365. }
  366. }
  367. // lower the top of theo mount ridges (we have to do the geometry of all this...)
  368. rotate([0, 0, -45]) {
  369. translate([- capsule_sep_max, -ridge_slot_width / 2, -0.4]) {
  370. cube([capsule_sep_max * 2, ridge_slot_width, 2]);
  371. }
  372. }
  373. }
  374. }
  375. }
  376. // render a complete microphone
  377. if (rendermic == 1) {
  378. capsule(45, elev_angle, leg_angles_top, 60, 0);
  379. capsule(-135, elev_angle, leg_angles_top, 60, 0);
  380. capsule(-45, -elev_angle, leg_angles_bot, 0, 1);
  381. capsule(135, -elev_angle, leg_angles_bot, 0, 1);
  382. // the mount
  383. mount([-45, 135], 1, capsule_bottom);
  384. // the sleeve closing it
  385. mount_sleeve(1, capsule_bottom);
  386. }
  387. // print all the parts separately
  388. if (rendermic == 0) {
  389. if (connect == 1) {
  390. part_rot = 90;
  391. part_height = 0;
  392. part_sep = capsule_radius * 2.5;
  393. // #3
  394. translate([part_sep, -part_sep, part_height]) { capsule(0, part_rot, leg_angles_top, 60, 0); }
  395. if (renderset != 0) {
  396. // #4
  397. translate([part_sep, part_sep, part_height]) { capsule(0, part_rot, leg_angles_top, 60, 0); }
  398. // #2
  399. translate([-part_sep, part_sep, part_height]) { capsule(0, part_rot, leg_angles_bot, -90, 1); }
  400. // #1
  401. translate([-part_sep, -part_sep, part_height]) { capsule(0, part_rot, leg_angles_bot, 90, 1); }
  402. // mount body
  403. translate([0, 0, mount_height]) { mount([-45, 135], 1, 0); }
  404. // mount sleeve
  405. translate([mount_radius * 8, 0, mount_height]) { mount_sleeve(1, 0); }
  406. // add connecting ridges to make it all one part
  407. difference() {
  408. for (rot_a = [-45, 45]) {
  409. rotate([0, 0, rot_a]) {
  410. translate([-wall / 2, -part_sep, 0]) {
  411. cube([wall, part_sep * 2, wall / 2]);
  412. }
  413. }
  414. }
  415. // remove them in the inside of the mount
  416. cylinder(r = mount_radius + wall / 2, h = wall / 2);
  417. }
  418. }
  419. } else {
  420. // connect == 2
  421. part_rot = -90;
  422. part_height = capsule_height;
  423. part_sep = capsule_radius * 2;
  424. // #3
  425. translate([part_sep, -part_sep, part_height]) { capsule(0, part_rot, leg_angles_top, 0, 0); }
  426. if (renderset != 0) {
  427. // #4
  428. translate([part_sep, part_sep, part_height]) { capsule(0, part_rot, leg_angles_top, 0, 0); }
  429. // #2
  430. translate([-part_sep, part_sep, part_height]) { capsule(0, part_rot, leg_angles_bot, -90, 1); }
  431. // #1
  432. translate([-part_sep, -part_sep, part_height]) { capsule(0, part_rot, leg_angles_bot, 90, 1); }
  433. // mount
  434. translate([0, 0, mount_height]) { mount([-45, 135], 1, 0); }
  435. // add connecting ridges to make it all one part
  436. difference() {
  437. for (rot_a = [-45, 45]) {
  438. rotate([0, 0, rot_a]) {
  439. translate([-wall / 2, -part_sep * 0.85, 0]) {
  440. cube([wall, part_sep * 1.75, wall / 2]);
  441. }
  442. }
  443. }
  444. // remove them in the inside of the mount
  445. cylinder(r = mount_radius + wall / 2, h = wall / 2);
  446. }
  447. }
  448. }
  449. }