small/cad/sma_rigid.scad
2023-05-04 14:57:04 +02:00

203 lines
4.5 KiB
OpenSCAD

include <threads.scad>;
// Resolution of outter surface (360 for 3D printing)
res = 32;
/*[ Array parameters ]*/
// sphere radius (mm):
r = 60;
// shell thickness (mm):
e = 6;
// microphones zenith coordinates (°):
theta = [0, 90, 90, 90, 90, 180, 54.7356, 54.7356, 54.7356, 54.7356, 125.264, 125.264, 125.264, 125.264];
// microphone azimuth coordinates (°):
phi = [0, 0, 90, 180, 270, 0, 45, 135, 225, 315, 45, 135, 225, 315];
/* the microphone array can be rotated to be in accordance with the array cut and mic stand position
*/
// microphones global rotation (°):
mics_rotate = [-90, 0, 0];
/*[ Cut parameters ]*/
// minimal zenith angle for the cut (°):
angle_min = 75;
// maximal zenith angle for the cut (°):
angle_max = 82;
// screws diameter, metric (mm):
d_screw = 3;
// screws number
n_screw = 4;
// screws azimuth angle offset (°):
screw_phi_offset = 0;
/*[ Mounting holes parameters ]*/
/*
The hole for passing the microphone cables is centered on the sphere cut. This eases the cable mounting and allows reducing the hole diameter because the mics plugs don't have to pass through the hole when assembling the SMA.
To optimize the hole diameter see here : http://hydra.nat.uni-magdeburg.de/packing/cci/cci.html#overview
*/
// azimuth offset for the cable hole (°):
hole_phi_offset = 45;
// hole diameter (mm):
d_hole = 10;
/*
The mic stand threaded hole should be close to the passing cable hole. It's direction is set as an offset from the cable hole direction.abs
*/
// threaded hole offset from cable hole [theta(°), phi(°)]:
dir_thread = [13, 0];
// Hollow sphere
module hollow(r1=r-e, r2=r, fn1=$fn, fn2=$fn){
difference(){
sphere(r=r2, $fn=fn1);
sphere(r=r1, $fn=fn2);
}
}
// Torus for "joint torique" for B&K 1/4" mics
module b_k(){
mirror([0,0,-1])
rotate_extrude($fn=32){
square([10.5/2,10]);
translate([10.6/2-1, 0])
circle(r=1,$fn=32);
translate([0,-1.1*e])
square([3.55, 1.1*e]);
}
}
echo(len(theta));
module mics(){
rotate(mics_rotate)
for (i = [0 : len(theta)-1]){
rotate([theta[i], 0, phi[i]])
translate([0, 0, r-e+1]){
b_k();
translate([3,3,e-1.8])
linear_extrude(3)
text(str(i+1), size=3);
}
}
}
module bottom_shell(r1= r-e, r2=r-e/2, r3=r, delta=0.2) {
union(){
difference(){
hollow(r1, r2-delta/2, fn1=24, fn2=24);
translate([0, 0, r2 * sin(90 - angle_min)-delta])
cylinder(r=1.1*r2, h=2*r);
}
difference(){
hollow(r1, r3, fn2=24, fn1=res);
translate([0, 0, r3 * sin(90 - angle_max)])
cylinder(r=1.1*r3, h=2*r);
}
}
}
module top_shell(r1= r-e, r2=r-e/2, r3=r, delta=0) {
union(){
difference(){
hollow(r1, r2+0.1, fn1=24, fn2=24);
translate([0, 0, -2*r+r2 * sin(90 - angle_min)])
cylinder(r=1.1*r2, h=2*r);
}
difference(){
hollow(r2, r3, fn1=res, fn2=24);
translate([0, 0, -2*r+r3 * sin(90 - angle_max)])
cylinder(r=1.1*r3, h=2*r);
}
}
}
module vis(d = d_screw, $fn=72) {
union(){
cylinder(d=d+0.2,h=e);
// param = [nut thickness, nut diameter, screw_head thikness]
param = d == 2 ? [1.6, 4.6, 1.2] : // M2
d == 2.5 ? [2, 5.8, 1.5] : // M2.5
d == 3 ? [2.4, 6.4, 1.7] : // M3
d == 4 ? [3.2, 8.1, 2.3] : // M4
d == 5 ? [4, 9.2, 2.8] : // M5
d == 6 ? [5, 11.5, 3.3] : false; // M6
translate([0,0,e-param[2]-0.2]){
cylinder(d1=d,d2=2*d,h=param[2]);
translate([0, 0, param[2]])
cylinder(d=2*d, h=1);
}
translate([0,0,-e/2])
cylinder(d=param[1]+0.2, h=param[0]+1, $fn=6);
}
}
module attach() {
rotate([(angle_min+angle_max)/2,0,hole_phi_offset])
cylinder(d=d_hole, h=100);
rotate([(angle_min+angle_max)/2 + dir_thread[0],0, hole_phi_offset + dir_thread[1]])
translate([0,0,(r-3*e)])
render()
//english_thread(3/8,16,3.5*e/25.4,internal=true);
metric_thread (diameter=6, pitch=1, length=20);
}
module vis_all(){
for (i = [0 : n_screw-1]){
rotate([(angle_min+angle_max)/2, 0, i*90+screw_phi_offset])
translate([0,0,r-e])
vis();
}
}
module bottom_shell_all(){
difference(){
bottom_shell();
attach();
vis_all();
mics();
}
}
module top_shell_all(){
difference(){
top_shell();
attach();
mics();
vis_all();
}
}
module test_vis(){
difference(){
translate([0,0,e/2])
cube([11, 11, e], center=true);
vis();
}
}
module test_mic(){
difference(){
translate([0, 0, -e/2])
cube([13, 13, e], center=true);
union(){
cylinder(r=3.55,h=2*e, center= true);
translate([0, 0, -1])
torus();
}
}
}
//top_shell_all();
bottom_shell_all();