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