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