1
0

octathingy.scad 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. //
  2. // Octathingy, Second Order Ambisonics Microphone
  3. //
  4. // based on:
  5. // "A second-order soundfield microphone with improved polar pattern shape"
  6. // by Eric Benjamin, Audio Engineering Society Convention Paper 8728,
  7. // October 2012, San Francisco
  8. // Copyright 2015, Fernando Lopez-Lezcano, All Rights Reserved
  9. // nando@ccrma.stanford.edu
  10. //
  11. //
  12. // This program is free software: you can redistribute it and/or modify
  13. // it under the terms of the GNU General Public License as published by
  14. // the Free Software Foundation, either version 3 of the License, or
  15. // (at your option) any later version.
  16. //
  17. // This program is distributed in the hope that it will be useful,
  18. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. // GNU General Public License for more details.
  21. //
  22. // You should have received a copy of the GNU General Public License
  23. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  24. //
  25. //
  26. // 3d Models released under the Creative Commons license as follows:
  27. // Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)
  28. // http://creativecommons.org/licenses/by-nc-sa/4.0/
  29. ////
  30. //// model parameters
  31. // dimensions of the EM182 electret microphone
  32. capsule_radius = 5;
  33. capsule_height = 4.5;
  34. // distance between face of capsule and center of array
  35. mic_radius = 14;
  36. // dimensions of capsule holder connection legs
  37. leg_width = 4;
  38. leg_thick = 2.5;
  39. // width of the ridge that connects to the mount
  40. ridge_width = 2;
  41. ridge_length = 2;
  42. // wall thickness of capsule holder
  43. wall = 1;
  44. // dimensions of microphone holder
  45. mount_radius = 4.5;
  46. // height of mount
  47. mount_height = 4;
  48. // type of octathingy
  49. // 0 -> regular octathingy (equilateral triangles in the square antiprism)
  50. // 1 -> tetrahedral compatible octathingy (same elevation angle as the tetrahedral mic)
  51. tetra_compat = 0;
  52. //// end of model parameters
  53. ////
  54. //// rendering control
  55. // what to render:
  56. // 0 -> ready to print
  57. // set = 0 -> one capsule, set = 1 -> four capsules
  58. // 1 -> the whole microhone with four capsules
  59. rendermic = 0;
  60. renderset = 1;
  61. // what type of connection to use between capsule holders:
  62. // 0 -> original cylinder beams
  63. // 1 -> interlocking beams (out)
  64. // 2 -> interlocking beams (in)
  65. connect = 1;
  66. // adjustment for the radius of the capsule
  67. // measured inside diameter of a trial print was around 7.5 to 8.2
  68. // instead of 10, capsule diameter was 9.99)
  69. fudge = 0.15;
  70. // adjustment for fit of slots in connection legs and mount
  71. fit = 0.2;
  72. // number of facets for rendering cylinders
  73. facets = 64;
  74. //// end of rendering control
  75. ////
  76. // define the elevation angle of the upper and lower rings
  77. //
  78. // http://eusebeia.dyndns.org/4d/antiprism4
  79. //
  80. // The Cartesian coordinates of the square antiprism,
  81. // centered on the origin and having edge length 2, are:
  82. //
  83. // (0, ±√2, 1/∜2)
  84. // (±√2, 0, 1/∜2)
  85. // (±1, ±1, −1/∜2)
  86. //
  87. // the elevation angle for the two rings of 4 is:
  88. //
  89. // 1/2*∜2 = 0.420448207627 (z for edge length = 1)
  90. // atan(1/(2*∜2) / 0.707) = 30.7358671024
  91. elev_angle = tetra_compat == 0 ? atan(1 / (2 * sqrt(sqrt(2))) * sqrt(2)) : atan(sqrt(1/2));
  92. // calculate half angle between vertices in the square antiprism
  93. // these angles define the length of the connecting legs
  94. //
  95. // z coordinate of antiprism vertices
  96. vert_z = sqrt(2) * tan(elev_angle) / 2;
  97. // vector length (same for all antiprism vertices)
  98. vert_n = norm([-0.5, -0.5, vert_z]);
  99. // half angle between adjacent vertices in either the upper or lower rings
  100. vert_angle_h = acos(([-0.5, -0.5, vert_z] / vert_n) * ([0.5, -0.5, vert_z] / vert_n)) / 2;
  101. // half angle between adjacent vertices in the upper and lower rings
  102. vert_angle_v = acos(([0.0, -1 / sqrt(2), -vert_z] / vert_n) * ([0.5, -0.5, vert_z] / vert_n)) / 2;
  103. // angles of the connection legs and adjacent capsule holders
  104. leg_angles = tetra_compat == 0 ?
  105. [
  106. [-63, vert_angle_h],
  107. [63, vert_angle_h],
  108. [-141, vert_angle_v],
  109. [141, vert_angle_v]
  110. ] :
  111. [
  112. [-60.5, vert_angle_h],
  113. [60.5, vert_angle_h],
  114. [-144.5, vert_angle_v],
  115. [144.5, vert_angle_v]
  116. ];
  117. // microphone holder geometry
  118. capsule_sep_min = (mic_radius - capsule_height) * cos(elev_angle) - (capsule_radius + wall) * sin(elev_angle);
  119. capsule_sep_max = mic_radius * cos(elev_angle) - (capsule_radius + wall) * sin(elev_angle);
  120. capsule_bottom = mic_radius * sin(elev_angle) + (capsule_radius + wall) * cos(elev_angle);
  121. mount_slot_depth = ridge_length * sin(elev_angle);
  122. ////////
  123. // microphone capsule holder
  124. // azimuth: horizontal orientation of the capsule
  125. // elevation: vertical orientation of the capsure
  126. // mounts: vectors containing the angle of the mount and the angle to the adjacent capsule
  127. // twist: rotate the whole capsule to match mounting legs
  128. module capsule (azimuth, elevation, mounts, twist, ridge) {
  129. rotate([0, 0, azimuth]) {
  130. rotate([0, (90 - elevation), 0]) {
  131. translate([0, 0, rendermic == 0 ? 0 : mic_radius - capsule_height]) {
  132. difference () {
  133. union () {
  134. // main capsule holder
  135. cylinder(r = capsule_radius + wall, h = capsule_height, $fn = facets);
  136. // the mounting legs
  137. for (angles = mounts) {
  138. rotate([0, 0, angles[0] + twist]) {
  139. // connect with cylindrical beams, very pretty
  140. leg_length = mic_radius * sin(angles[1]) - (capsule_radius + wall) * cos(angles[1]) + wall;
  141. if (connect == 0) {
  142. translate([capsule_radius - wall, 0, capsule_height - wall]) {
  143. rotate([0, 180 - (90 - angles[1]), 0]) {
  144. cylinder(d = leg_width, h = leg_length - 0.1, center = false, $fn = facets);
  145. }
  146. }
  147. }
  148. // connect with horizontal legs
  149. if (connect == 1) {
  150. leg_length = (mic_radius - capsule_height + leg_thick) * tan(angles[1]) - capsule_radius;
  151. slot_depth = leg_thick * cos(90 - 2 * angles[1]) + fit;
  152. translate([capsule_radius + leg_length + fudge, - leg_width / 3, 0]) {
  153. rotate([0, -90, 0]) {
  154. difference() {
  155. // thickness, width
  156. cube([leg_thick, leg_width, leg_length]);
  157. // cut slot in connector
  158. translate([0, leg_width / 3 - (fit / 2), 0]) {
  159. cube([leg_thick, leg_width / 3 + fit, slot_depth]);
  160. }
  161. }
  162. }
  163. }
  164. }
  165. // connect with vertical legs
  166. if (connect == 2) {
  167. leg_length = (mic_radius * tan(angles[1]) - capsule_radius) * tan(90 - angles[1]);
  168. slot_depth = leg_thick * (cos (90 - 2 * angles[1]) + tan(90 - 2 * angles[1])) + fit;
  169. translate([capsule_radius + fudge, - leg_width / 3, - leg_length + capsule_height]) {
  170. difference() {
  171. // thickness, width
  172. cube([leg_thick, leg_width, leg_length]);
  173. // cut slot in connector
  174. translate([0, leg_width / 3 - (fit / 2), 0]) {
  175. cube([leg_thick, leg_width / 3 + fit, slot_depth]);
  176. }
  177. }
  178. }
  179. }
  180. }
  181. }
  182. // add ridges for microphone mount
  183. if (ridge == 1) {
  184. rotate([0, 0, twist]) {
  185. translate([capsule_radius + fudge, - wall , 0]) {
  186. difference() {
  187. cube([ridge_length, ridge_width, capsule_height], center = false);
  188. //rotate([0, 90 - elev_angle, 0]) {
  189. // cube([ridge_length, ridge_width, capsule_height], center = false);
  190. //}
  191. }
  192. }
  193. }
  194. }
  195. }
  196. // make the hole for the capsule
  197. translate ([0, 0, -2]) {
  198. cylinder(r = capsule_radius + fudge, h = capsule_height + 2, $fn = facets);
  199. }
  200. // remove any extra connecting beam material from the face of the holder
  201. if (connect == 0) {
  202. translate ([0, 0, capsule_height]) {
  203. cylinder(r = capsule_radius + wall * 2, h = 2, $fn = facets);
  204. }
  205. }
  206. }
  207. }
  208. }
  209. }
  210. }
  211. // microphone mount
  212. //
  213. // angles: angles for mount slots
  214. // wall: thickness of cylinder wall
  215. // separation: height of mount with respect of the microphone assembly
  216. module mount (angles, wall, separation) {
  217. translate([0, 0, -(separation + 0.1)]) {
  218. difference() {
  219. union() {
  220. // grips for the capsule holder ridge
  221. for (rot = angles) {
  222. rotate([0, 0, rot]) {
  223. translate([-capsule_sep_max, -(ridge_width - fit / 2), -mount_height]) {
  224. cube([capsule_sep_max, ridge_width * 2 - fit, mount_height]);
  225. rotate([0, -elev_angle, 0]) {
  226. cube([capsule_sep_max, ridge_width * 2 - fit, mount_height * cos(elev_angle)]);
  227. }
  228. }
  229. }
  230. }
  231. translate([0, 0, -mount_height]) {
  232. cylinder(r = mount_radius + wall, h = mount_height, $fn = facets);
  233. }
  234. }
  235. // make the hole for the mount (* 2 to cut the ridge as well)
  236. translate([0, 0, -mount_height]) {
  237. cylinder(r = mount_radius, h = mount_height * 2, $fn = facets);
  238. }
  239. // cut the outside of the sloped ridge
  240. translate([0, 0, -mount_height]) {
  241. difference() {
  242. cylinder(r = capsule_sep_max + mount_height * 2, h = mount_height * 2, $fn = facets);
  243. cylinder(r = capsule_sep_max, h = mount_height * 2, $fn = facets);
  244. }
  245. }
  246. // and cut a slot for the ridges in the wall of the cylinder
  247. for (rot = angles) {
  248. rotate([0, 0, rot]) {
  249. translate([-capsule_sep_max * 2, -ridge_width + 4 * fit, -mount_slot_depth]) {
  250. cube([capsule_sep_max * 2, ridge_width + 2 * fit, mount_height * 2]);
  251. }
  252. }
  253. }
  254. }
  255. }
  256. }
  257. // render a complete microphone
  258. if (rendermic == 1) {
  259. for (az = [45, 135, -45, -135]) {
  260. capsule(az, elev_angle, leg_angles, 180, 0);
  261. capsule(az + 45, -elev_angle, leg_angles, 0, 1);
  262. }
  263. // the mount
  264. mount([0, 90, -90, 180], 1, capsule_bottom);
  265. }
  266. // print all the parts separately
  267. part_sep = capsule_radius * 2 * 3;
  268. if (rendermic == 0) {
  269. //translate([0, 0, 0]) { capsule(0, 90, leg_angles, 0, 0); }
  270. //translate([0, part_sep, 0]) { capsule(0, 90, leg_angles, 0); }
  271. translate([0, 0, 0]) { capsule(0, 90, leg_angles, 0, 1); }
  272. //translate([part_sep, part_sep]) { capsule(0, 90, leg_angles, 0); }
  273. }