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