chiark / gitweb /
adafruit-powerboost-common: sizing and test
[reprap-play.git] / adafruit-powerboost-common.scad
1 // -*- C -*-
2
3 include <nutbox.scad>
4 include <utils.scad>
5
6 psu_sz  = psu_sz_nom + [ 0.11, 0.44 ] + [ 0.25, 0.25 ];
7
8 psu_hole_pos = [ 2.05, // from back edge of psu_sz[0]
9                  0.55 * 0.5 * 25.4, // from centreline
10                  ];
11
12 psu_th = 1.70 + 0.25;
13 psu_th_for_clamp = 1.50;
14
15 psu_hole_dia = 2.5 - 0.5;
16 psu_connector_z = 2.9 + 0.1;
17 psu_connector_z_overlap = 0.15;
18 psu_connector_depth = 6.25;
19 psu_connector_w = 8.0 + 0.5;
20 psu_usb_protr = 0.6;
21
22 psu_clamp_th = 4.0 + 0.75;
23 psu_clamp_w = 8.0;
24 psu_clamp_gap = 0.4;
25
26 psu_board_clamp_ovlp = 4.5;
27 psu_board_nutbox = nutbox_data_M3;
28
29 psu_board_gap = 0.5;
30 psu_board_support_wall = 2;
31 psu_board_support_ovlp = 4.5;
32 psu_board_support_ovlp_ceil = 2;
33 psu_board_support_z = 2;
34
35 psu_baffle_gap = 1.0 + 0.5;
36
37 psu_y = +psu_sz[1]/2 + psu_usb_protr;
38
39 psu_usba_v_apart = 7.0;
40 psu_usba_v_from_edge = 4.86;
41 psu_usba_v_space_below = 1.5;
42 psu_usba_v_space_w = 1.7;
43 psu_usba_v_space_l = 3.0;
44
45 psu_test_ceil = 2.5;
46
47 // ----- calculated -----
48
49 psu_z = NutBox_h_base(psu_board_nutbox);
50 psu_z_down = psu_z + 0.1;
51 psu_fix_sz = NutBox_outer_size(psu_board_nutbox);
52 psu_board_nutbox_y = psu_sz[1]/2 + psu_board_nutbox[0]/2;
53
54 psu_mount_outer_sz = psu_sz +
55   [ psu_board_support_wall * 2,
56     max(psu_board_support_wall,
57         psu_board_nutbox_y + psu_fix_sz/2) ];
58
59 module PsuBoardRepresentation(){
60   linear_extrude(height= psu_th)
61     square(center=true, [psu_sz[0],psu_sz[1]]);
62 }
63
64 module PsuRepresentation(){
65   PsuBoardRepresentation();
66   translate([0, -psu_sz[1]/2, -psu_connector_z])
67     linear_extrude(height= psu_connector_z + psu_connector_z_overlap)
68     rectfromto([ -psu_connector_w/2, -10 ],
69                [ +psu_connector_w/2, psu_connector_depth ]);
70 }
71
72 module AtPsuMountCorner(mx,my){
73   mirror([mx,0,0])
74     mirror([0,my,0])
75       translate(-0.5 * [psu_sz[0], psu_sz[1], 0]
76                 -1 * [0,0, psu_z_down])
77         children();
78 }
79
80 module PsuMountCornerExtrude(mx,my, plus_z=psu_board_support_z){
81   AtPsuMountCorner(mx,my){
82     linear_extrude(height= psu_z_down + plus_z, convexity=10) {
83       children();
84     }
85   }
86 }
87
88 module PsuUsbAVSpacePlan(){
89   for (x= [-1,+1] * psu_usba_v_apart/2) {
90     translate([x, -psu_usba_v_from_edge ]) {
91       hull(){
92         for (y= [-1,+1] * 0.5 * (psu_usba_v_space_l - psu_usba_v_space_w)) {
93           translate([0,y])
94             circle(r= psu_usba_v_space_w);
95         }
96       }
97     }
98   }
99 }
100
101 module PsuMountPositiveMain(){
102   for (mx=[0,1]) {
103     for (my=[0,1]) {
104       PsuMountCornerExtrude(mx,my){
105         rectfromto(-[1,1]*psu_board_support_wall,
106                    +[1,1]*psu_board_support_ovlp);
107       }
108     }
109     // mount above at plug end
110     PsuMountCornerExtrude(mx,0, psu_th + psu_board_support_wall){
111       rectfromto(-[1,1]*psu_board_support_wall,
112                  [psu_board_support_ovlp,
113                   psu_board_support_ovlp_ceil]);
114     }
115   }
116   translate([0,0, -psu_z_down])
117     linear_extrude(psu_z_down - psu_baffle_gap, convexity=10)
118       PsuLedBafflePlan();
119 }
120
121 module PsuMountNegative(){
122   axis = [0, -psu_sz[1]/2, psu_th];
123   PsuRepresentation();
124   translate(axis)
125     rotate([atan(2 * psu_board_support_z / psu_sz[1]),
126             0,0])
127     translate(-axis)
128     PsuBoardRepresentation();
129 }
130
131 module PsuMountPositive(){
132   difference(){
133     intersection(){
134       PsuMountPositiveMain();
135       linextr_y_xz(-psu_y, psu_sz[1]*2) square(100, center=true);
136     }
137     PsuMountNegative();
138     intersection(){
139       hull(){
140         PsuBoardRepresentation();
141         translate([0,0,5]) PsuBoardRepresentation();
142       }
143       translate([-20,0,-20]) cube(40);
144     }
145   }
146   for (mx=[0,1]) {
147     PsuMountCornerExtrude(mx,1){
148       translate([psu_sz[0]/2 - psu_hole_pos[1],
149                  psu_hole_pos[0]]
150                 + psu_board_gap * [1,1] )
151         circle(r= psu_hole_dia/2);
152     }
153   }
154   difference(){
155     translate([0, psu_board_nutbox_y, 0])
156       rotate([0,0,180])
157       NutBox(psu_board_nutbox, psu_z_down);
158     translate([0, psu_sz[1]/2, 0])
159       linextr(-psu_usba_v_space_below, +10)
160       PsuUsbAVSpacePlan();
161   }
162 }
163
164 module PsuClamp(){ ////toplevel
165   rotate([180,0,0]) difference(){
166     linear_extrude(height=psu_clamp_th + psu_th_for_clamp, convexity=5) {
167       difference(){
168         hull(){
169           circle(r = psu_fix_sz/2);
170           translate([ -psu_board_nutbox[0]/2, 0])
171             square(center=true, [ psu_board_clamp_ovlp*2, psu_clamp_w ]);
172         }
173         circle(r = psu_board_nutbox[0]/2);
174       }
175     }
176     translate([0,0,-1]) linear_extrude(height=psu_th_for_clamp+1) {
177       translate([ -psu_board_nutbox[0]/2 + psu_clamp_gap, 0 ])
178         mirror([1,0])
179         translate([0,-20]) square(40);
180     }
181     linextr(-10,10) {
182       rotate(-90)
183         translate([0, -psu_board_nutbox[0]/2])
184         PsuUsbAVSpacePlan();
185     }
186   }
187 }
188
189 module PsuLedWindowsPlan(){
190   difference(){
191     PsuLedWindowsPlanCore();
192     PsuLedBafflePlan();
193   }
194 }
195
196 module PsuMountDemo() { ////toplevel
197   ceil = psu_test_ceil;
198
199   translate([0, psu_y, psu_z]) {
200     difference(){
201       PsuMountPositive();
202       linextr(-20, 0.1)
203         PsuLedWindowsPlan();
204     }
205     %PsuMountNegative();
206
207     color("yellow") translate([0,0, -psu_z - ceil])
208       linear_extrude(height=0.4, convexity=10)
209       PsuLedWindowsPlan();
210
211     color("blue") translate([0,0, -psu_z - ceil])
212       linear_extrude(height=0.4, convexity=10)
213       PsuLedLegendsPlan();
214
215     translate([0, psu_board_nutbox_y, 10])
216       rotate([180,0,0])
217       rotate([0,0,-90])
218       PsuClamp();
219   }
220 }
221
222 module PsuMountTest() { ////toplevel
223   ceil = psu_test_ceil;
224   $fs = 0.1;
225   $fa = 3;
226   difference(){
227     union(){
228       translate([0, psu_y, psu_z])
229         PsuMountPositive();
230       difference(){
231         linextr_x_yz(-(psu_sz[0]/2 + 5),
232                      +(psu_sz[0]/2 + 5)){
233           difference(){
234             rectfromto([0, -ceil], [psu_sz[1] + 10, psu_z + 10]);
235             rectfromto([ceil,0], 400*[1,1]);
236           }
237         }
238         translate([0, psu_y, psu_z]) {
239           PsuMountNegative();
240         }
241       }
242     }
243     translate([0, psu_y, psu_z]) {
244       linextr(-10, 0.1)
245         PsuLedWindowsPlan();
246     }
247   }
248 }
249
250 psu_multicolour_gap = 0.075;
251 psu_initial_layer_thick = 0.400;
252 psu_initial_layer_width = 0.750;
253 psu_window_ledge = 0.50; // each side
254
255 module PsuMountTestFullLayerFrame(ix) {
256   sz = psu_sz*2 + [1,1]*psu_initial_layer_width*(3+ix);
257   translate([0, psu_y]) difference(){
258     square(center=true, sz + 2*[1,1]*psu_initial_layer_width);
259     square(center=true, sz);
260   }
261 }
262
263
264 module PsuMountTestFullMain() { ////toplevel
265   ceil = psu_test_ceil;
266
267   linextr(0, psu_initial_layer_thick)
268     PsuMountTestFullLayerFrame(2);
269   
270   difference(){
271     translate([0,0, ceil])
272       PsuMountTest();
273
274     translate([0, psu_y, 0]) {
275       linextr(-1, psu_initial_layer_thick) {
276         offset(delta=psu_window_ledge + psu_multicolour_gap)
277           PsuLedWindowsPlan();
278         offset(delta=psu_multicolour_gap)
279           PsuLedLegendsPlan();
280       }
281     }
282   }
283 }
284
285 module PsuMountTestFullOneLayer(ix) {
286   linextr(0, psu_initial_layer_thick) {
287     PsuMountTestFullLayerFrame(ix);
288     translate([0, psu_y]) children();
289   }
290 }
291
292 module PsuMountTestFullText() { ////toplevel
293   PsuMountTestFullOneLayer(0)
294     PsuLedLegendsPlan();
295 }
296 module PsuMountTestFullWindows() { ////toplevel
297   PsuMountTestFullOneLayer(1)
298     offset(delta=psu_window_ledge)
299     PsuLedWindowsPlan();
300 }
301
302 module PsuMountTestFullDemo() { ////toplevel
303   color("blue") PsuMountTestFullMain();
304   color("yellow") PsuMountTestFullText();
305   %PsuMountTestFullWindows();
306 }