chiark / gitweb /
powerbank-bike-clamp: rotate, for test print
[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_factor = 1.5;
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 // calculated
39
40 hinge_stride = (clamp_width + hinge_gap_z) / hinge_lobes;
41
42 main_r = tube_dia/2 + main_th;
43
44 hinge_outer_r = hinge_around + hinge_pin/2;
45 hinge_y = tube_dia/2 + hinge_outer_r;
46
47 screw_max_y_lhs = -main_r -screw_nut_across/2;
48 screw_max_y_rhs = -main_r -knob_behind_across/2;
49
50 screw_y = min(screw_max_y_lhs,
51               screw_max_y_rhs);
52
53 bot_y = screw_y -max( screw_nut_across, knob_behind_across/2 )
54   -minor_wall_min;
55
56 echo(bot_y);
57
58 module TubePlan(){ circle(r = tube_dia/2); }
59 module HingePinPlan(){ translate([0, hinge_y]) circle(r= hinge_pin/2); }
60 module HingeBodyPlan(){ translate([0, hinge_y]) circle(r= hinge_outer_r); }
61
62 module TubeClampLeftPlan(){
63   difference(){
64     union(){
65       polygon([[ 0,                    hinge_y + hinge_outer_r ],
66                [ -main_r + overlap_l,  hinge_y + hinge_outer_r ],
67                [ -main_r + overlap_l,  bot_y                   ],
68                [ -clamp_gap/2,         bot_y                   ],
69                [ -clamp_gap/2,         0,                      ],
70                [ 0,                    0,                      ],
71                ]);
72       HingeBodyPlan();
73     }
74     TubePlan();
75     HingePinPlan();
76   }
77 }
78
79 module TubeClampLeft() { ////toplevel
80   linextr(-clamp_width/2, clamp_width/2)
81     TubeClampLeftPlan();
82 }
83
84 module TubeClampRightPlan(){
85   difference(){
86     union(){
87       rectfromto([ clamp_gap/2,                   bot_y ],
88                  [ clamp_gap/2 + behind_knob_th,  0     ]);
89       intersection(){
90         circle(r= main_r);
91         union(){
92           rectfromto([0,0],
93                       main_r *  [5,5]);
94           rectfromto([ clamp_gap/2, main_r*5 ],
95                       main_r * [2,-5]);
96         }
97       }
98       HingeBodyPlan();
99     }
100     TubePlan();
101     HingePinPlan();
102   }
103 }
104
105 module SomeClamp(hinge_alt=false){
106   difference(){
107     linextr(-clamp_width/2, clamp_width/2)
108       children(0);
109
110     linextr_x_yz(-main_r*5, main_r*5)
111       translate([screw_y, 0])
112       circle(r= screw/2);
113
114     for (i=[0 : hinge_lobes-1]) {
115       translate([0,
116                  hinge_y,
117                  -clamp_width/2 + i * hinge_stride
118                  + (hinge_alt ? hinge_stride/2 : 0)
119                  ])
120         linextr(-hinge_gap_z, hinge_stride/2)
121         square(hinge_outer_r*2 + hinge_gap_xy, center=true);
122     }
123   }
124 }
125
126 module TubeClampLeft() { ////toplevel
127   difference(){
128     SomeClamp(true)
129       TubeClampLeftPlan();
130
131     translate([0, screw_y, 0]) {
132       linextr_x_yz(-(clamp_gap/2 + screw_nut_th), 0)
133         square([screw_nut_across, screw_nut_across * bridge_slop_factor],
134                center=true);
135
136       linextr_x_yz(-main_r, -main_r + screw_head_h)
137         square([screw_head, screw_head * bridge_slop_factor],
138                center=true);
139     }
140   }
141 }
142
143 module TubeClampRight() { ////toplevel
144   rotate([180,0,0])
145     SomeClamp()
146     TubeClampRightPlan();
147 }
148
149 module TubeClampDemo() { ////toplevel
150   TubeClampLeft();
151   rotate([180,0,0])
152     TubeClampRight();
153 }