Octathingy_common.scad 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  1. //
  2. // Spherical Harmonics Ear Project (*SpHEAR)
  3. //
  4. // OctaSpHEAR or 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-2019, 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. ////
  31. //// overrides
  32. // inner radius of stalk
  33. mount_radius = 4.0;
  34. // this adds space for the protuding molex pins on which we solder
  35. pcb_low_clear = 15.0;
  36. pcb_hi_clear = 15.0;
  37. ////
  38. //// rendering control
  39. // what type of connection to use between capsule holders:
  40. // 0 -> original cylindrical angled legs
  41. // 1 -> interlocking horizontal legs
  42. // 2 -> interlocking vertical legs
  43. connect = 1;
  44. // adjustment for the radius of the capsule
  45. // measured inside diameter of a trial print was around 7.5 to 8.2
  46. // instead of 10, capsule diameter was 9.99)
  47. fudge = 0.15;
  48. // back and front clearance of pcb (components and leads)
  49. pcb_front = pcb_version == 2 ? 2.50 : 3.00;
  50. pcb_back = pcb_version == 2 ? 1.70 : 1.80;
  51. //// end of rendering control
  52. ////
  53. // define the elevation angle of the upper and lower rings
  54. //
  55. // http://eusebeia.dyndns.org/4d/antiprism4
  56. //
  57. // The Cartesian coordinates of the square antiprism,
  58. // centered on the origin and having edge length 2, are:
  59. //
  60. // (0, ±√2, 1/∜2)
  61. // (±√2, 0, 1/∜2)
  62. // (±1, ±1, −1/∜2)
  63. //
  64. // the elevation angle for the two rings of 4 is:
  65. //
  66. // 1/2*∜2 = 0.420448207627 (z for edge length = 1)
  67. // atan(1/(2*∜2) / 0.707) = 30.7358671024
  68. elev_angle = 90 - (tetra_compat == 0 ? atan(1 / (2 * sqrt(sqrt(2))) * sqrt(2)) : atan(sqrt(1/2)));
  69. // calculate half angle between vertices in the square antiprism
  70. // these angles define the length of the connecting legs
  71. //
  72. // z coordinate of antiprism vertices
  73. vert_z = (sqrt(2) / 2) / tan(elev_angle);
  74. // vector length (same for all antiprism vertices)
  75. vert_n = norm([-0.5, -0.5, vert_z]);
  76. // half angle between adjacent vertices in either the upper or lower rings
  77. vert_angle_h = acos(([-0.5, -0.5, vert_z] / vert_n) * ([0.5, -0.5, vert_z] / vert_n)) / 2;
  78. // half angle between adjacent vertices in the upper and lower rings
  79. vert_angle_v = acos(([0.0, -1 / sqrt(2), -vert_z] / vert_n) * ([0.5, -0.5, vert_z] / vert_n)) / 2;
  80. // angles of the connection legs and adjacent capsule holders
  81. leg_angles = tetra_compat == 0 ?
  82. [
  83. [-63, 90 - vert_angle_h, 0, 1],
  84. [63, 90 - vert_angle_h, 0, 1],
  85. [-141, 90 - vert_angle_v, 0, 1],
  86. [141, 90 - vert_angle_v, 0, 1]
  87. ] :
  88. [
  89. [-60.5, vert_angle_h, 19.5, 1],
  90. [60.5, vert_angle_h, 19.5, 1],
  91. [-144.3, vert_angle_v, 8, 2],
  92. [144.3, vert_angle_v, 8, 2]
  93. ];
  94. // microphone holder geometry
  95. capsule_sep_min = (mic_radius - capsule_height) * sin(elev_angle) - (capsule_radius + wall) * cos(elev_angle);
  96. capsule_sep_max = mic_radius * sin(elev_angle) - (capsule_radius + wall) * cos(elev_angle);
  97. capsule_bottom = mic_radius * cos(elev_angle) + (capsule_radius + wall) * sin(elev_angle);
  98. mount_radius_capsule = capsule_sep_max;
  99. // render the capsule array
  100. //
  101. module render_octa_capsule_array(z_offset) {
  102. translate([0, 0, z_offset]) {
  103. for (az = [45, 135, -45, -135]) {
  104. rotate([0, elev_angle, az]) {
  105. translate([0, 0, mic_radius - capsule_height]) {
  106. capsule(leg_angles, 180, 0, 0.0, 0.0, 0);
  107. }
  108. }
  109. rotate([0, 180 - elev_angle, az + 45]) {
  110. translate([0, 0, mic_radius - capsule_height]) {
  111. capsule(leg_angles, 0, 1, 0.0, 0.0, 0);
  112. }
  113. }
  114. }
  115. }
  116. }
  117. // capsule holder with conical mount
  118. //
  119. // ratio of capsule radius to transition length
  120. transition_ratio = 1.0;
  121. // ratio of capsule radius to bottom radius of holder
  122. holder_ratio = 0.4;
  123. // diameter of microphone capsule cable (Mogami 2490)
  124. capsule_cable_diam = 1.7;
  125. module capsule_holder(ratio, transition, hollow = true) {
  126. capsule_h = capsule_height;
  127. difference() {
  128. // main capsule holder, use a conical bore to press fit the capsule
  129. f = 0.05;
  130. cylinder(r = capsule_radius + fudge + wall, h = capsule_h, $fn = cfacets);
  131. if (hollow) {
  132. cylinder(r1 = capsule_radius + fudge, r2 = capsule_radius + fudge + f, h = capsule_h/2 + thin_mint, $fn = cfacets);
  133. translate([0, 0, capsule_h*1/2]) {
  134. cylinder(r = capsule_radius + fudge + f, h = capsule_h + thin_mint, $fn = cfacets);
  135. }
  136. }
  137. }
  138. // conical transition into core sphere
  139. transition_h = transition * capsule_radius;
  140. translate([0, 0, - transition_h]) {
  141. difference() {
  142. // add ridge to get a perfect alignment when inserting into core
  143. over = 0.5;
  144. cylinder(r2 = capsule_radius + fudge + wall, r1 = (capsule_radius) * ratio + wall + over, h = transition_h, $fn = facets);
  145. // add overhang so that we have a stop when inserting the capsule
  146. overhang = 0.2;
  147. if (hollow) cylinder(r2 = capsule_radius + fudge - overhang, r1 = (capsule_radius) * ratio, h = transition_h, $fn = facets);
  148. // add holes in the walls of the conical transition
  149. if (hollow) {
  150. for (r = [0:36:179]) {
  151. rotate([0, 90, r]) {
  152. translate([-transition_h, 0, -capsule_radius - 2 * wall])
  153. scale([7, 1.2, 1]) cylinder(r = 1.0, h = (capsule_radius + 2 * wall) * 2, $fn = facets);
  154. }
  155. }
  156. }
  157. }
  158. // lip to insert holder into core
  159. lip_d = 1.4 * wall;
  160. translate([0, 0, hollow == false ? -3 : -lip_d]) {
  161. difference() {
  162. // if not hollow make the ring longer to cut into core
  163. // cylinder(r = (capsule_radius) * ratio + wall + (hollow == true ? 0 : fit/2),
  164. cylinder(r = (capsule_radius) * ratio + wall + (hollow == true ? 0 : 0),
  165. h = hollow == true ? lip_d : 4.0, $fn = facets);
  166. if (hollow) { cylinder(r = capsule_cable_diam/2 * 1.4, h = lip_d + thin_mint, $fn = facets); }
  167. }
  168. }
  169. }
  170. }
  171. module capsule_holder_float(ratio, transition, hollow = true, depth = 0) {
  172. capsule_h = capsule_height;
  173. f = 0.05;
  174. difference() {
  175. // main capsule holder, use a conical bore to press fit the capsule
  176. cylinder(r = capsule_radius + fudge + wall, h = capsule_h + depth, $fn = cfacets);
  177. if (hollow) {
  178. cylinder(r1 = capsule_radius + fudge, r2 = capsule_radius + fudge + f, h = capsule_h/2 + thin_mint + depth, $fn = cfacets);
  179. translate([0, 0, capsule_h*1/2]) {
  180. cylinder(r = capsule_radius + fudge + f, h = capsule_h + thin_mint + depth, $fn = cfacets);
  181. }
  182. }
  183. }
  184. // overhang to act as a back stop for the capsule
  185. overhang = 0.3;
  186. translate([0, 0, -overhang]) difference() {
  187. cylinder(r = capsule_radius + fudge + wall, h = overhang, $fn = cfacets);
  188. if (hollow) {
  189. cylinder(r1 = capsule_radius + fudge, r2 = capsule_radius + fudge + f - overhang, h = overhang + thin_mint, $fn = cfacets);
  190. }
  191. }
  192. }
  193. // capsule holder array
  194. //
  195. module render_octa_capsule_holder_ring_array(rot = 0, rot2 = 0, hollow = true, depth = 0) {
  196. for (az = [45, 135, -45, -135]) {
  197. rotate([0, elev_angle, az]) {
  198. translate([0, 0, mic_radius - capsule_height]) {
  199. rotate([rot, 0, -rot2]) capsule_holder_float(holder_ratio, transition_ratio, hollow, depth);
  200. }
  201. }
  202. rotate([0, 180 - elev_angle, az + 45]) {
  203. translate([0, 0, mic_radius - capsule_height]) {
  204. rotate([rot, 0, rot2]) capsule_holder_float(holder_ratio, transition_ratio, hollow, depth);
  205. }
  206. }
  207. }
  208. }
  209. module render_octa_capsule_holder_array(hollow = true, depth = 0) {
  210. for (az = [45, 135, -45, -135]) {
  211. rotate([0, elev_angle, az]) {
  212. translate([0, 0, mic_radius - capsule_height]) {
  213. capsule_holder(holder_ratio, transition_ratio, hollow, depth);
  214. }
  215. }
  216. rotate([0, 180 - elev_angle, az + 45]) {
  217. translate([0, 0, mic_radius - capsule_height]) {
  218. capsule_holder(holder_ratio, transition_ratio, hollow, depth);
  219. }
  220. }
  221. }
  222. }
  223. module render_tetra_capsule_holder_array(hollow = true) {
  224. for (az = [45, 135, -45, -135]) {
  225. rotate([0, elev_angle, az]) {
  226. translate([0, 0, mic_radius - capsule_height]) {
  227. capsule_holder(holder_ratio, transition_ratio, hollow);
  228. }
  229. }
  230. rotate([0, 180 - elev_angle, az + 45]) {
  231. translate([0, 0, mic_radius - capsule_height]) {
  232. capsule_holder(holder_ratio, transition_ratio, hollow);
  233. }
  234. }
  235. }
  236. }
  237. // the spherical core and mounting stalk
  238. //
  239. // render = 0: the full sphere (for visualization)
  240. // render = 1: upper half
  241. // render = -1: lower half with stalk
  242. // thickness of ring that connects both halves of the core sphere
  243. core_ring_height = 5.0;
  244. // holes for screws that hold together both halves of the sphere
  245. module capsule_holder_screws(radius, wall, screw_r, shift = 0) {
  246. h_offset = 1.2;
  247. for (r = [90, 270]) {
  248. for (t = [0, 45]) {
  249. m = t > 0 ? 1 : 0;
  250. // 11.5 matches the angle for the flat shaves in the core
  251. mirror([0, 0, m]) rotate([0, 11.5, r + t]) translate([-(radius + 2 * wall), 0, shift]) {
  252. rotate([0, 90, 0]) {
  253. cylinder(r = screw_r, h = radius, $fn = facets);
  254. }
  255. }
  256. }
  257. }
  258. }
  259. // ring that connects the two halves of the core sphere
  260. module capsule_holder_ring(offset = 3.5, shift = 0) {
  261. s_radius = mic_radius - capsule_radius * (1 + transition_ratio) + offset;
  262. ring_h = core_ring_height - 0.2;
  263. translate([0, 0, -ring_h/2]) difference() {
  264. cylinder(r = s_radius - 2.5 * wall - fit, h = ring_h, $fn = facets);
  265. cylinder(r = s_radius - 4 * wall - fit, h = ring_h, $fn = facets);
  266. // shift the holes slightly so the two halves are pressed together
  267. translate([0, 0, ring_h/2]) capsule_holder_screws(s_radius, wall, 0.55, shift);
  268. }
  269. }
  270. // spherical core
  271. module capsule_holder_core(top_radius, height, render = 0, offset = 3.5) {
  272. s_radius = mic_radius - capsule_radius * (1 + transition_ratio) + offset;
  273. difference() {
  274. union() {
  275. difference() {
  276. // core
  277. sphere(r = s_radius, $fn = facets);
  278. sphere(r = s_radius - 2.5 * wall, $fn = facets);
  279. // holes for screws
  280. capsule_holder_screws(s_radius, wall, 0.9, 0.0);
  281. // remove slice at the top
  282. translate([-s_radius, -s_radius, s_radius - wall]) {
  283. cube([2 * s_radius, 2 * s_radius, s_radius]);
  284. }
  285. // shave sides as well (cosmetic, really)
  286. for (az = [45, 135, -45, -135]) rotate([0, -11.5, az + 45]) {
  287. translate([s_radius - 0.5 * wall, -s_radius/2, -s_radius/2]) {
  288. cube([s_radius, s_radius, s_radius]);
  289. }
  290. }
  291. for (az = [45, 135, -45, -135]) rotate([0, 11.5, az]) {
  292. translate([s_radius - 0.5 * wall, -s_radius/2, -s_radius/2]) {
  293. cube([s_radius, s_radius, s_radius]);
  294. }
  295. }
  296. // remove one half of the sphere
  297. if (render == 1) {
  298. translate([-mic_radius, -mic_radius, -mic_radius * 2]) cube([mic_radius * 2, mic_radius * 2, mic_radius * 2]);
  299. }
  300. if (render == -1) {
  301. translate([-mic_radius, -mic_radius, 0]) cube([mic_radius * 2, mic_radius * 2, mic_radius * 2]);
  302. }
  303. // make space for connection ring
  304. ring_h = core_ring_height;
  305. translate([0, 0, -ring_h/2]) {
  306. cylinder(r = s_radius - 2.5 * wall, h = ring_h, $fn = facets);
  307. }
  308. // hole for stalk
  309. if (render == -1) {
  310. translate([0, 0, -mic_radius]) cylinder(r = mount_radius, h = mic_radius, $fn = facets);
  311. }
  312. }
  313. // stalk that transitions into flare
  314. if (render == -1) {
  315. //stalk_len = 15.0;
  316. // normal length plus 10 to insert into flare
  317. stalk_len = height + 10.0 + 10.0;
  318. inset = wall;
  319. translate([0, 0, - (stalk_len - inset + s_radius)]) {
  320. difference() {
  321. cylinder(r = top_radius, h = stalk_len + inset, $fn = facets);
  322. cylinder(r = top_radius - wall, h = stalk_len + inset + thin_mint, $fn = facets);
  323. }
  324. }
  325. // add flange for coupling into flare
  326. translate([0, 0, - (height - inset - 0.5 + 10.0 + 10.0)]) {
  327. difference() {
  328. cylinder(r2 = top_radius, r1 = top_radius + wall, h = 10.0, $fn = facets);
  329. cylinder(r2 = top_radius - wall, r1 = top_radius, h = 10.0, $fn = facets);
  330. }
  331. }
  332. translate([top_radius, 0, - (height - inset - 0.5 + 10.0 + 10.0 + 10.0)]) {
  333. // add key to stalk so orientation is always correct
  334. difference() {
  335. cylinder(r = 0.4, h = 10.0, $fn = facets);
  336. }
  337. }
  338. }
  339. }
  340. // make holes for capsule holders
  341. render_octa_capsule_holder_array(false);
  342. }
  343. // index for aligning the two halves of core sphere
  344. rotate([0, 0, 22.5]) translate([s_radius, 0, 0]) {
  345. difference() {
  346. scale([1, 1, 2]) sphere(r = 0.5, $fn = facets);
  347. translate([-2.2, -1, -4]) cube([2, 2, 8]);
  348. if (render == 1) {
  349. translate([-2, -1, -8]) cube([4, 2, 8]);
  350. }
  351. if (render == -1) {
  352. translate([-2, -1, 0]) cube([4, 2, 8]);
  353. }
  354. }
  355. }
  356. }
  357. // capsule array stalk
  358. module capsule_holder_stalk(top_radius, height, render = 0, offset = 3.5) {
  359. s_radius = mic_radius - capsule_radius * (1 + transition_ratio) + offset;
  360. union() {
  361. // stalk that transitions into flare
  362. if (render == -1) {
  363. //stalk_len = 15.0;
  364. // normal length plus 10 to insert into flare
  365. stalk_len = height + 10.0 + 10.0;
  366. inset = wall;
  367. translate([0, 0, - (stalk_len - inset + s_radius)]) {
  368. difference() {
  369. cylinder(r = top_radius, h = stalk_len + inset, $fn = facets);
  370. cylinder(r = top_radius - wall, h = stalk_len + inset + thin_mint, $fn = facets);
  371. }
  372. }
  373. // add flange for coupling into flare
  374. translate([0, 0, - (height - inset - 0.5 + 10.0 + 10.0)]) {
  375. difference() {
  376. cylinder(r2 = top_radius, r1 = top_radius + wall, h = 10.0, $fn = facets);
  377. cylinder(r2 = top_radius - wall, r1 = top_radius, h = 10.0, $fn = facets);
  378. }
  379. }
  380. translate([top_radius, 0, - (height - inset - 0.5 + 10.0 + 10.0 + 10.0)]) {
  381. // add key to stalk so orientation is always correct
  382. difference() {
  383. cylinder(r = 0.4, h = 10.0, $fn = facets);
  384. }
  385. }
  386. }
  387. }
  388. // index for aligning the two halves of core sphere
  389. rotate([0, 0, 22.5]) translate([s_radius, 0, 0]) {
  390. difference() {
  391. scale([1, 1, 2]) sphere(r = 0.5, $fn = facets);
  392. translate([-2.2, -1, -4]) cube([2, 2, 8]);
  393. if (render == 1) {
  394. translate([-2, -1, -8]) cube([4, 2, 8]);
  395. }
  396. if (render == -1) {
  397. translate([-2, -1, 0]) cube([4, 2, 8]);
  398. }
  399. }
  400. }
  401. }
  402. // connect array to upper flare
  403. module flare_connector(top_radius, height, offset = 3.5) {
  404. s_radius = mic_radius - capsule_radius * (1 + transition_ratio) + offset;
  405. // stalk that transitions into flare
  406. //stalk_len = 15.0;
  407. // normal length plus 10 to insert into flare
  408. stalk_len = height + 10.0;
  409. inset = wall;
  410. translate([0, 0, - (2*stalk_len - inset + s_radius)]) {
  411. difference() {
  412. cylinder(r = top_radius, h = stalk_len + inset, $fn = facets);
  413. cylinder(r = top_radius - wall, h = stalk_len + inset + thin_mint, $fn = facets);
  414. }
  415. }
  416. translate([top_radius, 0, - (height - inset - 0.5 + 10.0 + 10.0 + 10.0)]) {
  417. // add key to stalk so orientation is always correct
  418. difference() {
  419. cylinder(r = 0.4, h = 13.0, $fn = facets);
  420. }
  421. }
  422. }
  423. // render individual capsules
  424. //
  425. module render_octa_capsule_top() {
  426. capsule(leg_angles, 180, 0, 0.0, 0.0, 0);
  427. }
  428. module render_octa_capsule_bot() {
  429. capsule(leg_angles, 0, 1, 0.0, 0.0, 0);
  430. }
  431. // render simple microphone stand mount
  432. //
  433. module render_simple_stand_mount(z_offset) {
  434. translate([0, 0, z_offset]) {
  435. mount([-45, 135], mount_wall, mic_mount_wall, mic_mount_height + mount_top_height + mount_height + capsule_bottom);
  436. }
  437. }