chiark / gitweb /
powerbank-bike-clamp: wip recess, move nfc and other work
[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
71 echo(bot_y);
72
73 module TubePlan(){ circle(r = tube_dia/2); }
74 module HingePinPlan(){ translate([0, hinge_y]) circle(r= hinge_pin/2); }
75 module HingeBodyPlan(){ translate([0, hinge_y]) circle(r= hinge_outer_r); }
76
77 module TubeClampLeftPlan(){
78   difference(){
79     union(){
80       polygon([[ 0,                    hinge_y + hinge_outer_r ],
81                [ -main_r + overlap_l,  hinge_y + hinge_outer_r ],
82                [ -main_r + overlap_l,  bot_y                   ],
83                [ -clamp_gap/2,         bot_y                   ],
84                [ -clamp_gap/2,         0,                      ],
85                [ 0,                    0,                      ],
86                ]);
87       HingeBodyPlan();
88     }
89     TubePlan();
90     HingePinPlan();
91   }
92 }
93
94 module TubeClampLeft() { ////toplevel
95   linextr(-clamp_width/2, clamp_width/2)
96     TubeClampLeftPlan();
97 }
98
99 module TubeClampRightPlan(){
100   difference(){
101     union(){
102       rectfromto([ clamp_gap/2,                   bot_y ],
103                  [ clamp_gap/2 + behind_knob_th,  0     ]);
104       intersection(){
105         circle(r= main_r);
106         union(){
107           rectfromto([0,0],
108                       main_r *  [5,5]);
109           rectfromto([ clamp_gap/2, main_r*5 ],
110                       main_r * [2,-5]);
111         }
112       }
113       HingeBodyPlan();
114     }
115     TubePlan();
116     HingePinPlan();
117   }
118 }
119
120 module SomeClamp(hinge_alt=false){
121   difference(){
122     linextr(-clamp_width/2, clamp_width/2)
123       children(0);
124
125     linextr_x_yz(-main_r*5, main_r*5)
126       translate([screw_y, 0])
127       circle(r= screw/2);
128
129     for (i=[0 : hinge_lobes-1]) {
130       translate([0,
131                  hinge_y,
132                  -clamp_width/2 + i * hinge_stride
133                  + (hinge_alt ? hinge_stride/2 : 0)
134                  ])
135         linextr(-hinge_gap_z, hinge_stride/2)
136         square(hinge_outer_r*2 + hinge_gap_xy, center=true);
137     }
138   }
139 }
140
141 module PowerBankItselfSidePlan(){
142   translate([0, bank_bot_y])
143     scale( bank_x_sz / ( (
144                           bank_eps_bbox_x[1] -
145                           bank_eps_bbox_x[0]
146                           ) * pspt_to_mm ))
147     translate(pspt_to_mm *
148               [-0.5 * (bank_eps_bbox_x[0] +
149                        bank_eps_bbox_x[1]),
150                -bank_eps_bbox_y[0]])
151     import("powerbank-anker-10000.dxf", convexity=5);
152 }
153
154 module PowerBankSidePlan(){ ////toplevel
155   render() difference(){
156     rectfromto([ -holder_x_sz/2,  0 ],
157                [ +holder_x_sz/2,  bank_recess_y + bank_bot_y ]);
158
159     PowerBankItselfSidePlan();
160   }
161 }
162 /*
163 module PowerBankStrapNocut(){ ////toplevel
164   hull(){
165     for (sx=[-1,+1]) {
166       translate(
167 */
168 module PowerBankHolderTest(){ ////toplevel
169   
170 }
171
172 module TubeClampLeft() { ////toplevel
173   difference(){
174     SomeClamp(true)
175       TubeClampLeftPlan();
176
177     translate([0, screw_y, 0]) {
178       linextr_x_yz(-(clamp_gap/2 + screw_nut_th), 0)
179         square([screw_nut_across,
180                 screw_nut_across / cos(30) + bridge_slop*2],
181                center=true);
182
183       linextr_x_yz(-main_r, -main_r + screw_head_h)
184         square([screw_head, screw_head + bridge_slop*2],
185                center=true);
186     }
187   }
188 }
189
190 module TubeClampRight() { ////toplevel
191   rotate([180,0,0])
192     SomeClamp()
193     TubeClampRightPlan();
194 }
195
196 module TubeClampDemo() { ////toplevel
197   TubeClampLeft();
198   rotate([180,0,0])
199     TubeClampRight();
200 }