1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,227 @@ |
1 |
+ |
|
2 |
+ |
|
3 |
+////////////////////////// |
|
4 |
+// Customizable settings |
|
5 |
+////////////////////////// |
|
6 |
+ |
|
7 |
+ |
|
8 |
+// Diameter of the hole on the bottom (in mm). |
|
9 |
+HoleDiameter = 7; |
|
10 |
+ |
|
11 |
+// Depth of the hole in the bottom (in mm). If you want the hole to go all the way through then set this to a number larger than the total height of the object. |
|
12 |
+HoleDepth = 10; |
|
13 |
+ |
|
14 |
+// If you want a D-shaped hole, set this to the thickness of the flat side (in mm). Larger values for the flat make the hole smaller. |
|
15 |
+HoleFlatThickness = 1; |
|
16 |
+ |
|
17 |
+// Height (in mm). If dome cap is selected, it is not included in height. The shaft length is also not counted. |
|
18 |
+KnobHeight = 16; |
|
19 |
+ |
|
20 |
+// Diameter of base of round part of knob (in mm). (Knurled ridges are not included in this measurement.) |
|
21 |
+KnobDiameter = 14; |
|
22 |
+ |
|
23 |
+// Shape of top of knob. "Recessed" type can be painted. |
|
24 |
+CapType = 0; // [0:Flat, 1:Recessed, 2:Dome] |
|
25 |
+ |
|
26 |
+// Do you want a large timer-knob style pointer? |
|
27 |
+TimerKnob=0; // [0:No, 1:Yes] |
|
28 |
+ |
|
29 |
+// Would you like a divot on the top to indicate direction? |
|
30 |
+Pointer1 = 0; // [0:No, 1:Yes] |
|
31 |
+ |
|
32 |
+// Would you like a line (pointer) on the front to indicate direction? |
|
33 |
+Pointer2 = 0; // [0:No, 1:Yes] |
|
34 |
+ |
|
35 |
+// Do you want finger ridges around the knob? |
|
36 |
+Knurled = 0; // [0:No, 1:Yes] |
|
37 |
+ |
|
38 |
+// 0 = A cylindrical knob, any other value will taper the knob. |
|
39 |
+TaperPercentage = 0; // [0:0%, 10:10%, 20:20%, 30:30%, 40:40%, 50:50%] |
|
40 |
+ |
|
41 |
+// Width of "dial" ring (in mm). Set to zero if you don't want the ring. |
|
42 |
+RingWidth = 0; |
|
43 |
+ |
|
44 |
+// The number of markings on the dial. Set to zero if you don't want markings. (RingWidth must be non-zero.) |
|
45 |
+RingMarkings = 10; |
|
46 |
+ |
|
47 |
+// diameter of the hole for the setscrew (in mm). If you don't need a hole, set this to zero. |
|
48 |
+ScrewHoleDiameter = 0; |
|
49 |
+ |
|
50 |
+// Length of the shaft on the bottom of the knob (in mm). If you don't want a shaft, set this value to zero. |
|
51 |
+ShaftLength = 0; |
|
52 |
+ |
|
53 |
+// Diameter of the shaft on the bottom of the knob (in mm). (ShaftLength must be non-zero.) |
|
54 |
+ShaftDiameter = 10; |
|
55 |
+ |
|
56 |
+// Would you like a notch in the shaft? It can be used for a press-on type knob (rather than using a setscrew). (ShaftLength must be non-zero.) |
|
57 |
+NotchedShaft = 0; // [0:No, 1:Yes] |
|
58 |
+ |
|
59 |
+ |
|
60 |
+ |
|
61 |
+////////////////////////// |
|
62 |
+//Advanced settings |
|
63 |
+////////////////////////// |
|
64 |
+ |
|
65 |
+RingThickness = 5*1; |
|
66 |
+DivotDepth = 1.5*1; |
|
67 |
+MarkingWidth = 1.5*1; |
|
68 |
+DistanceBetweenKnurls = 3*1; |
|
69 |
+TimerKnobConst = 1.8*1; |
|
70 |
+ |
|
71 |
+ |
|
72 |
+ |
|
73 |
+////////////////////////// |
|
74 |
+//Calculations |
|
75 |
+////////////////////////// |
|
76 |
+ |
|
77 |
+PI=3.14159265*1; |
|
78 |
+KnobMajorRadius = KnobDiameter/2; |
|
79 |
+KnobMinorRadius = KnobDiameter/2 * (1 - TaperPercentage/100); |
|
80 |
+KnobRadius = KnobMinorRadius + (KnobMajorRadius-KnobMinorRadius)/2; |
|
81 |
+KnobCircumference = PI*KnobDiameter; |
|
82 |
+Knurls = round(KnobCircumference/DistanceBetweenKnurls); |
|
83 |
+Divot=CapType; |
|
84 |
+ |
|
85 |
+TaperAngle=asin(KnobHeight / (sqrt(pow(KnobHeight, 2) + |
|
86 |
+ pow(KnobMajorRadius-KnobMinorRadius,2)))) - 90; |
|
87 |
+ |
|
88 |
+DivotRadius = KnobMinorRadius*.4; |
|
89 |
+ |
|
90 |
+ |
|
91 |
+union() |
|
92 |
+{ |
|
93 |
+translate([0, 0, (ShaftLength==0)? 0 : ShaftLength-0.001]) |
|
94 |
+difference() |
|
95 |
+{ |
|
96 |
+union() |
|
97 |
+{ |
|
98 |
+ // Primary knob cylinder |
|
99 |
+ cylinder(h=KnobHeight, r1=KnobMajorRadius, r2=KnobMinorRadius, |
|
100 |
+ $fn=50); |
|
101 |
+ |
|
102 |
+ if (Knurled) |
|
103 |
+ for (i=[0 : Knurls-1]) |
|
104 |
+ rotate([0, 0, i * (360/Knurls)]) |
|
105 |
+ translate([KnobRadius, 0, KnobHeight/2]) |
|
106 |
+ rotate([0, TaperAngle, 0]) rotate([0, 0, 45]) |
|
107 |
+ cube([2, 2, KnobHeight+.001], center=true); |
|
108 |
+ |
|
109 |
+ if (RingMarkings>0) |
|
110 |
+ for (i=[0 : RingMarkings-1]) |
|
111 |
+ rotate([0, 0, i * (360/RingMarkings)]) |
|
112 |
+ translate([KnobMajorRadius + RingWidth/2, 0, 1]) |
|
113 |
+ cube([RingWidth*.5, MarkingWidth, 2], center=true); |
|
114 |
+ |
|
115 |
+ if (Pointer2==1) |
|
116 |
+ translate([KnobRadius, 0, KnobHeight/2-2]) |
|
117 |
+ rotate([0, TaperAngle, 0]) |
|
118 |
+ cube([8, 3, KnobHeight], center=true); |
|
119 |
+ |
|
120 |
+ if (RingWidth>0) |
|
121 |
+ translate([0, 0, RingThickness/2]) |
|
122 |
+ cylinder(r1=KnobMajorRadius + RingWidth, r2=KnobMinorRadius, |
|
123 |
+ h=RingThickness, $fn=50, center=true); |
|
124 |
+ |
|
125 |
+ if (Divot==2) |
|
126 |
+ translate([0, 0, KnobHeight]) |
|
127 |
+ difference() |
|
128 |
+ { |
|
129 |
+ scale([1, 1, 0.5]) |
|
130 |
+ sphere(r=KnobMinorRadius, $fn=50, center=true); |
|
131 |
+ |
|
132 |
+ translate([0, 0, 0-(KnobMinorRadius+.001)]) |
|
133 |
+ cube([KnobMinorRadius*2.5, KnobMinorRadius*2.5, |
|
134 |
+ KnobMinorRadius*2], center=true); |
|
135 |
+ } |
|
136 |
+ |
|
137 |
+ if (TimerKnob==1) intersection() |
|
138 |
+ { |
|
139 |
+ translate([0, 0, 0-(KnobDiameter*TimerKnobConst) + KnobHeight]) |
|
140 |
+ sphere(r=KnobDiameter*TimerKnobConst, $fn=50, center=true); |
|
141 |
+ |
|
142 |
+ translate([0-(KnobDiameter*TimerKnobConst)*0.1, 0, |
|
143 |
+ KnobHeight/2]) |
|
144 |
+ scale([1, 0.5, 1]) |
|
145 |
+ cylinder(h=KnobHeight, r=(KnobDiameter*TimerKnobConst) * |
|
146 |
+ 0.8, $fn=3, center=true); |
|
147 |
+ } |
|
148 |
+} |
|
149 |
+ |
|
150 |
+// Pointer1: Offset hemispherical divot |
|
151 |
+if (Pointer1==1) |
|
152 |
+ translate([KnobMinorRadius*.55, 0, KnobHeight + DivotRadius*.6]) |
|
153 |
+ sphere(r=DivotRadius, $fn=40); |
|
154 |
+ |
|
155 |
+// Divot1: Centered cylynrical divot |
|
156 |
+if (Divot==1) |
|
157 |
+ translate([0, 0, KnobHeight]) |
|
158 |
+ cylinder(h=DivotDepth*2, r=KnobMinorRadius-1.5, $fn=50, |
|
159 |
+ center=true); |
|
160 |
+ |
|
161 |
+if (ShaftLength==0) |
|
162 |
+{ |
|
163 |
+ // Hole for shaft |
|
164 |
+ translate([0, 0, HoleDepth/2 - 0.001]) |
|
165 |
+ difference() |
|
166 |
+ { |
|
167 |
+ cylinder(r=HoleDiameter/2, h=HoleDepth, $fn=20, |
|
168 |
+ center=true); |
|
169 |
+ |
|
170 |
+ // Flat for D-shaped hole |
|
171 |
+ translate([(0-HoleDiameter)+HoleFlatThickness, 0, 0]) |
|
172 |
+ cube([HoleDiameter, HoleDiameter, HoleDepth+.001], |
|
173 |
+ center=true); |
|
174 |
+ } |
|
175 |
+ |
|
176 |
+ // Hole for setscrew |
|
177 |
+ if (ScrewHoleDiameter>0) |
|
178 |
+ translate([0 - (KnobMajorRadius+RingWidth+1)/2, 0, |
|
179 |
+ HoleDepth/2]) |
|
180 |
+ rotate([0, 90, 0]) |
|
181 |
+ cylinder(h=(KnobMajorRadius+RingWidth+1), |
|
182 |
+ r=ScrewHoleDiameter/2, $fn=20, center=true); |
|
183 |
+} |
|
184 |
+ |
|
185 |
+// Make sure bottom ends at z=0 |
|
186 |
+translate([0, 0, -10]) |
|
187 |
+ cube([(KnobMajorRadius+RingWidth) * 3, |
|
188 |
+ (KnobMajorRadius+RingWidth) * 3, 20], center=true); |
|
189 |
+} |
|
190 |
+ |
|
191 |
+if (ShaftLength>0) |
|
192 |
+ difference() |
|
193 |
+ { |
|
194 |
+ translate([0, 0, ShaftLength/2]) |
|
195 |
+ cylinder(h=ShaftLength, r=ShaftDiameter/2, $fn=20, |
|
196 |
+ center=true); |
|
197 |
+ |
|
198 |
+ if (NotchedShaft==1) |
|
199 |
+ { |
|
200 |
+ cube([HoleDiameter/2, ShaftDiameter*2, ShaftLength], |
|
201 |
+ center=true); |
|
202 |
+ } |
|
203 |
+ |
|
204 |
+ // Hole for shaft |
|
205 |
+ translate([0, 0, HoleDepth/2 - 0.001]) |
|
206 |
+ difference() |
|
207 |
+ { |
|
208 |
+ cylinder(r=HoleDiameter/2, h=HoleDepth, $fn=20, |
|
209 |
+ center=true); |
|
210 |
+ |
|
211 |
+ // Flat for D-shaped hole |
|
212 |
+ translate([(0-HoleDiameter)+HoleFlatThickness, 0, 0]) |
|
213 |
+ cube([HoleDiameter, HoleDiameter, HoleDepth+.001], |
|
214 |
+ center=true); |
|
215 |
+ } |
|
216 |
+ |
|
217 |
+ // Hole for setscrew |
|
218 |
+ if (ScrewHoleDiameter>0) |
|
219 |
+ translate([0 - (KnobMajorRadius+RingWidth+1)/2, 0, |
|
220 |
+ HoleDepth/2]) |
|
221 |
+ rotate([0, 90, 0]) |
|
222 |
+ cylinder(h=(KnobMajorRadius+RingWidth+1), |
|
223 |
+ r=ScrewHoleDiameter/2, $fn=20, center=true); |
|
224 |
+ } |
|
225 |
+} |
|
226 |
+ |
|
227 |
+ |