"""Through-hole rotary coded DIP switch, Nidec SH-7000 series, SH-7010C (real code) and SH-7030C (complementary code), 10 positions, top setting. The body is centred on the origin, its underside on the board's top face (the XY plane); the six pins are in two rows along X, 2.54 apart, the rows across Y. Dimensions from Nidec's SH-7000 catalogue, in the README.""" import math from steve import Model kind = "SH-7010C" # Type position = 0 # Rotor setting, 0 to 9 (the arrow points at it) # Nidec Components "Rotary Coded Switches (SMD) SH-7000" catalogue (PDF of 2025-02-05, nidec-components.com/e/catalog/switch/ # sh-7000.pdf), page 4, Outline Dimensions, SH-7010C (Real code) / SH-7030C (Complementary code), tolerance ±0.3 unless stated: # body 7.3 along the rows and 7.1 across them, 3.7 high; rotor slot 0.7 W x 2.8 L x 1 D; pins 6 - 0.6 wide, t = 0.15, 2.54 apart, # 7.62 ±0.5 between the two rows, 3.5 ±1 below the board. Page 5, P.C.B. dimensions (bottom view): 6 - 1 holes on a 2.54 ±0.1 grid, # the rows three steps (7.62) apart. TYPES = {"SH-7010C": "real code", "SH-7030C": "complementary code"} BODY_L = 7.3 BODY_W = 7.1 HEIGHT = 3.7 SLOT = (0.7, 2.8, 1.0) PIN_W = 0.6 PIN_T = 0.15 PITCH = 2.54 ROWS = 7.62 TAIL = 3.5 # Proportions, for looks only (the drawing doesn't dimension them; scaled from the page 4 views, README): the stainless steel cover's # thickness, the rotor's diameter and depth, the gap round it in the cover, and where the pins leave the housing. COVER_T = 0.2 ROTOR_D = 3.3 ROTOR_H = 1.4 RIM_GAP = 0.15 # the cover's opening is this much wider than the rotor all round PIN_TOP = 1.0 if kind not in TYPES: raise ValueError(f"no type {kind!r}: {', '.join(TYPES)}") if position not in range(10): raise ValueError("position is 0 to 9") housing_top = HEIGHT - COVER_T model = Model() # Housing (polyphenylene sulfide), under the cover. model.box("housing", BODY_L, BODY_W, housing_top, at=(0, 0, housing_top / 2), op="new", body="housing_body", name="Housing") # Cover (stainless steel), with the rotor's opening. model.box("cover", BODY_L, BODY_W, COVER_T, at=(0, 0, housing_top + COVER_T / 2), op="new", body="cover_body", name="Cover") model.cylinder("cover_opening", ROTOR_D / 2 + RIM_GAP, COVER_T + 0.2, at=(0, 0, housing_top - 0.1), op="cut", body="cover_body", name="Rotor opening") # Rotor (polyphenylene sulfide): ROTOR_H deep, flush with the cover, the setting slot 0.7 x 2.8, 1 deep, turned to the setting (36 degrees # a step); the housing is cut away round it. model.cylinder("rotor_seat", ROTOR_D / 2, ROTOR_H, at=(0, 0, HEIGHT - ROTOR_H), op="cut", body="housing_body", name="Rotor seat") model.cylinder("rotor", ROTOR_D / 2, ROTOR_H, at=(0, 0, HEIGHT - ROTOR_H), op="new", body="rotor_body", name="Rotor") model.plane("slot_plane", on="XY", offset=HEIGHT - SLOT[2], name="Slot floor") angle = math.radians(36 * position) c, s = math.cos(angle), math.sin(angle) hw, hl = SLOT[0] / 2, SLOT[1] / 2 with model.sketch("slot_sketch", on="slot_plane", name="Setting slot") as sk: sk.polyline("slot_outline", [(x * c - y * s, x * s + y * c) for x, y in ((-hl, -hw), (hl, -hw), (hl, hw), (-hl, hw))], closed=True) model.extrude("slot", "slot_sketch", distance=SLOT[2] + 0.1, op="cut", body="rotor_body", name="Setting slot") # Pins (copper alloy, gold plated): six strips 0.6 x 0.15, a tab from the housing's side at PIN_TOP, then down outside it to the tip, the # rows' centres 7.62 apart (on the page 5 hole grid, three 2.54 steps). pins = [] y_out = ROWS / 2 for row, sy in enumerate((-1, 1)): for col, x in enumerate((-PITCH, 0.0, PITCH)): n = row * 3 + col + 1 body = f"pin_{n}_body" model.box(f"pin_{n}", PIN_W, PIN_T, PIN_TOP + TAIL, at=(x, sy * y_out, (PIN_TOP - TAIL) / 2), op="new", body=body, name=f"Pin {n}") model.box(f"pin_{n}_tab", PIN_W, y_out - BODY_W / 2 + 0.01, PIN_T, at=(x, sy * (BODY_W / 2 + y_out) / 2, PIN_TOP - PIN_T / 2), op="join", body=body, name=f"Pin {n} tab") pins.append(body) # Materials from page 1 (Internal Structure): housing and rotor polyphenylene sulfide (pet, the closest density on the list), cover # stainless steel SUS 304 (stainless-304), pins copper alloy, gold plated (copper). model.material("pet", bodies=["housing_body"], color="#2b2c2f") model.material("stainless-304", bodies=["cover_body"], color="#c9ccd0") model.material("pet", bodies=["rotor_body"], color="#f2f1ec") model.material("copper", bodies=pins, color="#d8b25a") result = model.result()