chiark / gitweb /
powerbank-bike-clamp: wip
[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.5; // xxx
9 main_th = 3;
10 minor_wall_min = 1;
11
12 screw = 5.0 + 0.75;
13 screw_head = 10; // xxx
14 screw_nut_across = 10; // xxx
15 screw_nut_th = 5; // xxx
16 screw_head_h = 5; // xxx
17
18 knob_behind_across = 15; // xxx
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 $fs = 0.1;
32 $fa = 5;
33
34 // calculated
35
36 main_r = tube_dia/2 + main_th;
37
38 hinge_outer_r = hinge_around + hinge_pin/2;
39 hinge_y = tube_dia/2 + hinge_outer_r;
40
41 screw_max_y_lhs = -main_r -screw_nut_across/2;
42 screw_max_y_rhs = -main_r -knob_behind_across/2;
43
44 screw_y = min(screw_max_y_lhs,
45               screw_max_y_rhs);
46
47 bot_y = screw_y -max( screw_nut_across, knob_behind_across/2 )
48   -minor_wall_min;
49
50 echo(bot_y);
51
52 module TubePlan(){ circle(r = tube_dia/2); }
53 module HingePinPlan(){ translate([0, hinge_y]) circle(r= hinge_pin/2); }
54 module HingeBodyPlan(){ translate([0, hinge_y]) circle(r= hinge_outer_r); }
55
56 module TubeClampLeftPlan(){
57   difference(){
58     union(){
59       polygon([[ 0,                    hinge_y + hinge_outer_r ],
60                [ -main_r + overlap_l,  hinge_y + hinge_outer_r ],
61                [ -main_r + overlap_l,  bot_y                   ],
62                [ -clamp_gap/2,         bot_y                   ],
63                [ -clamp_gap/2,         0,                      ],
64                [ 0,                    0,                      ],
65                ]);
66       HingeBodyPlan();
67     }
68     TubePlan();
69     HingePinPlan();
70   }
71 }
72
73 module TubeClampLeft() { ////toplevel
74   linextr(-clamp_width/2, clamp_width/2)
75     TubeClampLeftPlan();
76 }
77
78 module TubeClampRightPlan(){
79   difference(){
80     union(){
81       rectfromto([ clamp_gap/2,                   bot_y ],
82                  [ clamp_gap/2 + behind_knob_th,  0     ]);
83       intersection(){
84         circle(r= main_r);
85         union(){
86           rectfromto([0,0],
87                       main_r *  [5,5]);
88           rectfromto([ clamp_gap/2, main_r*5 ],
89                       main_r * [2,-5]);
90         }
91       }
92       HingeBodyPlan();
93     }
94     TubePlan();
95     HingePinPlan();
96   }
97 }
98
99 module SomeClamp(){
100   difference(){
101     linextr(-clamp_width/2, clamp_width/2)
102       children(0);
103
104     linextr_x_yz(-main_r*5, main_r*5)
105       translate([screw_y, 0])
106       circle(r= screw/2);
107   }
108 }
109
110 module TubeClampLeft() { ////toplevel
111   difference(){
112     SomeClamp()
113       TubeClampLeftPlan();
114
115     translate([0, screw_y, 0]) {
116       linextr_x_yz(-(clamp_gap/2 + screw_nut_th), 0)
117         square([screw_nut_across, screw_nut_across * bridge_slop_factor],
118                center=true);
119
120       linextr_x_yz(-main_r, -main_r + screw_head_h)
121         square([screw_head, screw_head * bridge_slop_factor],
122                center=true);
123     }
124   }
125 }
126
127 module TubeClampRight() { ////toplevel
128   SomeClamp()
129     TubeClampRightPlan();
130 }
131
132 //TubeClampLeft();
133 //TubeClampRight();
134