chiark / gitweb /
adafruit-powerboost: wip common
[reprap-play.git] / adafruit-powerboost-500.scad
1 // -*- C -*-
2
3 psu_sz  = [ 21.7, 36.0 ] + [ 0.25, 0.25 ];
4
5 include <adafruit-powerboost-common.scad>
6
7 psu_th = 1.70 + 0.25;
8 psu_th_for_clamp = 1.50;
9
10 psu_hole_pos = [ 2.05, // from back edge of psu_sz[0]
11                  0.55 * 0.5 * 25.4, // from centreline
12                  ];
13 psu_hole_dia = 2.5 - 0.3;
14 psu_baffle_gap = 1.0 + 0.5;
15 psu_baffle_cnr_y = 7.45; // from connector end
16 psu_baffle_th = [ 0.8, 3.5 ];
17 psu_connector_z = 2.9 + 0.1;
18 psu_connector_z_overlap = 0.15;
19 psu_connector_depth = 6.25;
20 psu_connector_w = 8.0 + 0.5;
21 psu_usb_protr = 0.6;
22 psu_usbend_led_x = 4.5;
23 psu_innerend_led_depth = 10;
24
25 psu_clamp_th = 4.0 + 0.75;
26 psu_clamp_w = 8.0;
27 psu_clamp_gap = 0.4;
28
29 psu_board_clamp_ovlp = 4.5;
30 psu_board_support_wall = 2;
31 psu_board_nutbox = nutbox_data_M3;
32
33 psu_y = +psu_sz[1]/2 + psu_usb_protr;
34
35 // ----- calculated -----
36
37 psu_usbend_led_depth = psu_baffle_cnr_y*2 - psu_usbend_led_x;
38
39 psu_z = NutBox_h_base(psu_board_nutbox);
40 psu_z_down = psu_z + 0.1;
41
42
43 module PsuBoardRepresentation(){
44   linear_extrude(height= psu_th)
45     square(center=true, [psu_sz[0],psu_sz[1]]);
46 }
47
48 module PsuRepresentation(){
49   PsuBoardRepresentation();
50   translate([0, -psu_sz[1]/2, -psu_connector_z])
51     linear_extrude(height= psu_connector_z + psu_connector_z_overlap)
52     rectfromto([ -psu_connector_w/2, -10 ],
53                [ +psu_connector_w/2, psu_connector_depth ]);
54 }
55
56 module AtPsuMountCorner(mx,my){
57   mirror([mx,0,0])
58     mirror([0,my,0])
59       translate(-0.5 * [psu_sz[0], psu_sz[1], 0]
60                 -1 * [0,0, psu_z_down])
61         children();
62 }
63
64 module PsuMountCornerExtrude(mx,my, plus_z=board_support_z){
65   AtPsuMountCorner(mx,my){
66     linear_extrude(height= psu_z_down + plus_z, convexity=10) {
67       children();
68     }
69   }
70 }
71
72 module PsuLedBafflePlan(){
73   baffle_tr = [0, psu_baffle_cnr_y]
74     + 0.5 * [psu_baffle_th[1], psu_baffle_th[0]];
75   translate([0, -psu_sz[1]/2]) {
76     mirror([1,0,0]) {
77       rectfromto([-psu_baffle_th[1]/2, 0],
78                  baffle_tr);
79       rectfromto([-psu_sz[0]/2 - psu_board_support_wall *2,
80                   baffle_tr[1] - psu_baffle_th[0]],
81                  baffle_tr);
82     }
83   }
84 }
85
86 module PsuLedWindowsPlan(){
87   difference(){
88     union(){
89       AtPsuMountCorner(1,0) {
90         rectfromto([ -(psu_board_support_wall + 0.1),
91                      +psu_usbend_led_x ],
92                    [ psu_sz[0]/2,
93                      +psu_usbend_led_depth ]);
94       }
95       AtPsuMountCorner(0,0) {
96         sz = psu_baffle_cnr_y - psu_board_support_wall - psu_baffle_th[0];
97         translate([0, psu_baffle_cnr_y])
98           rectfromto([ -(psu_board_support_wall + 0.1),
99                        -sz/2 ],
100                      [ psu_sz[0]/2,
101                        +sz/2 ]);
102       }
103       AtPsuMountCorner(0,1){
104         rectfromto([0,0],
105                    [psu_sz[0]/2 - psu_hole_pos[1] - psu_hole_dia/2,
106                      psu_innerend_led_depth]);
107       }
108     }
109     PsuLedBafflePlan();
110     translate([0, -psu_sz[1]/2])
111       square(center=true, [psu_baffle_th[1], psu_sz[1]]);;
112   }
113 }
114
115 module PsuMountPositiveMain(){
116   for (mx=[0,1]) {
117     for (my=[0,1]) {
118       PsuMountCornerExtrude(mx,my){
119         rectfromto(-[1,1]*psu_board_support_wall,
120                    +[1,1]*board_support_ovlp);
121       }
122     }
123     // mount above at plug end
124     PsuMountCornerExtrude(mx,0, psu_th + psu_board_support_wall){
125       rectfromto(-[1,1]*psu_board_support_wall,
126                  [board_support_ovlp,
127                   board_support_ovlp_ceil]);
128     }
129   }
130   translate([0,0, -psu_z_down])
131     linear_extrude(psu_z_down - psu_baffle_gap, convexity=10)
132       PsuLedBafflePlan();
133 }
134
135 module PsuMountNegative(){
136   axis = [0, -psu_sz[1]/2, psu_th];
137   PsuRepresentation();
138   translate(axis)
139     rotate([atan(2 * board_support_z / psu_sz[1]),
140             0,0])
141     translate(-axis)
142     PsuBoardRepresentation();
143 }
144
145 module PsuMountPositive(){
146   difference(){
147     intersection(){
148       PsuMountPositiveMain();
149       linextr_y_xz(-psu_y, psu_sz[1]*2) square(100, center=true);
150     }
151     PsuMountNegative();
152     intersection(){
153       hull(){
154         PsuBoardRepresentation();
155         translate([0,0,5]) PsuBoardRepresentation();
156       }
157       translate([-20,0,-20]) cube(40);
158     }
159   }
160   for (mx=[0,1]) {
161     PsuMountCornerExtrude(mx,1){
162       translate([psu_sz[0]/2 - psu_hole_pos[1],
163                  psu_hole_pos[0]]
164                 + board_gap * [1,1] )
165         circle(r= psu_hole_dia/2);
166     }
167   }
168   translate([0, psu_sz[1]/2 + psu_board_nutbox[0]/2, 0])
169     rotate([0,0,180])
170     NutBox(psu_board_nutbox, psu_z_down);
171 }
172
173 module PsuClamp(){ ////toplevel
174   rotate([180,0,0]) difference(){
175     linear_extrude(height=psu_clamp_th + psu_th_for_clamp, convexity=5) {
176       difference(){
177         hull(){
178           circle(r = fix_sz/2);
179           translate([ -psu_board_nutbox[0]/2, 0])
180             square(center=true, [ psu_board_clamp_ovlp*2, psu_clamp_w ]);
181         }
182         circle(r = psu_board_nutbox[0]/2);
183       }
184     }
185     translate([0,0,-1]) linear_extrude(height=psu_th_for_clamp+1) {
186       translate([ -psu_board_nutbox[0]/2 + psu_clamp_gap, 0 ])
187         mirror([1,0])
188         translate([0,-20]) square(40);
189     }
190   }
191 }
192
193 module PsuMountDemo(ceil = 2.5) { ////toplevel
194   translate([0, psu_y, psu_z]) {
195     PsuMountPositive();
196     %PsuMountNegative();
197     color("yellow") translate([0,0, -psu_z - ceil])
198       linear_extrude(height=0.4, convexity=10)
199       PsuLedWindowsPlan();
200   }
201 }