summaryrefslogtreecommitdiff
path: root/body/stand.scad
blob: ea450b4aa4e65e1f813e86872eb1092198493b42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
include <body.scad>
include <body_config.scad>
include <helpers.scad>
include <holes.scad>

// 80 35 15

// screw holes on back plate
// 42.5 47.5

// back plate height from profile 47, thickness 10
// full h 67
back_plate_s = [80, 10, 67];
bps = back_plate_s;
// dist bitw back plate and back screw holder 26
bp_bsh_dist = 26;

// openscad y is scanner z, and wise versa
back_screw_holder_s = [80, 15, 35];
bshs = back_screw_holder_s;

// for base part mounted on profiles
base_wall_thickness = 10;
bwt = base_wall_thickness;

side_wall_s = [bwt, 65, 55];
sws = side_wall_s;

limit_switch_pcb_s = [40, 17, 1.6];
ls_pcb_s = limit_switch_pcb_s;

carriage_s = [80, 50, 32];
// scanner coords
carriage_top_y_offset = 56;
carriage_z_pos = 240;

module profile_20x20x50()
{
    scale([1, 1, 10])
    translate([-0.06, -61, -10])
    import("Modular profile 20x20 - 973094/files/Profilo_20x20_L50.stl");
}

module calibration_template()
{
    zo = 5;
    cs = carriage_s;
    // TODO: create a global var for this
    lhs = laser_holder_size();
    
    top_s = [bshs[0] + bwt * 2, sws[1], wt * 2];
    cut_s = [main_frame_width_x, sws[1] * 2, wt + $tiny_padding * 2];
    
    // decrease if there are some reflections
    adjustment_z = -0;
    
    translate([0, carriage_z_pos + carriage_s[1] - 5, lhs[2] / 2])
    translate([0, top_s[1] / 2, cut_s[2] / 2 + bshs[2] + bwt + wt])
    // arranged: should switch from triangles to surface
    // by rotating by 180 around scanner z axis
    translate([0, 0, adjustment_z])
    union()
    {        
        // centered
        rotate([0, 180, 0])
        {
            color("green", 0.3)
            translate([-125, 0, zo])
            translate([85, -50, -5.8])
            rotate([-90, 0, 0])
            rotate([0, 90, 0])
            import("calibration_template.stl");
        }
        
        {
            color("blue", 0.3)
            translate([-125, 0, zo])
            translate([85, -54, -5.8])
            rotate([-90, 0, 0])
            rotate([0, 90, 0])
            import("calibration_template.stl");
        }
        
        color("blue")
        {
            x_offsets = [-30, 0, 30];
            y_offsets = [0, 4];
            
            for (xo = x_offsets, yo = y_offsets)
            {
                translate([xo, -cs[1] + 0.45 + yo, 0])
                cylinder($fn = dToFn(m3), d = m3, h = 100, center = true);
            }
        }
    }
}

module calibration_template_holder()
{
    cs = carriage_s;
    
    calibration_template_holder_s = [cs[0], cs[1], 8];
    cths = calibration_template_holder_s;
    
    yo = cs[1] / 2 + carriage_z_pos;
    //zo = -cs[2] / 2 - 20 + carriage_top_y_offset;// + cs[2];
    zo = - 20 + carriage_top_y_offset + cths[2] / 2;


    difference()
    {
        translate([0, yo, zo])
        {
            color("orange", 0.5)
            cube(cths, center = true);
            
            top_cube_s = [cths[0], 13, 10.5];
            tcs = top_cube_s;
            
            color("red", 0.5)
            translate([-tcs[0] / 2, -3, 4])
            cube(tcs);
        }
        
        //color("red")
        translate([0, 0, cths[2] / 2])
        carriage_screw_holes();
    }
}

module calibration_template_holder_to_print()
{
    difference()
    {
        calibration_template_holder();
        calibration_template();
    }
}


// hot inserts for m4 are not needed;
// d_padding - diameter delta. can be set to 0
// if cutting a thread with a screw is needed, and
// to 0.5 for just a screw hole
module m4_screw_hole(hole_side, d_padding = 0.5)
{
    screw_hole(
        m = m4 + 0.2,
        id = m4 + 0.5,
        il = 15,
        hd = m4_head_diameter + 1,
        hh = m4_head_height,
        hs = hole_side);
}

module base_side_screw_holes()
{
    // right x offset
    rxo = bshs[0] / 2 + bwt - m4_head_height;
    lxo = -rxo;
    // back y offset
    byo = sws[1] * 1 / 8;
    fyo = sws[1] * 7 / 8;
    zo = -20 / 2;
    
    translate([lxo, byo, zo])
    m4_screw_hole(hole_side_left);

    translate([lxo, fyo, zo])
    m4_screw_hole(hole_side_left);

    translate([rxo, byo, zo])
    m4_screw_hole(hole_side_right);

    translate([rxo, fyo, zo])
    m4_screw_hole(hole_side_right);
}

limit_switch_pcb_screw_hole_d = 3.5;
lspshd = limit_switch_pcb_screw_hole_d;
// dist betw holes 19 14
// dist betw hole side and short qpcb side = 1-1.1,
// and 1.3 for long pcb side
ls_pcb_h_delta_long = 1.3;
ls_pcb_h_delta_short = 1.1;
ls_pcb_h_delta_btw_holes = 19;

// 56
// w 80 d 50 h 32

module carriage_screw_holes(d_padding)
{
    cs = carriage_s;
    yo = cs[1] / 2 + carriage_z_pos;
    zo = -cs[2] / 2 - 20 + carriage_top_y_offset;
    
    // scanner coords
    distance_between_holes_x = 60;
    distance_between_holes_z = 30;
    dbhx = distance_between_holes_x;
    dbhz = distance_between_holes_z;
    
    translate([0, yo, zo])
    {
        for (xo = [-dbhx / 2, dbhx / 2], yo = [-dbhz / 2, dbhz / 2])
        {
            translate([xo, yo, cs[2] / 2])
            m4_screw_hole(hole_side_top, d_padding = d_padding);
        }
    }
}

module carriage()
{

// carriage_top_z_offset
    cs = carriage_s;
    yo = cs[1] / 2 + carriage_z_pos;
    zo = -cs[2] / 2 - 20 + carriage_top_y_offset;


    difference()
    {
        translate([0, yo, zo])
        {
            color("grey", 0.5)
            cube(carriage_s, center = true);
        }
        
        //color("red")
        carriage_screw_holes();
    }
}

// limit switch designed by makerbot.com
// instructions: www.bigtree-tech.com
// license: GPLv3
module limit_switch()
{
    translate([0, -ls_pcb_s[1] / 2, 0])
    union()
    {
        limit_switch_size = [13, 6.5, 6.5];
        lss = limit_switch_size;
        // pcb
        color("red", 0.7)
        translate([0, 0, -ls_pcb_s[2] / 2])
        cube(ls_pcb_s, center = true);
        
        // switch itself
        
        // 6.5
        lss_xo = lss[0] / 2 - ls_pcb_s[0] / 2 + 6.5;
        lss_yo = -lss[1] / 2 + ls_pcb_s[1] / 2;
        lss_zo = -lss[2] / 2 - ls_pcb_s[2] / 2;
        color("black", 0.7)
        translate([lss_xo, lss_yo, lss_zo])
        cube(lss, center = true);
    }
    
    d = lspshd;
    x_delta = ls_pcb_h_delta_short;
    y_delta = ls_pcb_h_delta_long;
    xd = d / 2 - ls_pcb_s[0] / 2 + x_delta;
    yd = -d / 2 - y_delta;
    
    // screw holes
    color("green", 0.4)
    union()
    {
        translate([xd, yd, 0])
        cylinder($fn = dToFn(d), d = d, h = 4, center = true);
        
        translate([xd + ls_pcb_h_delta_btw_holes, yd, 0])
        cylinder($fn = dToFn(d), d = d, h = 4, center = true);
    }
    
    // holes to cut
    color("blue", 0.4)
    {
        m3_id = m3_hole_insert_diameter;
        m3_h = m3_hole_insert_height;
        translate([xd, yd, m3_h / 2])
        cylinder($fn = dToFn(m3_id), d = m3_id, h = m3_h, center = true);
        
        translate([xd + ls_pcb_h_delta_btw_holes, yd, m3_h / 2])
        cylinder($fn = dToFn(m3_id), d = m3_id, h = m3_h, center = true);
    }
}

module base()
{
    // base
    color("orange", 0.4)
    {
        // left wall
        translate([-sws[0] / 2 - bshs[0] / 2, sws[1] / 2, sws[2] / 2 - 20])
        cube(sws, center = true);
        
        // right wall
        translate([sws[0] / 2 + bshs[0] / 2, sws[1] / 2, sws[2] / 2 - 20])
        cube(sws, center = true);
        
        // top wall
        top_s = [bshs[0] + bwt * 2, sws[1], bwt];
        translate([0, top_s[1] / 2, top_s[2] / 2 + bshs[2]])
        cube(top_s, center = true);
    }
}

module stand()
{
    // back plate/motor holder
    color("black", 0.5)
    translate([0, -bps[1] / 2, bps[2] / 2 - 20])
    cube(bps, center = true);

    // back screw holder
    color("black", 0.5)
    translate([0, bshs[1] / 2 + bp_bsh_dist, bshs[2] / 2])
    cube(bshs, center = true);

    // profiles base
    color("grey")
    {
        translate([-(bshs[0] - 20) / 2, 0, -20 / 2])
        rotate([-90, 0, 0])
        profile_20x20x50();

        translate([(bshs[0] - 20) / 2, 0, -20 / 2])
        rotate([-90, 0, 0])
        profile_20x20x50();
    }
}

module stand_top_m3_holes()
{
    m3_id = m3_hole_insert_diameter;
    m3_h = m3_hole_insert_height;
    
    rxo = bshs[0] / 2 + bwt / 2;
    lxo = -rxo;
    
    for (xo = [rxo, lxo], yo = [sws[1] * 1 / 6, sws[1] * 3 / 6, sws[1] * 5 / 6])
    {
        translate([xo, yo, -20 + sws[2] + bwt + $tiny_padding])
        cylinder($fn = dToFn(m3_id), d = m3_id, h = m3_h * 2, center = true);
    }
}

module stand_top_m3_screw_holes()
{
    m3_id = m3_hole_insert_diameter;
    m3_h = m3_hole_insert_height;
    
    rxo = bshs[0] / 2 + bwt / 2;
    lxo = -rxo;
    
    
    for (xo = [rxo, lxo], yo = [sws[1] * 1 / 6, sws[1] * 3 / 6, sws[1] * 5 / 6])
    {
        translate([xo, yo, -20 + sws[2] + bwt + $tiny_padding])
        //cylinder($fn = dToFn(m3_id), d = m3_id, h = m3_h * 2, center = true);
        scale([1, 1, 2])
        screw_hole(
            m = m3,
            id = m3_hole_insert_diameter,
            il = m3_hole_insert_height * 2,
            hd = m3_head_diameter,
            hh = m3_head_height,
            hs = hole_side_top);
    }
}

module base_to_print()
{
    difference()
    {
        base();
        translate([0, sws[1], -20 + sws[2]])
        limit_switch();
        base_side_screw_holes();
        stand_top_m3_holes();
    }
}

module scanner_side_hole_cutters()
{
    id = 4;
    
    side_offsets = [
        back_bottom_side_hole_offset + [0, 0, 0],
        back_top_side_hole_offset + [0, 0, 0],
        top_side_hole_offset + [0, -id, -id],
        front_bottom_side_hole_offset + [0, -id * 2, 0],
        front_top_side_hole_offset + [0, -id * 2, 0]
    ];
    
    // left x offset
    lxo = -main_frame_width_x / 2;
    rxo = -lxo;
    
    color("red")
    //translate([0, 0, 0])
    translate([0, wt, 0])
    
    for (so = side_offsets)
    {
        translate(so + [lxo, 0, 0])
        screw_hole(
            m = m2,
            id = 4,
            il = m2_hole_insert_height * 2,
            hd = m2_head_diameter,
            hh = m2_head_height,
            hs = hole_side_left);
            
        translate(so + [rxo, 0, 0])
        screw_hole(
            m = m2,
            id = 4,
            il = m2_hole_insert_height * 2,
            hd = m2_head_diameter,
            hh = m2_head_height,
            hs = hole_side_right);
    }
}

module scanner_holder()
{
    top_s = [bshs[0] + bwt * 2, sws[1], wt * 2];
    cut_s = [main_frame_width_x, sws[1] * 2, wt + $tiny_padding * 2];
    
    difference()
    {
        color("green", 0.3)
        translate([0, top_s[1] / 2, top_s[2] / 2 + bshs[2] + bwt])
        cube(top_s, center = true);
        
        
        color("red", 0.3)
        translate([0, top_s[1] / 2, cut_s[2] / 2 + bshs[2] + bwt + wt])
        cube(cut_s, center = true);
    }
}

module scanner_holder_to_print()
{
    difference()
    {
        scanner_holder();
        stand_top_m3_screw_holes();
    }
}

module visualize_stand()
{
    carriage();

    calibration_template();
    calibration_template_holder();
    *calibration_template_holder_to_print();

    stand();

    union()
    {
        base();
        translate([0, sws[1], -20 + sws[2]])
        limit_switch();
        base_side_screw_holes();
        stand_top_m3_holes();
    }



    translate([0, -back_wall_offset + wt, -20 + sws[2] + bwt + wt])
    translate([0, 0, laser_holder_size()[2] / 2 + wt])
    {
        scanner_side_hole_cutters();

        color("yellow", 0.2)
        body_to_print();
        color("green", 0.3)
        
        visualize_range();
        visualize_xz_range();

    }

    //stand_top_m3_holes();
    //stand_top_m3_screw_holes();

    color("grey", 0.6)
    base_to_print();

    //scanner_holder();
    scanner_holder_to_print();
}

visualize_stand();