chiark / gitweb /
bike-lipo-box: wip
[reprap-play.git] / bike-lipo-box.scad
1 // -*- C -*-
2
3 include <commitid.scad>
4 include <utils.scad>
5 include <sealing-box.scad>
6
7 pxp6012_rad = 22.5 / 2 + 0.5; // make circular hole this size in outer wall
8 pxp6012_rad_outer = 32.0 / 2 - 0.5;
9
10 s1930_y = 30.2 + 0.2;
11 s1930_x =   22 + 0.2;
12 s1930_y_outer = 36.4 + 0.2;
13 s1930_x_outer = 27.6 + 0.2;
14
15 s1930_recess = 3;
16 s1930_around = 3;
17 s1930_behind = 3;
18
19 totx_inner = 180;
20 toty_outer = 95;
21 totz_outer = 31;
22
23 wallthick = 2.5;
24
25 // calculated
26
27 totx_outer = totx_inner + wallthick*2;
28 toty_inner = toty_outer - wallthick*2;
29 totz_inner = totz_outer - wallthick*2;
30
31 sb_box_sz = [totx_outer, totz_outer, toty_inner];
32
33 // origin is at centre on outer face wall
34 // outside is towards positive x
35 // mounting is vertical
36 module S1930_Positive(){
37   d = s1930_recess + s1930_behind;
38   translate([-d/2, 0,0])
39     cube([d,
40           s1930_x_outer + s1930_around,
41           s1930_y_outer + s1930_around], center=true);
42 }
43 module S1930_Negative(){
44   cube([60, s1930_x, s1930_y],
45        center=true);
46   translate([1, 0,0])
47     cube([s1930_recess*2+2, s1930_x_outer, s1930_y_outer],
48          center=true);
49 }
50
51 module TestWall(){ ////toplevel
52   sw_ctr = [25, wallthick, 25];
53
54   rotate([0,0,-90]){
55     difference(){
56       union(){
57         cube([50, wallthick, 42]);
58       }
59
60       translate([30, -1, 20])
61         rotate([-90,0,0])
62         cylinder(r = pxp6012_rad, h=10, $fn=60);
63
64       rotate([90,0,0])
65         Commitid_BestCount([15,40]);
66     }
67   }
68
69   difference(){
70     union(){
71       cube([50, wallthick, 50]);
72       translate(sw_ctr)
73         rotate([0,0,90])
74         S1930_Positive();
75     }
76
77     translate(sw_ctr) {
78       rotate([0,0,90])
79         S1930_Negative();
80     }
81   }    
82 }
83
84 ts_totx = 30;
85 ts_toty = 25;
86 ts_totz_inner = 8;
87
88 ts_box_sz = [ts_totx, ts_toty, ts_totz_inner];
89
90 $sealingbox_wallth = wallthick;
91 $sealingbox_floorth = wallthick;
92 $sealingbox_ceilth = wallthick;
93
94 module TestSealBox(){ ////toplevel
95   $sealingbox_sz = ts_box_sz;
96
97   SealingBox_RectBox();
98   ts_cidoff = ($sealingbox_cnrrad * (1-.7) + wallthick * .8) * [1,1];
99   translate(ts_cidoff)
100     Commitid_BestCount([ts_totx,ts_toty] - 2*ts_cidoff);
101 }
102
103 module TestSealLid(){ ////toplevel
104   $sealingbox_sz = ts_box_sz;
105
106   difference(){
107     SealingBox_RectLid();
108
109     translate([ts_totx * .75, ts_toty/2, 0])
110       cylinder(h=100, r=5);
111     
112     translate([-wallthick + $sealingbox_cnrrad*.5,
113                $sealingbox_cnrrad*.5 - wallthick,
114                ts_totz_inner + $sealingbox_ceilth])
115       Commitid_BestCount([ts_totx * .75 - 2.5 - ($sealingbox_cnrrad*.5),
116                           ts_toty - ($sealingbox_cnrrad*.5 - wallthick)*2]);
117   }
118 }
119
120 module TestSealLidPrint(){ ////toplevel
121   rotate([180,0,0]) TestSealLid();
122 }
123
124 module ProfileDemos(){ ////toplevel
125   $sealingbox_sz = ts_box_sz;
126
127   SealingBox_WallProfile();
128   color("blue") SealingBox_FloorProfile();
129   SealingBox_LidProfile();
130   color("blue") SealingBox_CeilProfile();
131   color("red") translate([-5,0]) square([1,ts_totz_inner]);
132 }
133
134 module Box(){ ////toplevel
135   $sealingbox_sz = sb_box_sz;
136
137   chargingconn_x = pxp6012_rad_outer + 1 + $sealingbox_cnrrad;
138   switch_x = chargingconn_x + pxp6012_rad_outer
139     + s1930_y_outer/2 + s1930_around;
140
141   difference(){
142     union(){
143       rotate([90,0,0])
144         translate([-wallthick,-wallthick, -toty_inner])
145         SealingBox_RectBox();
146
147       translate([switch_x, toty_inner, totz_inner/2])
148         rotate([90,0,90])
149         S1930_Positive();
150     }
151
152     // charging connector
153     translate([chargingconn_x,
154                toty_inner - (pxp6012_rad_outer + 5),
155                10])
156       cylinder(r= pxp6012_rad, h= totz_outer);
157
158     translate([switch_x, toty_inner, totz_inner/2])
159       rotate([90,0,90])
160       S1930_Negative();
161   }
162 }
163
164 //TestWall();
165 //ProfileDemos();
166 //TestSealBox();
167 //TestSealLid();
168 //FArcSegment_mask(350);