"""Through-hole round LED with two straight leads, Vishay's 5 mm (T-1 3/4) and 3 mm (T-1) packages, standing on the board at its lead standoffs. The body's axis is the Z axis, the cathode lead at -X and the anode at +X (2.54 nom. apart); the 5 mm flange's flat is on the cathode side. The board's top face is the XY plane. Dimensions from Vishay's data sheets, listed in the README.""" import math from steve import Model package = "5mm" # Package color = "red" # Lens colour (tinted diffused) tail = 3.0 # mm Leads below the board # Each entry: (body diameter, flange diameter, flange thickness, height from the flange's underside to the top, dome radius, # standoff below the flange's underside (the leads' kink, where the part seats: 12.5 - 8.7 and 5.8 - 4.4), lead spacing, lead size along X, lead size along Y), mm. # Vishay "TLHR540., TLHY540., TLHG540." Rev. 2.6, 09-Sep-2022, document 83012 (www.vishay.com/docs/83012/tlhg540.pdf), page 7, # "Package dimensions": body Ø 5 +/-0.15, flange Ø 5.8 +/-0.15, 8.7 +/-0.3 and 7.7 +/-0.15 from the top to the flange's underside and # top face, R 2.49 (sphere), 12.5 +/-0.3 from the top to the leads' kink, leads 0.5 +0.15/-0.05 square, 2.54 nom. apart. # Vishay "TLHR440., TLHO440., TLHY440., TLHG440." Rev. 3.8, 21-Mar-2023, document 83006 (www.vishay.com/doc?83006), page 9, "Package # dimensions": body Ø 2.9 +/-0.15, flange Ø 3.2 +/-0.15, 4.4 +/-0.3 and 3.4 +/-0.15, R 1.4 (sphere), 5.8 +/-0.3 to the kink, leads # 0.5 x 0.4, 2.54 nom. apart. PACKAGES = { "5mm": (5.0, 5.8, 1.0, 8.7, 2.49, 3.8, 2.54, 0.5, 0.5), "3mm": (2.9, 3.2, 1.0, 4.4, 1.4, 1.4, 2.54, 0.5, 0.4), } # Part numbers by package and colour (the sheets' tables), for the README: 5mm TLHR5400, TLHY5400, TLHG5400; 3mm TLHR4400, TLHY4400, # TLHG4400. COLORS = {"red": "#c8202a", "yellow": "#e8c21c", "green": "#3fa34d"} # Proportion, for looks (the 5 mm top view draws the flange's flat but doesn't dimension it): the flat is 0.88 x the flange's radius from # its centre. The 3 mm top view draws no flat. FLAT = 0.88 if package not in PACKAGES: raise ValueError(f"no package {package!r}: {', '.join(PACKAGES)}") if color not in COLORS: raise ValueError(f"no colour {color!r}: {', '.join(COLORS)}") Db, Df, tf, H, Rd, stand, pitch, lx, ly = PACKAGES[package] Rb, Rf = Db / 2, Df / 2 z0 = stand top = z0 + H model = Model() # Body: the flange, the cylinder and the dome (a sphere of radius R meeting the cylinder), revolved about the axis. dome = [(Rd * math.cos(math.radians(a)), top - Rd + Rd * math.sin(math.radians(a))) for a in range(0, 90, 10)] section = [(0, z0), (Rf, z0), (Rf, z0 + tf), (Rb, z0 + tf), (Rb, top - Rd)] + ([(Rd, top - Rd)] if Rd < Rb else []) + dome[1:] + [(0, top)] with model.sketch("body_sketch", on="XZ", name="Body") as sk: sk.polyline("body_section", section, closed=True) model.revolve("body", "body_sketch", axis="Z", op="new", body="body_body", name="Body") if package == "5mm": # The flange's flat on the cathode (-X) side. with model.sketch("flat_sketch", on="XY", name="Flange flat") as sk: sk.rect("flat_rect", (-Rf - 1, -Rf - 1), (-FLAT * Rf, Rf + 1)) model.extrude("flat", "flat_sketch", distance=z0 + tf, op="cut", body="body_body", name="Flange flat") # Leads: straight, from the tail below the board up to the flange's underside. leads = [] for name, sx in (("cathode", -1), ("anode", 1)): model.plane(f"{name}_plane", on="XY", offset=-tail, name=f"{name.title()} lead") with model.sketch(f"{name}_sketch", on=f"{name}_plane", name=f"{name.title()} lead") as sk: sk.rect(f"{name}_rect", (sx * pitch / 2 - lx / 2, -ly / 2), (sx * pitch / 2 + lx / 2, ly / 2)) model.extrude(f"{name}_lead", f"{name}_sketch", distance=tail + z0, op="new", body=f"{name}_body", name=f"{name.title()} lead") leads.append(f"{name}_body") # Materials, for looks and a rough mass: the body is tinted epoxy resin (density about 1.2), shown as pmma (1.18), the nearest clear # plastic in the material list, in the lens colour; the leads are tin-plated steel or copper alloy (the sheets don't say), shown as copper. model.material("pmma", bodies=["body_body"], color=COLORS[color]) model.material("copper", bodies=leads, color="#c9ccd1") result = model.result()