chiark / gitweb /
adafruit-powerboost: wip common
[reprap-play.git] / adafruit-powerboost-common.scad
1 // -*- C -*-
2
3 include <nutbox.scad>
4
5 psu_th = 1.70 + 0.25;
6 psu_th_for_clamp = 1.50;
7
8 psu_hole_dia = 2.5 - 0.3;
9 psu_connector_z = 2.9 + 0.1;
10 psu_connector_z_overlap = 0.15;
11 psu_connector_depth = 6.25;
12 psu_connector_w = 8.0 + 0.5;
13 psu_usb_protr = 0.6;
14
15 psu_clamp_th = 4.0 + 0.75;
16 psu_clamp_w = 8.0;
17 psu_clamp_gap = 0.4;
18
19 psu_board_clamp_ovlp = 4.5;
20 psu_board_support_wall = 2;
21 psu_board_nutbox = nutbox_data_M3;
22
23 psu_y = +psu_sz[1]/2 + psu_usb_protr;
24
25 // ----- calculated -----
26
27 psu_z = NutBox_h_base(psu_board_nutbox);
28 psu_z_down = psu_z + 0.1;
29
30 module PsuBoardRepresentation(){
31   linear_extrude(height= psu_th)
32     square(center=true, [psu_sz[0],psu_sz[1]]);
33 }
34
35 module PsuRepresentation(){
36   PsuBoardRepresentation();
37   translate([0, -psu_sz[1]/2, -psu_connector_z])
38     linear_extrude(height= psu_connector_z + psu_connector_z_overlap)
39     rectfromto([ -psu_connector_w/2, -10 ],
40                [ +psu_connector_w/2, psu_connector_depth ]);
41 }
42
43 module AtPsuMountCorner(mx,my){
44   mirror([mx,0,0])
45     mirror([0,my,0])
46       translate(-0.5 * [psu_sz[0], psu_sz[1], 0]
47                 -1 * [0,0, psu_z_down])
48         children();
49 }
50
51 module PsuMountCornerExtrude(mx,my, plus_z=board_support_z){
52   AtPsuMountCorner(mx,my){
53     linear_extrude(height= psu_z_down + plus_z, convexity=10) {
54       children();
55     }
56   }
57 }
58
59 module PsuMountPositiveMain(){
60   for (mx=[0,1]) {
61     for (my=[0,1]) {
62       PsuMountCornerExtrude(mx,my){
63         rectfromto(-[1,1]*psu_board_support_wall,
64                    +[1,1]*board_support_ovlp);
65       }
66     }
67     // mount above at plug end
68     PsuMountCornerExtrude(mx,0, psu_th + psu_board_support_wall){
69       rectfromto(-[1,1]*psu_board_support_wall,
70                  [board_support_ovlp,
71                   board_support_ovlp_ceil]);
72     }
73   }
74   translate([0,0, -psu_z_down])
75     linear_extrude(psu_z_down - psu_baffle_gap, convexity=10)
76       PsuLedBafflePlan();
77 }
78
79 module PsuMountNegative(){
80   axis = [0, -psu_sz[1]/2, psu_th];
81   PsuRepresentation();
82   translate(axis)
83     rotate([atan(2 * board_support_z / psu_sz[1]),
84             0,0])
85     translate(-axis)
86     PsuBoardRepresentation();
87 }
88
89 module PsuMountPositive(){
90   difference(){
91     intersection(){
92       PsuMountPositiveMain();
93       linextr_y_xz(-psu_y, psu_sz[1]*2) square(100, center=true);
94     }
95     PsuMountNegative();
96     intersection(){
97       hull(){
98         PsuBoardRepresentation();
99         translate([0,0,5]) PsuBoardRepresentation();
100       }
101       translate([-20,0,-20]) cube(40);
102     }
103   }
104   for (mx=[0,1]) {
105     PsuMountCornerExtrude(mx,1){
106       translate([psu_sz[0]/2 - psu_hole_pos[1],
107                  psu_hole_pos[0]]
108                 + board_gap * [1,1] )
109         circle(r= psu_hole_dia/2);
110     }
111   }
112   translate([0, psu_sz[1]/2 + psu_board_nutbox[0]/2, 0])
113     rotate([0,0,180])
114     NutBox(psu_board_nutbox, psu_z_down);
115 }
116
117 module PsuClamp(){ ////toplevel
118   rotate([180,0,0]) difference(){
119     linear_extrude(height=psu_clamp_th + psu_th_for_clamp, convexity=5) {
120       difference(){
121         hull(){
122           circle(r = fix_sz/2);
123           translate([ -psu_board_nutbox[0]/2, 0])
124             square(center=true, [ psu_board_clamp_ovlp*2, psu_clamp_w ]);
125         }
126         circle(r = psu_board_nutbox[0]/2);
127       }
128     }
129     translate([0,0,-1]) linear_extrude(height=psu_th_for_clamp+1) {
130       translate([ -psu_board_nutbox[0]/2 + psu_clamp_gap, 0 ])
131         mirror([1,0])
132         translate([0,-20]) square(40);
133     }
134   }
135 }
136
137 module PsuLedWindowsPlan(){
138   difference(){
139     PsuLedWindowsPlanCore();
140     PsuLedBafflePlan();
141   }
142 }
143
144 module PsuMountDemo(ceil = 2.5) { ////toplevel
145   translate([0, psu_y, psu_z]) {
146     PsuMountPositive();
147     %PsuMountNegative();
148     color("yellow") translate([0,0, -psu_z - ceil])
149       linear_extrude(height=0.4, convexity=10)
150       PsuLedWindowsPlan();
151   }
152 }