-
Notifications
You must be signed in to change notification settings - Fork 1
/
Core.scad
326 lines (263 loc) · 9.06 KB
/
Core.scad
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
// Golf ball official dimensions seem to range from 42.7-41.148mm. We'll round up to 43mm
golfball_diameter=43;
// How much of a rest we want the ball in.
golfball_rest_offset=2;
flipper_recess_scalar=1.25;
servo_width = 12.5;
servo_depth = 23.5;
//includes all the way up to just under the cam assembly
servo_height = 26;
// measure this before printing
servo_pin_height = 11;
servo_pin_depth = 32;
servo_pin_shelf_height = 2.5;
servo_recess_scalar = 1.25;
//servo_arm_scalar = 1.05;
//servo_arm_scalar2 = 1.5;
base_width = 150;
base_depth = 85;
base_height = 76;
//alt height without golf divert overhang
base_height = 56;
short_run_length = base_width/2;
run_opening = 70;
run_leaving = 55;
run_length = 120;
run_angle = 9;
run_level =4;
micro_run_level = -6;
divert_offset = 35;
solenoid_case_width = 12.5;
solenoid_case_depth = 20.5;
solenoid_case_height = 15;//12
solenoid_pin_diameter = 7.5;
solenoid_pin_length = 14;
solenoid_pin_length_retracted = 8;
solenoid_angle = 30;
solenoid_recess_scalar = 1.1;
//////////////////////////////
// Main geometry //
//////////////////////////////
//translate([0,0,0])print("red");
translate([0,-150,0])print("yellow");
print("green");
print("blue");
//servo_arm(1,1.5);
//translate([-143,-45,22])rotate([0,0,270])servo_arm(1.1,2);
//servo_arm(1.2,1.5);
//translate([-servo_width/2,-135,-18])rotate([90,90,180])servoCase(true);
// print the red, blue or green blocks
module print(state){
if (state=="red"){
red();
} else if (state=="blue"){
blue();
} else if (state=="green"){
green();
} else if (state=="yellow"){
yellow();
} else {
}
}
//
// Section 1
// Uncomment when printing
module yellow(){
color("red")import("builds/Pinball_Adaptor.stl", convexity=3);
}
module green(){
translate([0,0,base_height/2])difference(){
mainBox();
servoPinHoles(-9);
}
}
// a servo for the golf release mechanism
// comment out for building
//translate([-servo_width/2,-135,-18])rotate([90,90,180])servoCase(true);
// a solenoid for the golf release mechanism
//translate([0,-90,-2.26*solenoid_case_height+7])rotate([82,0,0])scale(solenoid_recess_scalar,solenoid_recess_scalar,solenoid_recess_scalar)solenoid(false);
// Section 2
// Uncomment when printing
module blue(){
translate([0,0,base_height/2])color("blue")setup3();
}
// check for flipper & servo alignment
//color("pink")translate([0,0,0])align_pin(150,3);
// Flipper: uncomment for printing
module red(){
color("red")translate([0,-200,0])rotate([0,0,0])flipper();
}
module mainBox(){
translate([0,-15,0])difference(){
setup1();
translate([0,21.25,-26])servoCase();
}
}
// Setup for recesses
module setup1(){
// comment out for build
//allow for servoCase();
//translate([0,21.25,-25])servoCase();
// comment out for build
//translate([0,-100,-20])solenoid();
section_flipper_recessed();
//translate([-28,-10,10])golf_ball();
}
module setup3(){
difference(){
release_mechanism();
translate([-servo_width/2,-135,-18])rotate([90,90,180])servoCase(true);
// allow void to install servo
translate([-servo_width/2,-135,-28])rotate([90,90,180])servoCase(true);
}
}
module release_mechanism(){
translate([0,-108,0])difference(){
section_2(30);
translate([0,1,14])golf_ball(1.15)translate([-servo_width/2,-135,-18])rotate([90,90,180])servoCase(true);
}
}
// Pins & Bolt Geometry
// module for checking alignment and M sized fixing
module align_pin(length,diameter){
rotate([180,0,0])cylinder($fn=24,h=length,r=diameter/2,center=true);
}
// Main section with Base geometry & golf runs removed
module section(){
difference(){
base();
translate([0,0,run_opening/4])divert();
}
}
// A section for holding and releasing the ball, iterated cylinders
module section_2(spread){
difference(){
base_2();
rotate([0,0,0])translate([0,-25,28])for (i=[0:spread]){
translate([i-spread/2,0,0])short_run(i+1);
}
}
}
// section with flipper recess
module section_flipper_recessed(){
difference(){
section();
flipper_recess();
}
}
// Balls
// average golf ball size
module golf_ball(scale){
sphere(d=(scale*golfball_diameter) + golfball_rest_offset);
}
// Main Runs Geometry
// 3 cylendrical golfball runs divert true or false
module divert() {
translate([0,-50,run_level])run();
rotate([-run_angle,0,0])translate([-divert_offset,0,0])run_true();
rotate([-run_angle,0,0])translate([divert_offset,0,0])run_false();
}
// Shorter cylinder for golf run with parameters
module short_run(){
rotate([270+run_angle,0,0])cylinder(h=short_run_length,r=run_opening/2,center=true);
translate([0,base_depth/2,0])rotate([270-run_angle,0,0])cylinder(h=short_run_length-10,r=run_opening/2,center=true);
}
// Basic cylindrical golf run
module run() {
rotate([270,0,0])cylinder(h=run_length,r1=run_opening/2,r2=run_leaving/2,center=true);
}
// First bit of the flipper section
module pre_run() {
rotate([270,0,0])cylinder(h=run_length,r1=run_opening/2,r2=run_leaving/2,center=true);
}
// golf run true direction
module run_true() {
rotate([0,0,20])run();
}
// golf run false direction
module run_false() {
rotate([0,0,-20])run();
}
// Base Geometrys
// Big chunk o' PLA
module base() {
color("green")cube([base_width,base_depth,base_height], true);
}
// another base that needs less material
module base_2() {
color("green")cube([base_width-30,base_depth-10,base_height], true);
}
module base_3() {
color("green")cube([base_width-30,base_depth-10,base_height], true);
}
// Servo/servo Case
// the main servo case with the cam bits
module servoCase(state){
//wider pin shelf recess
translate([0,0,servo_height/2-(servo_pin_height/2)])scale([servo_recess_scalar,servo_recess_scalar,servo_recess_scalar])cube([servo_width,servo_pin_depth, servo_pin_shelf_height], true);
translate([0,0,-servo_pin_height/6])cube([servo_width,servo_pin_depth,servo_height-(servo_height/8 )], true);
// Main case
cube([servo_width,servo_depth,servo_height], true);
//cam top
translate([0,servo_depth/-2 + 7.45,servo_height/2+2])scale([servo_recess_scalar,servo_recess_scalar,servo_recess_scalar])servoCamAssembly(11.5,5.25,6,4);
// a lever left/up if true, otherwise straight
if (state == true){
translate([0,servo_depth/-2+6,servo_height/2+8])for (i=[0:180]){
rotate([0,0,i])servoCamAssembly(7,4,15,4.5);
}
} else {
translate([0,servo_depth/-2+6,servo_height/2+8])servoCamAssembly(7,4,15,4);
}
}
// The Cam bits
module servoCamAssembly(first_cam_diameter,second_cam_diameter,distance, cam_height){
//allow for a clean break throught the main box geometry
linear_extrude(height = cam_height + 2, center = true, convexity = 0, twist = 0)servoCam(first_cam_diameter,second_cam_diameter,distance);
}
// cam hull for the cam top of a servo
module servoCam(first_cam_diameter,second_cam_diameter,distance){
hull() {
circle($fn = 24,d = first_cam_diameter);
translate([0,distance,0])circle($fn = 24,d = second_cam_diameter);
}
}
// servo attachment pins
module servoPinHoles(ypos) {
color("pink")translate([0,ypos + 0.6,0])align_pin(50,1.6);
color("pink")translate([0,ypos + 26.6,6])align_pin(50,1.6);
// last pin secures flipper and is positioned center of the larger servoCamAssembly hulled circle
color("pink")translate([0,servo_depth/4-5.75,0])align_pin(75,2);
}
// Imported Flipper from https://www.thingiverse.com/thing:1789
module flipper(){
flipper_scalar = 1.25;
scale([flipper_scalar,flipper_scalar,1.5])import("builds/flipper/files/flipper.stl", convexity=3);
}
//Flipper recess
module flipper_recess(){
for (i=[330:390])
translate([0,0,10])rotate([0,0,i])linear_extrude(height = 40, center = true, convexity = 10, twist = 0)hull(i+1) {
translate([0,-50,0])circle($fn = 24,d = 15);
translate([0,20,0])circle($fn = 24,d = 40);
} //resize([flipper_recess_scalar,flipper_recess_scalar,flipper_recess_scalar])import("builds/files/flipper.stl", convexity=3);
}
// Solenoid
module solenoid(state) {
cube([solenoid_case_width,solenoid_case_depth,solenoid_case_height], true);
// solenoid pin extended
if(state == false){
translate([0,solenoid_case_depth,0])rotate([90,0,0])cylinder($fn=12,solenoid_pin_length,r=solenoid_pin_diameter/2,true);
} else {
translate([0,solenoid_case_depth/2+solenoid_pin_length_retracted,0])rotate([90,0,0])cylinder($fn=12,solenoid_pin_length_retracted,r=solenoid_pin_diameter/2,true);
}
// wire space
translate([0,-solenoid_case_depth/4,solenoid_case_height/2])rotate([90,0,0])cylinder($fn=12,solenoid_pin_length,r=0.5,true);
}
// Wiring recess
module wire(wire_length) {
rotate([90,0,0])cylinder($fn=12,wire_length,r=0.5,true);
}
//9g_servo_arm
module servo_arm(scale,scale2){
scale([scale, scale, scale2])import("builds/servo_arm/files/9g_servo_arm_single.stl", convexity=3);
}