]> www.fi.muni.cz Git - bike-lights.git/blob - parts/rearlight.scad
00a3cf625caeac0028454c830f0f29212b0dc6ca
[bike-lights.git] / parts / rearlight.scad
1 // Holder for Fraen FHS-HEB1-LB01-x lens for Luxeon LEDs.
2 // I use it for my rear lights.
3
4 epsilon = 0.01;
5 infty = 100;
6 debug = 0;
7
8 heatsink_thickness = 2.5;
9 heatsink_width = 18-3.4;
10 heatsink_length = 58;
11
12 module fraen_lens_pin() {
13         cylinder(r1=2, r2=6.15/2, h=23);
14         translate([epsilon, 0, -5])
15                 cylinder(r=3.4/2, h=5+epsilon);
16 };
17
18 module fraen_lens() {
19         cylinder(r1=6, r2=30.51/2, h=23);
20         translate([9, 9, 0])   fraen_lens_pin();
21         translate([9, -9, 0])  fraen_lens_pin();
22         translate([-9, 9, 0])  fraen_lens_pin();
23         translate([-9, -9, 0]) fraen_lens_pin();
24 };
25
26 module heatsink() {
27         translate([-heatsink_length+ 5 +heatsink_width/2, -heatsink_width/2, 0])
28                 cube([heatsink_length, heatsink_width, heatsink_thickness]);
29 }
30
31 module seat_holder() {
32         translate([-41, 8, 29])
33                 cube([3, 30, 60], center=true);
34 };
35
36 module stem_ellipse(h, w, x, y) {
37         translate([x, y, 0])
38         difference() {
39                 translate([0, 0, 6])
40                         scale([1, w/2, h-6])
41                                 rotate([0, 90, 0])
42                                         cylinder(r=1, h=epsilon);
43                 translate([0, 0, -100]) cube([200, 200, 200], center=true);
44         };
45 }
46
47 module main() {
48         difference() {
49                 union() {
50                         hull() {
51                                 cylinder(r=34/2, h=33);
52                                 stem_ellipse(h = 15, w = 10, x = -21, y=-5);
53                         };
54                         hull() {
55                                 stem_ellipse(h = 15, w = 10, x = -21-epsilon, y=-5);
56                                 stem_ellipse(h = 15, w = 10, x = -33, y=-5);
57                         };
58                         hull() {
59                                 stem_ellipse(h = 15, w = 10, x = -33-epsilon, y=-5);
60                                 stem_ellipse(h = 25, w = 15, x = -40+epsilon, y=-2.5);
61                         };
62                         translate([-41, 5, 52/2])
63                                 cube([7, 30, 52], center=true);
64                         // bolt hole ring
65                         translate([-44+epsilon, 10, 40]) rotate([0, -90, 0]) difference() {
66                                 cylinder(r1=9, r2=6, h=3);
67                                 translate([0, 0, -epsilon])
68                                         cylinder(r=5, h=3+2*epsilon, $fn=6);
69                         }
70                         // screw hole ring
71                         translate([-38-epsilon, 10, 40]) rotate([0, 90, 0]) difference() {
72                                 cylinder(r1=9, r2=6, h=3);
73                                 translate([0, 0, -epsilon])
74                                         cylinder(r=5, h=3+2*epsilon);
75                         }
76                 };
77                 translate([-47, 10, 40]) rotate([0, 90, 0])
78                         cylinder(r=2.5, h=12);
79                 translate([0, 0, 6-heatsink_thickness])
80                         cylinder(r=31/2, h=32);
81                 translate([0, 0, 6])
82                         fraen_lens();
83                 heatsink();
84                 seat_holder();
85         }
86         if (debug == 1) {
87                 translate([0, 0, 6]) color("gray") fraen_lens();
88                 color("lightblue") heatsink();
89                 color("lightgreen") seat_holder();
90         }
91 }
92
93 module bolt_mount(d, h, w1, w2, fn) {
94         difference() {
95                 translate([0, 0, -epsilon])
96                         cylinder(r1=w2/2, r2=w1/2, h=h+epsilon);
97                 translate([0, 0, -2*epsilon])
98                 cylinder(r=d/2, h=h+3*epsilon, $fn=fn);
99         };
100 };
101
102 clip_h1 = 25; // inner height
103 clip_h2 = 18; // inner height
104 clip_l  = 35;
105 clip_wall = 2;
106 clip_space = 4;
107 clip_bolt1_x = 10;
108 clip_bolt2_x = 25;
109
110 module clip_top_circle() {
111         rotate([-90, 0, 0])
112         difference() {
113                 translate([-clip_space/2, 0, 0])
114                         cylinder(r=clip_wall, h = epsilon, $fn=32);
115                 translate([-infty/2, clip_wall/2-epsilon, -epsilon])
116                         cube(infty);
117                 translate([clip_wall+epsilon, -infty/2, -epsilon])
118                         cube(infty);
119         };
120 };
121
122 module clip_top() {
123         hull() {
124                 translate([0, 0, clip_h1/2+clip_wall])
125                         clip_top_circle();
126                 translate([0, clip_l-epsilon, clip_h2/2+clip_wall])
127                         clip_top_circle();
128         };
129 };
130
131 module seat_clip() {
132         difference() {
133                 polyhedron(points = [
134                         [-clip_wall-clip_space/2, 0, clip_h1/2+clip_wall],
135                         [-clip_wall-clip_space/2, clip_l, clip_h2/2+clip_wall],
136                         [-clip_wall-clip_space/2, clip_l, -clip_h2/2],
137                         [-clip_wall-clip_space/2, 0, -clip_h1/2],
138                         [ clip_wall+clip_space/2,  0, clip_h1/2+clip_wall],
139                         [ clip_wall+clip_space/2, clip_l, clip_h2/2+clip_wall],
140                         [ clip_wall+clip_space/2, clip_l, -clip_h2/2],
141                         [ clip_wall+clip_space/2, 0, -clip_h1/2],
142                 ], triangles = [
143                         [0, 2, 1], [3, 2, 0], [4, 5, 6], [6, 7, 4],
144                         [0, 1, 5], [5, 4, 0], [2, 3, 7], [7, 6, 2],
145                         [1, 2, 6], [6, 5, 1], [0, 7, 3], [7, 0, 4],
146                 ]);
147                 polyhedron(points = [
148                         [-clip_space/2, -epsilon, clip_h1/2],
149                         [-clip_space/2, clip_l+epsilon, clip_h2/2],
150                         [-clip_space/2, clip_l+epsilon, -clip_h2/2-epsilon],
151                         [-clip_space/2, -epsilon, -clip_h1/2-epsilon],
152                         [ clip_space/2, -epsilon, clip_h1/2],
153                         [ clip_space/2, clip_l+epsilon, clip_h2/2],
154                         [ clip_space/2, clip_l+epsilon, -clip_h2/2-epsilon],
155                         [ clip_space/2, -epsilon, -clip_h1/2-epsilon],
156                 ], triangles = [
157                         [0, 2, 1], [3, 2, 0], [4, 5, 6], [6, 7, 4],
158                         [0, 1, 5], [5, 4, 0], [2, 3, 7], [7, 6, 2],
159                         [1, 2, 6], [6, 5, 1], [0, 7, 3], [7, 0, 4],
160                 ]);
161                 // bolt holes
162                 translate([0, clip_bolt1_x, 0])
163                         rotate([0, 90, 0])
164                         translate([0, 0, -clip_wall-clip_space/2-epsilon])
165                         cylinder(r=1.5, h=2*clip_wall+clip_space+2*epsilon);
166                 translate([0, clip_bolt2_x, 0])
167                         rotate([0, 90, 0])
168                         translate([0, 0, -clip_wall-clip_space/2-epsilon])
169                         cylinder(r=1.5, h=2*clip_wall+clip_space+2*epsilon);
170         };
171
172         translate([-clip_space, clip_bolt1_x, 0])
173         rotate([0, -90, 0])
174         bolt_mount(6, 3, 7, 14, 6);
175
176         translate([-clip_space, clip_bolt2_x, 0])
177         rotate([0, -90, 0])
178         bolt_mount(6, 3, 7, 14, 6);
179
180         translate([clip_space, clip_bolt1_x, 0])
181         rotate([0, 90, 0])
182         bolt_mount(6, 3, 7, 14, 128);
183
184         translate([clip_space, clip_bolt2_x, 0])
185         rotate([0, 90, 0])
186         bolt_mount(6, 3, 7, 14, 128);
187
188         clip_top();
189 };
190
191 seat_clip();
192
193 difference() {
194         union() {
195                 hull() {
196                         translate([40, epsilon, 2])
197                                 clip_top();
198                         clip_top();
199                 };
200
201                 translate([40, 0, 25])
202                         rotate([-90, 0, 0])
203                                 cylinder(r=34/2, h=clip_l);
204
205                 hull() {
206                         translate([clip_space/2+epsilon, 0, 0])
207                                 cube([clip_wall-epsilon, clip_wall, clip_h1/2+2*clip_wall-epsilon]);
208                         translate([40, 0, 14+epsilon])
209                                 cube([clip_wall-epsilon, clip_wall, 34/2]);
210                 };
211         };
212         translate([40, 6, 25])
213                 rotate([-90, 0, 0]) {
214                         cylinder(r=31/2, h=clip_l);
215                         fraen_lens();
216                         heatsink();
217                 };
218 };
219
220 /*
221 if (debug == 1) {
222         difference() {
223                 main($fn=64);
224                 //translate([0, -100, 0]) cube([200, 200, 200], center=true);
225                 rotate([0, 0, 40])translate([0, -100, 0]) cube([200, 200, 200], center=true);
226         };
227 } else {
228         main($fn=128);
229 }
230 */