1
0

BigSpHEAR_20.scad 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. //
  2. // BigSpHEAR (Big Spherical Harmonics Ear), 20 capsule spherical 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. ////
  26. //// model parameters
  27. // dimensions of the EM182 electret microphone
  28. capsule_radius = 5;
  29. capsule_height = 4.5;
  30. // distance between face of capsule and center of array
  31. mic_radius = 25;
  32. // dimensions of capsule holder connection legs
  33. leg_width = 4;
  34. leg_thick = 3;
  35. // width of the ridge that connects to the mount
  36. ridge_width = 2;
  37. ridge_length = 2;
  38. // wall thickness of capsule holder
  39. wall = 1;
  40. // dimensions of microphone holder
  41. mount_radius = 4.5;
  42. // height of mount
  43. mount_height = 4;
  44. //// end of model parameters
  45. ////
  46. //// rendering control
  47. // what to render:
  48. // 0 -> ready to print
  49. // set = 0 -> one capsule, set = 1 -> a set of capsules
  50. // 1 -> the whole microhone with four capsules
  51. rendermic = 0;
  52. renderset = 1;
  53. // what type of connection to use between capsule holders:
  54. // 0 -> original cylinder beams
  55. // 1 -> interlocking beams (out)
  56. // 2 -> interlocking beams (in)
  57. connect = 1;
  58. // adjustment for the radius of the capsule
  59. // measured inside diameter of a trial print was around 7.5 to 8.2
  60. // instead of 10, capsule diameter was 9.99)
  61. fudge = 0.15;
  62. // adjustment for fit of slots in connection legs and mount
  63. fit = 0.1;
  64. slot_extra_depth = 1.0;
  65. // number of facets for rendering cylinders
  66. facets = 64;
  67. //// end of rendering control
  68. ////
  69. // https://en.wikipedia.org/wiki/Regular_dodecahedron
  70. //
  71. // cartesian coordinates of the vertices
  72. //
  73. // (±1, ±1, ±1)
  74. // (0, ±1/φ, ±φ)
  75. // (±1/φ, ±φ, 0)
  76. // (±φ, 0, ±1/φ)
  77. //
  78. // where φ = 1 + √5/2 is the golden ratio (also written τ) ≈ 1.618
  79. gold = (1 + sqrt(5)) / 2;
  80. diedral = 2 * asin(sqrt(3) * (sqrt(5) - 1) / 6) / 2;
  81. // first three elements are x,y,z coordinates, fourth element is twist of legs
  82. vertices =
  83. [
  84. [-1, -1, -1, diedral],
  85. [-1, -1, 1, 60 - diedral],
  86. [-1, 1, -1, - diedral],
  87. [-1, 1, 1, - 60 + diedral],
  88. [1, -1, -1, - diedral],
  89. [1, -1, 1, - 60 + diedral],
  90. [1, 1, -1, diedral],
  91. [1, 1, 1, 60 - diedral],
  92. [0, -1/gold, -gold, 0],
  93. [0, -1/gold, gold, 60],
  94. [0, 1/gold, -gold, 0],
  95. [0, 1/gold, gold, -60],
  96. [-1/gold, -gold, 0, - 60 / 2],
  97. [-1/gold, gold, 0, 60 / 2],
  98. [1/gold, -gold, 0, 60 / 2],
  99. [1/gold, gold, 0, -60 / 2],
  100. [-gold, 0, -1/gold, - 60],
  101. [-gold, 0, 1/gold, 0],
  102. [gold, 0, -1/gold, -60],
  103. [gold, 0, 1/gold, 0]
  104. ];
  105. // this needs to be fixed for this design (only works on the octathingy...)
  106. elev_angle = tetra_compat == 0 ? atan(1 / (2 * sqrt(sqrt(2))) * sqrt(2)) : atan(sqrt(1/2));
  107. // microphone holder geometry
  108. capsule_sep_min = (mic_radius - capsule_height) * cos(elev_angle) - (capsule_radius + wall) * sin(elev_angle);
  109. capsule_sep_max = mic_radius * cos(elev_angle) - (capsule_radius + wall) * sin(elev_angle);
  110. capsule_bottom = mic_radius * sin(elev_angle) + (capsule_radius + wall) * cos(elev_angle);
  111. mount_slot_depth = ridge_length * sin(elev_angle);
  112. ////////
  113. // microphone capsule holder
  114. // azimuth: horizontal orientation of the capsule
  115. // elevation: vertical orientation of the capsure
  116. // mounts: vectors containing the angle of the mount and the angle to the adjacent capsule
  117. // twist: rotate the whole capsule to match mounting legs
  118. module capsule (azimuth, elevation, mounts, twist, ridge) {
  119. rotate([0, 0, azimuth]) {
  120. rotate([0, (90 - elevation), 0]) {
  121. translate([0, 0, rendermic == 0 ? 0 : mic_radius - capsule_height]) {
  122. difference () {
  123. union () {
  124. // main capsule holder
  125. cylinder(r = capsule_radius + wall, h = capsule_height, $fn = facets);
  126. // the mounting legs
  127. for (angles = mounts) {
  128. rotate([0, 0, angles[0] + twist]) {
  129. // connect with cylindrical beams, very pretty
  130. leg_length = mic_radius * sin(angles[1]) - (capsule_radius + wall) * cos(angles[1]) + wall;
  131. if (connect == 0) {
  132. translate([capsule_radius - wall, 0, capsule_height - wall]) {
  133. rotate([0, 180 - (90 - angles[1]), 0]) {
  134. cylinder(d = leg_width, h = leg_length - 0.1, center = false, $fn = facets);
  135. }
  136. }
  137. }
  138. // connect with horizontal legs
  139. if (connect == 1) {
  140. leg_length = (mic_radius - capsule_height + leg_thick) * tan(angles[1]) - capsule_radius
  141. + slot_extra_depth;
  142. slot_depth = leg_thick * cos(90 - 2 * angles[1]) + slot_extra_depth + fit;
  143. rest_length = leg_length - leg_thick * tan(angles[1]);
  144. translate([capsule_radius + leg_length + fudge, - leg_width / 3, 0]) {
  145. rotate([0, -90, 0]) {
  146. difference() {
  147. union() {
  148. // leg
  149. cube([leg_thick, leg_width, leg_length]);
  150. // rest
  151. translate([0, -leg_width / 3 - (fit / 2),
  152. leg_length - rest_length + slot_extra_depth]) {
  153. cube([leg_thick, leg_width, rest_length]);
  154. }
  155. }
  156. // cut slot in connector
  157. translate([0, leg_width / 3 - (fit / 2), 0]) {
  158. cube([leg_thick, leg_width / 3 + fit, slot_depth]);
  159. }
  160. // make ramp in rest
  161. translate([-fit, 0, leg_length - rest_length + slot_extra_depth]) {
  162. rotate([0, 2 * angles[1], 0]) {
  163. translate([0, - leg_width / 3 - fit, 0]) {
  164. cube([leg_thick, leg_width / 3 + fit, rest_length + 2 * fit]);
  165. }
  166. }
  167. }
  168. }
  169. }
  170. }
  171. }
  172. // connect with vertical legs
  173. if (connect == 2) {
  174. leg_length = (mic_radius * tan(angles[1]) - capsule_radius) * tan(90 - angles[1]);
  175. slot_depth = leg_thick * (cos (90 - 2 * angles[1]) + tan(90 - 2 * angles[1])) + fit;
  176. translate([capsule_radius + fudge, - leg_width / 3, - leg_length + capsule_height]) {
  177. difference() {
  178. // thickness, width
  179. cube([leg_thick, leg_width, leg_length]);
  180. // cut slot in connector
  181. translate([0, leg_width / 3 - (fit / 2), 0]) {
  182. cube([leg_thick, leg_width / 3 + fit, slot_depth]);
  183. }
  184. }
  185. }
  186. }
  187. }
  188. }
  189. // add ridges for microphone mount
  190. if (ridge == 1) {
  191. rotate([0, 0, twist]) {
  192. translate([capsule_radius + fudge, - wall , 0]) {
  193. difference() {
  194. cube([ridge_length, ridge_width, capsule_height], center = false);
  195. //rotate([0, 90 - elev_angle, 0]) {
  196. // cube([ridge_length, ridge_width, capsule_height], center = false);
  197. //}
  198. }
  199. }
  200. }
  201. }
  202. }
  203. // make the hole for the capsule
  204. translate ([0, 0, -2]) {
  205. cylinder(r = capsule_radius + fudge, h = capsule_height + 2, $fn = facets);
  206. }
  207. // remove any extra connecting beam material from the face of the holder
  208. if (connect == 0) {
  209. translate ([0, 0, capsule_height]) {
  210. cylinder(r = capsule_radius + wall * 2, h = 2, $fn = facets);
  211. }
  212. }
  213. }
  214. }
  215. }
  216. }
  217. }
  218. // microphone mount
  219. //
  220. // angles: angles for mount slots
  221. // wall: thickness of cylinder wall
  222. // separation: height of mount with respect of the microphone assembly
  223. module mount (angles, wall, separation) {
  224. translate([0, 0, -(separation + 0.1)]) {
  225. difference() {
  226. union() {
  227. // grips for the capsule holder ridge
  228. for (rot = angles) {
  229. rotate([0, 0, rot]) {
  230. translate([-capsule_sep_max, -(ridge_width - fit / 2), -mount_height]) {
  231. cube([capsule_sep_max, ridge_width * 2 - fit, mount_height]);
  232. rotate([0, -elev_angle, 0]) {
  233. cube([capsule_sep_max, ridge_width * 2 - fit, mount_height * cos(elev_angle)]);
  234. }
  235. }
  236. }
  237. }
  238. translate([0, 0, -mount_height]) {
  239. cylinder(r = mount_radius + wall, h = mount_height, $fn = facets);
  240. }
  241. }
  242. // make the hole for the mount (* 2 to cut the ridge as well)
  243. translate([0, 0, -mount_height]) {
  244. cylinder(r = mount_radius, h = mount_height * 2, $fn = facets);
  245. }
  246. // cut the outside of the sloped ridge
  247. translate([0, 0, -mount_height]) {
  248. difference() {
  249. cylinder(r = capsule_sep_max + mount_height * 2, h = mount_height * 2, $fn = facets);
  250. cylinder(r = capsule_sep_max, h = mount_height * 2, $fn = facets);
  251. }
  252. }
  253. // and cut a slot for the ridges in the wall of the cylinder
  254. for (rot = angles) {
  255. rotate([0, 0, rot]) {
  256. translate([-capsule_sep_max * 2, -ridge_width + 4 * fit, -mount_slot_depth]) {
  257. cube([capsule_sep_max * 2, ridge_width + 2 * fit, mount_height * 2]);
  258. }
  259. }
  260. }
  261. }
  262. }
  263. }
  264. elev = atan(1/2);
  265. echo("diedral angle ", diedral);
  266. leg_angles =
  267. [
  268. [-120, diedral],
  269. [0, diedral],
  270. [120, diedral],
  271. ];
  272. // render a complete microphone
  273. if (rendermic == 1) {
  274. for (i = [0 : 1 : len(vertices) - 1]) {
  275. az = atan2(vertices[i][1], vertices[i][0]);
  276. el = 90 - acos(vertices[i][2] / norm([vertices[i][0], vertices[i][1], vertices[i][2]]));
  277. tw = vertices[i][3];
  278. echo(i, vertices[i], " az=", az, " el=", el);
  279. capsule(az, el, leg_angles, tw, 0);
  280. }
  281. } else {
  282. // print all the parts separately
  283. part_sep = capsule_radius * 4.2;
  284. if (renderset == 1) {
  285. if (connect == 1) {
  286. twist_all = 0;
  287. translate([0, 0, 0]) { capsule(0, 90, leg_angles, twist_all, 0); }
  288. translate([0, part_sep, 0]) { capsule(0, 90, leg_angles, twist_all, 0); }
  289. translate([part_sep, 0, 0]) { capsule(0, 90, leg_angles, twist_all, 0); }
  290. translate([part_sep, part_sep]) { capsule(0, 90, leg_angles, twist_all, 0); }
  291. translate([-part_sep, 0, 0]) { capsule(0, 90, leg_angles, twist_all, 0); }
  292. translate([-part_sep, part_sep]) { capsule(0, 90, leg_angles, twist_all, 0); }
  293. translate([-part_sep / 2, -part_sep * 2 / 3, 0]) { capsule(0, 90, leg_angles, twist_all, 0); }
  294. translate([part_sep / 2, -part_sep * 2 / 3, 0]) { capsule(0, 90, leg_angles, twist_all, 0); }
  295. // ridges to connect all parts
  296. translate([-part_sep + wall, part_sep / 2 - wall, 0]) {
  297. cube([part_sep * 2, wall, wall / 2]);
  298. }
  299. for (d = [-part_sep, 0, part_sep]) {
  300. translate([wall + d, capsule_radius, 0]) {
  301. cube([wall, part_sep - capsule_radius * 2, wall / 2]);
  302. }
  303. }
  304. for (d = [-part_sep / 2, part_sep / 2]) {
  305. translate([wall + d, - part_sep * 2 / 3 + capsule_radius, 0]) {
  306. cube([wall, part_sep / 2 + part_sep * 2 / 3 - capsule_radius, wall / 2]);
  307. }
  308. }
  309. }
  310. } else {
  311. // just a single capsule holder
  312. translate([0, 0, 0]) { capsule(0, 90, leg_angles, 0, 0); }
  313. }
  314. }