X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;ds=sidebyside;f=hc-sr04.scad;h=2055eb414b4c4e8d8426445b29be25789d574504;hb=de6bb578c39b9d8e9ec1e6ba54026f6a2900da73;hp=2e040ffd1bcf14f8c998497ea5cc134540708a56;hpb=7a8f6bd13ad4eac8f76a185fa18d78bc792d5b8f;p=things.git diff --git a/hc-sr04.scad b/hc-sr04.scad index 2e040ff..2055eb4 100644 --- a/hc-sr04.scad +++ b/hc-sr04.scad @@ -4,34 +4,39 @@ infty = 100; wall = 1.5; cyl_r = 8 + 0.5; -cyl_x = 27 / 2; -cyl_h = 10; // above pcb, max 13.8; +cyl_x = 26.6 / 2; +cyl_h = 8; // above pcb, max 13.8; -pcb_x = 45 + 0.5; -pcb_y = 20 + 0.5; -xtal_h = 4; -pcb_supp = 3; -pcb_h = 5; // 1.2 + space for connector etc +pcb_x = 45.6 + 0.7; +pcb_y = 20.2 + 0.5; +xtal_h = 5; +pcb_supp = 3; // side support thickness +pcb_h = 8; // 1.2 + space for connector etc +pcb_thick = 2.5; cyl_base = pcb_x/2 + wall - cyl_x; -conn_x = 12.5; -conn_y = 10; +conn_x = 10 + 0.5; +conn_y = 15; -cable_w = 5; -cable_h = 2; +cable_w = 7; +cable_h = 4; -mount_h = 3; -screw_sp = 5; +screw_head = 7.5; +screw_d = 4; +screw_base = 2*wall; + +clip_r = 1; +clip_h = 8; module sensor() { hull() { - // pcb and the space above it + // space above pcb translate([-pcb_x/2, -pcb_y/2, -eps]) - cube([pcb_x, pcb_y, pcb_h+eps]); + cube([pcb_x, pcb_y, pcb_h-pcb_thick+eps]); // connector translate([-conn_x/2, pcb_y/2-eps, -eps]) - cube([conn_x, conn_y+eps, pcb_h+eps]); + cube([conn_x, conn_y+eps, pcb_h-pcb_thick+eps]); } // cable protrusion translate([-cable_w/2, pcb_y/2+conn_y-eps, -eps]) @@ -40,9 +45,12 @@ module sensor() { // cylinders for (x = [-1, 1]) translate([cyl_x*x, 0, pcb_h - eps]) cylinder(r = cyl_r, h = cyl_h + 2+wall + eps); + // pcb + translate([-pcb_x/2, -pcb_y/2, pcb_h-pcb_thick-eps]) + cube([pcb_x, pcb_y, pcb_thick+eps]); // space below the pcb (xtal, etc) - translate([-pcb_x/2+pcb_supp, -pcb_y/2, pcb_h - eps]) - cube([pcb_x - 2*pcb_supp, pcb_y, xtal_h+eps]); + translate([-pcb_x/2+pcb_supp, -pcb_y/2, pcb_h-pcb_thick - eps]) + cube([pcb_x - 2*pcb_supp, pcb_y, xtal_h+pcb_thick+eps]); }; module case_body() { hull() { @@ -54,39 +62,45 @@ module case_body() { for (x = [-1, 1]) translate([cyl_x*x, 0, pcb_h + cyl_h]) cylinder(r = cyl_base, h = wall); - translate([0, 7, pcb_h + cyl_h]) + translate([0, 8, pcb_h + cyl_h]) cylinder(r = cyl_base, h = wall); // connector translate([-conn_x/2-wall, pcb_y/2-wall, 0]) - cube([conn_x+2*wall, conn_y+2*wall, pcb_h+wall]); - } - for (x = [0, 180]) rotate([0, 0, x]) hull() { - // eps-wide cube - translate([pcb_x/2-eps, -4/2-wall, pcb_h + cyl_h + wall -eps]) - cube([eps, 4+2*wall, eps]); - // bottom plate - translate([pcb_x/2+wall, -screw_sp/2-wall, 0]) - cube([screw_sp+wall, screw_sp+2*wall, wall]); + cube([conn_x+2*wall, conn_y+2*wall, pcb_h-pcb_thick+wall]); + // screw mounts + for (x = [1, -1]) scale([x, 1, 1]) + translate([pcb_x/2+wall, -screw_head/2-wall, 0]) + cube([screw_head, screw_head+2*wall, screw_base]); } } -difference() { - case_body(); - # sensor(); - // mount holes - for (x = [0, 180]) rotate([0, 0, x]) { - translate([pcb_x/2+wall, -screw_sp/2, wall]) - cube([screw_sp +wall+eps, screw_sp, pcb_h + cyl_h + eps]); - translate([pcb_x/2+1+wall, -3/2, -eps]) - cube([3, 3, wall + 2*eps]); +module case() { + difference() { + case_body(); + difference() { + sensor(); + // pcb clip + translate([-clip_h/2, -pcb_y/2, pcb_h-pcb_thick-clip_r/2]) + rotate([0, 90, 0]) + cylinder(r=clip_r, h = clip_h, $fn = 4); + } + // mount holes + for (x = [-1, 1]) scale([x, 1, 1]) { + translate([pcb_x/2+wall, -screw_head/2, screw_base]) + cube([screw_head+eps, screw_head, infty]); + // screw hole + translate([pcb_x/2+wall+screw_head/2-screw_d/2, -screw_d/2, -eps]) + cube([screw_d, screw_d, infty]); + } + // text + translate([0, 3.5, pcb_h + cyl_h + eps]) + rotate([0, 0, 90]) + linear_extrude(height=wall) + text("CVT FI", font="DejaVu Sans:style=Bold", size=5, + halign="center", valign="center"); } - // text - translate([0, 3, pcb_h + cyl_h + eps]) - rotate([0, 0, 90]) - linear_extrude(height=wall) - text("CVT FI", font="DejaVu Sans:style=Bold", size=5, - halign="center", valign="center"); - } +rotate([180, 0, 0]) // rotate it for easier print + case();