]> www.fi.muni.cz Git - openparking.git/blobdiff - things/hc-sr04.scad
Infinite reads handling
[openparking.git] / things / hc-sr04.scad
index a9d1a1cb39af146314f9771dda76fb0c728b9bc2..432eabfd665b44499f654e065403efbb7d508dcf 100644 (file)
@@ -4,11 +4,11 @@ infty = 100;
 wall = 1.5;
 
 cyl_r = 8 + 0.5;
-cyl_x = 26.6 / 2;
+cyl_x = 26.4 / 2;
 cyl_h = 8; // above pcb, max 13.8;
 
-pcb_x = 45.6 + 1.0;
-pcb_y = 20.2 + 0.7;
+pcb_x = 45.6 + 1.2;
+pcb_y = 20.2 + 1.0;
 xtal_h = 5;
 pcb_supp = 3; // side support thickness
 pcb_h = 8; // 1.2 + space for connector etc
@@ -16,11 +16,11 @@ pcb_thick = 2.5;
 
 cyl_base = pcb_x/2 + wall - cyl_x;
 
-conn_x = 10 + 0.5;
-conn_y = 15;
-
-cable_w = 7;
-cable_h = 4;
+conn_x = 18 + 2*wall;
+conn_z0 = 8;
+conn_y = 5;
+conn_x0 = conn_x - 1.5*conn_z0;
+conn_len = 35;
 
 screw_head = 7.5;
 screw_d = 4;
@@ -38,9 +38,13 @@ module sensor() {
                translate([-conn_x/2, pcb_y/2-eps, -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])
-               cube([cable_w, 2*wall + eps, cable_h]);
+       // cable cover hole
+       hull() {
+               translate([-conn_x0/2+wall, pcb_y/2-eps, conn_z0-1.5*wall-eps])
+                       cube([conn_x0-2*wall, conn_y+conn_len+2*eps, pcb_h+cyl_h+wall+eps-conn_z0]);
+               translate([-conn_x/2+1.5*wall, pcb_y/2-eps, -wall])
+                       cube([conn_x-3*wall, conn_y+conn_len+2*eps, pcb_h+cyl_h+wall-conn_z0]);
+       }
 
        // cylinders
        for (x = [-1, 1]) translate([cyl_x*x, 0, pcb_h - eps])
@@ -62,17 +66,25 @@ module case_body() {
                for (x = [-1, 1]) translate([cyl_x*x, 0, pcb_h + cyl_h])
                        cylinder(r = cyl_base, h = wall);
 
-               translate([0, 8, pcb_h + cyl_h])
-                       cylinder(r = cyl_base, h = wall);
+               // front (see cable cover)
+               translate([-conn_x0/2, conn_y+pcb_y/2, conn_z0-eps])
+                       cube([conn_x0, wall, pcb_h+cyl_h+wall+eps-conn_z0]);
+               translate([-conn_x/2, conn_y+pcb_y/2, 0])
+                       cube([conn_x, wall, pcb_h+cyl_h+wall-conn_z0]);
 
-               // connector
-               translate([-conn_x/2-wall, pcb_y/2-wall, 0])
-                       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]);
        }
+
+       // cable cover
+       hull() {
+               translate([-conn_x0/2, conn_y+pcb_y/2, conn_z0-eps])
+                       cube([conn_x0, conn_len, pcb_h+cyl_h+wall+eps-conn_z0]);
+               translate([-conn_x/2, conn_y+pcb_y/2, 0])
+                       cube([conn_x, conn_len, pcb_h+cyl_h+wall-conn_z0]);
+       }
 }
 
 module case() {