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