]> www.fi.muni.cz Git - openparking.git/blob - things/hc-sr04.scad
hc-sr04.scad: alternative cable outlet
[openparking.git] / things / hc-sr04.scad
1 eps = 0.01;
2 infty = 100;
3
4 wall = 1.5;
5
6 cyl_r = 8 + 0.5;
7 cyl_x = 26.6 / 2;
8 cyl_h = 8; // above pcb, max 13.8;
9
10 pcb_x = 45.6 + 1.0;
11 pcb_y = 20.2 + 0.7;
12 xtal_h = 5;
13 pcb_supp = 3; // side support thickness
14 pcb_h = 8; // 1.2 + space for connector etc
15 pcb_thick = 2.5;
16
17 cyl_base = pcb_x/2 + wall - cyl_x;
18
19 conn_x = 18 + 2*wall;
20 conn_z0 = 8;
21 conn_y = 5;
22 conn_x0 = conn_x - 1.5*conn_z0;
23 conn_len = 35;
24
25 screw_head = 7.5;
26 screw_d = 4;
27 screw_base = 2*wall;
28
29 clip_r = 1;
30 clip_h = 8;
31
32 module sensor() {
33         hull() {
34                 // space above pcb
35                 translate([-pcb_x/2, -pcb_y/2, -eps])
36                         cube([pcb_x, pcb_y, pcb_h-pcb_thick+eps]);
37                 // connector
38                 translate([-conn_x/2, pcb_y/2-eps, -eps])
39                         cube([conn_x, conn_y+eps, pcb_h-pcb_thick+eps]);
40         }
41         // cable cover hole
42         hull() {
43                 translate([-conn_x0/2+wall, conn_y+pcb_y/2-eps, conn_z0-wall-eps])
44                         cube([conn_x0-2*wall, conn_len+2*eps, pcb_h+cyl_h+wall+eps-conn_z0]);
45                 translate([-conn_x/2+wall, conn_y+pcb_y/2-eps, -wall])
46                         cube([conn_x-2*wall, conn_len+2*eps, pcb_h+cyl_h+wall-conn_z0]);
47         }
48
49         // cylinders
50         for (x = [-1, 1]) translate([cyl_x*x, 0, pcb_h - eps])
51                 cylinder(r = cyl_r, h = cyl_h + 2+wall + eps);
52         // pcb
53         translate([-pcb_x/2, -pcb_y/2, pcb_h-pcb_thick-eps])
54                 cube([pcb_x, pcb_y, pcb_thick+eps]);
55         // space below the pcb (xtal, etc)
56         translate([-pcb_x/2+pcb_supp, -pcb_y/2, pcb_h-pcb_thick - eps])
57                 cube([pcb_x - 2*pcb_supp, pcb_y, xtal_h+pcb_thick+eps]);
58 };
59 module case_body() {
60         hull() {
61                 // pcb
62                 translate([-pcb_x/2-wall, -pcb_y/2-wall, 0])
63                         cube([pcb_x+2*wall, pcb_y+2*wall, pcb_h+wall]);
64
65                 // cylinders
66                 for (x = [-1, 1]) translate([cyl_x*x, 0, pcb_h + cyl_h])
67                         cylinder(r = cyl_base, h = wall);
68
69                 // front (see cable cover)
70                 translate([-conn_x0/2, conn_y+pcb_y/2, conn_z0-eps])
71                         cube([conn_x0, wall, pcb_h+cyl_h+wall+eps-conn_z0]);
72                 translate([-conn_x/2, conn_y+pcb_y/2, 0])
73                         cube([conn_x, wall, pcb_h+cyl_h+wall-conn_z0]);
74
75                 // screw mounts
76                 for (x = [1, -1]) scale([x, 1, 1])
77                         translate([pcb_x/2+wall, -screw_head/2-wall, 0])
78                                 cube([screw_head, screw_head+2*wall, screw_base]);
79         }
80
81         // cable cover
82         hull() {
83                 translate([-conn_x0/2, conn_y+pcb_y/2, conn_z0-eps])
84                         cube([conn_x0, conn_len, pcb_h+cyl_h+wall+eps-conn_z0]);
85                 translate([-conn_x/2, conn_y+pcb_y/2, 0])
86                         cube([conn_x, conn_len, pcb_h+cyl_h+wall-conn_z0]);
87         }
88 }
89
90 module case() {
91         difference() {
92                 case_body();
93                 difference() {
94                         sensor();
95                         // pcb clip
96                         translate([-clip_h/2, -pcb_y/2, pcb_h-pcb_thick-clip_r/2])
97                         rotate([0, 90, 0])
98                         cylinder(r=clip_r, h = clip_h, $fn = 4);
99                 }
100                 // mount holes
101                 for (x = [-1, 1]) scale([x, 1, 1]) {
102                         translate([pcb_x/2+wall, -screw_head/2, screw_base])
103                                 cube([screw_head+eps, screw_head, infty]);
104                         // screw hole
105                         translate([pcb_x/2+wall+screw_head/2-screw_d/2, -screw_head/2, -eps])
106                                 cube([screw_d, screw_head, infty]);
107                 }
108                 // text
109                 translate([0, 3.5, pcb_h + cyl_h + eps])
110                         rotate([0, 0, 90])
111                         linear_extrude(height=wall)
112                         text("CVT FI", font="DejaVu Sans:style=Bold", size=5,
113                                 halign="center", valign="center");
114         }
115 }
116
117 rotate([180, 0, 0]) // rotate it for easier print
118         case();