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