chiark / gitweb /
belt-slot-cut-jig: use calculated number of iterations
[reprap-play.git] / belt-slot-cut-jig.scad
1 // -*- C -*-
2
3 // todo
4 //  various registration marks
5 //   protrustions at ends at strap width and middle
6 //   grooves on top face at 1/4,1/2,3/4 length and 1/2 width
7
8 crewpunch_slop = 0.3;
9
10 holder_min_wall = 2;
11 holder_attach_near_wall = 5;
12
13 holder_attach_xsz = 5;
14 holder_ctie_width = 4.0 + 0.5;
15 holder_ctie_thick = 3.0 + 0.5;
16 holder_attach_walls = 3;
17 holder_attach_roof = 2.5;
18
19 holder_corner_round = 2.0;
20
21 jig_interval = 25;
22 strap_width = 26.75 + 0.7;
23 strap_thick = 3;
24 edgewall_width = 3;
25
26 punch_travel = 8;
27
28 main_slop = 0.25;
29
30 jig_max_len = 160; // print diagonally
31 //jig_max_len = 30;
32
33 registrationgroove_width = 0.8;
34 registrationgroove_depth = 1.2;
35
36 registrationprotrusion_poke = 3;
37 registrationprotrusion_slope = 0.75;
38
39 jig_overlap = 1;
40
41 // from careful measurement
42
43 crewpunch_shape =
44   [[  6, [0.6, 6.0], [1.6, 12.3] ],
45    [  8, [1.1, 6.2], [1.9, 12.5] ],
46    [ 10, [1.6, 6.5], [2.1, 12.8] ],
47    [ 12, [1.8, 6.6], [2.3, 12.7] ],
48    [ 14, [2.1, 6.8], [2.6, 13.0] ],
49    [ 16, [2.4, 6.9], [2.7, 13.2] ],
50    [ 18, [2.5, 7.0], [2.9, 13.3] ],
51    [ 22, [3.1, 7.1], [3.2, 13.4] ],
52    [ 26, [3.3, 7.2], [3.5, 13.6] ], 
53    ];
54
55 crewpunch_shaft_max_y = 7.5;
56
57 crewpunch_systematic_size_error = +0.36;
58
59 crewpunch_smallest_shape = crewpunch_shape[0];
60 crewpunch_biggest_shape = crewpunch_shape[len(crewpunch_shape)-1];
61
62 crewpunch_skew_angle = 3.5; //degrees
63 crewpunch_skew_yoff = +1.1; //mm
64
65 // computed
66
67 punch_dx = 0.5 * (-crewpunch_biggest_shape[2][0]
68                   +crewpunch_biggest_shape[2][1]);
69 punch_dy = 0.5 * (+crewpunch_biggest_shape[1][1]
70                   -crewpunch_biggest_shape[1][0]) + crewpunch_skew_yoff;
71
72 attach_ysz = holder_attach_walls*2 + holder_ctie_width;
73
74 holder_block_zsz = crewpunch_biggest_shape[0] - crewpunch_smallest_shape[0];
75 holder_xsz = crewpunch_biggest_shape[2][0] + crewpunch_biggest_shape[2][1] +
76   holder_min_wall*2;
77
78 holder_skewangle_yextra = holder_xsz/2 * sin(abs(crewpunch_skew_angle));
79
80 holder_max_y = punch_dy + crewpunch_biggest_shape[1][0] + holder_min_wall
81   + crewpunch_systematic_size_error + holder_skewangle_yextra;
82
83 holder_attach_max_y = punch_dy
84   - max(crewpunch_biggest_shape[1][1], crewpunch_shaft_max_y)
85   - crewpunch_systematic_size_error - holder_skewangle_yextra;
86
87 holder_block_min_y = punch_dy
88   - crewpunch_biggest_shape[1][1] - holder_attach_near_wall +
89   - crewpunch_systematic_size_error - holder_skewangle_yextra;
90
91 holder_all_min_y = holder_attach_max_y - attach_ysz;
92
93 jig_max_y = max(holder_max_y + main_slop, strap_width/2) + edgewall_width;
94 jig_min_y = min(holder_all_min_y - main_slop, -strap_width/2) - edgewall_width;
95
96 jig_main_zsz = holder_block_zsz + punch_travel;
97
98 jig_ends_extra = 2;
99
100 jig_iters = floor((jig_max_len - jig_ends_extra) / jig_interval);
101 //jig_iters=2;
102 echo(jig_iters);
103
104 // objects
105
106 module CrewPunch(){
107   ourslop = crewpunch_slop - crewpunch_systematic_size_error;
108   hull(){
109     for(layer=crewpunch_shape){
110       translate([0,0, layer[0]]){
111         for(xind=[0,1]) //translate([xind?0:1,0,0])
112           for(yind=[0,1]) //translate([0,yind?0.5:0,0])
113             mirror([xind?1:0,0,0]) mirror([0,yind?0:1,0]){
114               translate([-0.1,-0.1,-0.1])
115                 cube([0.1 + layer[2][xind] + ourslop,
116                       0.1 + layer[1][1-yind] + ourslop,
117                       0.2]);
118             }
119       }
120     }
121   }
122 }
123
124 module MaybeRoundedCube(sizes, roundedness){
125   if (roundedness > 0) {
126     translate([roundedness, roundedness, 0]){
127       minkowski(){
128         cube([sizes[0] - roundedness*2,
129               sizes[1] - roundedness*2,
130               sizes[2]]);
131         cylinder(h=0.05, r=roundedness, $fn=20);
132       }
133     }
134   } else {
135     cube(sizes);
136   }
137 }
138
139 module PunchHolder(cutouts=true){
140   roundedness = cutouts ? holder_corner_round : 0;
141     difference(){
142       translate([-holder_xsz/2, holder_block_min_y, 0])
143         MaybeRoundedCube([holder_xsz,
144                           holder_max_y - holder_block_min_y,
145                           holder_block_zsz],
146                          roundedness);
147       if (cutouts)
148         rotate([0,0,-crewpunch_skew_angle])
149         translate([punch_dx,
150                    punch_dy,
151                    -crewpunch_smallest_shape[0]])
152           CrewPunch();
153     }
154     difference(){
155       translate([-holder_attach_xsz/2, holder_all_min_y, 0])
156         MaybeRoundedCube([holder_attach_xsz,
157                           attach_ysz,
158                           holder_block_zsz + punch_travel
159                           + holder_ctie_thick + holder_attach_roof + 1],
160                          roundedness);
161       if (cutouts)
162         translate([-30,
163                    holder_all_min_y + holder_attach_walls,
164                    holder_block_zsz + punch_travel])
165           cube([60, holder_ctie_width, holder_ctie_thick]);
166     }
167 }
168
169 module RegistrationGroove(l){
170   // runs along the +ve X axis for length l but at correct z pos
171   translate([0, 0, jig_main_zsz + 0.1]) {
172     rotate([90,0,90])
173       linear_extrude(height=l)
174       polygon([[-registrationgroove_width/2, 0],
175                [ +registrationgroove_width/2, 0],
176                [ 0, -registrationgroove_depth ]]);
177   }
178 }
179
180 module OneJig(){
181   difference(){
182     translate([-(jig_interval/2 + jig_overlap),
183                jig_min_y,
184                -strap_thick])
185       cube([jig_interval + 2,
186             jig_max_y - jig_min_y,
187             jig_main_zsz + strap_thick]);
188     minkowski(){
189       cube([main_slop*2, main_slop*2, 50], center=true);
190       PunchHolder(false);
191     }
192     translate([-100, -strap_width/2, -10])
193       cube([200, strap_width, 10]);
194    translate([-100,0,0])
195      RegistrationGroove(200);
196    for (xfrac=[-1/4,0,+1/4])
197      translate([jig_interval * xfrac, -100, 0])
198        rotate([0,0,90])
199        RegistrationGroove(200);
200   }
201 }
202
203 module RegistrationProtrusion(){
204   // points towards the positive x axis
205   xsz = registrationprotrusion_poke;
206   ysz = registrationprotrusion_poke;
207   diag_sz = xsz * sqrt(2);
208   zsz = diag_sz / registrationprotrusion_slope;
209   hull(){
210     translate([0, 0, 0.1]){
211       linear_extrude(height=0.1)
212         polygon([[   0, -ysz ],
213                  [ xsz,    0 ],
214                  [   0,  ysz ]]);
215       translate([-0.1, 0, zsz ])
216         rotate([0,0,45])
217         cube(0.1);
218     }
219   }
220 }
221
222 module Jig(){
223   for(end=[0,1]){
224     for(yfrac=[-1/2, 0, 1/2]){
225       translate([ end
226                   ? jig_interval * (jig_iters - 0.5)
227                   : -jig_interval/2,
228                  yfrac * strap_width,
229                  0])
230         rotate([0,0, end ? 0 : 180])
231         translate([ jig_overlap, 0, 0 ])
232         RegistrationProtrusion();
233     }
234   }
235   for (i=[0:jig_iters-1]) {
236     translate([jig_interval * i, 0, 0])
237       OneJig();
238   }
239 }
240
241 module JigT(){ ////toplevel
242   rotate([0,0,-45])
243     translate([0,0,jig_main_zsz])
244     rotate([180,0,0])
245     Jig();
246 }
247
248 module PunchHolderT(){ ////toplevel
249   PunchHolder(true);
250 }
251
252 module Demo(){ ////toplevel
253   %PunchHolder();
254   Jig();
255 }
256
257 module Kit(){ ////toplevel
258   JigT();
259   rotate([0,0,-45]){
260     translate([(jig_iters-1)*jig_interval/2,
261                jig_min_y - holder_max_y - 5,
262                0])
263       PunchHolder();
264   }
265 }
266
267 //CrewPunch();
268 //PunchHolder();
269 //PunchHolder(false);
270 //OneJig();
271 //Jig();
272 //Demo();
273 //JigT();
274 //RegistrationProtrusion();
275 //PunchHolderT();
276 //Kit();