Skip to content

Commit ec7e098

Browse files
cad(enclosure): improve render, move springs
1 parent 95f38e5 commit ec7e098

File tree

2 files changed

+54
-23
lines changed

2 files changed

+54
-23
lines changed

cad/column_rod_enclosure.py

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ class Spec:
4242
cell_count_x: int = 4
4343
dot_hole_id: float = 1.7
4444

45-
pcb_length_x: float = 95
46-
pcb_length_y: float = 99
45+
pcb_length_x: float = 95.1
46+
pcb_length_y: float = 99.1
4747

4848
# Settings controlling the Z travel of the PCB inside in the enclosure.
4949
pcb_thickness: float = 0.8
@@ -283,18 +283,13 @@ def make_enclosure_top(spec: Spec) -> bd.Part | bd.Compound:
283283
# + spec.pcb_travel_z
284284
# )
285285
for x_corner, y_corner in product((1, -1), (1, -1)):
286-
for x_small_multiplier, y_small_multiplier in ((1, 0), (0, 1)):
286+
for x_cut_in, y_cut_in in (
287+
(spec.spring_post_margin_from_pcb_edge, spec.spring_post_od),
288+
# (spec.spring_post_od, spec.spring_post_margin_from_pcb_edge),
289+
):
287290
p += bd.Pos(
288-
x_corner
289-
* (
290-
spec.pcb_length_x / 2
291-
- spec.spring_post_margin_from_pcb_edge * x_small_multiplier
292-
),
293-
y_corner
294-
* (
295-
spec.pcb_length_y / 2
296-
- spec.spring_post_margin_from_pcb_edge * y_small_multiplier
297-
),
291+
x_corner * (spec.pcb_length_x / 2 - x_cut_in),
292+
y_corner * (spec.pcb_length_y / 2 - y_cut_in),
298293
spring_post_y_max,
299294
) * bd.Cylinder(
300295
radius=spec.spring_post_od / 2,
@@ -346,7 +341,7 @@ def make_enclosure_bottom(spec: Spec) -> bd.Part | bd.Compound:
346341
# Add the stand offs from the bottom wall.
347342
# Used to be at the `spec.get_pcb_raiser_screw_coordinates()` locations, but place
348343
# at the corners now.
349-
for x_sign, y_sign in product((1, -1), (1, -1)):
344+
for x_sign, y_sign in product((1, -1, 0), (1, -1)):
350345
p += bd.Pos(
351346
x_sign * spec.pcb_length_x / 2,
352347
y_sign * spec.pcb_length_y / 2,
@@ -401,12 +396,39 @@ def preview_both_enclosure_parts(spec: Spec) -> bd.Part | bd.Compound:
401396
"""Preview both the top and bottom enclosure parts."""
402397
p = bd.Part(None)
403398

404-
enclosure_top = make_enclosure_top(spec).translate((0, 0, 3))
405-
enclosure_bottom = make_enclosure_bottom(spec).translate((0, 0, -13))
399+
enclosure_top = make_enclosure_top(spec).translate((0, 0, 0))
400+
enclosure_bottom = make_enclosure_bottom(spec).translate((0, 0, 0))
401+
402+
pcb_in_lower_pos = bd.Pos(
403+
Z=(
404+
spec.enclosure_bottom_wall_standoff_height
405+
+ spec.enclosure_wall_thickness_bottom
406+
)
407+
) * bd.Box(
408+
spec.pcb_length_x - 0.2,
409+
spec.pcb_length_y - 0.2,
410+
spec.pcb_thickness,
411+
align=bde.align.ANCHOR_BOTTOM,
412+
)
413+
414+
pcb_in_raised_pos = bd.Pos(
415+
Z=(
416+
spec.enclosure_bottom_wall_standoff_height
417+
+ spec.enclosure_wall_thickness_bottom
418+
+ spec.pcb_travel_z
419+
)
420+
) * bd.Box(
421+
spec.pcb_length_x - 0.2,
422+
spec.pcb_length_y - 0.2,
423+
spec.pcb_thickness,
424+
align=bde.align.ANCHOR_BOTTOM,
425+
)
406426

407427
# Debugging: Add a breakpoint on the next line.
408428
p += enclosure_top
409429
p += enclosure_bottom
430+
p += pcb_in_lower_pos
431+
p += pcb_in_raised_pos
410432

411433
return p
412434

firmware/main.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -322,17 +322,26 @@ def demo_gp_leds() -> None:
322322
PIN_GP_LED_1.value(0)
323323

324324

325-
def demo_zeroing_corner_motor() -> None:
326-
"""Try zeroing the top-left (U10 [corner 0] + U25 [hall 8]) corner motor."""
325+
def demo_zeroing_corner_motor(corner_number: int) -> None:
326+
"""Try zeroing the top-left (U10 [corner 0] + U25 [hall 8]) corner motor.
327+
328+
Note that the large cam lobe is aligned with the magnet. Thus, when zeroed, the cam
329+
presses "into" the PCB.
330+
"""
331+
assert 0<=corner_number <= 3
332+
shift_register_motor_number = corner_number + 8
333+
hall_sensor_number = corner_number + 8
334+
335+
327336
reg_off = [False] * 16
328337

329338
reg_cw = [False] * 16
330-
reg_cw[8 + 0] = True
331-
reg_cw[8 + 1] = False
339+
reg_cw[shift_register_motor_number + 0] = True
340+
reg_cw[shift_register_motor_number + 1] = False
332341

333342
reg_ccw = [False] * 16
334-
reg_ccw[8 + 0] = False
335-
reg_ccw[8 + 1] = True
343+
reg_ccw[shift_register_motor_number + 0] = False
344+
reg_ccw[shift_register_motor_number + 1] = True
336345

337346
for i in range(100):
338347
# Set the motor to spin in one direction.
@@ -341,7 +350,7 @@ def demo_zeroing_corner_motor() -> None:
341350
set_shift_registers(reg_off)
342351

343352
# Read the hall sensor.
344-
val = read_hall_sensor_u16(8)
353+
val = read_hall_sensor_u16(hall_sensor_number)
345354
print(f"Hall sensor: {val:,}")
346355

347356
time.sleep(1)

0 commit comments

Comments
 (0)