chiark / gitweb /
adafruit-powerboost: demo, make window cutouts
[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 // ----- calculated -----
40
41 psu_z = NutBox_h_base(psu_board_nutbox);
42 psu_z_down = psu_z + 0.1;
43
44 module PsuBoardRepresentation(){
45   linear_extrude(height= psu_th)
46     square(center=true, [psu_sz[0],psu_sz[1]]);
47 }
48
49 module PsuRepresentation(){
50   PsuBoardRepresentation();
51   translate([0, -psu_sz[1]/2, -psu_connector_z])
52     linear_extrude(height= psu_connector_z + psu_connector_z_overlap)
53     rectfromto([ -psu_connector_w/2, -10 ],
54                [ +psu_connector_w/2, psu_connector_depth ]);
55 }
56
57 module AtPsuMountCorner(mx,my){
58   mirror([mx,0,0])
59     mirror([0,my,0])
60       translate(-0.5 * [psu_sz[0], psu_sz[1], 0]
61                 -1 * [0,0, psu_z_down])
62         children();
63 }
64
65 module PsuMountCornerExtrude(mx,my, plus_z=psu_board_support_z){
66   AtPsuMountCorner(mx,my){
67     linear_extrude(height= psu_z_down + plus_z, convexity=10) {
68       children();
69     }
70   }
71 }
72
73 module PsuMountPositiveMain(){
74   for (mx=[0,1]) {
75     for (my=[0,1]) {
76       PsuMountCornerExtrude(mx,my){
77         rectfromto(-[1,1]*psu_board_support_wall,
78                    +[1,1]*psu_board_support_ovlp);
79       }
80     }
81     // mount above at plug end
82     PsuMountCornerExtrude(mx,0, psu_th + psu_board_support_wall){
83       rectfromto(-[1,1]*psu_board_support_wall,
84                  [psu_board_support_ovlp,
85                   psu_board_support_ovlp_ceil]);
86     }
87   }
88   translate([0,0, -psu_z_down])
89     linear_extrude(psu_z_down - psu_baffle_gap, convexity=10)
90       PsuLedBafflePlan();
91 }
92
93 module PsuMountNegative(){
94   axis = [0, -psu_sz[1]/2, psu_th];
95   PsuRepresentation();
96   translate(axis)
97     rotate([atan(2 * psu_board_support_z / psu_sz[1]),
98             0,0])
99     translate(-axis)
100     PsuBoardRepresentation();
101 }
102
103 module PsuMountPositive(){
104   difference(){
105     intersection(){
106       PsuMountPositiveMain();
107       linextr_y_xz(-psu_y, psu_sz[1]*2) square(100, center=true);
108     }
109     PsuMountNegative();
110     intersection(){
111       hull(){
112         PsuBoardRepresentation();
113         translate([0,0,5]) PsuBoardRepresentation();
114       }
115       translate([-20,0,-20]) cube(40);
116     }
117   }
118   for (mx=[0,1]) {
119     PsuMountCornerExtrude(mx,1){
120       translate([psu_sz[0]/2 - psu_hole_pos[1],
121                  psu_hole_pos[0]]
122                 + psu_board_gap * [1,1] )
123         circle(r= psu_hole_dia/2);
124     }
125   }
126   translate([0, psu_sz[1]/2 + psu_board_nutbox[0]/2, 0])
127     rotate([0,0,180])
128     NutBox(psu_board_nutbox, psu_z_down);
129 }
130
131 module PsuClamp(){ ////toplevel
132   rotate([180,0,0]) difference(){
133     linear_extrude(height=psu_clamp_th + psu_th_for_clamp, convexity=5) {
134       difference(){
135         hull(){
136           circle(r = fix_sz/2);
137           translate([ -psu_board_nutbox[0]/2, 0])
138             square(center=true, [ psu_board_clamp_ovlp*2, psu_clamp_w ]);
139         }
140         circle(r = psu_board_nutbox[0]/2);
141       }
142     }
143     translate([0,0,-1]) linear_extrude(height=psu_th_for_clamp+1) {
144       translate([ -psu_board_nutbox[0]/2 + psu_clamp_gap, 0 ])
145         mirror([1,0])
146         translate([0,-20]) square(40);
147     }
148   }
149 }
150
151 module PsuLedWindowsPlan(){
152   difference(){
153     PsuLedWindowsPlanCore();
154     PsuLedBafflePlan();
155   }
156 }
157
158 module PsuMountDemo(ceil = 2.5) { ////toplevel
159   translate([0, psu_y, psu_z]) {
160     difference(){
161       PsuMountPositive();
162       linextr(-20, 0.1)
163         PsuLedWindowsPlan();
164     }
165     %PsuMountNegative();
166     color("yellow") translate([0,0, -psu_z - ceil])
167       linear_extrude(height=0.4, convexity=10)
168       PsuLedWindowsPlan();
169   }
170 }
171
172 module PsuMountTest(ceil = 2.5) { ////toplevel
173   difference(){
174     union(){
175       translate([0, psu_y, psu_z])
176         PsuMountPositive();
177       difference(){
178         linextr_x_yz(-(psu_sz[0]/2 + 5),
179                      +(psu_sz[0]/2 + 5)){
180           difference(){
181             rectfromto([-ceil, -ceil], [psu_sz[1] + 5, psu_z + 10]);
182             rectfromto([0,0], 400*[1,1]);
183           }
184         }
185         translate([0, psu_y, psu_z]) {
186           PsuMountNegative();
187         }
188       }
189     }
190     translate([0, psu_y, psu_z]) {
191       linextr(-10, 0.1)
192         PsuLedWindowsPlan();
193     }
194   }
195 }