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