forked from waynegramlich/ezcad3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSynchro_Drive.py
executable file
·3514 lines (3107 loc) · 111 KB
/
Synchro_Drive.py
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
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python
from EZCAD3 import *
# Assemblies:
class Base(Part):
def __init__(self, up):
Part.__init__(self,up)
self.left_front_synchro_ = Synchro_Drive(self)
self.right_front_synchro_ = Synchro_Drive(self)
def construct(self):
left_front_synchro = self.left_front_synchro_
right_front_synchro = self.right_front_synchro_
one = L(mm = 1.00)
zero = L()
self.twist_axis_dy_l = twist_axis_dy = L(inch = 16.00)
z_axis = P(zero, zero, one)
front_right = P(zero, -twist_axis_dy / 2, zero)
front_left = P(zero, twist_axis_dy / 2, zero)
left_front_synchro.place(translate = front_right)
right_front_synchro.place(translate = front_left,
axis = z_axis, rotate = Angle(180))
class Strut_Assembly(Part):
def __init__(self, up):
Part.__init__(self, up)
#self.strut_ = Strut(self)
self.strut_top_ = Strut_Top(self)
def construct(self):
# Grab some relevant *Part*'s:
synchro_drive = self.up
motor_assembly = synchro_drive.motor_assembly_
motor_base = motor_assembly.motor_base_
# Grab coordnates for point J:
j_x = motor_base.j_x_l
j_y = motor_base.j_y_l
class Strut(Part):
def __init__(self, up):
Part.__init__(self, up)
def construct(self):
# Grab some relevant *Part*'s:
strut_assembly = self.up
synchro_drive = strut_assembly.up
strut_top = strut_assembly.strut_top_
motor_assembly = synchro_drive.motor_assembly_
y0 = motor_assembly.n.y
y1 = strut_top.n.y
x0 = L(inch = "1/4")
x1 = -L(inch = "1/4")
z0 = motor_assembly.t.z
z1 = z0 + L(inch = 0.125)
corner1 = P(x0, y0, z0)
corner2 = P(x1, y1, z1)
print("Strut: c1={0} c2={1}".format(corner1, corner2))
self.block(comment = "Strut",
color = Color("violet"),
corner1 = corner1,
corner2 = corner2,
top = "t")
class Strut_Top(Part):
def __init__(self, up):
Part.__init__(self, up)
def construct(self):
# Grab some *Part*'s from the *Part* tree:
strut_assembly = self.up
synchro = strut_assembly.up
base = synchro.up
motor_assembly = synchro.motor_assembly_
motor_base = motor_assembly.motor_base_
# Grab distance between the two twist axes from *base*:
twist_axis_dy = base.twist_axis_dy_l
# Point J and/or M in *motor_base* of the motor assembly
# is the closest that strut assembly can get to its partner
# on the other side. Points Q and R are mirror image of
# points J and M across the X axis line that goes through
# the pair origin O.
#
# +-------+
# / |
# / o |
# / |
# / /
# / /
# / /
# / /
# M J Q----------R
# | | | Right |
# | | | Strut |
# | Left | | Assembly |
# | Motor | T----------S
# | Assembly | || ||
# +----------+ || ||
# || || || ||
# || || O || ||
# || || || ||
# || || +----------+
# || || | Right |
# R----------Q | Motor |
# | Left | | Assembly |
# | Strut | | |
# | Assembly | | |
# S----------T J M
# / /
# / /
# / /
# / /
# | /
# | o /
# | /
# +-------+
#
# +Y
# ^
# |
# O----> +X
#
# where:
# "O" is the origin of the *Synchro_Pair*.
# "o" is the twist axis for each motor assembly. Note that
# the twist axis aligns in Y with "O".
# "||" Is a strut pair (upper and lower.)
# "J" is an inside point for the motor base assembly.
# "M" is an outside point for the motor base assembly,
# where Jy = My on the same motor assembly.
# "Q" Mirror of "J"
# "R" Mirror of "M"
# Grab X/Y coordinates of J and M from *motor_base*:
j_x = motor_base.j_x_l
j_y = motor_base.j_y_l
m_x = motor_base.m_x_l
m_y = motor_base.m_y_l
# Length of the top strut in Y:
self.dy_l = dy = L(mm = 50.00)
# Compute the X/Y locations of Q, R, S, and T. Remember, the
# origin coordinates are still around the sychro twist axis.
self.q_x_l = q_x = j_x
self.q_y_l = q_y = twist_axis_dy - j_y
self.r_x_l = r_x = m_x
self.r_y_l = r_y = twist_axis_dy - m_y
self.s_x_l = s_x = r_x
self.s_y_l = s_y = r_y - dy
self.t_x_l = t_x = q_x
self.t_y_l = t_y = q_y - dy
z0 = motor_base.b.z
z3 = motor_base.t.z
self.block(comment = "Strut Top Block",
color = Color("orange"),
corner1 = P(q_x, q_y, z0),
corner2 = P(s_x, s_y, z3),
top = "t")
class Synchro_Drive(Part):
def __init__(self, up):
Part.__init__(self, up)
self.wheel_assembly_ = Wheel_Assembly(self)
self.motor_assembly_ = Motor_Assembly(self)
self.strut_assembly_ = Strut_Assembly(self)
def construct(self):
zero = L()
one = L(mm = 1.00)
motor_assembly = self.motor_assembly_
motor_assembly.place(
axis = P(zero, zero, one))
# rotate = Angle(deg = 130))
class Motor_Assembly(Part):
def __init__(self, up):
Part.__init__(self, up)
self.motor_base_ = Motor_Base(self)
self.motor_base_cover_ = Motor_Base_Cover(self)
self.motor_base_screws_ = Motor_Base_Screws(self)
self.drive_belt_ = Belt(self)
self.drive_magnet_ = Magnet(self)
self.drive_motor_ = Motor(self)
self.drive_motor_pulley_ = Pulley(self)
self.drive_motor_pulley_screws_ = Drive_Motor_Pulley_Screws(self)
self.drive_motor_pulley_top_ = Pulley_Top(self)
self.end_screws_ = End_Screws(self)
self.pcb_ = PCB(self)
self.twist_belt_ = Belt(self)
self.twist_magnet_ = Magnet(self)
self.twist_motor_ = Motor(self)
self.twist_motor_pulley_ = Pulley(self)
self.twist_motor_pulley_screws_ = Twist_Motor_Pulley_Screws(self)
self.twist_motor_pulley_top_ = Pulley_Top(self)
def construct(self):
# Grab some values from *self*:
motor_assembly = self
drive_belt = motor_assembly.drive_belt_
drive_magnet = motor_assembly.drive_magnet_
drive_motor = motor_assembly.drive_motor_
drive_motor_pulley = motor_assembly.drive_motor_pulley_
drive_motor_pulley_top = motor_assembly.drive_motor_pulley_top_
#drive_motor_pulley_top = motor_assembly.drive_motor_pulley_top_
motor_base = motor_assembly.motor_base_
motor_base_cover = motor_assembly.motor_base_cover_
pcb = motor_assembly.pcb_
synchro_drive = self.up
twist_magnet = motor_assembly.twist_magnet_
twist_motor = motor_assembly.twist_motor_
twist_motor_pulley = motor_assembly.twist_motor_pulley_
twist_motor_pulley_top = motor_assembly.twist_motor_pulley_top_
twist_belt = motor_assembly.twist_belt_
# Define some constants:
zero = L()
sqrt2 = math.sqrt(2)
motor_base_cover.invisible_set()
# Grab some values from *wheel_assembly:
wheel_assembly = synchro_drive.wheel_assembly_
gear_box = wheel_assembly.gear_box_
turn_table = wheel_assembly.turn_table_
twist_wheel_pulley = wheel_assembly.twist_wheel_pulley_
drive_wheel_pulley = wheel_assembly.drive_wheel_pulley_
wheel = wheel_assembly.wheel_
# If the wheel radius is R and its witdh is W, (R+W/2)*sqrt(2)
# is a pretty close approximation to the radius of the *wheel_sweep*,
# which is the circle that entirly encloses the wheel location:
wheel_sweep = (wheel.diameter_l / 2 + wheel.width_l / 2) * sqrt2
self.motor_shaft_radius_l = motor_shaft_radius = \
wheel_sweep + twist_motor.spur_gear_body_diameter_l / 2 - \
twist_motor.shaft_offset_l
# The timing belts are basically specified by the number of teeth
# on the belt. Furthermore, the number of teeth seems to be a
# multiple of 5. We start by computing the desired distance between
# the wheel vertical shaft and the twist motor shaft. Then
# that is reduced to a *teeth_radius*. Next, we compute the minimum
# of *belt_teeth*. Next, we round up to a multiple of 5. Finally,
# we recompute the final updated *motor_shaft_radius*:
pulley_teeth = twist_motor_pulley.teeth_count_i
pulley_pitch = twist_motor_pulley.pitch_l
teeth_radius = int(math.ceil(motor_shaft_radius / pulley_pitch))
#print("motor_shaft_radius={0} teeth_radius={1} pulley_teeth={2}".
# format(motor_shaft_radius, teeth_radius, pulley_teeth))
belt_teeth = pulley_teeth + 2 * teeth_radius
while belt_teeth % 5 != 0:
belt_teeth += 1 # Round up
motor_shaft_radius = \
pulley_pitch * float((belt_teeth - pulley_teeth) / 2)
#print("belt_teeth={0} motor_shaft_radius={1}".
# format(belt_teeth, motor_shaft_radius))
# Normally the position of the twist and drive motor shafts
# is computed using polar coordinates from the main shaft.
# All of these various positions of everything are written
# into a file called pcb_holes.txt which is shown below:
#
# pcb corner1: pcb_x=150.0 pcb_y=150.0 x=5.0 y=70.0
# pcb corner2: pcb_x=50.0 pcb_y=50.0 x=105.0 y=170.0
# drive_shaft: pcb_x=107.890135052 pcb_y=121.189510914
# x=47.1098649476 y=98.810489086
# twist_shaft: pcb_x=77.4986166491 pcb_y=140.925993734
# x=77.5013833509 y=79.0740062661
# J #4-40:: pcb_x=147.0 pcb_y=145.0 x=8.0 y=75.0
# K #4-40:: pcb_x=147.0 pcb_y=100.0 x=8.0 y=120.0
# L #4-40:: pcb_x=53.0 pcb_y=100.0 x=102.0 y=120.0
# M #4-40:: pcb_x=53.0 pcb_y=147.0 x=102.0 y=73.0
# N #6-32: pcb_x=143.65 pcb_y=90.65 x=11.35 y=129.35
# O #6-32: pcb_x=143.65 pcb_y=56.35 x=11.35 y=163.65
# P #6-32: pcb_x=56.35 pcb_y=90.65 x=98.65 y=129.35
# Q #6-32: pcb_x=56.35 pcb_y=56.35 x=98.65 y=163.65
#
# After the PCB has been manufactured using these numbers,
# everything has to be made relative to the M corner on
# the Motor_Base. The M corner is (PCBc2.x-3, PCBc1.y+3).
motor_base_m_x = motor_base.m_x_l
motor_base_m_y = motor_base.m_y_l
pcb_corner1_x = motor_base_m_x - L(mm=102) + L(mm=5) - L(mm=3)
pcb_corner1_y = motor_base_m_y - L(mm=73) + L(mm=70) + L(mm=3)
# Offsets from PCB corner1 to twist and drive motor shaft:
twist_motor_dx = L(mm=77.5013833509 - 5)
twist_motor_dy = L(mm=79.0740062661 - 70)
drive_motor_dx = L(mm=47.1098649476 - 5)
drive_motor_dy = L(mm=98.8104890861 - 70)
self.twist_motor_x_l = twist_motor_x = pcb_corner1_x + twist_motor_dx
self.twist_motor_y_l = twist_motor_y = pcb_corner1_y + twist_motor_dy
self.drive_motor_x_l = drive_motor_x = pcb_corner1_x + drive_motor_dx
self.drive_motor_y_l = drive_motor_y = pcb_corner1_y + drive_motor_dy
#print("twist_motor=({0},{1}".format(twist_motor_x, twist_motor_y))
#print("drive_motor=({0},{1}".format(drive_motor_x, drive_motor_y))
#self.twist_motor_angle_a = twist_motor_angle = Angle(deg = 66)
#self.drive_motor_angle_a = drive_motor_angle = Angle(deg = 48)
self.twist_motor_angle_a = twist_motor_angle = Angle(deg = 48)
self.drive_motor_angle_a = drive_motor_angle = Angle(deg = 66)
# Use this code *before* PCB is manufactured:
# Compute the twist/drive motor shaft locations:
#self.twist_motor_x_l = twist_motor_x = \
# motor_shaft_radius.cosine(twist_motor_angle)
#self.twist_motor_y_l = twist_motor_y = \
# motor_shaft_radius.sine(twist_motor_angle)
#self.drive_motor_x_l = drive_motor_x = \
# motor_shaft_radius.cosine(drive_motor_angle)
#self.drive_motor_y_l = drive_motor_y = \
self.drive_motor_shaft_x_l = drive_motor_shaft_x = drive_motor_x
self.drive_motor_shaft_y_l = drive_motor_shaft_y = \
drive_motor_y - drive_motor.shaft_offset_l
self.twist_motor_shaft_x_l = twist_motor_shaft_x = twist_motor_x
self.twist_motor_shaft_y_l = twist_motor_shaft_y = \
twist_motor_y - twist_motor.shaft_offset_l
# Configure *drive_belt*:
drive_wheel_pulley_lip_bz = \
drive_wheel_pulley.b.z + drive_wheel_pulley.lip_height_l
drive_wheel_pulley_lip_tz = drive_wheel_pulley.t.z
drive_wheel_pulley_lip_cz = \
(drive_wheel_pulley_lip_bz + drive_wheel_pulley_lip_tz) / 2
drive_belt_height = L(inch = "1/8")
drive_belt.configure(
r1 = drive_wheel_pulley.tooth_radius_l,
x1 = zero,
y1 = zero,
z1 = drive_wheel_pulley_lip_cz - drive_belt_height / 2,
r2 = drive_wheel_pulley.tooth_radius_l,
x2 = drive_motor_shaft_x,
y2 = drive_motor_shaft_y,
z2 = drive_wheel_pulley_lip_cz + drive_belt_height / 2,
width = drive_wheel_pulley.tooth_height_l)
# Configure *drive_magnet*:
drive_magnet_dz = L(inch = "1/8")
drive_magnet.configure(
diameter = L(inch = "1/4"),
dz = drive_magnet_dz,
x = drive_motor_shaft_x,
y = drive_motor_shaft_y,
z_bottom = pcb.magnet_z_top_l - drive_magnet_dz)
# Configure *drive_motor_pulley*:
drive_motor_pulley_lip_height = \
(drive_wheel_pulley.t.z - drive_wheel_pulley.belt_width_l - \
drive_wheel_pulley.belt_width_extra_l) - twist_motor_pulley.b.z
drive_motor_pulley.configure(
belt_class = drive_wheel_pulley.belt_class_s,
belt_width = drive_wheel_pulley.belt_width_l,
belt_width_extra = drive_wheel_pulley.belt_width_extra_l,
holes_radius = L(mm = 10.00),
lip_extra = drive_wheel_pulley.lip_extra_l,
lip_height = drive_motor_pulley_lip_height,
name = "Drive_Motor_Pulley",
set_screw_dz = drive_motor_pulley_lip_height / 2,
shaft_diameter = drive_motor.shaft_diameter_l,
teeth_count = drive_wheel_pulley.teeth_count_i,
x = drive_motor_shaft_x,
y = drive_motor_shaft_y,
z_bottom = twist_motor_pulley.b.z)
# Configure *drive_motor_pulley_top*:
drive_motor_pulley_top_lip_dz = L(mm = 6.00)
drive_motor_pulley_top_z_bottom = drive_motor_pulley.t.z
drive_motor_pulley_top_hub_dz = pcb.magnet_z_top_l - \
drive_motor_pulley_top_z_bottom - drive_motor_pulley_top_lip_dz
drive_motor_pulley_top.configure(
hub_diameter = drive_motor.shaft_diameter_l + L(mm = 6),
hub_dz = drive_motor_pulley_top_hub_dz,
lip_diameter = drive_wheel_pulley.dx,
lip_dz = drive_motor_pulley_top_lip_dz,
magnet_diameter = drive_magnet.dx,
magnet_dz = drive_magnet.dz,
shaft_diameter = drive_motor.shaft_diameter_l,
x = drive_motor_shaft_x,
y = drive_motor_shaft_y,
z_bottom = drive_motor_pulley.t.z)
# Do *pcb* configuration:
pcb_x1 = motor_base.m_x_l - L(100)
pcb_y1 = motor_base.m_y_l
pcb_dz = L(mm = 1.6)
#pcb_x1 = L(mm = 5)
#pcb_y1 = L(mm = 70)
pcb.configure(x1 = pcb_x1, y1 = pcb_y1,
x2 = pcb_x1 + L(mm = 100), y2 = pcb_y1 + L(mm = 100),
dz = pcb_dz, z_bottom = motor_base.t.z - pcb_dz)
#print("pcb.bsw={0} pcb.tne={1}".format(pcb.bsw, pcb.tne))
# Do the *twist_belt* configuration:
twist_wheel_pulley_lip_bz = \
twist_wheel_pulley.b.z + twist_wheel_pulley.lip_height_l
twist_wheel_pulley_lip_tz = twist_wheel_pulley.t.z
twist_wheel_pulley_lip_cz = \
(twist_wheel_pulley_lip_bz + twist_wheel_pulley_lip_tz) / 2
twist_belt_height = L(inch = "1/8")
twist_belt.configure(
r1 = twist_wheel_pulley.tooth_radius_l,
x1 = zero,
y1 = zero,
z1 = twist_wheel_pulley_lip_cz - twist_belt_height / 2,
r2 = twist_wheel_pulley.tooth_radius_l,
x2 = twist_motor_shaft_x,
y2 = twist_motor_shaft_y,
z2 = twist_wheel_pulley_lip_cz + twist_belt_height / 2,
width = twist_wheel_pulley.tooth_height_l)
# Configure *twist_magnet*:
twist_magnet_dz = L(inch = "1/8")
twist_magnet.configure(
diameter = L(inch = "1/4"),
dz = twist_magnet_dz,
x = twist_motor_shaft_x,
y = twist_motor_shaft_y,
z_bottom = pcb.magnet_z_top_l - twist_magnet_dz)
# Do the *twist_motor* configuration:
twist_motor.configure(
x = twist_motor_x,
y = twist_motor_y,
z = motor_base.b.z,
spur_gear_body_dz = L(mm = 27.00))
drive_motor.configure(
x = drive_motor_x,
y = drive_motor_y,
z = motor_base.b.z,
spur_gear_body_dz = L(mm = 18.50))
# Do the *twist_motor_pulley* configuration:
twist_motor_pulley.configure(
belt_class = twist_wheel_pulley.belt_class_s,
belt_width = twist_wheel_pulley.belt_width_l,
belt_width_extra = twist_wheel_pulley.belt_width_extra_l,
lip_extra = twist_wheel_pulley.lip_extra_l,
lip_height = L(mm = 2.00),
name = "Twist_Motor_Pulley",
holes_radius = L(mm = 10.00),
shaft_diameter = twist_motor.shaft_diameter_l,
teeth_count = twist_wheel_pulley.teeth_count_i,
x = twist_motor_shaft_x,
y = twist_motor_shaft_y,
z_bottom = motor_base.b.z + motor_base.floor_dz_l + L(mm = 0.50))
# Configure *twist_motor_pulley_top*:
twist_motor_pulley_top_lip_dz = L(mm = 8.00)
twist_motor_pulley_top_z_bottom = twist_motor_pulley.t.z
twist_motor_pulley_top_hub_dz = pcb.magnet_z_top_l - \
twist_motor_pulley_top_z_bottom - twist_motor_pulley_top_lip_dz
twist_motor_pulley_top.configure(
hub_diameter = twist_motor.shaft_diameter_l + L(mm = 6),
hub_dz = twist_motor_pulley_top_hub_dz,
lip_diameter = twist_wheel_pulley.dx,
lip_dz = twist_motor_pulley_top_lip_dz,
magnet_diameter = twist_magnet.dx,
magnet_dz = twist_magnet.dz,
set_screw_dz = L(mm = 4.00),
shaft_diameter = twist_motor.shaft_diameter_l,
x = twist_motor_shaft_x,
y = twist_motor_shaft_y,
z_bottom = twist_motor_pulley.t.z)
zero = L()
self.base_bz_l = base_bz = gear_box.t.z + turn_table.height_l
class Wheel_Assembly(Part):
def __init__(self, up):
Part.__init__(self, up)
# List all of the sub-*Part*'s that make up a wheel assembly:
self.bottom_bearing_ = Bearing(self)
self.drive_wheel_pulley_ = Pulley(self)
self.drive_wheel_pulley_top_ = Pulley_Top(self)
self.drive_wheel_pulley_screws_ = Drive_Wheel_Pulley_Screws(self)
self.gear_box_ = Gear_Box(self)
self.gear_box_bottom_ = Gear_Box_Bottom(self)
self.gear_box_bottom_screws_ = Gear_Box_Screws(self, label="Bottom")
self.gear_box_shelf_ = Gear_Box_Shelf(self)
self.gear_box_shelf_screws_ = Gear_Box_Screws(self, label="Shelf")
self.gear_box_top_ = Gear_Box_Top(self)
self.gear_box_top_screws_ = Gear_Box_Screws(self, label="Top")
self.horizontal_shaft_ = Horizontal_Shaft(self)
self.north_bearing_ = Bearing(self)
self.north_gear_box_side_ = Gear_Box_Side(self, False)
self.south_bearing_ = Bearing(self)
self.south_bevel_gear_ = \
Bevel_Gear(self, part_name = "A 1M 4-Y16016", color = Color("red"))
self.south_gear_box_side_ = Gear_Box_Side(self, True)
self.south_shim_ = Shim(self)
self.top_bearing_ = Bearing(self)
self.top_bevel_gear_ = \
Bevel_Gear(self, part_name = "A 1M 4-Y16016", color = Color("red"))
self.top_shim_ = Shim(self)
self.turn_table_ = Turn_Table(self)
self.turn_table_bottom_screws_ = Turn_Table_Bottom_Screws(self)
self.twist_wheel_pulley_ = Pulley(self)
self.twist_wheel_pulley_top_ = Pulley_Top(self)
self.twist_wheel_pulley_screws_ = Twist_Wheel_Pulley_Screws(self)
self.vertical_shaft_ = Vertical_Shaft(self)
self.west_gear_box_cover_ = Gear_Box_Cover(self)
self.wheel_ = Wheel(self)
def construct(self):
""" *Wheel_Assembly*: Construct method. """
# The origin of this assembly is at the logical intersection
# of the vertical shaft and the horizontal shaft. The horizontal
# axis is aligned with the Y axis; this causes the wheel to be
# oriented to roll in the direction of the X axis.
# Grab some values from *wheel_assembly* (i.e. *self*):
wheel_assembly = self
bottom_bearing = wheel_assembly.bottom_bearing_
drive_wheel_pulley = wheel_assembly.drive_wheel_pulley_
drive_wheel_pulley_top = wheel_assembly.drive_wheel_pulley_top_
gear_box = wheel_assembly.gear_box_
gear_box_cover = wheel_assembly.west_gear_box_cover_
gear_box_bottom = wheel_assembly.gear_box_bottom_
gear_box_bottom_screws = wheel_assembly.gear_box_bottom_screws_
gear_box_side = wheel_assembly.south_gear_box_side_
gear_box_shelf = wheel_assembly.gear_box_shelf_
gear_box_shelf_screws = wheel_assembly.gear_box_shelf_screws_
gear_box_top = wheel_assembly.gear_box_top_
gear_box_top_screws = wheel_assembly.gear_box_top_screws_
north_bearing = wheel_assembly.north_bearing_
south_bearing = wheel_assembly.south_bearing_
south_bevel_gear = wheel_assembly.south_bevel_gear_
south_shim = wheel_assembly.south_shim_
top_bearing = wheel_assembly.top_bearing_
top_bevel_gear = wheel_assembly.top_bevel_gear_
top_shim = wheel_assembly.top_shim_
turn_table = wheel_assembly.turn_table_
twist_wheel_pulley = wheel_assembly.twist_wheel_pulley_
twist_wheel_pulley_top = wheel_assembly.twist_wheel_pulley_top_
vertical_shaft = wheel_assembly.vertical_shaft_
synchro_drive = wheel_assembly.up
motor_assembly = synchro_drive.motor_assembly_
motor_base = motor_assembly.motor_base_
twist_motor_pulley = motor_assembly.twist_motor_pulley_
belt_width_extra = L(inch=.012)
lip_height = (twist_motor_pulley.t.z - \
twist_motor_pulley.belt_width_l - \
twist_motor_pulley.belt_width_extra_l) - turn_table.b.z
twist_wheel_pulley.configure(
bearing_diameter = top_bearing.diameter_l,
bearing_sides = top_bearing.sides_i,
bearing_width = top_bearing.width_l,
belt_class = "MXL",
belt_width = L(inch = "1/8"),
belt_width_extra = belt_width_extra,
lip_extra = L(mm = 0.5),
lip_height = lip_height,
name = "Twist_Wheel_Pulley",
shaft_diameter = L(inch = "1/2"),
teeth_count = 46,
z_bottom = gear_box.t.z)
twist_wheel_pulley_top.configure(
lip_diameter = twist_wheel_pulley.lip_diameter_l,
lip_dz = L(mm = 2.00),
shaft_diameter = (top_bearing.diameter_l + top_bearing.bore_l) / 2,
z_bottom = twist_wheel_pulley.t.z)
drive_wheel_pulley.configure(
belt_class = "MXL",
belt_width = L(inch = "1/8"),
belt_width_extra = belt_width_extra,
holes_radius = L(mm = 10.00),
lip_extra = L(mm = 0.50),
lip_height = L(mm = 2.00),
name = "Drive_Wheel_Pulley",
shaft_diameter = vertical_shaft.diameter_l,
teeth_count = 46,
z_bottom = twist_wheel_pulley_top.t.z + L(mm = 1.00))
# hub_diameter = vertical_shaft.dx + L(mm = 10),
drive_wheel_pulley_top.configure(
hub_diameter = drive_wheel_pulley.dx,
hub_dz = L(mm = 6.00),
lip_diameter = drive_wheel_pulley.dx,
lip_dz = L(mm = 2.00),
set_screw_dz = L(mm = 4.00),
shaft_diameter = vertical_shaft.dx,
z_bottom = drive_wheel_pulley.t.z)
# Compute various locations along the Y axis:
zero = L()
y0 = zero
y1 = y0 + south_bevel_gear.major_diameter_l
y2 = y1 + south_shim.width_l
y3 = y2 + south_bearing.width_l / 2
y4 = y2 + south_bearing.width_l
y5 = y4 + gear_box_side.bearing_lip_dy_l
# The pockets that screws go to are all the same for the top, shelf,
# and bottom:
self.pocket_wall_dx_l = pocket_wall_dx = L(mm = 4.00)
self.pocket_wall_dy_l = pocket_wall_dy = L(mm = 4.00)
self.pocket_dx_l = \
gear_box.dx - 2 * gear_box_cover.dx - 2 * pocket_wall_dx
self.pocket_dy_l = \
gear_box.dy - 2 * gear_box_side.dy - 2 * pocket_wall_dy
self.pocket_dz_l = L(mm = 8.00)
# Place various items into the wheel assembly:
one = L(mm = 1.0)
x_axis = P(one, zero, zero)
degrees_90 = Angle(deg = 90)
# Place the 4 bearings:
south_bearing.place(axis = x_axis,
rotate = degrees_90, translate = P(zero, -y3, zero))
north_bearing.place(axis = x_axis,
rotate = degrees_90, translate = P(zero, y3, zero))
bottom_bearing.place(translate = P(zero, zero, gear_box_shelf.t.z -
gear_box_shelf.bearing_lip_dz_l - bottom_bearing.width_l / 2))
p = P(zero, zero, twist_wheel_pulley.t.z - top_bearing.width_l / 2)
top_bearing.place(translate = p)
# Place the horizontal bevel gear. (The vertical bevel gear is
# is already placed relative to the origin.):
south_bevel_gear.place(axis = x_axis, rotate = degrees_90)
# Place the shims on next to the bevel gears:
top_shim.place(translate = P(zero, zero, y1))
south_shim.place(axis = x_axis,
rotate = degrees_90, translate = P(zero, -y1, zero))
# Drop in the turn table:
turn_table.place(translate = P(zero, zero, gear_box.t.z))
# Configure the screws:
gear_box_bottom_screws.configure(
z = gear_box_bottom.screw_z_l,
gear_box_part = gear_box_bottom)
gear_box_shelf_screws.configure(
z = gear_box_shelf.screw_z_l,
gear_box_part = gear_box_shelf)
gear_box_top_screws.configure(
z = gear_box_top.screw_z_l,
gear_box_part = gear_box_top)
# Various parts:
class Bearing(Part):
def construct(self):
# R6ZZ Shield Ball Bearing from VBX.Com:
self.bore_l = bore = L(inch = "3/8")
self.diameter_l = diameter = L(inch = "7/8")
self.width_l = width = L(inch = "9/32")
self.sides_i = sides = 60
zero = L()
self.cylinder(comment = "Bearing Cylinder",
material = Material("steel", ""),
color = Color("blue"),
diameter = diameter,
start = P(zero, zero, -width / 2),
end = P(zero, zero, width / 2),
sides = sides)
self.hole(comment = "Bore Hole",
diameter = bore,
start = P(zero, zero, -width / 2),
end = P(zero, zero, width / 2),
flags = "t",
sides = sides)
class Belt(Part):
def __init__(self, up):
Part.__init__(self, up)
zero = L()
self.x1_l = zero
self.y1_l = zero
self.x2_l = zero
self.y2_l = zero
def configure(self, r1 = None, x1 = None, y1 = None, z1 = None,
r2 = None, x2 = None, y2 = None, z2 = None, width = None):
# Check argument_types:
none_type = type(None)
assert type(x1) == none_type or isinstance(x1, L)
assert type(y1) == none_type or isinstance(y1, L)
assert type(z1) == none_type or isinstance(z1, L)
assert type(r1) == none_type or isinstance(r1, L)
assert type(x2) == none_type or isinstance(x2, L)
assert type(y2) == none_type or isinstance(y2, L)
assert type(z2) == none_type or isinstance(z2, L)
assert type(r2) == none_type or isinstance(r2, L)
assert type(width) == none_type or isinstance(width, L)
# Load up configuration values:
if isinstance(r1, L):
self.r1_l = r1
if isinstance(x1, L):
self.x1_l = x1
if isinstance(y1, L):
self.y1_l = y1
if isinstance(z1, L):
self.z1_l = z1
if isinstance(r2, L):
self.r2_l = r2
if isinstance(x2, L):
self.x2_l = x2
if isinstance(y2, L):
self.y2_l = y2
if isinstance(z2, L):
self.z2_l = z2
if isinstance(width, L):
self.width_l = width
def construct(self):
# Grab values from *self*:
r1 = self.r1_l
x1 = self.x1_l
y1 = self.y1_l
z1 = self.z1_l
r2 = self.r2_l
x2 = self.x2_l
y2 = self.y2_l
z2 = self.z2_l
width = self.width_l
zero = L()
# Figure out direction vector from (*x1*, *y1*) to (*x2*, *y2*).
dx = x2 - x1
dy = y2 - y1
bearing = dy.arc_tangent2(dx)
# Compute the 4 corners of the belt (*x1a*, *y1a*), (*x1b*, *y1b*),
# (*x2a*, *y2a*), and (*x2b*, *y2b*):
sqrt2_r1 = math.sqrt(2) * r1
angle1a = bearing + Angle(deg = 135)
x1a = x1 + sqrt2_r1.cosine(angle1a)
y1a = y1 + sqrt2_r1.sine(angle1a)
angle1b = bearing - Angle(deg = 135)
x1b = x1 + sqrt2_r1.cosine(angle1b)
y1b = y1 + sqrt2_r1.sine(angle1b)
sqrt2_r2 = math.sqrt(2) * r2
angle2a = bearing + Angle(deg = 45)
x2a = x2 + sqrt2_r2.cosine(angle2a)
y2a = y2 + sqrt2_r2.sine(angle2a)
angle2b = bearing - Angle(deg = 45)
x2b = x2 + sqrt2_r2.cosine(angle2b)
y2b = y2 + sqrt2_r2.sine(angle2b)
outer_contour = Contour()
outer_contour.bend_append(P(x2a, y2a, z1), r2)
outer_contour.bend_append(P(x2b, y2b, z1), r2)
outer_contour.bend_append(P(x1b, y1b, z1), r1)
outer_contour.bend_append(P(x1a, y1a, z1), r1)
# Compute center of belt:
center_z1 = (P(x1, y1, z1) + P(x2, y2, z1)) / 2
center_z2 = (P(x1, y1, z2) + P(x2, y2, z2)) / 2
inner_contour = outer_contour.adjust(
delta = -width,
start = center_z1,
end = center_z2)
self.extrude(
comment = "Belt ({0},{1},{2}) - ({3},{4},{5})".
format(r1, x1, y1, r2, x2, y2),
material = Material("plastic", "ABS"),
color = Color("brown"),
outer_contour = outer_contour,
inner_contours = [inner_contour],
start = center_z1,
end = center_z2)
class Bevel_Gear(Part):
def __init__(self, up, part_name, color):
Part.__init__(self, up)
# Check argument types:
assert isinstance(part_name, str)
assert isinstance(color, Color)
# Lookup up the *bevel_gear*:
bevel_gear_table = Bevel_Gear_Table()
table = bevel_gear_table.table
assert part_name in table
bevel_gear_data = table[part_name]
# Load up *self*:
self.part_name_s = part_name
self.bevel_gear_data_o = bevel_gear_data
self.color = color
self.pitch_i = bevel_gear_data.pitch
self.teeth_i = bevel_gear_data.teeth
self.pitch_diameter_l = bevel_gear_data.pitch_diameter
self.outside_diameter_l = bevel_gear_data.outside_diameter
self.bore_l = bevel_gear_data.bore
self.height_l = bevel_gear_data.height
self.hub_diameter_l = bevel_gear_data.hub_diameter
self.hub_heigh_l = bevel_gear_data.hub_height
self.major_diameter_l = bevel_gear_data.major_diameter
def construct(self):
# Grab some values from *bevel_gear*:
bevel_gear_data = self.bevel_gear_data_o
material = bevel_gear_data.material
outside_diameter = bevel_gear_data.outside_diameter
bore = bevel_gear_data.bore
height = bevel_gear_data.height
hub_diameter = bevel_gear_data.hub_diameter
hub_height = bevel_gear_data.hub_height
major_diameter = bevel_gear_data.major_diameter
color = self.color
zero = L()
self.nz_l = major_diameter
self.cylinder(comment = "Bevel Gear Teeth",
material = material,
color = Color("red"),
diameter = outside_diameter,
start = P(zero, zero, major_diameter - height),
end = P(zero, zero, major_diameter - hub_height),
sides = 30)
self.cylinder(comment = "Bevel Gear Hub",
diameter = hub_diameter,
start = P(zero, zero, major_diameter - hub_height),
end = P(zero, zero, major_diameter),
sides = 30)
self.hole(comment = "Bore Hole",
diameter = bore,
start = P(zero, zero, major_diameter),
end = P(zero, zero, major_diameter - height),
flags = "t")
class Bevel_Gear_Data:
# From www.sdp-si.com:
#
# Mat Teeth PD OD Bore Height Hub Diam Hub Height Maj Diam
#
# 48 Pitch:
# Actel 15 .313 .350 .125 7/32 1/4 1/8 5/16
# Nylon 18 .375 .404 .125 9/32 21/64 1/4 13/32
# Nylon 24 .500 .529 .187 3/8 3/8 1/4 17/3
# 32 Pitch:
# Nylon 24 .750 .800 .187 13/32 1/2 3/16 11/16
# Nylon 16 .500 .550 .187 11/32 13/32 3/16 1/2
# 24 Pitch:
# Nylon 24 1.000 1.045 .253 9/16 5/8 3/16 7/8
# Nylon 30 1.250 1.310 .250 37/64 5/8 5/16 1-1/32
# Nylon 36 1.500 1.560 .312 39/64 11/16 5/16 1-3/16
# 16 Pitch:
# Nylon 16 1.000 1.090 .375 3/4 3/4 7/16 1-1/16
# ~Nylon 32 2.000 2.088 .500 7/8 1-1/4 3/8 1-9/16
# Part number: 1M 4-ppttt Where pp is pitch and ttt is teeth
#
# Part Number 1-24 25-99 100-249 250-999 1000+
# A 1M 4-Y48015: 2.85 1.73 1.31 1.11 0.87
# A 1M 4-Y48018: 2.85 1.73 1.31 1.11 0.87
# A 1M 4-Y48024: 2.85 1.73 1.31 1.11 0.86
#
# A 1M 4-Y32024: 2.96 1.83 1.39 1.19 0.94
# A 1M 4-Y32016: 2.92 1.80 1.36 1.16 0.92
#
# A 1M 4-Y24024: 3.39 2.31 1.87 1.67 1.45
# A 1M 4-Y24030: 3.41 2.34 1.89 1.70 1.47
# A 1M 4-Y24036: 3.46 2.37 1.92 1.72 1.50
#
# A 1M 4-Y16016: 3.41 2.34 1.89 1.70 1.47
# A 1M 4-Y16032: 5.63 4.28 3.67 3.43 3.17
def __init__(self, part_name = None, material = None, pitch = None,
teeth = None, pitch_diameter = None, outside_diameter = None,
bore = None, height = None, hub_diameter = None, hub_height = None,
major_diameter = None, cost1_24 = None, cost25_99 = None,
cost100_249 = None, cost250_999 = None, cost_1000_plus = None):
# Check argument types:
assert isinstance(part_name, str)
assert isinstance(material, Material)
assert isinstance(pitch, int)
assert isinstance(teeth, int)
assert isinstance(pitch_diameter, L)
assert isinstance(outside_diameter, L)
assert isinstance(bore, L)
assert isinstance(height, L)
assert isinstance(hub_diameter, L)
assert isinstance(hub_height, L)
assert isinstance(major_diameter, L)
assert isinstance(cost1_24, float)
assert isinstance(cost25_99, float)
assert isinstance(cost100_249, float)
assert isinstance(cost250_999, float)
assert isinstance(cost_1000_plus, float)
# Load up *self*:
self.part_name = part_name
self.material = material
self.pitch = pitch
self.teeth = teeth
self.pitch_diameter = pitch_diameter
self.outside_diameter = outside_diameter
self.bore = bore
self.height = height
self.hub_diameter = hub_diameter
self.hub_height = hub_height
self.major_diameter = major_diameter
self.cost1_24 = cost1_24
self.cost25_99 = cost25_99
self.cost100_249 = cost100_249
self.cost250_999 = cost250_999
self.cost_1000_plus = cost_1000_plus
class Bevel_Gear_Table:
def __init__(self):
bevel_gears = [
Bevel_Gear_Data(
part_name = "A 1M 4-Y48015",
material = Material("plastic", "actel"),
pitch = 48,
teeth = 15,
pitch_diameter = L(inch = 0.313),
outside_diameter = L(inch = 0.350),
bore = L(inch = 0.125),
height = L(inch = "7/32"),
hub_diameter = L(inch = "1/4"),
hub_height = L(inch = "1/8"),
major_diameter = L(inch = "5/16"),
cost1_24 = 2.85,
cost25_99 = 1.73,
cost100_249 = 1.31,
cost250_999 = 1.11,
cost_1000_plus = 0.87),
Bevel_Gear_Data(
part_name = "A 1M 4-Y16016",
material = Material("plastic", "nylon"),
pitch = 16,
teeth = 16,
pitch_diameter = L(inch = 1.000),
outside_diameter = L(inch = 1.090),
bore = L(inch = 0.375),
height = L(inch = "3/4"),
hub_diameter = L(inch = "3/4"),
hub_height = L(inch = "7/16"),
major_diameter = L(inch = "1-1/16"),
cost1_24 = 3.41,
cost25_99 = 2.34,
cost100_249 = 1.89,
cost250_999 = 1.70,
cost_1000_plus = 1.47) ]
self.table = table = {}
for bevel_gear in bevel_gears:
part_name = bevel_gear.part_name
assert not part_name in table
table[part_name] = bevel_gear
class Drive_Motor_Pulley_Screws(Part):
def __init__(self, up):
Part.__init__(self, up)
self.screw0_ = Fastener(self, comment="screw0")
self.screw1_ = Fastener(self, comment="screw1")
self.screw2_ = Fastener(self, comment="screw2")
self.screw3_ = Fastener(self, comment="screw3")
def construct(self):
# Grab some values from *wheel_assembly*:
wheel_assembly = self.up
drive_motor_pulley = wheel_assembly.drive_motor_pulley_
drive_motor_pulley_top = wheel_assembly.drive_motor_pulley_top_
# Create the 6 screws:
screw0 = self.screw0_
screw1 = self.screw1_
screw2 = self.screw2_
screw3 = self.screw3_
screws = [screw0, screw1, screw2, screw3]
# Compute some Z axis locations:
z0 = drive_motor_pulley.b.z