1
0

Octathingy_common.scad 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. //
  2. // Spherical Harmonics Ear Project (*SpHEAR)
  3. //
  4. // Octathingy, Second Order Ambisonics Microphone
  5. //
  6. // based on:
  7. // "A second-order soundfield microphone with improved polar pattern shape"
  8. // by Eric Benjamin, Audio Engineering Society Convention Paper 8728,
  9. // October 2012, San Francisco
  10. // Copyright 2015-2016, Fernando Lopez-Lezcano, All Rights Reserved
  11. // nando@ccrma.stanford.edu
  12. //
  13. //
  14. // This program is free software: you can redistribute it and/or modify
  15. // it under the terms of the GNU General Public License as published by
  16. // the Free Software Foundation, either version 3 of the License, or
  17. // (at your option) any later version.
  18. //
  19. // This program is distributed in the hope that it will be useful,
  20. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. // GNU General Public License for more details.
  23. //
  24. // You should have received a copy of the GNU General Public License
  25. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  26. //
  27. // 3d Models released under the Creative Commons license as follows:
  28. // Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)
  29. // http://creativecommons.org/licenses/by-nc-sa/4.0/
  30. include <SpHEAR_common.scad>
  31. ////
  32. //// model parameters
  33. // dimensions of the electret microphone capsule
  34. capsule_radius = 5;
  35. capsule_height = 4.5;
  36. // distance between face of capsule and center of array
  37. mic_radius = 14;
  38. // dimensions of capsule holder connection legs
  39. leg_width = 5;
  40. leg_thick = 1.75;
  41. // width of the ridge that connects to the mount
  42. ridge_width = 2;
  43. ridge_length = 2;
  44. // depth of the connector mount ridge
  45. ridge_depth = 3.0;
  46. // add to the thickness of ridges
  47. ridge_wfit = 0.1;
  48. ridge_hfit = 3;
  49. // wall thickness of capsule holder
  50. wall = 1;
  51. // dimensions of microphone holder
  52. mount_radius = 4.5;
  53. mount_wall = 0.75;
  54. // height of mount
  55. mount_height = 4;
  56. // type of octathingy
  57. // 0 -> regular octathingy (equilateral triangles in the square antiprism)
  58. // 1 -> tetrahedral compatible octathingy (same elevation angle as the tetrahedral mic)
  59. tetra_compat = 1;
  60. //// end of model parameters
  61. ////
  62. //// rendering control
  63. // what type of connection to use between capsule holders:
  64. // 0 -> original cylindrical angled legs
  65. // 1 -> interlocking horizontal legs
  66. // 2 -> interlocking vertical legs
  67. connect = 1;
  68. // adjustment for the radius of the capsule
  69. // measured inside diameter of a trial print was around 7.5 to 8.2
  70. // instead of 10, capsule diameter was 9.99)
  71. fudge = 0.15;
  72. // adjustment for fit of slots in connection legs and mount
  73. fit = 0.1;
  74. // number of facets for rendering cylinders
  75. facets = 64;
  76. //// end of rendering control
  77. ////
  78. // define the elevation angle of the upper and lower rings
  79. //
  80. // http://eusebeia.dyndns.org/4d/antiprism4
  81. //
  82. // The Cartesian coordinates of the square antiprism,
  83. // centered on the origin and having edge length 2, are:
  84. //
  85. // (0, ±√2, 1/∜2)
  86. // (±√2, 0, 1/∜2)
  87. // (±1, ±1, −1/∜2)
  88. //
  89. // the elevation angle for the two rings of 4 is:
  90. //
  91. // 1/2*∜2 = 0.420448207627 (z for edge length = 1)
  92. // atan(1/(2*∜2) / 0.707) = 30.7358671024
  93. elev_angle = 90 - (tetra_compat == 0 ? atan(1 / (2 * sqrt(sqrt(2))) * sqrt(2)) : atan(sqrt(1/2)));
  94. // calculate half angle between vertices in the square antiprism
  95. // these angles define the length of the connecting legs
  96. //
  97. // z coordinate of antiprism vertices
  98. vert_z = (sqrt(2) / 2) / tan(elev_angle);
  99. // vector length (same for all antiprism vertices)
  100. vert_n = norm([-0.5, -0.5, vert_z]);
  101. // half angle between adjacent vertices in either the upper or lower rings
  102. vert_angle_h = acos(([-0.5, -0.5, vert_z] / vert_n) * ([0.5, -0.5, vert_z] / vert_n)) / 2;
  103. // half angle between adjacent vertices in the upper and lower rings
  104. vert_angle_v = acos(([0.0, -1 / sqrt(2), -vert_z] / vert_n) * ([0.5, -0.5, vert_z] / vert_n)) / 2;
  105. // angles of the connection legs and adjacent capsule holders
  106. leg_angles = tetra_compat == 0 ?
  107. [
  108. [-63, 90 - vert_angle_h, 0, 1],
  109. [63, 90 - vert_angle_h, 0, 1],
  110. [-141, 90 - vert_angle_v, 0, 1],
  111. [141, 90 - vert_angle_v, 0, 1]
  112. ] :
  113. [
  114. [-60.5, vert_angle_h, 19.5, 1],
  115. [60.5, vert_angle_h, 19.5, 1],
  116. [-144.3, vert_angle_v, 8, 2],
  117. [144.3, vert_angle_v, 8, 2]
  118. ];
  119. // microphone holder geometry
  120. capsule_sep_min = (mic_radius - capsule_height) * sin(elev_angle) - (capsule_radius + wall) * cos(elev_angle);
  121. capsule_sep_max = mic_radius * sin(elev_angle) - (capsule_radius + wall) * cos(elev_angle);
  122. capsule_bottom = mic_radius * cos(elev_angle) + (capsule_radius + wall) * sin(elev_angle);
  123. mount_radius_capsule = capsule_sep_max;
  124. // render the capsule array
  125. //
  126. module render_octa_capsule_array(z_offset) {
  127. translate([0, 0, z_offset]) {
  128. for (az = [45, 135, -45, -135]) {
  129. rotate([0, elev_angle, az]) {
  130. translate([0, 0, mic_radius - capsule_height]) {
  131. capsule(leg_angles, 180, 0, 0.0, 0.0, 0);
  132. }
  133. }
  134. rotate([0, 180 - elev_angle, az + 45]) {
  135. translate([0, 0, mic_radius - capsule_height]) {
  136. capsule(leg_angles, 0, 1, 0.0, 0.0, 0);
  137. }
  138. }
  139. }
  140. }
  141. }
  142. // capsule holder with cylindrical mount
  143. //
  144. // ratio of capsule radius to transition length
  145. transition_ratio = 1.0;
  146. // ratio of capsule radius to bottom radius of holder
  147. holder_ratio = 0.4;
  148. // diameter of microphone capsule cable (Mogami 2490)
  149. capsule_cable_diam = 1.7;
  150. module capsule_holder(ratio, transition, hollow = true) {
  151. capsule_h = capsule_height + capsule_ring_h;
  152. difference() {
  153. // main capsule holder
  154. cylinder(r = capsule_radius + fudge + wall, h = capsule_h, $fn = cfacets);
  155. if (hollow) cylinder(r = capsule_radius + fudge, h = capsule_h + thin_mint, $fn = cfacets);
  156. }
  157. // conical transition into core sphere
  158. transition_h = transition * capsule_radius;
  159. translate([0, 0, - transition_h]) {
  160. difference() {
  161. cylinder(r2 = capsule_radius + fudge + wall, r1 = (capsule_radius) * ratio + wall, h = transition_h, $fn = facets);
  162. // add overhang so that we have a stop when inserting the capsule
  163. overhang = 0.2;
  164. if (hollow) cylinder(r2 = capsule_radius + fudge - overhang, r1 = (capsule_radius) * ratio, h = transition_h, $fn = facets);
  165. // add holes in the walls of the conical transition
  166. if (hollow) {
  167. for (r = [0:36:179]) {
  168. rotate([0, 90, r]) {
  169. translate([-transition_h, 0, -capsule_radius - 2 * wall])
  170. scale([7, 1.3, 1]) cylinder(r = 1.0, h = (capsule_radius + 2 * wall) * 2, $fn = facets);
  171. }
  172. }
  173. }
  174. }
  175. // lip to insert holder into core
  176. lip_d = 1.4 * wall;
  177. translate([0, 0, hollow == false ? -3 : -lip_d]) {
  178. difference() {
  179. // if not hollow make the ring longer to cut into core
  180. cylinder(r = (capsule_radius) * ratio + wall + (hollow == true ? 0 : fit/2),
  181. h = hollow == true ? lip_d : 4.0, $fn = facets);
  182. if (hollow) { cylinder(r = capsule_cable_diam/2 * 1.4, h = lip_d + thin_mint, $fn = facets); }
  183. }
  184. }
  185. }
  186. }
  187. // capsule holder array
  188. //
  189. module capsule_holder_array(hollow = true) {
  190. for (az = [45, 135, -45, -135]) {
  191. rotate([0, elev_angle, az]) {
  192. translate([0, 0, mic_radius - capsule_height]) {
  193. capsule_holder(holder_ratio, transition_ratio, hollow);
  194. }
  195. }
  196. rotate([0, 180 - elev_angle, az + 45]) {
  197. translate([0, 0, mic_radius - capsule_height]) {
  198. capsule_holder(holder_ratio, transition_ratio, hollow);
  199. }
  200. }
  201. }
  202. }
  203. // the spherical core and mounting stalk
  204. //
  205. // render = 0: the full sphere (for visualization)
  206. // render = 1: upper half
  207. // render = -1: lower half with stalk
  208. // thinkness of ring that connects both halves of the core sphere
  209. core_ring_height = 5.0;
  210. // holes for screws that hold together both halves of the sphere
  211. module capsule_holder_screws(radius, wall) {
  212. h_offset = 1.2;
  213. for (r = [90, 270]) {
  214. for (t = [0, 45]) {
  215. m = t > 0 ? 1 : 0;
  216. // 11.5 matches the angle for the flat shaves in the core
  217. mirror([0, 0, m]) rotate([0, 11.5, r + t]) translate([-(radius + 2 * wall), 0, 0]) {
  218. rotate([0, 90, 0]) {
  219. cylinder(r = 0.65, h = radius, $fn = facets);
  220. }
  221. }
  222. }
  223. }
  224. }
  225. // ring that holds the two halves of the sphere together
  226. module capsule_holder_ring(offset = 3.5) {
  227. s_radius = mic_radius - capsule_radius * (1 + transition_ratio) + offset;
  228. ring_h = core_ring_height - 0.2;
  229. translate([0, 0, -ring_h/2]) difference() {
  230. cylinder(r = s_radius - 2.5 * wall - fit, h = ring_h, $fn = facets);
  231. cylinder(r = s_radius - 4 * wall - fit, h = ring_h, $fn = facets);
  232. translate([0, 0, ring_h/2]) capsule_holder_screws(s_radius, wall);
  233. }
  234. }
  235. // spherical core
  236. module capsule_holder_core(top_radius, render = 0, offset = 3.5) {
  237. s_radius = mic_radius - capsule_radius * (1 + transition_ratio) + offset;
  238. difference() {
  239. union() {
  240. difference() {
  241. // core
  242. sphere(r = s_radius, $fn = facets);
  243. sphere(r = s_radius - 2.5 * wall, $fn = facets);
  244. // holes for screws
  245. capsule_holder_screws(s_radius, wall);
  246. // remove slice at the top
  247. translate([-s_radius, -s_radius, s_radius - wall]) {
  248. cube([2 * s_radius, 2 * s_radius, s_radius]);
  249. }
  250. // shave sides as well (cosmetic, really)
  251. for (az = [45, 135, -45, -135]) rotate([0, -11.5, az + 45]) {
  252. translate([s_radius - 0.5 * wall, -s_radius/2, -s_radius/2]) {
  253. cube([s_radius, s_radius, s_radius]);
  254. }
  255. }
  256. for (az = [45, 135, -45, -135]) rotate([0, 11.5, az]) {
  257. translate([s_radius - 0.5 * wall, -s_radius/2, -s_radius/2]) {
  258. cube([s_radius, s_radius, s_radius]);
  259. }
  260. }
  261. // remove one half of the sphere
  262. if (render == 1) {
  263. translate([-mic_radius, -mic_radius, -mic_radius * 2]) cube([mic_radius * 2, mic_radius * 2, mic_radius * 2]);
  264. }
  265. if (render == -1) {
  266. translate([-mic_radius, -mic_radius, 0]) cube([mic_radius * 2, mic_radius * 2, mic_radius * 2]);
  267. }
  268. // make space for connection ring
  269. ring_h = core_ring_height;
  270. translate([0, 0, -ring_h/2]) {
  271. cylinder(r = s_radius - 2.5 * wall, h = ring_h, $fn = facets);
  272. }
  273. // hole for stalk
  274. if (render == -1) {
  275. translate([0, 0, -mic_radius]) cylinder(r = mount_radius, h = mic_radius, $fn = facets);
  276. }
  277. }
  278. // stalk that transitions into flare
  279. if (render == -1) {
  280. //stalk_len = 15.0;
  281. // normal length plus 10 to insert into flare
  282. stalk_len = stalk_height + 10.0 + 10.0;
  283. inset = wall;
  284. translate([0, 0, - (stalk_len - inset + s_radius)]) {
  285. difference() {
  286. cylinder(r = top_radius, h = stalk_len + inset, $fn = facets);
  287. cylinder(r = top_radius - wall, h = stalk_len + inset + thin_mint, $fn = facets);
  288. }
  289. }
  290. // add flange for coupling into flare
  291. translate([0, 0, - (stalk_height - inset - 0.5 + 10.0 + 10.0)]) {
  292. difference() {
  293. cylinder(r2 = top_radius, r1 = top_radius + wall, h = 10.0, $fn = facets);
  294. cylinder(r2 = top_radius - wall, r1 = top_radius, h = 10.0, $fn = facets);
  295. }
  296. }
  297. translate([top_radius, 0, - (stalk_height - inset - 0.5 + 10.0 + 10.0 + 10.0)]) {
  298. // add key to stalk so orientation is always correct
  299. difference() {
  300. cylinder(r = 0.4, h = 10.0, $fn = facets);
  301. }
  302. }
  303. }
  304. }
  305. // make holes for capsule holders
  306. capsule_holder_array(false);
  307. }
  308. // index for aligning the two halves of core sphere
  309. rotate([0, 0, 22.5]) translate([s_radius, 0, 0]) {
  310. difference() {
  311. scale([1, 1, 2]) sphere(r = 0.5, $fn = facets);
  312. translate([-2.2, -1, -4]) cube([2, 2, 8]);
  313. if (render == 1) {
  314. translate([-2, -1, -8]) cube([4, 2, 8]);
  315. }
  316. if (render == -1) {
  317. translate([-2, -1, 0]) cube([4, 2, 8]);
  318. }
  319. }
  320. }
  321. }
  322. // render individual capsules
  323. //
  324. module render_octa_capsule_top() {
  325. capsule(leg_angles, 180, 0, 0.0, 0.0, 0);
  326. }
  327. module render_octa_capsule_bot() {
  328. capsule(leg_angles, 0, 1, 0.0, 0.0, 0);
  329. }
  330. // render simple microphone stand mount
  331. //
  332. module render_simple_stand_mount(z_offset) {
  333. translate([0, 0, z_offset]) {
  334. mount([-45, 135], mount_wall, mic_mount_wall, mic_mount_height + mount_top_height + mount_height + capsule_bottom);
  335. }
  336. }