Skip to content

Commit b0715a8

Browse files
cad: add assembly_jig part
1 parent 5e7cb0d commit b0715a8

File tree

1 file changed

+79
-35
lines changed

1 file changed

+79
-35
lines changed

cad/column_rod_housing_assembly.py

Lines changed: 79 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ class HousingSpec:
137137
zeroing_magnet_od: float = 2.0
138138
zeroing_magnet_height: float = 0.7 # Sink it a bit more.
139139

140+
# MARK: Assembly jig settings.
141+
motor_body_od: float = 4.7
142+
140143
def __post_init__(self) -> None:
141144
"""Post initialization checks."""
142145
magnet_coord_y = (
@@ -443,8 +446,9 @@ def make_housing(spec: HousingSpec) -> bd.Part | bd.Compound:
443446
# -Y, stick through the wall, small diameter.
444447
p_neg_rod += (
445448
bd.Cylinder(
446-
radius=spec.rod_od_through_wall_pivot_side / 2
447-
+ spec.rod_slop_diameter / 2,
449+
radius=(
450+
spec.rod_od_through_wall_pivot_side / 2 + spec.rod_slop_diameter / 2
451+
),
448452
height=(spec.inner_cavity_size_y),
449453
align=bde.align.ANCHOR_BOTTOM,
450454
)
@@ -474,10 +478,8 @@ def make_housing(spec: HousingSpec) -> bd.Part | bd.Compound:
474478
return p
475479

476480

477-
def make_final_octagon_cam_rod(
478-
motor_side: Literal["+Z", "-Z"] = "+Z",
479-
) -> bd.Part | bd.Compound:
480-
"""Make the octagon cam rod."""
481+
def get_nominal_housing_spec() -> HousingSpec:
482+
"""Get the nominal housing specification."""
481483
cam_spec = dot_column_cam_rod_octagon.MainSpec()
482484

483485
rod_part = dot_column_cam_rod_octagon.make_cam_rod(cam_spec)
@@ -492,6 +494,14 @@ def make_final_octagon_cam_rod(
492494
length=cam_spec.cam_rod_length,
493495
),
494496
)
497+
return housing_spec
498+
499+
500+
def make_final_octagon_cam_rod(
501+
motor_side: Literal["+Z", "-Z"] = "+Z",
502+
) -> bd.Part | bd.Compound:
503+
"""Make the octagon cam rod."""
504+
housing_spec = get_nominal_housing_spec()
495505

496506
full_rod_part = make_octagon_rod(housing_spec, motor_side=motor_side)
497507

@@ -501,20 +511,7 @@ def make_final_octagon_cam_rod(
501511
def make_octagon_cam_housing_no_rods() -> bd.Part | bd.Compound:
502512
"""Make the octagon cam housing in place."""
503513
# TODO(KilowattSynthesis): Could add arg - housing_spec_overrides: dict[str, Any]
504-
cam_spec = dot_column_cam_rod_octagon.MainSpec()
505-
506-
rod_part = dot_column_cam_rod_octagon.make_cam_rod(cam_spec)
507-
508-
housing_spec = HousingSpec(
509-
rod_part=rod_part,
510-
rod_props=GenericRodProperties(
511-
min_od=cam_spec.cam_rod_diameter_major,
512-
max_od=cam_spec.cam_rod_diameter_major,
513-
od_top_end=cam_spec.cam_rod_diameter_major,
514-
od_bottom_end=cam_spec.cam_rod_diameter_major,
515-
length=cam_spec.cam_rod_length,
516-
),
517-
)
514+
housing_spec = get_nominal_housing_spec()
518515

519516
print_pcb_column_x_coords(housing_spec)
520517

@@ -528,17 +525,7 @@ def make_octagon_cam_housing_assembly_preview() -> bd.Part | bd.Compound:
528525
rod_part_pos_z = make_final_octagon_cam_rod("+Z")
529526
rod_part_neg_z = make_final_octagon_cam_rod("-Z")
530527

531-
cam_spec = dot_column_cam_rod_octagon.MainSpec()
532-
housing_spec = HousingSpec(
533-
rod_part=dot_column_cam_rod_octagon.make_cam_rod(cam_spec),
534-
rod_props=GenericRodProperties(
535-
min_od=cam_spec.cam_rod_diameter_major,
536-
max_od=cam_spec.cam_rod_diameter_major,
537-
od_top_end=cam_spec.cam_rod_diameter_major,
538-
od_bottom_end=cam_spec.cam_rod_diameter_major,
539-
length=cam_spec.cam_rod_length,
540-
),
541-
)
528+
housing_spec = get_nominal_housing_spec()
542529

543530
p = bd.Part(None)
544531
p += make_octagon_cam_housing_no_rods()
@@ -595,16 +582,72 @@ def print_pcb_column_x_coords(
595582
)
596583

597584

585+
def assembly_jig(housing_spec: HousingSpec) -> bd.Part | bd.Compound:
586+
"""Create the assembly jig for the column rod housing.
587+
588+
Holds the motors in place so they can be soldered into the PCB easily.
589+
"""
590+
p = bd.Part(None)
591+
592+
# Create the base of the jig.
593+
p += bd.Box(
594+
housing_spec.total_x + 10,
595+
jig_total_y := 10,
596+
10,
597+
align=bde.align.ANCHOR_BOTTOM,
598+
)
599+
600+
# Create holes for the motor bodies.
601+
for cell_x in housing_spec.get_cell_center_x_values():
602+
rod_x = cell_x + housing_spec.rod_pitch_x / 2
603+
604+
p -= bd.Pos(X=rod_x, Z=housing_spec.rod_center_z_from_bottom) * (
605+
# Rounded cylinder is the top.
606+
bd.Cylinder(
607+
radius=housing_spec.motor_body_od / 2 + 0.2,
608+
height=30, # Arbitrary.
609+
).rotate(
610+
axis=bd.Axis.X,
611+
# -90 puts the top-side of the rod at the back.
612+
angle=-90,
613+
)
614+
# Square extension out the bottom.
615+
+ bd.Box(
616+
housing_spec.motor_body_od + 0.4,
617+
30, # Arbitrary through the bottom.
618+
30, # Arbitrary through the bottom.
619+
align=bde.align.ANCHOR_TOP,
620+
)
621+
)
622+
623+
# Remove the main box so it can sorta slot in over it.
624+
for z_rot in (0, 180):
625+
p -= (
626+
bd.Box(
627+
housing_spec.total_x + 0.4,
628+
jig_total_y,
629+
30,
630+
align=(bd.Align.CENTER, bd.Align.MAX, bd.Align.MIN),
631+
)
632+
.translate((0, -jig_total_y / 2 + 3, 0))
633+
.rotate(bd.Axis.Z, angle=z_rot)
634+
)
635+
636+
return p
637+
638+
598639
def preview_all() -> bd.Part | bd.Compound:
599640
"""Quick preview of all the parts."""
600641
housing_part = make_octagon_cam_housing_no_rods()
601-
rod_part = make_final_octagon_cam_rod().translate((0, -10, 0))
642+
rod_part = make_final_octagon_cam_rod().translate((-40, 0, 0))
643+
644+
assembly_jig_part = assembly_jig(get_nominal_housing_spec()).translate((0, -25, 0))
602645

603646
housing_and_rod_assembly = make_octagon_cam_housing_assembly_preview().translate(
604647
(0, 25, 0)
605648
)
606649

607-
p = housing_part + rod_part + housing_and_rod_assembly
650+
p = housing_part + rod_part + housing_and_rod_assembly + assembly_jig_part
608651

609652
if isinstance(p, list):
610653
p = bd.Compound(p)
@@ -674,13 +717,14 @@ def printable_cam_rods() -> bd.Part | bd.Compound:
674717
logger.info(f"Running {py_file_name}")
675718

676719
parts = {
677-
"printable_cam_rods": show(printable_cam_rods()),
720+
"preview_all": show(preview_all()),
721+
"printable_cam_rods": (printable_cam_rods()),
678722
"octagon_cam_rod": (make_final_octagon_cam_rod()),
679723
"octagon_cam_housing": (make_octagon_cam_housing_no_rods()),
680724
"octagon_cam_housing_assembly_preview": (
681725
make_octagon_cam_housing_assembly_preview()
682726
),
683-
"preview_all": (preview_all()),
727+
"assembly_jig": (assembly_jig(get_nominal_housing_spec())),
684728
}
685729

686730
logger.info("Saving CAD model(s)...")

0 commit comments

Comments
 (0)