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