"""Vishay IR receiver modules for remote control, by package: Cast, Minicast, Mold and Minimold. Three leads in a row and an epoxy body with a domed lens on its front. The body's underside is the XY plane, the leads run down (-Z) at their full length as supplied, the pin row runs along X and is centred on the body, the leads' plane is Y = 0 and the lens looks toward -Y. The body with its lens is one solid and each lead is its own solid. Dimensions from Vishay's data sheets; see the README.""" from steve import Model package = "Cast" # Vishay package name # All from the sheets' page 7, PACKAGE DIMENSIONS in millimeters (not indicated tolerances +/-0.2 on the Minicast, Mold and # Minimold drawings). # Cast: Vishay TSOP311.., TSOP313.., TSOP315.. data sheet, Rev. 1.8, 13-Mar-2024 (document 82493), drawing 6.550-5095.01-4 issue # 20 (the same drawing in TSOP312.., TSOP314.., Rev. 2.1, 13-Mar-2024, document 82492): body 10 +/-0.3 wide, 12.5 +/-0.4 high, # 4 +/-0.3 deep, 5.8 +/-0.3 deep over the lens; lens R 2.75, the centre of the sensitive area (9.2) above the underside; 30.6 # +/-0.5 overall (leads 18.1); leads 0.5 (+0.15/-0.05) wide, 0.4 (+0.10/-0.05) thick, a wider part 0.65 (+0.10/-0.15); pins # 2.54 nom. and 3 x 2.54 = 7.62 nom. from the first; the leads' near face 1.4 +/-0.3 from the body's back. # Minicast: Vishay TSOP382.., TSOP384.. data sheet, Rev. 2.1, 27-May-2025 (document 82491), drawing 6.550-5263.01-4 issue 12: # body 5 wide, 6.95 +/-0.3 high, 2.8 deep, 4.8 deep over the lens; lens R 2, (4) wide; 8.25 +/-0.3 from the top to the leads' # shoulder line (1.3 below the body) and (5.55) from that line to the lens centre (4.25 above the underside); 30.5 +/-0.5 # overall (leads 23.55); leads 0.7 max. wide, 0.5 max. thick, a wider part 0.85 max., starting 0.9 below the shoulder line # and 1.1 long; pitch 2.54 nom.; (1.54) from an outer lead's stub (inner edge) to that lead's outer edge, so the stub's inner # edge is 2.54 + 0.35 - 1.54 = 1.35 from the middle; the leads' near face 1.2 +/-0.2 from the back. # Mold: Vishay TSOP32S40F, TSOP34S40F data sheet, Rev. 1.2, 26-Feb-2024 (document 82669), drawing 6.550-5169.01-4 issue 9: body # 6 wide, 6.95 high, 3.9 deep over its upper 5.3 and 4.1 deep below that, 5.6 deep over the lens; lens R 2.5; 8.25 to the # shoulder line (1.3 below the body), (5.55) to the lens centre (4.25 above the underside); 30.5 +/-0.5 overall (leads 23.55); # leads 0.7 max. wide, 0.5 max. thick, a wider part 0.85 max., starting 1 below the shoulder line and 1 long; pitch 2.54 nom.; # 0.89 from an outer lead's stub (inner edge) to that lead's centre line, so the stub's inner edge is 2.54 - 0.89 = 1.65 from # the middle; the leads' near face 1.3 from the back. # Minimold: Vishay TSOP331.., TSOP333.., TSOP335.. data sheet, Rev. 1.8, 28-May-2025 (document 82742), drawing 6.550-5335.01-4 # issue 2: body 5.4 wide, 6.35 high, 2.25 deep, 5 deep over the lens; lens R2.5 (so it stands on a collar 5 - 2.25 - 2.5 = 0.25 # long); 7.6 to the shoulder line (1.25 below the body), (5.05) to the lens centre (3.8 above the underside); 15.2 +/-0.3 # overall (leads 8.85); leads (3 x) 0.6 +/-0.1 wide, 0.3 +/-0.1 thick, a wider part (3 x) 0.85 max., starting (0.95) below the # shoulder line and (1.1) long; pitch 2.54 nom.; the leads' near face 0.95 from the back. # width X, height Z, block depth Y, depth over the lens, lens radius, lens centre above the underside, lead length below the # body, lead width, lead thickness, wider part's width, leads' near face from the back, pin positions along X PACKAGES = { "Cast": {"width": 10.0, "height": 12.5, "block": 4.0, "depth": 5.8, "lens_r": 2.75, "lens_z": 9.2, "lead_len": 18.1, "lead_w": 0.5, "lead_t": 0.4, "bulge_w": 0.65, "back": 1.4, "pins": (-3.81, -1.27, 3.81)}, "Minicast": {"width": 5.0, "height": 6.95, "block": 2.8, "depth": 4.8, "lens_r": 2.0, "lens_z": 4.25, "lead_len": 23.55, "lead_w": 0.7, "lead_t": 0.5, "bulge_w": 0.85, "back": 1.2, "pins": (-2.54, 0.0, 2.54)}, "Mold": {"width": 6.0, "height": 6.95, "block": 3.9, "depth": 5.6, "lens_r": 2.5, "lens_z": 4.25, "lead_len": 23.55, "lead_w": 0.7, "lead_t": 0.5, "bulge_w": 0.85, "back": 1.3, "pins": (-2.54, 0.0, 2.54)}, "Minimold": {"width": 5.4, "height": 6.35, "block": 2.25, "depth": 5.0, "lens_r": 2.5, "lens_z": 3.8, "lead_len": 8.85, "lead_w": 0.6, "lead_t": 0.3, "bulge_w": 0.85, "back": 0.95, "pins": (-2.54, 0.0, 2.54)}, } # The outer leads' jog (none on the Cast package, whose leads are straight): shoulder line below the body, the wider part's start # below that line and its length, and the stub's inner edge from the middle where the drawing dimensions it. JOGS = { "Minicast": {"shoulder": 1.3, "bulge_at": 0.9, "bulge_len": 1.1, "stub_in": 1.35}, "Mold": {"shoulder": 1.3, "bulge_at": 1.0, "bulge_len": 1.0, "stub_in": 1.65}, "Minimold": {"shoulder": 1.25, "bulge_at": 0.95, "bulge_len": 1.1}, } # The Mold body's lower part: 6.95 - 5.3 = 1.65 high and 4.1 deep. MOLD_FOOT = (1.65, 4.1) # Proportions, for looks (the drawings show these but don't dimension them; README): where the Cast leads' wider part starts # below the body and how long it is; the outer leads' stub width and the thickness of the run from the stub out to the lead; # the Minimold stub's inner edge from the middle. PROPORTIONS = { "Cast": {"bulge_at": 2.1, "bulge_len": 1.6}, "Minicast": {"stub_w": 0.5, "run": 0.6}, "Mold": {"stub_w": 0.5, "run": 0.6}, "Minimold": {"stub_w": 0.55, "run": 0.5, "stub_in": 1.5}, } if package not in PACKAGES: raise ValueError(f"no package {package!r}: {', '.join(PACKAGES)}") D = PACKAGES[package] P = PROPORTIONS[package] J = JOGS.get(package) W, H, block, depth, R, zc = D["width"], D["height"], D["block"], D["depth"], D["lens_r"], D["lens_z"] w, t, bw, lead_len = D["lead_w"], D["lead_t"], D["bulge_w"], D["lead_len"] back = D["back"] + t / 2 # the body's back face, from the leads' middle plane (Y = 0) face = back - block # the block's front face tip = back - depth # the lens's front model = Model() if package == "Mold": foot_h, foot_d = MOLD_FOOT model.box("block", W, block, H - foot_h, at=(0, back - block / 2, foot_h + (H - foot_h) / 2), op="new", body="body_body", name="Body") model.box("foot", W, foot_d, foot_h, at=(0, back - foot_d / 2, foot_h / 2), op="join", body="body_body", name="Body, lower part") # The lens: a ball of radius R whose front is the package's depth from the back; the block's front face cuts it to a cap. model.sphere("lens", R, at=(0, tip + R, zc), op="join", body="body_body", name="Lens") else: model.box("block", W, block, H, at=(0, back - block / 2, H / 2), op="new", body="body_body", name="Body") if package == "Minimold": # A half ball on a short collar, its axis along Y through the lens centre. yc = tip + R with model.sketch("lens_sketch", on="YZ", name="Lens") as sk: sk.polyline("lens_sides", [(yc, zc + R), (face, zc + R), (face, zc), (tip, zc)], closed=False) sk.arc("lens_arc", (yc, zc), R, 90, 180) model.revolve("lens", "lens_sketch", axis=((0, 0, zc), (0, 1, 0)), op="join", body="body_body", name="Lens") else: # An upright round column from the underside up to the lens centre, then a ball top. Its axis is R behind the lens's # front: inside the block on the Cast package, on the block's front face on the Minicast. ya = tip + R with model.sketch("lens_sketch", on="YZ", name="Lens") as sk: sk.polyline("lens_sides", [(ya, zc + R), (ya, 0), (tip, 0), (tip, zc)], closed=False) sk.arc("lens_arc", (ya, zc), R, 90, 180) model.revolve("lens", "lens_sketch", axis=((0, ya, 0), (0, 0, 1)), op="join", body="body_body", name="Lens") def side(x, top, sign): """One side of a lead from z = -top down to its end, with the wider part's step, top to bottom; sign -1 is the left side.""" if J: b0 = J["shoulder"] + J["bulge_at"] b1 = b0 + J["bulge_len"] else: b0 = P["bulge_at"] b1 = b0 + P["bulge_len"] a, b = x + sign * w / 2, x + sign * bw / 2 return [(a, -top), (a, -b0), (b, -b0), (b, -b1), (a, -b1), (a, -lead_len)] leads = [] for n, x in enumerate(D["pins"]): if J and x != 0: # An outer lead: a stub out of the body down to the shoulder line, a run outward, then the lead. s = 1 if x > 0 else -1 xi = J.get("stub_in", P.get("stub_in")) shoulder, run = J["shoulder"], P["run"] inner = [(s * xi, 0), (s * xi, -shoulder)] + [(s * px, pz) for px, pz in side(abs(x), shoulder, -1)] outer = [(s * px, pz) for px, pz in side(abs(x), shoulder - run, 1)] pts = inner + outer[::-1] + [(s * (xi + P["stub_w"]), -(shoulder - run)), (s * (xi + P["stub_w"]), 0)] else: pts = side(x, 0, -1) + side(x, 0, 1)[::-1] with model.sketch(f"lead_{n}_sketch", on="XZ", name=f"Lead {n + 1}") as sk: sk.polyline(f"lead_{n}_outline", pts, closed=True) model.extrude(f"lead_{n}", f"lead_{n}_sketch", distance=t, both=True, op="new", body=f"lead_{n}_body", name=f"Lead {n + 1}") leads.append(f"lead_{n}_body") # Materials: the sheets say the "epoxy package contains an IR filter" and that the parts are "assembled on a lead frame" (Mold: # "on a PCB"), and name nothing further. The body is the dark filter epoxy, shown as pmma (1.18; epoxy is about 1.2); the leads # are metal, shown as copper. model.material("pmma", bodies=["body_body"], color="#2a2a30") model.material("copper", bodies=leads, color="#c9ccd1") result = model.result()