chiark / gitweb /
adafruit-powerboost: legends wip
[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.3;
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 // ----- calculated -----
46
47 psu_z = NutBox_h_base(psu_board_nutbox);
48 psu_z_down = psu_z + 0.1;
49 psu_fix_sz = NutBox_outer_size(psu_board_nutbox);
50 psu_board_nutbox_y = psu_sz[1]/2 + psu_board_nutbox[0]/2;
51
52 module PsuBoardRepresentation(){
53   linear_extrude(height= psu_th)
54     square(center=true, [psu_sz[0],psu_sz[1]]);
55 }
56
57 module PsuRepresentation(){
58   PsuBoardRepresentation();
59   translate([0, -psu_sz[1]/2, -psu_connector_z])
60     linear_extrude(height= psu_connector_z + psu_connector_z_overlap)
61     rectfromto([ -psu_connector_w/2, -10 ],
62                [ +psu_connector_w/2, psu_connector_depth ]);
63 }
64
65 module AtPsuMountCorner(mx,my){
66   mirror([mx,0,0])
67     mirror([0,my,0])
68       translate(-0.5 * [psu_sz[0], psu_sz[1], 0]
69                 -1 * [0,0, psu_z_down])
70         children();
71 }
72
73 module PsuMountCornerExtrude(mx,my, plus_z=psu_board_support_z){
74   AtPsuMountCorner(mx,my){
75     linear_extrude(height= psu_z_down + plus_z, convexity=10) {
76       children();
77     }
78   }
79 }
80
81 module PsuUsbAVSpacePlan(){
82   for (x= [-1,+1] * psu_usba_v_apart/2) {
83     translate([x, -psu_usba_v_from_edge ]) {
84       hull(){
85         for (y= [-1,+1] * (psu_usba_v_space_l - psu_usba_v_space_w)) {
86           translate([0,y])
87             circle(r= psu_usba_v_space_w);
88         }
89       }
90     }
91   }
92 }
93
94 module PsuMountPositiveMain(){
95   for (mx=[0,1]) {
96     for (my=[0,1]) {
97       PsuMountCornerExtrude(mx,my){
98         rectfromto(-[1,1]*psu_board_support_wall,
99                    +[1,1]*psu_board_support_ovlp);
100       }
101     }
102     // mount above at plug end
103     PsuMountCornerExtrude(mx,0, psu_th + psu_board_support_wall){
104       rectfromto(-[1,1]*psu_board_support_wall,
105                  [psu_board_support_ovlp,
106                   psu_board_support_ovlp_ceil]);
107     }
108   }
109   translate([0,0, -psu_z_down])
110     linear_extrude(psu_z_down - psu_baffle_gap, convexity=10)
111       PsuLedBafflePlan();
112 }
113
114 module PsuMountNegative(){
115   axis = [0, -psu_sz[1]/2, psu_th];
116   PsuRepresentation();
117   translate(axis)
118     rotate([atan(2 * psu_board_support_z / psu_sz[1]),
119             0,0])
120     translate(-axis)
121     PsuBoardRepresentation();
122 }
123
124 module PsuMountPositive(){
125   difference(){
126     intersection(){
127       PsuMountPositiveMain();
128       linextr_y_xz(-psu_y, psu_sz[1]*2) square(100, center=true);
129     }
130     PsuMountNegative();
131     intersection(){
132       hull(){
133         PsuBoardRepresentation();
134         translate([0,0,5]) PsuBoardRepresentation();
135       }
136       translate([-20,0,-20]) cube(40);
137     }
138   }
139   for (mx=[0,1]) {
140     PsuMountCornerExtrude(mx,1){
141       translate([psu_sz[0]/2 - psu_hole_pos[1],
142                  psu_hole_pos[0]]
143                 + psu_board_gap * [1,1] )
144         circle(r= psu_hole_dia/2);
145     }
146   }
147   difference(){
148     translate([0, psu_board_nutbox_y, 0])
149       rotate([0,0,180])
150       NutBox(psu_board_nutbox, psu_z_down);
151     translate([0, psu_sz[1]/2, 0])
152       linextr(-psu_usba_v_space_below, +10)
153       PsuUsbAVSpacePlan();
154   }
155 }
156
157 module PsuClamp(){ ////toplevel
158   rotate([180,0,0]) difference(){
159     linear_extrude(height=psu_clamp_th + psu_th_for_clamp, convexity=5) {
160       difference(){
161         hull(){
162           circle(r = psu_fix_sz/2);
163           translate([ -psu_board_nutbox[0]/2, 0])
164             square(center=true, [ psu_board_clamp_ovlp*2, psu_clamp_w ]);
165         }
166         circle(r = psu_board_nutbox[0]/2);
167       }
168     }
169     translate([0,0,-1]) linear_extrude(height=psu_th_for_clamp+1) {
170       translate([ -psu_board_nutbox[0]/2 + psu_clamp_gap, 0 ])
171         mirror([1,0])
172         translate([0,-20]) square(40);
173     }
174     linextr(-10,10) {
175       rotate(-90)
176       PsuUsbAVSpacePlan();
177     }
178   }
179 }
180
181 module PsuLedWindowsPlan(){
182   difference(){
183     PsuLedWindowsPlanCore();
184     PsuLedBafflePlan();
185   }
186 }
187
188 module PsuMountDemo(ceil = 2.5) { ////toplevel
189   translate([0, psu_y, psu_z]) {
190     difference(){
191       PsuMountPositive();
192       linextr(-20, 0.1)
193         PsuLedWindowsPlan();
194     }
195     %PsuMountNegative();
196
197     color("yellow") translate([0,0, -psu_z - ceil])
198       linear_extrude(height=0.4, convexity=10)
199       PsuLedWindowsPlan();
200
201     color("blue") translate([0,0, -psu_z - ceil])
202       linear_extrude(height=0.4, convexity=10)
203       PsuLedLegendsPlan();
204
205     translate([0, psu_board_nutbox_y, 10])
206       rotate([180,0,0])
207       rotate([0,0,-90])
208       PsuClamp();
209   }
210 }
211
212 module PsuMountTest(ceil = 2.5) { ////toplevel
213   $fs = 0.1;
214   $fa = 3;
215   difference(){
216     union(){
217       translate([0, psu_y, psu_z])
218         PsuMountPositive();
219       difference(){
220         linextr_x_yz(-(psu_sz[0]/2 + 5),
221                      +(psu_sz[0]/2 + 5)){
222           difference(){
223             rectfromto([0, -ceil], [psu_sz[1] + 10, psu_z + 10]);
224             rectfromto([ceil,0], 400*[1,1]);
225           }
226         }
227         translate([0, psu_y, psu_z]) {
228           PsuMountNegative();
229         }
230       }
231     }
232     translate([0, psu_y, psu_z]) {
233       linextr(-10, 0.1)
234         PsuLedWindowsPlan();
235     }
236   }
237 }