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