]> www.fi.muni.cz Git - things.git/blob - hc-sr04.scad
hc-src04: text label (req. openscad 2015)
[things.git] / 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 = 27 / 2;
8 cyl_h = 10; // above pcb, max 13.8;
9
10 pcb_x = 45 + 0.5;
11 pcb_y = 20 + 0.5;
12 xtal_h = 4;
13 pcb_supp = 3;
14 pcb_h = 5; // 1.2 + space for connector etc
15
16 cyl_base = pcb_x/2 + wall - cyl_x;
17
18 conn_x = 12.5;
19 conn_y = 10;
20
21 cable_w = 5;
22 cable_h = 2;
23
24 mount_h = 3;
25 screw_sp = 5;
26
27 module sensor() {
28         hull() {
29                 // pcb and the space above it
30                 translate([-pcb_x/2, -pcb_y/2, -eps])
31                         cube([pcb_x, pcb_y, pcb_h+eps]);
32                 // connector
33                 translate([-conn_x/2, pcb_y/2-eps, -eps])
34                         cube([conn_x, conn_y+eps, pcb_h+eps]);
35         }
36         // cable protrusion
37         translate([-cable_w/2, pcb_y/2+conn_y-eps, -eps])
38                 cube([cable_w, 2*wall + eps, cable_h]);
39
40         // cylinders
41         for (x = [-1, 1]) translate([cyl_x*x, 0, pcb_h - eps])
42                 cylinder(r = cyl_r, h = cyl_h + 2+wall + eps);
43         // space below the pcb (xtal, etc)
44         translate([-pcb_x/2+pcb_supp, -pcb_y/2, pcb_h - eps])
45                 cube([pcb_x - 2*pcb_supp, pcb_y, xtal_h+eps]);
46 };
47 module case_body() {
48         hull() {
49                 // pcb
50                 translate([-pcb_x/2-wall, -pcb_y/2-wall, 0])
51                         cube([pcb_x+2*wall, pcb_y+2*wall, pcb_h+wall]);
52
53                 // cylinders
54                 for (x = [-1, 1]) translate([cyl_x*x, 0, pcb_h + cyl_h])
55                         cylinder(r = cyl_base, h = wall);
56
57                 translate([0, 7, pcb_h + cyl_h])
58                         cylinder(r = cyl_base, h = wall);
59
60                 // connector
61                 translate([-conn_x/2-wall, pcb_y/2-wall, 0])
62                         cube([conn_x+2*wall, conn_y+2*wall, pcb_h+wall]);
63         }
64         for (x = [0, 180]) rotate([0, 0, x]) hull() {
65                 // eps-wide cube
66                 translate([pcb_x/2-eps, -4/2-wall, pcb_h + cyl_h + wall -eps])
67                         cube([eps, 4+2*wall, eps]);
68                 // bottom plate
69                 translate([pcb_x/2+wall, -screw_sp/2-wall, 0])
70                         cube([screw_sp+wall, screw_sp+2*wall, wall]);
71         }
72 }
73
74 difference() {
75         case_body();
76         # sensor();
77         // mount holes
78         for (x = [0, 180]) rotate([0, 0, x]) {
79                 translate([pcb_x/2+wall, -screw_sp/2, wall])
80                         cube([screw_sp +wall+eps, screw_sp, pcb_h + cyl_h + eps]);
81                 translate([pcb_x/2+1+wall, -3/2, -eps])
82                         cube([3, 3, wall + 2*eps]);
83         }
84         // text
85         translate([0, 3, pcb_h + cyl_h + eps])
86                 rotate([0, 0, 90])
87                 linear_extrude(height=wall)
88                 text("CVT FI", font="DejaVu Sans:style=Bold", size=5,
89                         halign="center", valign="center");
90
91 }
92