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