TinySpHEAR_common.scad 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. //
  2. // TinySpHEAR, Tiny Spherical Harmonics Ear,
  3. // First Order (B-format) Ambisonics Microphone Common Modules and Variables
  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 = 1.75;
  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_wfit = 0.1;
  50. ridge_hfit = 3;
  51. // dimensions of microphone mount
  52. mount_radius = 3.5;
  53. mount_wall = 0.75;
  54. // height and eccentricity of top connector
  55. mount_top_height = 15.0;
  56. mount_top_eccentricity = 1.3;
  57. // height of mount
  58. mount_height = 40;
  59. // microphone stand mount
  60. //
  61. // diameter of existing shielded wires (x 4)
  62. mic_wire_diam = 1.5;
  63. mic_wire_hole_radius = 3.0;
  64. mic_wire_hole_offset = 5;
  65. // standard microphone stand
  66. // measured diameter = 13.5, inside diameter of sleeve = 13.79 (
  67. mic_mount_radius = 13.50 / 2;
  68. // add this to inside diameter
  69. mic_mount_fit = 0.1;
  70. mic_mount_slot_height = 11.5;
  71. mic_mount_slot_width = 4.25;
  72. mic_mount_slot_radius = 6.25 / 2;
  73. mic_mount_wall = 1.5;
  74. mic_mount_height = 35.0 + mic_wire_hole_offset + mic_wire_hole_radius + 2 * mic_mount_wall;
  75. //// end of model parameters
  76. ////
  77. //// rendering control
  78. // what to render:
  79. // 0 -> ready to print
  80. // set = 0 -> one capsule, set = 1 -> four capsules
  81. // 1 -> the whole microhone with four capsules
  82. rendermic = 0;
  83. renderset = 1;
  84. // what type of connection to use between capsule holders:
  85. // 0 -> original cylindrical angled legs
  86. // 1 -> interlocking horizontal legs
  87. // 2 -> interlocking vertical legs
  88. connect = 1;
  89. // how many mount ridges to create
  90. // 0 -> no ridges
  91. // 1 -> 1 ridge
  92. // 2 -> 2 ridges
  93. ridges = 1;
  94. //// end of rendering control
  95. ////
  96. // elevation angle for the capsule holders (fixed for this microphone)
  97. elev_angle = atan(sqrt(1/2));
  98. // angles of the connection legs and adjacent capsule holders
  99. leg_angles_top =
  100. [
  101. [-120, elev_angle],
  102. [0, elev_angle],
  103. [120, elev_angle]
  104. ];
  105. leg_angles_bot =
  106. [
  107. [-120, elev_angle],
  108. [120, elev_angle]
  109. ];
  110. // adjustment for the inner radius of the capsule holder
  111. // measured inside diameter of a trial print was around 7.5 to 8.2
  112. // instead of 10, capsule diameter was 9.99)
  113. // 0.1 -> 0.08: Ultimaker 2 + Extended plus APL (2016.06.17)
  114. fudge = 0.08;
  115. // adjustment for fit of slots in connection legs and mount
  116. // 0.1: initial setting
  117. // 0.1 ->0.15: Ultimaker 2 + Extended plus APL (2016.06.17)
  118. fit = 0.15;
  119. // number of facets for rendering cylinders
  120. facets = 64;
  121. // render capsule holders with better resolution
  122. cfacets = 128;
  123. // microphone structure geometry
  124. capsule_sep_min = (mic_radius - capsule_height) * cos(elev_angle) - (capsule_radius + wall) * sin(elev_angle);
  125. capsule_sep_max = mic_radius * cos(elev_angle) - (capsule_radius + wall) * sin(elev_angle);
  126. capsule_bottom = mic_radius * sin(elev_angle) + (capsule_radius + wall) * cos(elev_angle);
  127. mount_radius_capsule = capsule_sep_max;
  128. ////////
  129. // microphone capsule holder
  130. // azimuth: horizontal orientation of the capsule
  131. // elevation: vertical orientation of the capsule
  132. // mounts: vectors containing the angle of the mount and the angle to the adjacent capsule
  133. // twist: rotate the whole capsule to match mounting legs
  134. // ridge: add 0, 1 or 2 ridges for attaching the structure to the mount
  135. // ridge_wfit: tune the fit, used for carving slots in mount
  136. // ridge_hfit: adjust height of ridges when carving out the capsule rests
  137. // solid: make the capsule holder solid, used in the mount code to carve the capsule rests
  138. module capsule (azimuth, elevation, mounts, twist, ridge, ridge_wfit = 0.0, ridge_hfit = 0.0, solid = 0) {
  139. rotate([0, 0, azimuth]) {
  140. rotate([0, (90 - elevation), 0]) {
  141. translate([0, 0, (rendermic == 0 && solid == 0) ? 0 : mic_radius - capsule_height]) {
  142. difference () {
  143. union () {
  144. // main capsule holder
  145. cylinder(r = capsule_radius + wall, h = capsule_height, $fn = cfacets);
  146. // the mounting legs
  147. for (angles = mounts) {
  148. rotate([0, 0, angles[0] + twist]) {
  149. // connect with cylindrical beams, very pretty
  150. if (connect == 0) {
  151. leg_length = mic_radius * cos(angles[1]) - capsule_radius * sin(angles[1]);
  152. translate([capsule_radius - wall, 0, capsule_height - wall]) {
  153. rotate([0, 180 - angles[1], 0]) {
  154. cylinder(d = leg_width, h = leg_length - 0.3, center = false, $fn = facets);
  155. }
  156. }
  157. }
  158. // connect with horizontal legs
  159. if (connect == 1) {
  160. leg_length = (mic_radius - capsule_height + leg_thick) * tan(90 - angles[1]) - capsule_radius;
  161. slot_depth = leg_thick * cos(90 - 2 * angles[1]) + wall + fit;
  162. translate([capsule_radius + leg_length + fudge, - leg_width / 3, 0]) {
  163. rotate([0, -90, 0]) {
  164. difference() {
  165. // thickness, width
  166. cube([leg_thick, leg_width, leg_length]);
  167. // cut slot in connector
  168. translate([0, leg_width / 3 - (fit / 2), 0]) {
  169. cube([leg_thick, leg_width / 3 + fit, slot_depth]);
  170. }
  171. }
  172. }
  173. }
  174. }
  175. // connect with vertical legs
  176. if (connect == 2) {
  177. // fix this 0.2 == (2 * fudge?)
  178. leg_length = (mic_radius * tan(90 - angles[1]) - capsule_radius) * tan(angles[1]) - 0.2;
  179. slot_depth = leg_thick * cos (90 - (2 * angles[1]));
  180. translate([capsule_radius - leg_thick / 2 + fudge, - leg_width / 3,
  181. - leg_length + capsule_height]) {
  182. difference() {
  183. // the connection
  184. difference() {
  185. cube([leg_thick + leg_thick / 2, leg_width, leg_length]);
  186. translate([-leg_thick + wall - fudge, 0, - capsule_height + fudge]) {
  187. cube([leg_thick, leg_width, leg_length]);
  188. }
  189. }
  190. // cut slot in connector
  191. translate([0, leg_width / 3 - (fit / 2), 0]) {
  192. cube([leg_thick + leg_thick / 2, leg_width / 3 + fit, slot_depth]);
  193. }
  194. }
  195. }
  196. }
  197. }
  198. }
  199. // add ridges for microphone mount
  200. ridge_length = (mic_radius - capsule_height) / tan(elev_angle) - (capsule_radius + wall);
  201. if (ridge == 2) {
  202. rotate([0, 0, twist]) {
  203. translate([capsule_radius + wall - ridge_length / 2, (ridge_width + ridge_wfit) / 2, 0]) {
  204. cube([ridge_length * 3 / 2, ridge_width + ridge_wfit, capsule_height + ridge_hfit], center = false);
  205. }
  206. translate([capsule_radius + wall - ridge_length / 2, - (ridge_width + ridge_wfit) * 3 / 2, 0]) {
  207. cube([ridge_length * 3 / 2, ridge_width + ridge_wfit, capsule_height + ridge_hfit], center = false);
  208. }
  209. }
  210. }
  211. if (ridge == 1) {
  212. rotate([0, 0, twist]) {
  213. translate([capsule_radius + wall - ridge_length / 2, - (ridge_width + ridge_wfit) / 2, 0]) {
  214. cube([ridge_length * 3 / 2, ridge_width + ridge_wfit, capsule_height + ridge_hfit], center = false);
  215. }
  216. }
  217. }
  218. }
  219. // make the hole for the capsule (also cuts leg overhang for vertical connectors)
  220. if (solid != 1) {
  221. translate ([0, 0, -capsule_height]) {
  222. cylinder(r = capsule_radius + fudge, h = capsule_height * 2, $fn = cfacets);
  223. }
  224. }
  225. // remove any extra connecting beam material from the face of the holder
  226. if (connect == 0) {
  227. translate ([0, 0, capsule_height]) {
  228. cylinder(r = capsule_radius + wall * 2, h = 2, $fn = cfacets);
  229. }
  230. }
  231. }
  232. }
  233. }
  234. }
  235. }
  236. // simple microphone mount, clips into standard microphone stand
  237. //
  238. // angles: angles for mount slots
  239. // wall: thickness of cylinder wall
  240. // stand_wall: thickness of stand mount wall
  241. // separation: height of mount with respect of the microphone assembly (for display)
  242. module ellipsoid(height, rad_bot, rad_top, eccentricity) {
  243. linear_extrude(height = height, scale = [eccentricity, rad_top / rad_bot]) {
  244. circle(r = rad_bot, $fn = facets);
  245. }
  246. }
  247. module mount (angles, wall, stand_wall, separation) {
  248. translate([0, 0, -separation]) {
  249. difference() {
  250. union() {
  251. // conic section
  252. translate([0, 0, mic_mount_height + mount_height]) {
  253. rotate([0, 0, 45]) {
  254. difference() {
  255. ellipsoid(mount_top_height, mount_radius + wall, mount_radius_capsule, mount_top_eccentricity);
  256. ellipsoid(mount_top_height, mount_radius, mount_radius_capsule * 0.5, mount_top_eccentricity * 1.05);
  257. }
  258. }
  259. }
  260. // stalk
  261. translate([0, 0, mic_mount_height + mount_height * 2/3]) {
  262. difference() {
  263. cylinder(r = mount_radius + wall, h = mount_height / 3, $fn = facets);
  264. // make the hole for the mount
  265. cylinder(r = mount_radius, h = mount_height / 3, $fn = facets);
  266. }
  267. }
  268. // transition to stand mount
  269. translate([0, 0, mic_mount_height]) {
  270. difference() {
  271. cylinder(r2 = mount_radius + wall, r1 = mic_mount_radius + mic_mount_fit + stand_wall,
  272. h = mount_height * 2 / 3, $fn = facets);
  273. // make the hole for the mount
  274. cylinder(r2 = mount_radius, r1 = mic_mount_radius + mic_mount_fit,
  275. h = mount_height * 2 / 3, $fn = facets);
  276. }
  277. }
  278. // stand mount
  279. translate([0, 0, 0]) {
  280. difference() {
  281. union() {
  282. // main mount cylinder
  283. translate([0, 0, 0]) {
  284. difference() {
  285. cylinder(r = mic_mount_radius + mic_mount_fit + stand_wall, h = mic_mount_height, $fn = facets);
  286. // make the hole for the mount (* 1.5 to cut the ridge as well)
  287. cylinder(r = mic_mount_radius + mic_mount_fit, h = mic_mount_height, $fn = facets);
  288. }
  289. }
  290. }
  291. // slot for fitting into microphone stand
  292. translate([mic_mount_radius - stand_wall / 2, - mic_mount_slot_width / 2, 0]) {
  293. cube([2 * stand_wall, mic_mount_slot_width, mic_mount_slot_height]);
  294. }
  295. // eyelet for microphone stand
  296. translate([mic_mount_radius - stand_wall / 2, 0, mic_mount_slot_height]) {
  297. rotate([0, 90, 0]) {
  298. cylinder(r = mic_mount_slot_radius, h = 2 * stand_wall, $fn = facets);
  299. }
  300. }
  301. // hole for microphone wiring
  302. translate([mic_mount_radius - stand_wall / 2, 0, mic_mount_height - mic_wire_hole_offset]) {
  303. rotate([0, 90, 0]) {
  304. cylinder(r = mic_wire_hole_radius, h = 2 * stand_wall, $fn = facets);
  305. }
  306. }
  307. }
  308. }
  309. }
  310. // indentations that match the two lower capsule holders
  311. translate([0, 0, mic_mount_height + mount_height + mount_top_height +
  312. (mic_radius - capsule_height) + capsule_height * sin(elev_angle)]) {
  313. capsule(angles[0], -elev_angle, [], 0, 1, ridge_wfit, ridge_hfit, 1);
  314. capsule(angles[1], -elev_angle, [], 0, 1, ridge_wfit, ridge_hfit, 1);
  315. }
  316. }
  317. }
  318. }