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