1
0

TinySphEAR.scad 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  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;
  40. ridge_slot_width = 4.5;
  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 = 20;
  48. //// end of model parameters
  49. ////
  50. //// rendering control
  51. // what to render:
  52. // 0 -> ready to print
  53. // set = 0 -> one capsule, set = 1 -> four capsules
  54. // 1 -> the whole microhone with four capsules
  55. rendermic = 1;
  56. renderset = 0;
  57. // what type of connection to use between capsule holders:
  58. // 0 -> original cylinder beams
  59. // 1 -> interlocking beams (out)
  60. // 2 -> interlocking beams (in)
  61. connect = 1;
  62. //// end of rendering control
  63. ////
  64. // elevation angle for the capsule holders (fixed for this microphone)
  65. elev_angle = atan(sqrt(1/2));
  66. // angles of the connection legs and adjacent capsule holders
  67. leg_angles_top =
  68. [
  69. [-120, elev_angle],
  70. [0, elev_angle],
  71. [120, elev_angle]
  72. ];
  73. leg_angles_bot =
  74. [
  75. [-120, elev_angle],
  76. [120, elev_angle]
  77. ];
  78. // adjustment for the inner radius of the capsule holder
  79. // measured inside diameter of a trial print was around 7.5 to 8.2
  80. // instead of 10, capsule diameter was 9.99)
  81. fudge = 0.15;
  82. // adjustment for fit of slots in connection legs and mount
  83. fit = 0.2;
  84. // number of facets for rendering cylinders
  85. facets = 64;
  86. // microphone holder geometry
  87. capsule_sep_min = (mic_radius - capsule_height) * cos(elev_angle) - (capsule_radius + wall) * sin(elev_angle);
  88. capsule_sep_max = mic_radius * cos(elev_angle) - (capsule_radius + wall) * sin(elev_angle);
  89. capsule_bottom = mic_radius * sin(elev_angle) + (capsule_radius + wall) * cos(elev_angle);
  90. mount_slot_depth = ridge_length * sin(elev_angle);
  91. ////////
  92. // microphone capsule holder
  93. // azimuth: horizontal orientation of the capsule
  94. // elevation: vertical orientation of the capsure
  95. // mounts: vectors containing the angle of the mount and the angle to the adjacent capsule
  96. // twist: rotate the whole capsule to match mounting legs
  97. // ridge: 1 -> print ridge for mount
  98. module capsule (azimuth, elevation, mounts, twist, ridge) {
  99. rotate([0, 0, azimuth]) {
  100. rotate([0, (90 - elevation), 0]) {
  101. translate([0, 0, rendermic == 0 ? 0 : mic_radius - capsule_height]) {
  102. difference () {
  103. union () {
  104. // main capsule holder
  105. cylinder(r = capsule_radius + wall, h = capsule_height, $fn = facets);
  106. // the mounting legs
  107. for (angles = mounts) {
  108. rotate([0, 0, angles[0] + twist]) {
  109. // connect with cylindrical beams, very pretty
  110. if (connect == 0) {
  111. leg_length = mic_radius * cos(angles[1]) - capsule_radius * sin(angles[1]);
  112. translate([capsule_radius - wall, 0, capsule_height - wall]) {
  113. rotate([0, 180 - angles[1], 0]) {
  114. cylinder(d = leg_width, h = leg_length - 0.3, center = false, $fn = facets);
  115. }
  116. }
  117. }
  118. // connect with horizontal legs
  119. if (connect == 1) {
  120. leg_length = (mic_radius - capsule_height + leg_thick) * tan(90 - angles[1]) - capsule_radius;
  121. slot_depth = leg_thick * cos(90 - 2 * angles[1]) + wall + fit;
  122. translate([capsule_radius + leg_length + fudge, - leg_width / 3, 0]) {
  123. rotate([0, -90, 0]) {
  124. difference() {
  125. // thickness, width
  126. cube([leg_thick, leg_width, leg_length]);
  127. // cut slot in connector
  128. translate([0, leg_width / 3 - (fit / 2), 0]) {
  129. cube([leg_thick, leg_width / 3 + fit, slot_depth]);
  130. }
  131. }
  132. }
  133. }
  134. }
  135. // connect with vertical legs
  136. if (connect == 2) {
  137. // fix this 0.2 == (2 * fudge?)
  138. leg_length = (mic_radius * tan(90 - angles[1]) - capsule_radius) * tan(angles[1]) - 0.2;
  139. slot_depth = leg_thick * cos (90 - (2 * angles[1]));
  140. translate([capsule_radius - leg_thick / 2 + fudge, - leg_width / 3,
  141. - leg_length + capsule_height]) {
  142. difference() {
  143. // thickness, width
  144. difference() {
  145. cube([leg_thick + leg_thick / 2, leg_width, leg_length]);
  146. translate([0, 0, -capsule_height + fudge]) {
  147. cube([leg_thick / 2, leg_width, leg_length]);
  148. }
  149. }
  150. // cut slot in connector
  151. translate([0, leg_width / 3 - (fit / 2), 0]) {
  152. cube([leg_thick + leg_thick / 2, leg_width / 3 + fit, slot_depth]);
  153. }
  154. }
  155. }
  156. }
  157. }
  158. }
  159. // add ridges for microphone mount
  160. if (ridge == 1) {
  161. rotate([0, 0, twist]) {
  162. translate([capsule_radius - ridge_length / 2 + fudge, ridge_slot_width / 2, 0]) {
  163. cube([ridge_length * 3 / 2, ridge_width, capsule_height], center = false);
  164. }
  165. translate([capsule_radius - ridge_length / 2 + fudge, -ridge_width - ridge_slot_width / 2, 0]) {
  166. cube([ridge_length * 3 / 2, ridge_width, capsule_height], center = false);
  167. }
  168. }
  169. }
  170. }
  171. // make the hole for the capsule
  172. translate ([0, 0, 0]) {
  173. cylinder(r = capsule_radius + fudge, h = capsule_height, $fn = facets);
  174. }
  175. // remove any extra connecting beam material from the face of the holder
  176. if (connect == 0) {
  177. translate ([0, 0, capsule_height]) {
  178. cylinder(r = capsule_radius + wall * 2, h = 2, $fn = facets);
  179. }
  180. }
  181. }
  182. }
  183. }
  184. }
  185. }
  186. // microphone mount
  187. //
  188. // angles: angles for mount slots
  189. // wall: thickness of cylinder wall
  190. // separation: height of mount with respect of the microphone assembly
  191. module mount (angles, wall, separation) {
  192. translate([0, 0, -(separation + 0.0)]) {
  193. difference() {
  194. union() {
  195. // main mount cylinder
  196. translate([0, 0, -mount_height]) {
  197. difference() {
  198. cylinder(r = mount_radius + wall, h = mount_height, $fn = facets);
  199. // make the hole for the mount (* 1.5 to cut the ridge as well)
  200. cylinder(r = mount_radius, h = mount_height * 1.5, $fn = facets);
  201. }
  202. }
  203. // make rests for microphone ridges thicker
  204. rotate([0, 0, 45]) {
  205. for (move = [- (ridge_slot_width / 2 + ridge_width), (ridge_slot_width / 2 + ridge_width) - 2 * wall]) {
  206. translate([move, -mount_radius, -mount_height]) {
  207. cube([2 * wall, mount_radius * 2, mount_height]);
  208. }
  209. }
  210. }
  211. }
  212. // shave exterior of the cylinder, erases extensions that protrude
  213. translate([0, 0, -mount_height]) {
  214. difference() {
  215. cylinder(r = mount_radius + 2 * wall, h = mount_height, $fn = facets);
  216. cylinder(r = mount_radius + wall, h = mount_height, $fn = facets);
  217. }
  218. }
  219. // cut a slot for the ridges in the wall of the cylinder
  220. for (rot = angles) {
  221. rotate([0, -elev_angle, rot]) {
  222. translate([-capsule_sep_max * 2, 0.5 * ridge_slot_width - fit / 2, mount_slot_depth - wall]) {
  223. cube([capsule_sep_max * 2, ridge_slot_width + fit, mount_height]);
  224. }
  225. translate([-capsule_sep_max * 2, - 1.5 * ridge_slot_width - fit / 2, mount_slot_depth - wall]) {
  226. cube([capsule_sep_max * 2, ridge_slot_width + fit, mount_height]);
  227. }
  228. // top of the ridge
  229. // translate([-capsule_sep_max * 2, -ridge_slot_width, mount_slot_depth]) {
  230. // cube([capsule_sep_max * 2, 2 * ridge_slot_width + fit, mount_height]);
  231. // }
  232. }
  233. }
  234. // lower the top of theo mount ridges (we have to do the geometry of all this...)
  235. rotate([0, 0, -45]) {
  236. translate([- capsule_sep_max, -ridge_slot_width / 2, -0.4]) {
  237. cube([capsule_sep_max * 2, ridge_slot_width, 2]);
  238. }
  239. }
  240. }
  241. }
  242. }
  243. // render a complete microphone
  244. if (rendermic == 1) {
  245. capsule(45, elev_angle, leg_angles_top, 60, 0);
  246. capsule(-135, elev_angle, leg_angles_top, 60, 0);
  247. capsule(-45, -elev_angle, leg_angles_bot, 0, 1);
  248. capsule(135, -elev_angle, leg_angles_bot, 0, 1);
  249. // the mount
  250. mount([-45, 135], 1, capsule_bottom);
  251. }
  252. // print all the parts separately
  253. if (rendermic == 0) {
  254. if (connect == 1) {
  255. part_rot = 90;
  256. part_height = 0;
  257. part_sep = capsule_radius * 2.5;
  258. // #3
  259. translate([part_sep, -part_sep, part_height]) { capsule(0, part_rot, leg_angles_top, 60, 0); }
  260. if (renderset != 0) {
  261. // #4
  262. translate([part_sep, part_sep, part_height]) { capsule(0, part_rot, leg_angles_top, 60, 0); }
  263. // #2
  264. translate([-part_sep, part_sep, part_height]) { capsule(0, part_rot, leg_angles_bot, -90, 1); }
  265. // #1
  266. translate([-part_sep, -part_sep, part_height]) { capsule(0, part_rot, leg_angles_bot, 90, 1); }
  267. // mount
  268. translate([0, 0, mount_height]) { mount([-45, 135], 1, 0); }
  269. // add connecting ridges to make it all one part
  270. difference() {
  271. for (rot_a = [-45, 45]) {
  272. rotate([0, 0, rot_a]) {
  273. translate([-wall / 2, -part_sep, 0]) {
  274. cube([wall, part_sep * 2, wall / 2]);
  275. }
  276. }
  277. }
  278. // remove them in the inside of the mount
  279. cylinder(r = mount_radius + wall / 2, h = wall / 2);
  280. }
  281. }
  282. } else {
  283. // connect == 2
  284. part_rot = -90;
  285. part_height = capsule_height;
  286. part_sep = capsule_radius * 2;
  287. // #3
  288. translate([part_sep, -part_sep, part_height]) { capsule(0, part_rot, leg_angles_top, 0, 0); }
  289. if (renderset != 0) {
  290. // #4
  291. translate([part_sep, part_sep, part_height]) { capsule(0, part_rot, leg_angles_top, 0, 0); }
  292. // #2
  293. translate([-part_sep, part_sep, part_height]) { capsule(0, part_rot, leg_angles_bot, -90, 1); }
  294. // #1
  295. translate([-part_sep, -part_sep, part_height]) { capsule(0, part_rot, leg_angles_bot, 90, 1); }
  296. // mount
  297. translate([0, 0, mount_height]) { mount([-45, 135], 1, 0); }
  298. // add connecting ridges to make it all one part
  299. difference() {
  300. for (rot_a = [-45, 45]) {
  301. rotate([0, 0, rot_a]) {
  302. translate([-wall / 2, -part_sep * 0.85, 0]) {
  303. cube([wall, part_sep * 1.75, wall / 2]);
  304. }
  305. }
  306. }
  307. // remove them in the inside of the mount
  308. cylinder(r = mount_radius + wall / 2, h = wall / 2);
  309. }
  310. }
  311. }
  312. }