summaryrefslogtreecommitdiff
path: root/mech/pcb_case/tolerance_tests.scad
blob: c15cf50dd056ba7a3d361fee7c99692fbb726b34 (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
include <bolt.scad>
include <nut.scad>
include <panel.scad>

use <rounded_cube.scad>

module bolt_drilling() {
	steps = 3;
	step_width = 0.1;
	height = 3;

	for(i = [-steps : steps]) {
		tol = bolt_ds_tol + i * step_width;
		echo(bolt_ds_tol=tol);
		translate([i*5*bolt_ds,0,0])
			difference() {
				cube([5*bolt_ds, 5*bolt_ds, height]);
				translate([2.5*bolt_ds,2.5*bolt_ds,0]) {
					cylinder(d=bolt_ds+tol,h=height,$fn=50);
				}
			}
	}
}

module nut_drilling() {
	steps = 3;
	step_width = 0.1;

	for(i = [-steps : steps]) {
		tol = nut_d_tol + i * step_width;
		echo(nut_d_tol=tol);
		translate([i*5*nut_d,0,0])
			difference() {
				cube([5*nut_d, 5*nut_d, 2*nut_h]);
				translate([2.5*nut_d,2.5*nut_d,0]) {
					union() {
						cylinder(d=bolt_ds,h=2*nut_h,$fn=50);
						translate([0,0,nut_h])
							cylinder(d=tol+nut_d,h=nut_h,$fn=50);
					}
				}
			}
	}
}

module panel_thickness() {
	steps = 3;
	step_width = 0.2;

	t = 2;
	height = 2*t;

	for(i = [-steps : steps]) {
		tol = panel_dim_0_tol + i * step_width;
		echo(panel_dim_0_tol=tol);
		translate([i*5*t,0,0])
			difference() {
				cube([5*t, 5*t, height]);
				translate([2*t, 0, t]) {
					cube([t+tol, 5*t, t]);
				}
			}
	}

	translate([0, 6*t, 0]) rotate([0, -90, 0]) rounded_cube([t, 4*t, 7*t], t);
}

module panel_width_height() {
	steps = 3;
	step_width = 0.2;

	t = 2;
	height = 3*t;

	for(i = [-steps : steps]) {
		tol = panel_dim_1_2_tol + i * step_width;
		echo(panel_dim_1_2_tol=tol);
		translate([i*3*t,0,0])
			difference() {
				cube([3*t, 8*t, height]);
				translate([t, t-tol/2, t]) {
					rounded_cube([t+panel_dim_0_tol, 6*t+tol, 6*t+tol], t);
				}
			}
	}

	translate([0, 9*t, 0]) rotate([0, -90, 0]) rounded_cube([t, 6*t, 6*t], t);
}

bolt_drilling();
translate([0, 20, 0]) nut_drilling();
translate([0, 90, 0]) panel_thickness();
translate([0, 50, 0]) panel_width_height();