chiark / gitweb /
powerbank-bike-clamp: rotate (comment, format, nfc)
[reprap-play.git] / powerbank-bike-clamp.scad
1 // -*- C -*-
2
3 include <utils.scad>
4
5 tube_dia = 22.4;
6
7 hinge_around = 2.5;
8 hinge_pin = 1.8 + 0.75;
9 main_th = 3;
10 minor_wall_min = 1;
11
12 screw = 5.0 + 0.75;
13 screw_head = 8.7 + 1.2;
14 screw_nut_across = 7.9 + 0.75;
15 screw_nut_th = 3.9 + 0.75;
16 screw_head_h = 3.6 + 0.75;
17
18 knob_behind_across = 12.2 + 0.75;
19 behind_knob_th = 5;
20
21 clamp_width = 20;
22
23 clamp_gap = 2;
24
25 lower_th = 1;
26
27 overlap_l = 0.1;
28
29 bridge_slop = 1.2;
30
31 hinge_lobes = 2;
32 hinge_gap_z = 0.75;
33 hinge_gap_xy = 0.75;
34
35 $fs = 0.1;
36 $fa = 5;
37
38 bank_eps_bbox_x = [149, 598];
39 bank_eps_bbox_y = [274, 1452];
40
41 bank_x_sz = (24.9 + 0.5);
42 bank_recess_y = 5;
43 bank_recess_dx = 3;
44
45 strap_th = 3;
46 strap_above = 2.5;
47
48 // calculated
49
50 pspt_to_mm = 25.4 / 72;
51
52 hinge_stride = (clamp_width + hinge_gap_z) / hinge_lobes;
53
54 main_r = tube_dia/2 + main_th;
55
56 hinge_outer_r = hinge_around + hinge_pin/2;
57 hinge_y = tube_dia/2 + hinge_outer_r;
58
59 screw_max_y_lhs = -main_r -screw_nut_across/2;
60 screw_max_y_rhs = -main_r -knob_behind_across/2;
61
62 screw_y = min(screw_max_y_lhs,
63               screw_max_y_rhs);
64
65 bot_y = screw_y -max( screw_nut_across, knob_behind_across/2 )
66   -minor_wall_min;
67
68 holder_x_sz = bank_x_sz + bank_recess_dx*2;
69 bank_bot_y = strap_above + strap_th;
70 strap_r = strap_th;
71
72 echo(bot_y);
73
74 module TubePlan(){ circle(r = tube_dia/2); }
75 module HingePinPlan(){ translate([0, hinge_y]) circle(r= hinge_pin/2); }
76 module HingeBodyPlan(){ translate([0, hinge_y]) circle(r= hinge_outer_r); }
77
78 module TubeClampLeftPlan(){
79   difference(){
80     union(){
81       polygon([[ 0,                    hinge_y + hinge_outer_r ],
82                [ -main_r + overlap_l,  hinge_y + hinge_outer_r ],
83                [ -main_r + overlap_l,  bot_y                   ],
84                [ -clamp_gap/2,         bot_y                   ],
85                [ -clamp_gap/2,         0,                      ],
86                [ 0,                    0,                      ],
87                ]);
88       HingeBodyPlan();
89     }
90     TubePlan();
91     HingePinPlan();
92   }
93 }
94
95 module TubeClampLeft() { ////toplevel
96   linextr(-clamp_width/2, clamp_width/2)
97     TubeClampLeftPlan();
98 }
99
100 module TubeClampRightPlan(){
101   difference(){
102     union(){
103       rectfromto([ clamp_gap/2,                   bot_y ],
104                  [ clamp_gap/2 + behind_knob_th,  0     ]);
105       intersection(){
106         circle(r= main_r);
107         union(){
108           rectfromto([0,0],
109                       main_r *  [5,5]);
110           rectfromto([ clamp_gap/2, main_r*5 ],
111                       main_r * [2,-5]);
112         }
113       }
114       HingeBodyPlan();
115     }
116     TubePlan();
117     HingePinPlan();
118   }
119 }
120
121 module SomeClamp(hinge_alt=false){
122   difference(){
123     linextr(-clamp_width/2, clamp_width/2)
124       children(0);
125
126     linextr_x_yz(-main_r*5, main_r*5)
127       translate([screw_y, 0])
128       circle(r= screw/2);
129
130     for (i=[0 : hinge_lobes-1]) {
131       translate([0,
132                  hinge_y,
133                  -clamp_width/2 + i * hinge_stride
134                  + (hinge_alt ? hinge_stride/2 : 0)
135                  ])
136         linextr(-hinge_gap_z, hinge_stride/2)
137         square(hinge_outer_r*2 + hinge_gap_xy, center=true);
138     }
139   }
140 }
141
142 module PowerBankItselfSidePlan(){
143   translate([0, bank_bot_y])
144     scale( bank_x_sz / ( (
145                           bank_eps_bbox_x[1] -
146                           bank_eps_bbox_x[0]
147                           ) * pspt_to_mm ))
148     translate(pspt_to_mm *
149               [-0.5 * (bank_eps_bbox_x[0] +
150                        bank_eps_bbox_x[1]),
151                -bank_eps_bbox_y[0]])
152     import("powerbank-anker-10000.dxf", convexity=5);
153 }
154
155 module PowerBankSidePlan(){ ////toplevel
156   render() difference(){
157     rectfromto([ -holder_x_sz/2,  0 ],
158                [ +holder_x_sz/2,  bank_recess_y + bank_bot_y ]);
159
160     PowerBankItselfSidePlan();
161   }
162 }
163
164 module PowerBankStrapCut(){ ////toplevel
165   difference(){
166     rectfromto([ -holder_x_sz, -0.05 ],
167                [ +holder_x_sz, strap_th + strap_r ]);
168     hull(){
169       for (sx=[-1,+1]) {
170         translate([sx * (holder_x_sz/2 - strap_r + 0.1),
171                    strap_th + strap_r])
172           circle(strap_r);
173       }
174     }
175   }
176 }
177
178 module PowerBankHolderTest(){ ////toplevel
179   difference(){
180     linextr(-20,20) PowerBankSidePlan();
181     linextr(0, strap_th) PowerBankStrapCut();
182   }
183 }
184
185 module TubeClampLeft() { ////toplevel
186   // We want this to print with the recess overhand to the right
187   // where the workpiece cooling fan is
188   rotate([0,0,180]){
189     difference(){
190       SomeClamp(true)
191         TubeClampLeftPlan();
192
193       translate([0, screw_y, 0]) {
194         linextr_x_yz(-(clamp_gap/2 + screw_nut_th), 0)
195           square([screw_nut_across,
196                   screw_nut_across / cos(30) + bridge_slop*2],
197                  center=true);
198
199         linextr_x_yz(-main_r, -main_r + screw_head_h)
200           square([screw_head, screw_head + bridge_slop*2],
201                  center=true);
202       }
203     }
204   }
205 }
206
207 module TubeClampRight() { ////toplevel
208   rotate([0,0,180])
209     rotate([180,0,0])
210     SomeClamp()
211     TubeClampRightPlan();
212 }
213
214 module TubeClampDemo() { ////toplevel
215   TubeClampLeft();
216   rotate([180,0,0])
217     TubeClampRight();
218 }