1
0

first_order.scad 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. //
  2. // TinySphEAR, Tiny Spherical Ear, First Order (B-format) Ambisonics Microphone
  3. //
  4. // Copyright 2015, Fernando Lopez-Lezcano, All Rights Reserved
  5. // nando@ccrma.stanford.edu
  6. //
  7. //
  8. // This program is free software: you can redistribute it and/or modify
  9. // it under the terms of the GNU General Public License as published by
  10. // the Free Software Foundation, either version 3 of the License, or
  11. // (at your option) any later version.
  12. //
  13. // This program is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. // GNU General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU General Public License
  19. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. //
  21. //
  22. // 3d Models released under the Creative Commons license as follows:
  23. // Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)
  24. // http://creativecommons.org/licenses/by-nc-sa/4.0/
  25. // https://en.wikipedia.org/wiki/Tetrahedron
  26. // angle of capsule to vertical axis = atan(sqrt(2)) = 54.7356103172
  27. ////
  28. //// model parameters
  29. // dimensions of the EM182 electret microphone
  30. capsule_radius = 5;
  31. capsule_height = 4.5;
  32. // distance between face of capsule and center of array
  33. mic_radius = 10;
  34. // dimensions of capsule holder connection legs
  35. leg_width = 4;
  36. leg_thick = 2.5;
  37. // width of the ridge that connects to the mount
  38. ridge_width = 2;
  39. ridge_length = 2;
  40. // wall thickness of capsule holder
  41. wall = 1;
  42. // dimensions of microphone holder
  43. mount_radius = 3.5;
  44. // height of mount
  45. mount_height = 4;
  46. //// end of model parameters
  47. ////
  48. //// rendering control
  49. // what to render:
  50. // 0 -> ready to print
  51. // set = 0 -> one capsule, set = 1 -> four capsules
  52. // 1 -> the whole microhone with four capsules
  53. rendermic = 1;
  54. renderset = 0;
  55. // what type of connection to use between capsule holders:
  56. // 0 -> original cylinder beams
  57. // 1 -> interlocking beams (out)
  58. // 2 -> interlocking beams (in)
  59. connect = 1;
  60. //// end of rendering control
  61. ////
  62. // elevation angle for the capsule holders (fixed for this microphone)
  63. elev_angle = atan(sqrt(1/2));
  64. // angles of the connection legs and adjacent capsule holders
  65. leg_angles_top =
  66. [
  67. [-120, elev_angle],
  68. [0, elev_angle],
  69. [120, elev_angle]
  70. ];
  71. leg_angles_bot =
  72. [
  73. [-120, elev_angle],
  74. [120, elev_angle]
  75. ];
  76. // adjustment for the radius of the capsule
  77. // measured inside diameter of a trial print was around 7.5 to 8.2
  78. // instead of 10, capsule diameter was 9.99)
  79. fudge = 0.15;
  80. // adjustment for fit of slots in connection legs and mount
  81. fit = 0.2;
  82. // number of facets for rendering cylinders
  83. facets = 64;
  84. // microphone holder geometry
  85. capsule_sep_min = (mic_radius - capsule_height) * cos(elev_angle) - (capsule_radius + wall) * sin(elev_angle);
  86. capsule_sep_max = mic_radius * cos(elev_angle) - (capsule_radius + wall) * sin(elev_angle);
  87. capsule_bottom = mic_radius * sin(elev_angle) + (capsule_radius + wall) * cos(elev_angle);
  88. mount_slot_depth = ridge_length * sin(elev_angle);
  89. ////////
  90. // microphone capsule holder
  91. // azimuth: horizontal orientation of the capsule
  92. // elevation: vertical orientation of the capsure
  93. // mounts: vectors containing the angle of the mount and the angle to the adjacent capsule
  94. // twist: rotate the whole capsule to match mounting legs
  95. // ridge: 1 -> print ridge for mount
  96. module capsule (azimuth, elevation, mounts, twist, ridge) {
  97. rotate([0, 0, azimuth]) {
  98. rotate([0, (90 - elevation), 0]) {
  99. translate([0, 0, rendermic == 0 ? 0 : mic_radius - capsule_height]) {
  100. difference () {
  101. union () {
  102. // main capsule holder
  103. cylinder(r = capsule_radius + wall, h = capsule_height, $fn = facets);
  104. // the mounting legs
  105. for (angles = mounts) {
  106. rotate([0, 0, angles[0] + twist]) {
  107. // connect with cylindrical beams, very pretty
  108. if (connect == 0) {
  109. leg_length = mic_radius * cos(angles[1]) - capsule_radius * sin(angles[1]);
  110. translate([capsule_radius - wall, 0, capsule_height - wall]) {
  111. rotate([0, 180 - angles[1], 0]) {
  112. cylinder(d = leg_width, h = leg_length - 0.3, center = false, $fn = facets);
  113. }
  114. }
  115. }
  116. // connect with horizontal legs
  117. if (connect == 1) {
  118. leg_length = (mic_radius - capsule_height + leg_thick) * tan(90 - angles[1]) - capsule_radius;
  119. slot_depth = leg_thick * cos(90 - 2 * angles[1]) + fit;
  120. translate([capsule_radius + leg_length + fudge, - leg_width / 3, 0]) {
  121. rotate([0, -90, 0]) {
  122. difference() {
  123. // thickness, width
  124. cube([leg_thick, leg_width, leg_length]);
  125. // cut slot in connector
  126. translate([0, leg_width / 3 - (fit / 2), 0]) {
  127. cube([leg_thick, leg_width / 3 + fit, slot_depth]);
  128. }
  129. }
  130. }
  131. }
  132. }
  133. // connect with vertical legs
  134. if (connect == 2) {
  135. leg_length = (mic_radius * tan(90 - angles[1]) - capsule_radius) * tan(angles[1]);
  136. slot_depth = leg_thick * cos (90 - (2 * angles[1]));
  137. translate([capsule_radius + fudge, - leg_width / 3, - leg_length + capsule_height]) {
  138. difference() {
  139. // thickness, width
  140. cube([leg_thick, leg_width, leg_length]);
  141. // cut slot in connector
  142. translate([0, leg_width / 3 - (fit / 2), 0]) {
  143. cube([leg_thick, leg_width / 3 + fit, slot_depth]);
  144. }
  145. }
  146. }
  147. }
  148. }
  149. }
  150. // add ridges for microphone mount
  151. if (ridge == 1) {
  152. rotate([0, 0, twist]) {
  153. translate([capsule_radius + fudge, - wall , 0]) {
  154. cube([ridge_length, ridge_width, capsule_height], center = false);
  155. }
  156. }
  157. }
  158. }
  159. // make the hole for the capsule
  160. translate ([0, 0, -2]) {
  161. cylinder(r = capsule_radius + fudge, h = capsule_height + 2, $fn = facets);
  162. }
  163. // remove any extra connecting beam material from the face of the holder
  164. if (connect == 0) {
  165. translate ([0, 0, capsule_height]) {
  166. cylinder(r = capsule_radius + wall * 2, h = 2, $fn = facets);
  167. }
  168. }
  169. }
  170. }
  171. }
  172. }
  173. }
  174. // microphone mount
  175. //
  176. // angles: angles for mount slots
  177. // wall: thickness of cylinder wall
  178. // separation: height of mount with respect of the microphone assembly
  179. module mount (angles, wall, separation) {
  180. translate([0, 0, -(separation + 0.1)]) {
  181. difference() {
  182. union() {
  183. // grips for the capsule holder ridge
  184. for (rot = angles) {
  185. rotate([0, 0, rot]) {
  186. translate([-capsule_sep_max, -(ridge_width - fit / 2), -mount_height]) {
  187. cube([capsule_sep_max, ridge_width * 2 - fit, mount_height]);
  188. rotate([0, -elev_angle, 0]) {
  189. cube([capsule_sep_max, ridge_width * 2 - fit, mount_height * cos(elev_angle)]);
  190. }
  191. }
  192. }
  193. }
  194. translate([0, 0, -mount_height]) {
  195. cylinder(r = mount_radius + wall, h = mount_height, $fn = facets);
  196. }
  197. }
  198. // make the hole for the mount (* 1.5 to cut the ridge as well)
  199. translate([0, 0, -mount_height]) {
  200. cylinder(r = mount_radius, h = mount_height * 1.5, $fn = facets);
  201. }
  202. // cut the outside of the sloped ridge
  203. translate([0, 0, -mount_height]) {
  204. difference() {
  205. cylinder(r = capsule_sep_max + mount_height * 1.5, h = mount_height * 1.5, $fn = facets);
  206. cylinder(r = capsule_sep_max, h = mount_height * 1.5, $fn = facets);
  207. }
  208. }
  209. // and cut a slot for the ridges in the wall of the cylinder
  210. for (rot = angles) {
  211. rotate([0, 0, rot]) {
  212. translate([-capsule_sep_max * 2, -ridge_width + 4 * fit, -mount_slot_depth]) {
  213. cube([capsule_sep_max * 2, ridge_width + 2 * fit, mount_height]);
  214. }
  215. }
  216. }
  217. }
  218. }
  219. }
  220. // render a complete microphone
  221. if (rendermic == 1) {
  222. capsule(45, elev_angle, leg_angles_top, 60, 0);
  223. capsule(-135, elev_angle, leg_angles_top, 60, 0);
  224. capsule(-45, -elev_angle, leg_angles_bot, 0, 1);
  225. capsule(135, -elev_angle, leg_angles_bot, 0, 1);
  226. // the mount
  227. mount([-45, 135], 1, capsule_bottom);
  228. }
  229. // print all the parts separately
  230. // at most print two parts at the same time
  231. part_sep = capsule_radius * 2 * 3;
  232. if (rendermic == 0) {
  233. translate([0, -part_sep / 2, 0]) { capsule(0, 90, [-120, 0, 120], 0, 0); }
  234. if (renderset != 0) {
  235. //translate([0, part_sep / 2, 0]) { capsule(0, 90, [-120, 0, 120], 0, 0); }
  236. translate([0, part_sep / 2, 0]) { capsule(0, 90, [-120, 120], 0, 1); }
  237. //translate([0, 1.5 * part_sep, 0]) { capsule(0, 90, [-120, 120], 0, 1); }
  238. //translate([part_sep / 2, -part_sep * 0.75, 0]) { mount([-45, 135], 1, 0); }
  239. }
  240. }