chiark / gitweb /
powerbank-bike-clamp: wip recess
[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 echo(bot_y);
69
70 module TubePlan(){ circle(r = tube_dia/2); }
71 module HingePinPlan(){ translate([0, hinge_y]) circle(r= hinge_pin/2); }
72 module HingeBodyPlan(){ translate([0, hinge_y]) circle(r= hinge_outer_r); }
73
74 module TubeClampLeftPlan(){
75   difference(){
76     union(){
77       polygon([[ 0,                    hinge_y + hinge_outer_r ],
78                [ -main_r + overlap_l,  hinge_y + hinge_outer_r ],
79                [ -main_r + overlap_l,  bot_y                   ],
80                [ -clamp_gap/2,         bot_y                   ],
81                [ -clamp_gap/2,         0,                      ],
82                [ 0,                    0,                      ],
83                ]);
84       HingeBodyPlan();
85     }
86     TubePlan();
87     HingePinPlan();
88   }
89 }
90
91 module TubeClampLeft() { ////toplevel
92   linextr(-clamp_width/2, clamp_width/2)
93     TubeClampLeftPlan();
94 }
95
96 module TubeClampRightPlan(){
97   difference(){
98     union(){
99       rectfromto([ clamp_gap/2,                   bot_y ],
100                  [ clamp_gap/2 + behind_knob_th,  0     ]);
101       intersection(){
102         circle(r= main_r);
103         union(){
104           rectfromto([0,0],
105                       main_r *  [5,5]);
106           rectfromto([ clamp_gap/2, main_r*5 ],
107                       main_r * [2,-5]);
108         }
109       }
110       HingeBodyPlan();
111     }
112     TubePlan();
113     HingePinPlan();
114   }
115 }
116
117 module SomeClamp(hinge_alt=false){
118   difference(){
119     linextr(-clamp_width/2, clamp_width/2)
120       children(0);
121
122     linextr_x_yz(-main_r*5, main_r*5)
123       translate([screw_y, 0])
124       circle(r= screw/2);
125
126     for (i=[0 : hinge_lobes-1]) {
127       translate([0,
128                  hinge_y,
129                  -clamp_width/2 + i * hinge_stride
130                  + (hinge_alt ? hinge_stride/2 : 0)
131                  ])
132         linextr(-hinge_gap_z, hinge_stride/2)
133         square(hinge_outer_r*2 + hinge_gap_xy, center=true);
134     }
135   }
136 }
137
138 module PowerBankSidePlan(){ ////toplevel
139   render() difference(){
140     rectfromto([ -(bank_x_sz/2 + bank_recess_dx),  -(strap_above + strap_th) ],
141                [ +(bank_x_sz/2 + bank_recess_dx),  bank_recess_y ]);
142
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
155 module PowerBankHolder(){ ////toplevel
156   
157 }
158
159 module TubeClampLeft() { ////toplevel
160   difference(){
161     SomeClamp(true)
162       TubeClampLeftPlan();
163
164     translate([0, screw_y, 0]) {
165       linextr_x_yz(-(clamp_gap/2 + screw_nut_th), 0)
166         square([screw_nut_across,
167                 screw_nut_across / cos(30) + bridge_slop*2],
168                center=true);
169
170       linextr_x_yz(-main_r, -main_r + screw_head_h)
171         square([screw_head, screw_head + bridge_slop*2],
172                center=true);
173     }
174   }
175 }
176
177 module TubeClampRight() { ////toplevel
178   rotate([180,0,0])
179     SomeClamp()
180     TubeClampRightPlan();
181 }
182
183 module TubeClampDemo() { ////toplevel
184   TubeClampLeft();
185   rotate([180,0,0])
186     TubeClampRight();
187 }