TinySpHEAR_common.scad 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. //
  2. // Spherical Harmonics Ear Project (*SpHEAR)
  3. //
  4. // TinySpHEAR, First Order (B-format) Ambisonics Microphone
  5. // Common Modules and Variables
  6. //
  7. // Copyright 2015-2016, Fernando Lopez-Lezcano, All Rights Reserved
  8. // nando@ccrma.stanford.edu
  9. //
  10. // This program is free software: you can redistribute it and/or modify
  11. // it under the terms of the GNU General Public License as published by
  12. // the Free Software Foundation, either version 3 of the License, or
  13. // (at your option) any later version.
  14. //
  15. // This program is distributed in the hope that it will be useful,
  16. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. // GNU General Public License for more details.
  19. //
  20. // You should have received a copy of the GNU General Public License
  21. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  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. //// default model parameters
  30. ////
  31. // microphone capsule array
  32. //
  33. // dimensions of the electret microphone capsule
  34. capsule_radius = 5;
  35. capsule_height = 4.5;
  36. // distance between the face of a capsule and the center of array
  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. // width of the ridge that connects to the mount
  43. ridge_width = 2.0;
  44. ridge_slot_width = 2.0;
  45. // depth of the connector mount ridge
  46. ridge_depth = 3.0;
  47. // add to the thickness of ridges
  48. ridge_wfit = 0.1;
  49. ridge_hfit = 3;
  50. // wall thickness of the capsule holder
  51. wall = 1;
  52. // microphone mount
  53. //
  54. mount_radius = 3.5;
  55. mount_wall = 0.75;
  56. // height and eccentricity of top connector
  57. mount_top_height = 15.0;
  58. mount_top_eccentricity = 1.3;
  59. // height of mount
  60. mount_height = 40;
  61. // microphone stand mount
  62. //
  63. // diameter of existing shielded wires (x 4)
  64. mic_wire_diam = 1.5;
  65. mic_wire_hole_radius = 3.0;
  66. mic_wire_hole_offset = 5;
  67. // standard microphone stand
  68. // measured diameter = 13.5, inside diameter of sleeve = 13.79 (
  69. mic_mount_radius = 13.50 / 2;
  70. // add this to inside diameter
  71. mic_mount_fit = 0.2;
  72. mic_mount_slot_height = 11.5;
  73. mic_mount_slot_width = 4.25;
  74. mic_mount_slot_radius = 6.25 / 2;
  75. mic_mount_wall = 1.5;
  76. mic_mount_height = 20.0 + mic_wire_hole_offset + mic_wire_hole_radius + 2 * mic_mount_wall;
  77. //// end of model parameters
  78. ////
  79. //// rendering control
  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.12;
  110. // adjustment for fit of slots in connection legs and mount
  111. // 0.1: initial setting
  112. // 0.1 ->0.15: Ultimaker 2 + Extended plus APL (2016.06.17)
  113. fit = 0.15;
  114. // number of facets for rendering cylinders
  115. facets = 64;
  116. // render capsule holders with better resolution
  117. cfacets = 128;
  118. // microphone structure geometry
  119. capsule_sep_min = (mic_radius - capsule_height) * cos(elev_angle) - (capsule_radius + wall) * sin(elev_angle);
  120. capsule_sep_max = mic_radius * cos(elev_angle) - (capsule_radius + wall) * sin(elev_angle);
  121. capsule_bottom = mic_radius * sin(elev_angle) + (capsule_radius + wall) * cos(elev_angle);
  122. mount_radius_capsule = capsule_sep_max;
  123. // simple microphone mount, clips into standard microphone stand
  124. //
  125. // angles: angles for mount slots
  126. // wall: thickness of cylinder wall
  127. // stand_wall: thickness of stand mount wall
  128. // separation: height of mount with respect of the microphone assembly (for display)
  129. module ellipsoid(height, rad_bot, rad_top, eccentricity) {
  130. linear_extrude(height = height, scale = [eccentricity, rad_top / rad_bot]) {
  131. circle(r = rad_bot, $fn = facets);
  132. }
  133. }
  134. module mount (angles, wall, stand_wall, separation) {
  135. translate([0, 0, -separation]) {
  136. difference() {
  137. union() {
  138. // conic section
  139. translate([0, 0, mic_mount_height + mount_height]) {
  140. rotate([0, 0, 45]) {
  141. difference() {
  142. ellipsoid(mount_top_height, mount_radius + wall, mount_radius_capsule, mount_top_eccentricity);
  143. ellipsoid(mount_top_height, mount_radius, mount_radius_capsule * 0.5, mount_top_eccentricity * 1.05);
  144. }
  145. }
  146. }
  147. // stalk
  148. translate([0, 0, mic_mount_height + mount_height * 2/3]) {
  149. difference() {
  150. cylinder(r = mount_radius + wall, h = mount_height / 3, $fn = facets);
  151. // make the hole for the mount
  152. cylinder(r = mount_radius, h = mount_height / 3, $fn = facets);
  153. }
  154. }
  155. // transition to stand mount
  156. translate([0, 0, mic_mount_height]) {
  157. difference() {
  158. cylinder(r2 = mount_radius + wall, r1 = mic_mount_radius + mic_mount_fit + stand_wall,
  159. h = mount_height * 2 / 3, $fn = facets);
  160. // make the hole for the mount
  161. cylinder(r2 = mount_radius, r1 = mic_mount_radius + mic_mount_fit,
  162. h = mount_height * 2 / 3, $fn = facets);
  163. }
  164. }
  165. // stand mount
  166. translate([0, 0, 0]) {
  167. difference() {
  168. union() {
  169. // main mount cylinder
  170. translate([0, 0, 0]) {
  171. difference() {
  172. cylinder(r = mic_mount_radius + mic_mount_fit + stand_wall, h = mic_mount_height, $fn = facets);
  173. // make the hole for the mount (* 1.5 to cut the ridge as well)
  174. cylinder(r = mic_mount_radius + mic_mount_fit, h = mic_mount_height, $fn = facets);
  175. }
  176. }
  177. }
  178. // slot for fitting into microphone stand
  179. translate([mic_mount_radius - stand_wall / 2, - mic_mount_slot_width / 2, 0]) {
  180. cube([2 * stand_wall, mic_mount_slot_width, mic_mount_slot_height]);
  181. }
  182. // eyelet for microphone stand
  183. translate([mic_mount_radius - stand_wall / 2, 0, mic_mount_slot_height]) {
  184. rotate([0, 90, 0]) {
  185. cylinder(r = mic_mount_slot_radius, h = 2 * stand_wall, $fn = facets);
  186. }
  187. }
  188. // hole for microphone wiring
  189. translate([mic_mount_radius - stand_wall / 2, 0, mic_mount_height - mic_wire_hole_offset]) {
  190. rotate([0, 90, 0]) {
  191. cylinder(r = mic_wire_hole_radius, h = 2 * stand_wall, $fn = facets);
  192. }
  193. }
  194. }
  195. }
  196. }
  197. // indentations that match the two lower capsule holders
  198. translate([0, 0, mic_mount_height + mount_height + mount_top_height +
  199. (mic_radius - capsule_height) + capsule_height * cos(elev_angle)]) {
  200. rotate([0, (90 + elev_angle), angles[0]]) {
  201. translate([0, 0, mic_radius - capsule_height]) {
  202. capsule([], 0, 1, ridge_wfit, ridge_hfit, 1);
  203. }
  204. }
  205. rotate([0, (90 + elev_angle), angles[1]]) {
  206. translate([0, 0, mic_radius - capsule_height]) {
  207. capsule([], 0, 1, ridge_wfit, ridge_hfit, 1);
  208. }
  209. }
  210. }
  211. }
  212. }
  213. }
  214. // render a tetrahedral capsule array
  215. //
  216. module render_tetra_capsule_array_old(z_offset) {
  217. translate([0, 0, z_offset]) {
  218. // all four capsules
  219. rotate([0, (90 - elev_angle), 45]) {
  220. translate([0, 0, mic_radius - capsule_height]) {
  221. capsule(leg_angles_top, 60, 0, 0.0, 0.0, 0);
  222. }
  223. }
  224. rotate([0, (90 - elev_angle), -135]) {
  225. translate([0, 0, mic_radius - capsule_height]) {
  226. capsule(leg_angles_top, 60, 0, 0.0, 0.0, 0);
  227. }
  228. }
  229. rotate([0, (90 + elev_angle), -45]) {
  230. translate([0, 0, mic_radius - capsule_height]) {
  231. capsule(leg_angles_bot, 0, 1, 0.0, 0.0, 0);
  232. }
  233. }
  234. rotate([0, (90 + elev_angle), 135]) {
  235. translate([0, 0, mic_radius - capsule_height]) {
  236. capsule(leg_angles_bot, 0, 1, 0.0, 0.0, 0);
  237. }
  238. }
  239. }
  240. }
  241. module render_tetra_capsule_array(z_offset) {
  242. translate([0, 0, z_offset]) {
  243. // all four capsules
  244. rotate([0, (90 - elev_angle), 45]) {
  245. translate([0, 0, mic_radius - capsule_height]) {
  246. capsule(leg_angles_top, 60, 0, 0.0, 0.0, 0);
  247. }
  248. }
  249. rotate([0, (90 - elev_angle), -135]) {
  250. translate([0, 0, mic_radius - capsule_height]) {
  251. capsule(leg_angles_top, 60, 0, 0.0, 0.0, 0);
  252. }
  253. }
  254. rotate([0, (90 + elev_angle), -45]) {
  255. translate([0, 0, mic_radius - capsule_height]) {
  256. capsule(leg_angles_top, 0, 0, 0.0, 0.0, 0);
  257. }
  258. }
  259. rotate([0, (90 + elev_angle), 135]) {
  260. translate([0, 0, mic_radius - capsule_height]) {
  261. capsule(leg_angles_top, 0, 0, 0.0, 0.0, 0);
  262. }
  263. }
  264. }
  265. }
  266. // render individual capsules
  267. //
  268. module render_tetra_capsule_top() {
  269. capsule(leg_angles_top, 60, 0, 0.0, 0.0, 0);
  270. }
  271. module render_tetra_capsule_bot() {
  272. capsule(leg_angles_bot, 0, 1, 0.0, 0.0, 0);
  273. }
  274. // render simple microphone stand mount
  275. //
  276. module render_simple_stand_mount(z_offset) {
  277. translate([0, 0, z_offset]) {
  278. mount([-45, 135], mount_wall, mic_mount_wall, mic_mount_height + mount_top_height + mount_height + capsule_bottom);
  279. }
  280. }