chiark / gitweb /
poster-tube-lid: catch: rework mostly done ?
[reprap-play.git] / bike-lipo-box.scad
1 // -*- C -*-
2
3 include <commitid.scad>
4 include <utils.scad>
5 include <sealing-box.scad>
6 include <bike-lipo-box-gland.scad>
7
8 pxp6012_rad = 22.5 / 2 + 0.5; // make circular hole this size in outer wall
9 pxp6012_rad_outer = 32.0 / 2 - 0.5;
10
11 s1930_y = 30.2 + 0.2;
12 s1930_x =   22 + 0.2;
13 s1930_y_outer = 36.4 + 0.2;
14 s1930_x_outer = 27.6 + 0.2;
15
16 s1930_recess = 3;
17 s1930_around = 3;
18 s1930_behind = 3;
19
20 jdae12pa_rad = 12 / 2 + 0.5;
21 jdae12pa_rad_outer = 19 / 2 + 0.5; // head of an "M12 bolt"
22
23 totx_inner = 180;
24 toty_outer = 95;
25 totz_inner = 27.0;
26
27 wallthick = 2.5;
28
29 cabledia = 8.7;
30
31 strap_w = 5 + 1;
32 strap_th = 4 + 1;
33 strap_pillar = 3;
34 strap_pillard = 5;
35 strap_over = 2;
36
37 lipokeeper_w = 10;
38 lipokeeper_h = 8;
39 lipokeeper_d_min = 2;
40 lipokeeper_slope = 0.75;
41 lipokeeper_end_h = 12;
42 lipokeeper_end_d_min = 15;
43
44 straps_at_box = [45, 95, 125, 160];
45 straps_every = 30;
46
47 // calculated
48
49 totx_outer = totx_inner + wallthick*2;
50 toty_inner = toty_outer - wallthick*2;
51 totz_outer = totz_inner + wallthick*2;
52
53 sb_box_sz = [totx_outer, totz_outer, toty_inner];
54
55 // origin is at centre on outer face wall
56 // outside is towards positive x
57 // mounting is vertical
58 module S1930_Positive(){
59   d = s1930_recess + s1930_behind;
60   translate([-d/2, 0,0])
61     cube([d,
62           s1930_x_outer + s1930_around,
63           s1930_y_outer + s1930_around], center=true);
64 }
65 module S1930_Negative(){
66   cube([60, s1930_x, s1930_y],
67        center=true);
68   translate([1, 0,0])
69     cube([s1930_recess*2+2, s1930_x_outer, s1930_y_outer],
70          center=true);
71 }
72
73 module TestWall(){ ////toplevel
74   sw_ctr = [25, wallthick, 25];
75
76   rotate([0,0,-90]){
77     difference(){
78       union(){
79         cube([50, wallthick, 42]);
80       }
81
82       translate([30, -1, 20])
83         rotate([-90,0,0])
84         cylinder(r = pxp6012_rad, h=10, $fn=60);
85
86       rotate([90,0,0])
87         Commitid_BestCount([15,40]);
88     }
89   }
90
91   difference(){
92     union(){
93       cube([50, wallthick, 50]);
94       translate(sw_ctr)
95         rotate([0,0,90])
96         S1930_Positive();
97     }
98
99     translate(sw_ctr) {
100       rotate([0,0,90])
101         S1930_Negative();
102     }
103   }    
104 }
105
106 ts_totx = 30;
107 ts_toty = 25;
108 ts_totz_inner = 8;
109
110 ts_box_sz = [ts_totx, ts_toty, ts_totz_inner];
111
112 $sealingbox_wallth = wallthick;
113 $sealingbox_floorth = wallthick;
114 $sealingbox_ceilth = wallthick;
115
116 module TestSealBox(){ ////toplevel
117   $sealingbox_sz = ts_box_sz;
118
119   SealingBox_RectBox();
120   ts_cidoff = ($sealingbox_cnrrad * (1-.7) + wallthick * .8) * [1,1];
121   translate(ts_cidoff)
122     Commitid_BestCount([ts_totx,ts_toty] - 2*ts_cidoff);
123 }
124
125 module TestSealLid(){ ////toplevel
126   $sealingbox_sz = ts_box_sz;
127
128   difference(){
129     SealingBox_RectLid();
130
131     translate([ts_totx * .75, ts_toty/2, 0])
132       cylinder(h=100, r=5);
133     
134     translate([-wallthick + $sealingbox_cnrrad*.5,
135                $sealingbox_cnrrad*.5 - wallthick,
136                ts_totz_inner + $sealingbox_ceilth])
137       Commitid_BestCount([ts_totx * .75 - 2.5 - ($sealingbox_cnrrad*.5),
138                           ts_toty - ($sealingbox_cnrrad*.5 - wallthick)*2]);
139   }
140 }
141
142 module TestSealLidPrint(){ ////toplevel
143   rotate([180,0,0]) TestSealLid();
144 }
145
146 module ProfileDemos(){ ////toplevel
147   $sealingbox_sz = ts_box_sz;
148
149   SealingBox_WallProfile();
150   color("blue") SealingBox_FloorProfile();
151   SealingBox_LidProfile();
152   color("blue") SealingBox_CeilProfile();
153   color("red") translate([-5,0]) square([1,ts_totz_inner]);
154 }
155
156 module AtGlands(){
157   for (dgy=[-15,-45]) {
158     translate([totx_inner + wallthick - $sealingbox_cnrrad * .3,
159                toty_inner + dgy,
160                totz_inner/2])
161       children();
162   }
163 }
164
165 module StrapKeepers(at){
166   strap_x_tot = strap_w + strap_pillar*2;
167
168   for (sx= at) {
169     echo("strapkeeper at ",sx);
170     translate([sx - strap_x_tot, 0, 0])
171       difference(){
172       translate([0,0, -0.1])
173         cube([strap_x_tot, strap_pillard, strap_th + strap_over]);
174       translate([strap_pillar, -1, 0])
175         cube([strap_w, strap_pillard+2, strap_th]);
176     }
177   }
178 }
179
180 chargingconn_x = pxp6012_rad_outer + 1 + $sealingbox_cnrrad;
181 switch_x = chargingconn_x + pxp6012_rad_outer
182   + s1930_y_outer/2 + s1930_around;
183
184 module AtSealingBox(){
185   rotate([90,0,0])
186     translate([-wallthick,-wallthick, -toty_inner])
187     children();
188 }
189
190 module Box(){ ////toplevel
191   $sealingbox_sz = sb_box_sz;
192
193   difference(){
194     union(){
195       AtSealingBox()
196         SealingBox_RectBox();
197
198       translate([switch_x, toty_inner, totz_inner/2])
199         rotate([90,0,90])
200         S1930_Positive();
201
202       // keepers for lipo
203       for (keepers= [[ 35, lipokeeper_d_min,     lipokeeper_h,
204                        [ 40, 80, 120, 150 ] ],
205                      [ 10, lipokeeper_end_d_min, lipokeeper_end_h,
206                        [ 25 ] ]
207                      // each entry: [ y, d_min, h, [ x, ...] ]
208                      ])
209         for (kx= keepers[3]) {
210           translate([kx, keepers[0], -1])
211             hull(){
212               cube([lipokeeper_w, keepers[1], keepers[2] +1]);
213               cube([lipokeeper_w,
214                     keepers[1] + keepers[2] / lipokeeper_slope,
215                     1]);
216             }
217       }
218
219       AtGlands()
220         GlandPositive(cabledia);
221
222       translate([0, toty_inner+wallthick, -wallthick])
223         rotate([180, 0,0])
224         StrapKeepers(straps_at_box);
225     }
226
227     // charging connector
228     translate([chargingconn_x,
229                toty_inner - (pxp6012_rad_outer + 5),
230                10])
231       cylinder(r= pxp6012_rad, h= totz_outer);
232
233     // vent connector
234     translate([chargingconn_x,
235                toty_inner - (pxp6012_rad_outer*2 + 5 + 15 +
236                              jdae12pa_rad_outer),
237                10])
238       cylinder(r= jdae12pa_rad, h= totz_outer);
239
240     translate([switch_x, toty_inner, totz_inner/2])
241       rotate([90,0,90])
242       S1930_Negative();
243
244     AtGlands()
245       GlandNegative(cabledia);
246
247     translate(-$sealingbox_cnrrad * [1,1,0] +
248               [totx_inner, toty_inner/2, -wallthick])
249       rotate([0,0,180])
250       scale([2,2,1])
251       Commitid_Full16_M();
252   }
253 }
254
255 module BoxPrint(){ ////toplevel
256   rotate([-90,0,-90])
257     Box();
258 }
259
260 module Lid(){ ////toplevel
261   $sealingbox_sz = sb_box_sz;
262   difference(){
263     union(){
264       AtSealingBox()
265         SealingBox_RectLid();
266       translate([0, -wallthick, -SealingBox_lidbigger()])
267         mirror([0,0,1])
268         StrapKeepers([ straps_every : straps_every
269                        : totx_inner-straps_every ]);
270     }
271
272     translate($sealingbox_cnrrad * [1,0,1])
273       rotate([90,0,0])
274       scale([1.5, 1.5, 1])
275       Commitid_Small16_M();
276   }
277 }
278
279 module LidPrint(){ ////toplevel
280   rotate([90,0,-90])
281     Lid();
282 }
283
284 module Demo(){ ////toplevel
285   color("blue") Box();
286   color("red") Lid();
287 }
288
289 //TestWall();
290 //ProfileDemos();
291 //TestSealBox();
292 //TestSealLid();
293 //FArcSegment_mask(350);
294 //StrapKeepers();