summaryrefslogtreecommitdiff
path: root/gimbal.scad
blob: d16f6e0cc2146024448dd0d703ee6d9d697f6126 (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
// sphere diameter
d = 30;
cutoff = 3;
c = 3;
base = 10;

screw_len = 15;
screw_dia = 25.4/4;
screw_head_len = 5;

mount_screw_dia = 4;
mount_screw_head_dia = 10;

// retainer wire hole diameter
retainer_dia = 1;

splitter_tolerance = 0.2;
e = 0.01;
$fn = 500;

use <simplethreads.scad>;

module screw() {
    translate([0, 0, 2*screw_head_len - screw_dia/2])
    thread_imperial(1/16, screw_dia/25.4, 12, screw_len*16/25.4);

    intersection() {
	cylinder(r1=2*screw_head_len, r2=0, h=2*screw_head_len);
	cube([2*screw_head_len, 2*screw_head_len, 10*screw_head_len], center=true);
    }
}

module two_half_screws()
    for (i = [0,1])
    translate([i*2*screw_head_len, -i*(screw_len + screw_head_len), 0])
    intersection() {
	rotate([90, i*180, i*180])
	screw();

	translate([0, 0, 50])
	cube(100, center=true);
    }

module grip()
    for (i = [0:19])
        rotate(i*360/20)
	translate([d/2-3, 0, -5/2])
	cube([3,2,5]);

module ball()
    difference() {
	// sphere with top and bottom cap removed
	sphere(d/2);
	for (i = [-1,1])
            translate([0, 0, i * (d - cutoff)]) cube(d, center=true);

	// screw hole (thin ot the top, thickening in the center, big
	// square at the bottom)
	translate([0, 0, d/2 - cutoff - screw_len/2 + screw_head_len/2]) {
	    cylinder(r=screw_dia/2, h=d, center=true);

	    mirror([0, 0, 1])
	    intersection() {
		cylinder(r1=0, r2=d, h=d);
		cube([2*screw_head_len, 2*screw_head_len, 10*screw_head_len], center=true);
	    }
	}

	// horizontal grip
	grip();
	// vertical grip at the upper half sphere (but not at the top)
	difference() {
	    rotate([90, -5, 0]) grip();
	    cylinder(r1=0, r2=sqrt(pow(d/2, 2) - pow(d/2-cutoff, 2)), h=d/2-cutoff);
	    translate([0, 0, -d+4]) cylinder(r=d/2, h=d);
	}
    }

module shell() {
    difference() {
	// sphere with cylinder to bottom
	mirror([0, 0, 1])
	assign(r2=d/2+c)
	union() {
	    sphere(r=r2);
	    cylinder(r=r2, h=r2 + base);
	}

	// hollow out the sphere
	sphere(d/2);

	// reduce top to a cone, so that an attached surface can
	// rotate freely
	assign(a=2 * (45 - acos((d - 2*cutoff) / d)))
	assign(h=d * tan(a))
	translate([0, 0, d/2 - h - cutoff*cos(a/2)])
	difference() {
	    cylinder(r=d, h=d);
	    cylinder(r1=d, r2=0, h=h);
	}
	
	// add intro region
	intersection() {
		cylinder(r=d/2, h=2*d);

		translate([0,0,d])
		cube([d-2*cutoff, d*2, 2*d], center=true);
	}

	// path for 1/4" screw; lets you rotate the sphere after
	// pushing it in (and allows later removal of it)
	hull() {
	    cylinder(r=screw_dia/2, h=d);
	    rotate([90, 0, 90])
	      cylinder(r=screw_dia/2, h=d);
	}
	
	// mounting screw hole
	assign(rs=mount_screw_dia)
	assign(rh=mount_screw_head_dia)
	union() {
	    cylinder(r=rs/2, h=3*(d+base), center=true);
	    translate([0, 0, -d/2-rh]) cylinder(r1=0, r2=rh/2, h=rh);
	    translate([0, 0, -d/2   ]) cylinder(r=rh/2, h=d);
	}

	// holes for retainer wire
	for (i = [-1,1])
	    translate([i*d/4, 0, -d/2 - base/2 - c])
	    rotate([90, 0, 0])
	    cylinder(r=retainer_dia, h=2*d, center=true);
    }
}

module shell_splitter(e2=0)
    assign(w1 = d + 2*c + e)
    assign(w2 = 1.4 * mount_screw_head_dia + e2)
    assign(h  = base + c)
    translate([-w1/2, -w2/2, -h - d/2]) {
	cube([w1, w2, 2/3*h+e]);
	
	rotate([90, 0, 90])
	translate([w2/2, 2/3*h, 0])
	cylinder(h=w1, r=w2/2);

	translate([0, w2/2, 2/3*h])
	rotate([45, 0, 0])
	cube([w1, w2/2, w2/2]);
    }

module shell_upper()
    difference() {
	shell();
	translate([0, 0, -e]) shell_splitter(splitter_tolerance);
    }

module shell_lower()
  intersection() {
	shell();
	shell_splitter();
    }

module exploded_view() {
    translate([0, 0, -2*base]) shell_lower();
    shell_upper();
    translate([0,0,20]) rotate([90, 0, 90]) ball();

    translate([-0.7*d - c - screw_len, 0, 20])
    rotate(90)
    two_half_screws();
}

module assembled_view() {
    shell_lower();
    shell_upper();
    assign(a=2 * (45 - acos((d - 2*cutoff) / d)))
    rotate([-a, 0, 90]) {
	ball();
	screw();
    }
}

exploded_view();
contact: Jan Huwald // Impressum