1
0

TinySphEAR.scad 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. //
  2. // TinySpHEAR, Tiny Spherical Harmonics Ear,
  3. // First Order (B-format) Ambisonics Microphone
  4. //
  5. // Copyright 2015-2016, Fernando Lopez-Lezcano, All Rights Reserved
  6. // nando@ccrma.stanford.edu
  7. //
  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. //
  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. //// model parameters
  30. // dimensions of the electret microphone capsule
  31. capsule_radius = 5;
  32. capsule_height = 4.5;
  33. // distance between the face of a capsule and the center of array
  34. //
  35. // for a 10mm capsule: with vertical legs -> 10.5mm min radius
  36. // with horizontal legs -> 10mm min radius
  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 = 3;
  42. // wall thickness of the capsule holder
  43. wall = 1;
  44. // width of the ridge that connects to the mount
  45. // measured: ridge = 2.20mm, slot = 2.0 .. 2.35mm
  46. ridge_width = 2.0;
  47. ridge_slot_width = 2.0;
  48. // add to the thickness of ridges
  49. ridge_fit = 0.1;
  50. // dimensions of microphone mount
  51. mount_radius = 2.75;
  52. mount_wall = 0.75;
  53. // height of mount
  54. mount_height = 40;
  55. // microphone stand mount
  56. //
  57. // diameter of existing shielded wires (x 4)
  58. mic_wire_diam = 1.5;
  59. mic_wire_hole_radius = 2.5;
  60. mic_wire_hole_offset = 5;
  61. // standard microphone stand
  62. // measured diameter = 13.5, inside diameter of sleeve = 13.79 (
  63. mic_mount_radius = 13.50 / 2;
  64. // add this to inside diameter
  65. mic_mount_fit = 0.1;
  66. mic_mount_slot_height = 11.5;
  67. mic_mount_slot_width = 4.25;
  68. mic_mount_slot_radius = 6.25 / 2;
  69. mic_mount_wall = 1.5;
  70. mic_mount_height = 35.0 + mic_wire_hole_offset + mic_wire_hole_radius + 2 * mic_mount_wall;
  71. //// end of model parameters
  72. ////
  73. //// rendering control
  74. // what to render:
  75. // 0 -> ready to print
  76. // set = 0 -> one capsule, set = 1 -> four capsules
  77. // 1 -> the whole microhone with four capsules
  78. rendermic = 1;
  79. renderset = 0;
  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.15;
  110. // adjustment for fit of slots in connection legs and mount
  111. fit = 0.1;
  112. // number of facets for rendering cylinders
  113. facets = 64;
  114. // microphone structure geometry
  115. capsule_sep_min = (mic_radius - capsule_height) * cos(elev_angle) - (capsule_radius + wall) * sin(elev_angle);
  116. capsule_sep_max = mic_radius * cos(elev_angle) - (capsule_radius + wall) * sin(elev_angle);
  117. capsule_bottom = mic_radius * sin(elev_angle) + (capsule_radius + wall) * cos(elev_angle);
  118. mount_radius_capsule = capsule_sep_max;
  119. ////////
  120. // microphone capsule holder
  121. // azimuth: horizontal orientation of the capsule
  122. // elevation: vertical orientation of the capsule
  123. // mounts: vectors containing the angle of the mount and the angle to the adjacent capsule
  124. // twist: rotate the whole capsule to match mounting legs
  125. // ridge: add 0, 1 or 2 ridges for attaching the structure to the mount
  126. // ridge_fit: tune the fit, used for carving slots in mount
  127. // solid: make the capsule holder solid, used in the mount code to carve the capsule rests
  128. module capsule (azimuth, elevation, mounts, twist, ridge, ridge_fit = 0.0, solid = 0) {
  129. rotate([0, 0, azimuth]) {
  130. rotate([0, (90 - elevation), 0]) {
  131. translate([0, 0, (rendermic == 0 && solid == 0) ? 0 : mic_radius - capsule_height]) {
  132. difference () {
  133. union () {
  134. // main capsule holder
  135. cylinder(r = capsule_radius + wall, h = capsule_height, $fn = facets);
  136. // the mounting legs
  137. for (angles = mounts) {
  138. rotate([0, 0, angles[0] + twist]) {
  139. // connect with cylindrical beams, very pretty
  140. if (connect == 0) {
  141. leg_length = mic_radius * cos(angles[1]) - capsule_radius * sin(angles[1]);
  142. translate([capsule_radius - wall, 0, capsule_height - wall]) {
  143. rotate([0, 180 - angles[1], 0]) {
  144. cylinder(d = leg_width, h = leg_length - 0.3, center = false, $fn = facets);
  145. }
  146. }
  147. }
  148. // connect with horizontal legs
  149. if (connect == 1) {
  150. leg_length = (mic_radius - capsule_height + leg_thick) * tan(90 - angles[1]) - capsule_radius;
  151. slot_depth = leg_thick * cos(90 - 2 * angles[1]) + wall + fit;
  152. translate([capsule_radius + leg_length + fudge, - leg_width / 3, 0]) {
  153. rotate([0, -90, 0]) {
  154. difference() {
  155. // thickness, width
  156. cube([leg_thick, leg_width, leg_length]);
  157. // cut slot in connector
  158. translate([0, leg_width / 3 - (fit / 2), 0]) {
  159. cube([leg_thick, leg_width / 3 + fit, slot_depth]);
  160. }
  161. }
  162. }
  163. }
  164. }
  165. // connect with vertical legs
  166. if (connect == 2) {
  167. // fix this 0.2 == (2 * fudge?)
  168. leg_length = (mic_radius * tan(90 - angles[1]) - capsule_radius) * tan(angles[1]) - 0.2;
  169. slot_depth = leg_thick * cos (90 - (2 * angles[1]));
  170. translate([capsule_radius - leg_thick / 2 + fudge, - leg_width / 3,
  171. - leg_length + capsule_height]) {
  172. difference() {
  173. // the connection
  174. difference() {
  175. cube([leg_thick + leg_thick / 2, leg_width, leg_length]);
  176. translate([-leg_thick + wall - fudge, 0, - capsule_height + fudge]) {
  177. cube([leg_thick, leg_width, leg_length]);
  178. }
  179. }
  180. // cut slot in connector
  181. translate([0, leg_width / 3 - (fit / 2), 0]) {
  182. cube([leg_thick + leg_thick / 2, leg_width / 3 + fit, slot_depth]);
  183. }
  184. }
  185. }
  186. }
  187. }
  188. }
  189. // add ridges for microphone mount
  190. ridge_length = (mic_radius - capsule_height) / tan(elev_angle) - (capsule_radius + wall);
  191. if (ridge == 2) {
  192. rotate([0, 0, twist]) {
  193. translate([capsule_radius + wall - ridge_length / 2, (ridge_width - ridge_fit) / 2, 0]) {
  194. cube([ridge_length * 3 / 2, ridge_width - ridge_fit, capsule_height], center = false);
  195. }
  196. translate([capsule_radius + wall - ridge_length / 2, - (ridge_width - ridge_fit) * 3 / 2, 0]) {
  197. cube([ridge_length * 3 / 2, ridge_width - ridge_fit, capsule_height], center = false);
  198. }
  199. }
  200. }
  201. if (ridge == 1) {
  202. rotate([0, 0, twist]) {
  203. translate([capsule_radius + wall - ridge_length / 2, - (ridge_width - ridge_fit) / 2, 0]) {
  204. cube([ridge_length * 3 / 2, ridge_width - ridge_fit, capsule_height], center = false);
  205. }
  206. }
  207. }
  208. }
  209. // make the hole for the capsule (also cuts leg overhang for vertical connectors)
  210. if (solid != 1) {
  211. translate ([0, 0, -capsule_height]) {
  212. cylinder(r = capsule_radius + fudge, h = capsule_height * 2, $fn = facets);
  213. }
  214. }
  215. // remove any extra connecting beam material from the face of the holder
  216. if (connect == 0) {
  217. translate ([0, 0, capsule_height]) {
  218. cylinder(r = capsule_radius + wall * 2, h = 2, $fn = facets);
  219. }
  220. }
  221. }
  222. }
  223. }
  224. }
  225. }
  226. // microphone mount
  227. //
  228. // clips into standard microphone stand
  229. //
  230. // angles: angles for mount slots
  231. // wall: thickness of cylinder wall
  232. // stand_wall: thickness of stand mount wall
  233. // separation: height of mount with respect of the microphone assembly
  234. module ellipsoid(height, rad_bot, rad_top, eccentricity) {
  235. linear_extrude(height = height, scale = [eccentricity, rad_top / rad_bot]) {
  236. circle(r = rad_bot, $fn = facets);
  237. }
  238. }
  239. module mount (angles, wall, stand_wall, separation) {
  240. cone_height = 5;
  241. translate([0, 0, -separation]) {
  242. difference() {
  243. union() {
  244. // conic section
  245. translate([0, 0, mic_mount_height + mount_height]) {
  246. rotate([0, 0, 45]) {
  247. difference() {
  248. ellipsoid(cone_height, mount_radius + wall, mount_radius_capsule, 1.4);
  249. ellipsoid(cone_height, mount_radius, mount_radius_capsule * 0.5, 1.4 * 1.1);
  250. }
  251. }
  252. }
  253. // stalk
  254. translate([0, 0, mic_mount_height + mount_height * 2/3]) {
  255. difference() {
  256. cylinder(r = mount_radius + wall, h = mount_height / 3, $fn = facets);
  257. // make the hole for the mount
  258. cylinder(r = mount_radius, h = mount_height / 3, $fn = facets);
  259. }
  260. }
  261. // transition to stand mount
  262. translate([0, 0, mic_mount_height]) {
  263. difference() {
  264. cylinder(r2 = mount_radius + wall, r1 = mic_mount_radius + mic_mount_fit + stand_wall,
  265. h = mount_height * 2 / 3, $fn = facets);
  266. // make the hole for the mount
  267. cylinder(r2 = mount_radius, r1 = mic_mount_radius + mic_mount_fit,
  268. h = mount_height * 2 / 3, $fn = facets);
  269. }
  270. }
  271. // stand mount
  272. translate([0, 0, 0]) {
  273. difference() {
  274. union() {
  275. // main mount cylinder
  276. translate([0, 0, 0]) {
  277. difference() {
  278. cylinder(r = mic_mount_radius + mic_mount_fit + stand_wall, h = mic_mount_height, $fn = facets);
  279. // make the hole for the mount (* 1.5 to cut the ridge as well)
  280. cylinder(r = mic_mount_radius + mic_mount_fit, h = mic_mount_height, $fn = facets);
  281. }
  282. }
  283. }
  284. // slot for fitting into microphone stand
  285. translate([mic_mount_radius - stand_wall / 2, - mic_mount_slot_width / 2, 0]) {
  286. cube([2 * stand_wall, mic_mount_slot_width, mic_mount_slot_height]);
  287. }
  288. // eyelet for microphone stand
  289. translate([mic_mount_radius - stand_wall / 2, 0, mic_mount_slot_height]) {
  290. rotate([0, 90, 0]) {
  291. cylinder(r = mic_mount_slot_radius, h = 2 * stand_wall, $fn = facets);
  292. }
  293. }
  294. // hole for microphone wiring
  295. translate([mic_mount_radius - stand_wall / 2, 0, mic_mount_height - mic_wire_hole_offset]) {
  296. rotate([0, 90, 0]) {
  297. cylinder(r = mic_wire_hole_radius, h = 2 * stand_wall, $fn = facets);
  298. }
  299. }
  300. }
  301. }
  302. }
  303. // indentations that match the two lower capsule holders
  304. translate([0, 0, mic_mount_height + mount_height + cone_height +
  305. (mic_radius - capsule_height) + capsule_height * sin(elev_angle)]) {
  306. capsule(angles[0], -elev_angle, [], 0, 1, 0.1, 1);
  307. capsule(angles[1], -elev_angle, [], 0, 1, 0.1, 1);
  308. }
  309. }
  310. }
  311. }
  312. // render a complete microphone
  313. if (rendermic == 1) {
  314. // all four capsules
  315. capsule(45, elev_angle, leg_angles_top, 60, 0, 0.0, 0);
  316. capsule(-135, elev_angle, leg_angles_top, 60, 0, 0.0, 0);
  317. capsule(-45, -elev_angle, leg_angles_bot, 0, 1, 0.0, 0);
  318. capsule(135, -elev_angle, leg_angles_bot, 0, 1, 0.0, 0);
  319. // the mount
  320. mount([-45, 135], mount_wall, mic_mount_wall, mic_mount_height + mount_height + 5 + capsule_bottom);
  321. }
  322. // print all the parts separately
  323. if (rendermic == 0) {
  324. if (connect == 1) {
  325. part_rot = 90;
  326. part_height = 0;
  327. part_sep = capsule_radius * 2.5;
  328. // #3
  329. translate([part_sep, -part_sep, part_height]) { capsule(0, part_rot, leg_angles_top, 60, 0); }
  330. if (renderset != 0) {
  331. // #4
  332. translate([part_sep, part_sep, part_height]) { capsule(0, part_rot, leg_angles_top, 60, 0); }
  333. // #2
  334. translate([-part_sep, part_sep, part_height]) { capsule(0, part_rot, leg_angles_bot, -90, 1); }
  335. // #1
  336. translate([-part_sep, -part_sep, part_height]) { capsule(0, part_rot, leg_angles_bot, 90, 1); }
  337. // mount body
  338. translate([0, 0, mount_height]) { mount([-45, 135], 1, 0); }
  339. // add connecting ridges to make it all one part
  340. difference() {
  341. for (rot_a = [-45, 45]) {
  342. rotate([0, 0, rot_a]) {
  343. translate([-wall / 2, -part_sep, 0]) {
  344. cube([wall, part_sep * 2, wall / 2]);
  345. }
  346. }
  347. }
  348. // remove them in the inside of the mount
  349. cylinder(r = mount_radius + wall / 2, h = wall / 2);
  350. }
  351. }
  352. } else {
  353. // connect == 2
  354. part_rot = -90;
  355. part_height = capsule_height;
  356. part_sep = capsule_radius * 2;
  357. // #3
  358. translate([part_sep, -part_sep, part_height]) { capsule(0, part_rot, leg_angles_top, 0, 0); }
  359. if (renderset != 0) {
  360. // #4
  361. translate([part_sep, part_sep, part_height]) { capsule(0, part_rot, leg_angles_top, 0, 0); }
  362. // #2
  363. translate([-part_sep, part_sep, part_height]) { capsule(0, part_rot, leg_angles_bot, -90, 1); }
  364. // #1
  365. translate([-part_sep, -part_sep, part_height]) { capsule(0, part_rot, leg_angles_bot, 90, 1); }
  366. // stand mount
  367. *translate([0, 0, 0]) {
  368. mount_to_stand([-45, 135], mount_wall, mic_mount_wall, 0);
  369. }
  370. // add connecting ridges to make it all one part
  371. difference() {
  372. for (rot_a = [-45, 45]) {
  373. rotate([0, 0, rot_a]) {
  374. translate([-wall / 2, -part_sep * 0.85, 0]) {
  375. cube([wall, part_sep * 1.75, wall / 2]);
  376. }
  377. }
  378. }
  379. // remove them in the inside of the mount
  380. *cylinder(r = mic_mount_radius + mount_wall / 2, h = wall / 2);
  381. }
  382. }
  383. }
  384. }