chiark / gitweb /
adafruit-powerboost-500: transfer from other tree
[reprap-play.git] / adafruit-powerboost-500.scad
1 // -*- C -*-
2
3 include <nutbox.scad>
4
5 psu_sz  = [ 21.7, 36.0 ] + [ 0.25, 0.25 ];
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 // ----- calculated -----
34
35 psu_usbend_led_depth = psu_baffle_cnr_y*2 - psu_usbend_led_x;
36
37 psu_z = NutBox_h_base(psu_board_nutbox);
38 psu_z_down = psu_z + 0.1;
39
40
41 module PsuBoardRepresentation(){
42   linear_extrude(height= psu_th)
43     square(center=true, [psu_sz[0],psu_sz[1]]);
44 }
45
46 module PsuRepresentation(){
47   PsuBoardRepresentation();
48   translate([0, -psu_sz[1]/2, -psu_connector_z])
49     linear_extrude(height= psu_connector_z + psu_connector_z_overlap)
50     rectfromto([ -psu_connector_w/2, -10 ],
51                [ +psu_connector_w/2, psu_connector_depth ]);
52 }
53
54 module AtPsuMountCorner(mx,my){
55   mirror([mx,0,0])
56     mirror([0,my,0])
57       translate(-0.5 * [psu_sz[0], psu_sz[1], 0]
58                 -1 * [0,0, psu_z_down])
59         children();
60 }
61
62 module PsuMountCornerExtrude(mx,my, plus_z=board_support_z){
63   AtPsuMountCorner(mx,my){
64     linear_extrude(height= psu_z_down + plus_z, convexity=10) {
65       children();
66     }
67   }
68 }
69
70 module PsuLedBafflePlan(){
71   baffle_tr = [0, psu_baffle_cnr_y]
72     + 0.5 * [psu_baffle_th[1], psu_baffle_th[0]];
73   translate([0, -psu_sz[1]/2]) {
74     mirror([1,0,0]) {
75       rectfromto([-psu_baffle_th[1]/2, 0],
76                  baffle_tr);
77       rectfromto([-psu_sz[0]/2 - psu_board_support_wall *2,
78                   baffle_tr[1] - psu_baffle_th[0]],
79                  baffle_tr);
80     }
81   }
82 }
83
84 module PsuLedWindowsPlan(){
85   difference(){
86     union(){
87       AtPsuMountCorner(1,0) {
88         rectfromto([ -(psu_board_support_wall + 0.1),
89                      +psu_usbend_led_x ],
90                    [ psu_sz[0]/2,
91                      +psu_usbend_led_depth ]);
92       }
93       AtPsuMountCorner(0,0) {
94         sz = psu_baffle_cnr_y - psu_board_support_wall - psu_baffle_th[0];
95         translate([0, psu_baffle_cnr_y])
96           rectfromto([ -(psu_board_support_wall + 0.1),
97                        -sz/2 ],
98                      [ psu_sz[0]/2,
99                        +sz/2 ]);
100       }
101       AtPsuMountCorner(0,1){
102         rectfromto([0,0],
103                    [psu_sz[0]/2 - psu_hole_pos[1] - psu_hole_dia/2,
104                      psu_innerend_led_depth]);
105       }
106     }
107     PsuLedBafflePlan();
108     translate([0, -psu_sz[1]/2])
109       square(center=true, [psu_baffle_th[1], psu_sz[1]]);;
110   }
111 }
112
113 module PsuMountPositiveMain(){
114   for (mx=[0,1]) {
115     for (my=[0,1]) {
116       PsuMountCornerExtrude(mx,my){
117         rectfromto(-[1,1]*psu_board_support_wall,
118                    +[1,1]*board_support_ovlp);
119       }
120     }
121     // mount above at plug end
122     PsuMountCornerExtrude(mx,0, psu_th + psu_board_support_wall){
123       rectfromto(-[1,1]*psu_board_support_wall,
124                  [board_support_ovlp,
125                   board_support_ovlp_ceil]);
126     }
127   }
128   translate([0,0, -psu_z_down])
129     linear_extrude(psu_z_down - psu_baffle_gap, convexity=10)
130       PsuLedBafflePlan();
131 }
132
133 module PsuMountNegative(){
134   axis = [0, -psu_sz[1]/2, psu_th];
135   PsuRepresentation();
136   translate(axis)
137     rotate([atan(2 * board_support_z / psu_sz[1]),
138             0,0])
139     translate(-axis)
140     PsuBoardRepresentation();
141 }
142
143 module PsuMountPositive(){
144   difference(){
145     PsuMountPositiveMain();
146     PsuMountNegative();
147     intersection(){
148       hull(){
149         PsuBoardRepresentation();
150         translate([0,0,5]) PsuBoardRepresentation();
151       }
152       translate([-20,0,-20]) cube(40);
153     }
154   }
155   for (mx=[0,1]) {
156     PsuMountCornerExtrude(mx,1){
157       translate([psu_sz[0]/2 - psu_hole_pos[1],
158                  psu_hole_pos[0]]
159                 + board_gap * [1,1] )
160         circle(r= psu_hole_dia/2);
161     }
162   }
163   translate([0, psu_sz[1]/2 + psu_board_nutbox[0]/2, 0])
164     rotate([0,0,180])
165     NutBox(psu_board_nutbox, psu_z_down);
166 }
167
168 module PsuClamp(){ ////toplevel
169   rotate([180,0,0]) difference(){
170     linear_extrude(height=psu_clamp_th + psu_th_for_clamp, convexity=5) {
171       difference(){
172         hull(){
173           circle(r = fix_sz/2);
174           translate([ -psu_board_nutbox[0]/2, 0])
175             square(center=true, [ psu_board_clamp_ovlp*2, psu_clamp_w ]);
176         }
177         circle(r = psu_board_nutbox[0]/2);
178       }
179     }
180     translate([0,0,-1]) linear_extrude(height=psu_th_for_clamp+1) {
181       translate([ -psu_board_nutbox[0]/2 + psu_clamp_gap, 0 ])
182         mirror([1,0])
183         translate([0,-20]) square(40);
184     }
185   }
186 }