]> www.fi.muni.cz Git - heater.git/blob - case.scad
case.scad: mods after the first testing print
[heater.git] / case.scad
1 /* TODO
2 - vybrani pro otevreni
3 - mozna sirsi misto na baterku?
4 - vetsi vybrani pro baterku ve vicku
5 - kuzelova dira pro tlacitka
6 - jine diry pro uchyceni
7 - zvetsit vybrani na strane tlacitek
8 - mozna prilis velky klip zasunovaciho konce baterky
9 - diry pro neizolovany drat muzou byt mensi
10 - sirsi zakladna
11 - mensi horni cast klipu baterky - pri 0.7 je sirka nahore 16 mm.
12 */
13
14 lowres = 1;
15
16 // 18650 is ~18mm diameter, ~65mm length, 
17 batt_diam = 18 + 0.6;
18 batt_len = 65 + 1.5;
19 wall = 2.2;
20 base_h = 3;
21 cable_sep = 2.5;
22
23
24 eps = 0.01;
25 infty = 300;
26
27 pcb_len = 36 + 1;
28 pcb_thick = 1.2 + 0.3;
29 pcb_groove = 1;
30 pcb_width = 11 + 0.5;
31
32 batt_clip_h = base_h + pcb_width - pcb_groove;
33
34 wire_thick = 2.2;
35 wire_sep = 3.5;
36 cable_out_diam = 5.2;
37
38 pcbside_protrusion_len = 20;
39 pcbside_protrusion_diam = 2.5;
40 battside_protrusion_len = 10;
41 battside_protrusion_diam = 2;
42
43 base_batt_extend = wall + pcb_thick; // extend the base on the battery side
44
45 cover_sep = 0.1;
46
47 uswitch_diam = 2.5 + 0.5;
48 led_diam = 3 + 0.5;
49 s2_xoff = -160 * 25.4/1000;
50 led_xoff = 90 * 25.4/1000;
51 s1_xoff = 340 * 25.4/1000;
52
53 pcb_clip_w = 7;
54 pcb_clip_off = led_xoff + pcb_clip_w/2;
55
56 module base() {
57         translate([0, 0, base_h/2]) {
58                 hull() {
59                         cube([batt_len + 2*wall + 2*cable_sep, batt_diam + 2*wall, base_h], center=true);
60                         // under the PCB
61                         translate([0, -batt_diam/2-wall-pcb_thick/2-wall/2, 0])
62                                 cube([batt_len + 2*wall, pcb_thick + wall + eps, base_h], center=true);
63                         // battery-side extension
64                         translate([0, batt_diam/2 + wall + base_batt_extend, 0])
65                                 cube([batt_len + 2*wall, eps, base_h], center=true);
66                 };
67         };
68 }
69 module base_protrusions() {
70         // pcb-side side protrusion
71         translate([-pcbside_protrusion_len/2, -batt_diam/2-2*wall-pcb_thick, base_h-pcbside_protrusion_diam/2])
72                 rotate([0, 90, 0])
73                 cylinder(r = pcbside_protrusion_diam/2, h = pcbside_protrusion_len, $fn = 6);
74         
75         // battery-side side protrusion
76         translate([-battside_protrusion_len/2, batt_diam/2+wall+base_batt_extend, base_h-battside_protrusion_diam/2])
77                 rotate([0, 90, 0])
78                 cylinder(r = battside_protrusion_diam/2, h = battside_protrusion_len, $fn = 6);
79 };
80
81 module pcb_clips() {
82         // rear part of the PCB holder (behind S1)
83         translate([pcb_clip_off, -batt_diam/2-wall-pcb_thick+eps, 0])
84                 cube([pcb_clip_w, pcb_thick+wall, pcb_width + wall + base_h - pcb_groove]);
85         // side part of the PCB holder (near the battery wires)
86         translate([-pcb_len/2-wall, -batt_diam/2-pcb_thick-2*wall, 0])
87                 cube([pcb_groove+wall, pcb_thick+2*wall+eps, pcb_width + wall + base_h - pcb_groove]);
88 };
89
90 module batt_clips() {
91         difference() {
92                 union() {
93                         // frot + rear part of the battery clip
94                         for (r = [0, 180]) {
95                         rotate([0, 0, r])
96                         translate([batt_len/2+wall/2, 0, batt_clip_h/2+wall/2])
97                                 hull() {
98                                         cube([wall, batt_diam + 2*wall, batt_clip_h + wall], center=true); 
99                                         translate([-15/2, 0, -batt_clip_h/2])
100                                         cube([15, batt_diam+2*wall, wall], center=true);
101                                 };
102                         }
103                         // middle clips
104                         translate([pcb_clip_off+pcb_clip_w/2, 0, batt_clip_h/2+wall/2])
105                                 hull() {
106                                         cube([pcb_clip_w, batt_diam + 2*wall, batt_clip_h + wall], center=true);
107                                         translate([0, 0, -batt_clip_h/2])
108                                         cube([2*pcb_clip_w, batt_diam+2*wall, wall], center=true);
109                                 };
110                         // pcb holder - pcb side only
111                         translate([-pcb_len/2-wall, -batt_diam/2-wall, 0])
112                                 hull() {
113                                         cube([pcb_groove + wall, batt_diam/2 + wall, base_h + pcb_width + wall - pcb_groove]);
114                                         translate([-3*(pcb_groove+wall), 0, 0])
115                                         cube([4*(pcb_groove+wall), batt_diam/2 + wall, base_h]);
116                                 };
117                 }
118                 // top part rounded
119                 difference() {
120                         translate([0, 0, infty/4 + wall + batt_diam/2])
121                                 cube([infty/2, infty/2, infty/2], center=true);
122                         translate([-infty/2, 0, batt_diam/2+wall])
123                                 rotate([0, 90, 0])
124                                 cylinder(r=batt_diam/2+wall, h = infty);
125                 };
126         };
127 };
128
129 module battery() {
130         // battery
131         translate([-batt_len/2, 0, batt_diam/2+wall])
132                 rotate([0, 90, 0])
133                 cylinder(r=batt_diam/2, h = batt_len);
134 };
135
136 module main() {
137         difference() {
138                 union() {
139                         base();
140                         base_protrusions();
141                         pcb_clips();
142                         batt_clips();
143                 };
144                 // the PCB itself
145                 translate([0, -batt_diam/2-wall-pcb_thick/2, base_h - pcb_groove + pcb_width/2])
146                         cube([pcb_len, pcb_thick, pcb_width], center=true);
147                 // battery
148                 battery();
149                 // 4 wire holes at the battery ends
150                 for (j=[-wire_sep/2, wire_sep/2]) 
151                 for (i=[-wire_sep/2, wire_sep/2]) 
152                 translate([-infty/2, i, batt_diam/2 + wall+j])
153                         rotate([0, 90, 0])
154                         rotate([0, 0, 90])
155                         cylinder(r=wire_thick/2, h = infty, $fn=6);
156
157                 // holes for wire from battery to the PCB
158                 translate([-infty/2, -batt_diam/2, base_h + wire_thick/2])
159                         rotate([0, 90, 0])
160                         rotate([0, 0, 90])
161                         cylinder(r=wire_thick/2, h = infty, $fn=6);
162                 // hole for the cable outlet
163                 translate([-pcb_len/2+pcb_groove+cable_out_diam/2, -batt_diam/2-pcb_thick-2*wall, -infty/2])
164                         cylinder(r=cable_out_diam/2, h = infty, $fn=6);
165                 // holes for binding to the shoe
166                 for (x = [
167                          pcb_len/2 + wall + wire_thick/2 + wire_sep,
168                          pcb_len/2 + wall + wire_thick/2,
169                         -pcb_len/2 - wall - wire_thick/2 - wire_sep,,
170                         -pcb_len/2 - wall - wire_thick/2 ]) {
171                         for (y = [-1,1]) {
172                                 translate([x, y*(batt_diam/2 + wall + wire_thick/2), -infty/2])
173                                         cylinder(r=wire_thick/2, h=infty, $fn=6);
174                         };
175                 };
176                 // hole for easy opening
177                 translate([-battside_protrusion_len/2, batt_diam/2+wall+base_batt_extend, base_h-3*battside_protrusion_diam/2])
178                 rotate([0, 90, 0])
179                 cylinder(r = battside_protrusion_diam/2, h = battside_protrusion_len, $fn = 4);
180                 
181         };
182 };
183
184 module cover_internal() {
185         hull() { 
186                 base();
187                 // battery + wall + cable space
188                 translate([-batt_len/2, 0, batt_diam/2+wall])
189                         rotate([0, 90, 0])
190                         cylinder(r=batt_diam/2, h = batt_len);
191                 // battery top
192                 translate([0, 0, wall + batt_clip_h])
193                         cube([batt_len+2*wall + cable_sep, batt_diam + 2*wall, eps], center=true);
194                 // space for PCB
195                 translate([-pcb_len/2-wall, -batt_diam/2-2*wall-pcb_thick, base_h-pcb_groove])
196                         cube([pcb_len+2*wall, wall+pcb_thick, pcb_width+wall]);
197         };
198 };
199
200 module cover_hole() {
201         difference() {
202                 cover_internal();
203                 for (r = [0, 180]) {
204                         rotate([0, 0, r]) 
205                         translate([batt_len/2, -infty/2, wall + batt_clip_h])
206                                 cube(infty);
207                 }
208         };
209         base_protrusions();
210 };
211
212 module cover() {
213         difference() {
214                 minkowski() {
215                         cover_internal();
216                         if (lowres == 1) {
217                                 sphere(wall+cover_sep, $fn=6);
218                         } else {
219                                 sphere(wall+cover_sep, $fn=16);
220                         }
221                 }
222                 minkowski() {
223                         cover_hole();
224                         sphere(cover_sep, $fn=8);
225                 };
226                 // s2 hole
227                 translate([s2_xoff, 0, base_h-pcb_groove + pcb_width/2])
228                         rotate([90, 0, 0])
229                         cylinder(r=uswitch_diam/2, h = infty, $fn=6);
230                 // LED hole
231                 translate([led_xoff, 0, base_h-pcb_groove + pcb_width/2])
232                         rotate([90, 0, 0])
233                         cylinder(r=led_diam/2, h = infty, $fn=6);
234                 // s1 hole
235                 translate([s1_xoff, 0, base_h-pcb_groove + pcb_width/2])
236                         rotate([90, 0, 0])
237                         cylinder(r=uswitch_diam/2, h = infty, $fn=6);
238                 // xy plane
239                 translate([0, 0, -infty/2]) cube(infty, center=true);
240         }
241 };
242
243 translate([0, -19, 0])
244         main($fn=128);
245
246 /*
247 translate([0, 19, 0])
248         cover_hole();
249 */
250
251 // cover($fn=128);
252 // translate([0, 17, batt_diam + 3*wall + cover_sep])
253 // rotate([180, 0, 0])
254 //      cover($fn=128);
255
256 translate([0, 19, 0]) {
257         if (lowres == 1) {
258                 cover($fn=16);
259         } else {
260                 cover($fn=128);
261         }
262 }