1
0

SpHEAR_common.scad 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. //
  2. // Spherical Harmonics Ear Project (*SpHEAR)
  3. //
  4. // Common Modules and Variables
  5. //
  6. // Copyright 2015-2016, Fernando Lopez-Lezcano, All Rights Reserved
  7. // nando@ccrma.stanford.edu
  8. //
  9. // This program is free software: you can redistribute it and/or modify
  10. // it under the terms of the GNU General Public License as published by
  11. // the Free Software Foundation, either version 3 of the License, or
  12. // (at your option) any later version.
  13. //
  14. // This program is distributed in the hope that it will be useful,
  15. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. // GNU General Public License for more details.
  18. //
  19. // You should have received a copy of the GNU General Public License
  20. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  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. ////
  26. //// default model parameters
  27. ////
  28. // microphone capsule array
  29. //
  30. // dimensions of the electret microphone capsule
  31. capsule_radius = 5;
  32. capsule_height = 4.5;
  33. // distance between the face of a capsule and the center of array
  34. mic_radius = 9.6;
  35. // dimensions of the capsule holder connection legs
  36. // a width of 4mm is too thin, 5mm prints better
  37. leg_width = 5;
  38. leg_thick = 1.75;
  39. // wall thickness of the capsule holder
  40. wall = 1;
  41. // width of the ridge that connects to the mount
  42. ridge_width = 2.0;
  43. ridge_slot_width = 2.0;
  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. // microphone mount
  50. //
  51. mount_radius = 3.5;
  52. mount_wall = 0.75;
  53. // height and eccentricity of top connector
  54. mount_top_height = 10.0;
  55. mount_top_eccentricity = 1.3;
  56. // height of mount
  57. mount_height = 40;
  58. // microphone stand mount
  59. //
  60. // diameter of existing shielded wires (x 4)
  61. mic_wire_diam = 1.5;
  62. mic_wire_hole_radius = 3.0;
  63. mic_wire_hole_offset = 5;
  64. // standard microphone stand
  65. // measured diameter = 13.5, inside diameter of sleeve = 13.79 (
  66. mic_mount_radius = 13.50 / 2;
  67. // add this to inside diameter
  68. mic_mount_fit = 0.2;
  69. mic_mount_slot_height = 11.5;
  70. mic_mount_slot_width = 4.25;
  71. mic_mount_slot_radius = 6.25 / 2;
  72. mic_mount_wall = 1.5;
  73. mic_mount_height = 35.0 + mic_wire_hole_offset + mic_wire_hole_radius + 2 * mic_mount_wall;
  74. //// end of model parameters
  75. ////
  76. //// rendering control
  77. // what type of connection to use between capsule holders:
  78. // 0 -> original cylindrical angled legs
  79. // 1 -> interlocking horizontal legs
  80. // 2 -> interlocking vertical legs
  81. connect = 1;
  82. // how many mount ridges to create
  83. // 0 -> no ridges
  84. // 1 -> 1 ridge
  85. // 2 -> 2 ridges
  86. ridges = 1;
  87. //// end of rendering control
  88. ////
  89. // adjustment for the inner radius of the capsule holder
  90. // measured inside diameter of a trial print was around 7.5 to 8.2
  91. // instead of 10, capsule diameter was 9.99)
  92. // 0.1 -> 0.08: Ultimaker 2 + Extended plus APL (2016.06.17)
  93. fudge = 0.08;
  94. // adjustment for fit of slots in connection legs and mount
  95. // 0.1: initial setting
  96. // 0.1 ->0.15: Ultimaker 2 + Extended plus APL (2016.06.17)
  97. fit = 0.15;
  98. // number of facets for rendering cylinders
  99. facets = 64;
  100. // render capsule holders with better resolution
  101. cfacets = 128;
  102. ////////
  103. // microphone capsule holder
  104. // mounts: vectors containing the angle of the mount and the angle to the adjacent capsule
  105. // twist: rotate the whole capsule to match mounting legs
  106. // ridge: add 0, 1 or 2 ridges for attaching the structure to the mount
  107. // ridge_wfit: tune the fit, used for carving slots in mount
  108. // ridge_hfit: adjust height of ridges when carving out the capsule rests
  109. // solid: make the capsule holder solid, used in the mount code to carve the capsule rests
  110. module capsule (mounts, twist, ridge, ridge_wfit = 0.0, ridge_hfit = 0.0, solid = 0) {
  111. difference () {
  112. union () {
  113. // main capsule holder
  114. cylinder(r = capsule_radius + wall, h = capsule_height, $fn = cfacets);
  115. // the mounting legs
  116. for (angles = mounts) {
  117. rotate([0, 0, angles[0] + twist]) {
  118. // connect with cylindrical beams, very pretty
  119. if (connect == 0) {
  120. leg_length = mic_radius * cos(angles[1]) - capsule_radius * sin(angles[1]);
  121. translate([capsule_radius - wall, 0, capsule_height - wall]) {
  122. rotate([0, 180 - angles[1], 0]) {
  123. cylinder(d = leg_width, h = leg_length - 0.3, center = false, $fn = facets);
  124. }
  125. }
  126. }
  127. // connect with horizontal legs
  128. if (connect == 1) {
  129. leg_length = (mic_radius - capsule_height + leg_thick) * tan(90 - angles[1]);
  130. slot_depth = leg_thick / cos(90 - 2 * angles[1]);
  131. slot_xtra_depth = (angles[1] < 45) ? (leg_thick * tan(90 - 2 * angles[1])) : 0.0;
  132. translate([0, - leg_width / 3, 0]) {
  133. difference() {
  134. cube([leg_length, leg_width, leg_thick]);
  135. // cut slot in connector
  136. translate([leg_length - slot_depth - slot_xtra_depth - fit, leg_width / 3 - (fit / 2), 0]) {
  137. cube([slot_depth + slot_xtra_depth + fit, leg_width / 3 + fit, leg_thick]);
  138. }
  139. }
  140. }
  141. }
  142. // connect with vertical legs
  143. if (connect == 2) {
  144. // fix this 0.2 == (2 * fudge?)
  145. leg_length = (mic_radius * tan(90 - angles[1]) - capsule_radius) * tan(angles[1]) - 0.2;
  146. slot_depth = leg_thick * cos (90 - (2 * angles[1]));
  147. translate([capsule_radius - leg_thick / 2 + fudge, - leg_width / 3,
  148. - leg_length + capsule_height]) {
  149. difference() {
  150. // the connection
  151. difference() {
  152. cube([leg_thick + leg_thick / 2, leg_width, leg_length]);
  153. translate([-leg_thick + wall - fudge, 0, - capsule_height + fudge]) {
  154. cube([leg_thick, leg_width, leg_length]);
  155. }
  156. }
  157. // cut slot in connector
  158. translate([0, leg_width / 3 - (fit / 2), 0]) {
  159. cube([leg_thick + leg_thick / 2, leg_width / 3 + fit, slot_depth]);
  160. }
  161. }
  162. }
  163. }
  164. }
  165. }
  166. // add ridges for microphone mount
  167. ridge_length = (mic_radius - capsule_height) / tan(elev_angle) - (capsule_radius + wall);
  168. if (ridge == 2) {
  169. rotate([0, 0, twist]) {
  170. translate([capsule_radius + wall - ridge_length / 2, (ridge_width + ridge_wfit) / 2, 0]) {
  171. cube([ridge_length * 3 / 2, ridge_width + ridge_wfit, capsule_height + ridge_hfit], center = false);
  172. }
  173. translate([capsule_radius + wall - ridge_length / 2, - (ridge_width + ridge_wfit) * 3 / 2, 0]) {
  174. cube([ridge_length * 3 / 2, ridge_width + ridge_wfit, capsule_height + ridge_hfit], center = false);
  175. }
  176. }
  177. }
  178. if (ridge == 1) {
  179. rotate([0, 0, twist]) {
  180. difference() {
  181. translate([capsule_radius + wall / 2, - (ridge_width + ridge_wfit) / 2, 0]) {
  182. cube([ridge_depth + wall / 2, ridge_width + ridge_wfit, capsule_height + ridge_hfit], center = false);
  183. }
  184. translate([capsule_radius + wall + ridge_length, - (ridge_width + ridge_wfit) / 2, 0]) {
  185. rotate([0, elev_angle, 0]) {
  186. cube([ridge_depth, ridge_width + ridge_wfit, capsule_height * 2], center = false);
  187. }
  188. }
  189. }
  190. }
  191. }
  192. }
  193. // make the hole for the capsule (also cuts leg overhang for vertical connectors)
  194. if (solid != 1) {
  195. translate ([0, 0, -capsule_height]) {
  196. cylinder(r = capsule_radius + fudge, h = capsule_height * 2, $fn = cfacets);
  197. }
  198. }
  199. // remove any extra connecting beam material from the face of the holder
  200. if (connect == 0) {
  201. translate ([0, 0, capsule_height]) {
  202. cylinder(r = capsule_radius + wall * 2, h = 2, $fn = cfacets);
  203. }
  204. }
  205. }
  206. }
  207. //// shared modules for zapnspark printed circuit board
  208. // one printed circuit board
  209. module pcb(length, width, thick) {
  210. translate([-width/2, 0, 0]) {
  211. cube([width, thick, length]);
  212. }
  213. }
  214. // one printed circuit board with space in the front and back for components
  215. module pcb_clear(length, width, thick, slot_depth, front, back) {
  216. translate([0, - (thick + front)]) {
  217. pcb(length, width, thick);
  218. // clear space in the front
  219. translate([- (width/2 - slot_depth), thick, 0]) {
  220. cube([width - 2 * slot_depth, front, length]);
  221. }
  222. // clear space in the back
  223. translate([- (width/2 - slot_depth), - back, 0]) {
  224. cube([width - 2 * slot_depth, back, length]);
  225. }
  226. }
  227. }
  228. //// shared modules for mount
  229. // rectangular block with rounded corners
  230. module rounded_block(height, width, depth, radius) {
  231. dw = width - radius;
  232. dd = depth - radius;
  233. minkowski() {
  234. translate([-dw, -dd, 0]) {
  235. cube([dw * 2, dd * 2, height / 2]);
  236. }
  237. cylinder(r = radius, h = height / 2, $fn = facets);
  238. }
  239. }
  240. // rectangular inset block with rounded corners
  241. module rounded_block_relative(height, ref_width, ref_depth, ref_corner, radius_inc) {
  242. corner = ref_corner * ((ref_width + radius_inc) / ref_width);
  243. rounded_block(height, ref_width + radius_inc, ref_depth + radius_inc, corner);
  244. }
  245. // box with rounded corners
  246. module rounded_box(height, width, depth, radius, wall) {
  247. iradius = radius * ((width - wall) / width);
  248. difference() {
  249. rounded_block(height, width, depth, radius);
  250. rounded_block(height, width - wall, depth - wall, iradius);
  251. }
  252. }