"""Surface-mount diode in a small plastic package (SOD-123, SOD-323, SOD-523 or SMF), by Vishay's package drawings. Centred on the origin with the seating plane on the XY plane and the length along X: the moulded body, the cathode band on top at the -X end, and a lead at each end (each lead its own solid). SOD-123 and SOD-323 have gull-wing leads that leave the body's ends and bend down to a foot; SOD-523 and SMF have flat leads along the board under the body's ends. Dimensions from Vishay's drawings; see the README.""" from steve import Model package = "SOD-123" # SOD-123, SOD-323, SOD-523 or SMF (DO-219AB) # package: (lead style, body length, body width, lead width, height, lead thickness, foot, length over the leads, standoff under the body), # ranges (min, max) in mm. Foot: gull-wing leads, from the lead's tip to the inside of its bend; SMF's flat leads, the lead's whole length # from its tip; None where the drawing doesn't give it. # Vishay Semiconductors, "Package Dimensions for ESD-, Zener-, Small Signal Switching-, and Schottky Diodes", document number 80128, # revision 1.4, 11-Oct-2022 (https://www.vishay.com/docs/80128/package_information.pdf), "PACKAGE DIMENSIONS in millimeters (inches)": # SOD-123 page 25 (drawing S8-V-3910.01-001, rev. 4, 24 Sep 2009), SOD-323 page 26 (S8-V-3910.02-001, rev. 6, 23 Sep 2016), # SOD-523 page 27 (S8-V-3880.02-003, rev. 3, 27 May 2019), SMF (DO-219AB) page 31 (S8-V-3915.01-001, rev. 5, 09 Oct 2017). OUTLINES = { "SOD-123": ("gull", (2.55, 2.85), (1.40, 1.70), (0.45, 0.65), (1.0, 1.35), (0.10, 0.15), (0.25, 0.45), (3.55, 3.85), (0.0, 0.1)), "SOD-323": ("gull", (1.60, 1.95), (1.1, 1.5), (0.20, 0.40), (0.8, 1.15), (0.10, 0.15), (0.25, 0.40), (2.50, 2.85), (0.0, 0.1)), "SOD-523": ("flat", (1.1, 1.3), (0.7, 0.9), (0.18, 0.35), (0.55, 0.75), (0.1, 0.2), None, (1.5, 1.7), (0.0, 0.1)), "SMF": ("flat", (2.7, 2.9), (1.7, 1.9), (0.8, 1.2), (0.88, 1.08), (0.05, 0.25), (0.35, 0.85), (3.5, 3.9), (0.0, 0.1)), } # Proportions, for looks (the drawings show these but don't dimension them): a gull-wing lead's middle leaves the body at half its height; # leads run INTO into the body (SOD-523's from the body's end; SOD-123's and SOD-323's arms), in a room cut out of it; the cathode band is # 0.12 of the body's length wide, 0.1 of it in from the -X end, and 0.03 proud of the top. INTO = 0.15 BAND_W = 0.12 BAND_IN = 0.1 BAND_T = 0.03 def mid(pair): return (pair[0] + pair[1]) / 2 style, BL, BW, LW, HT, LT, FOOT, SPAN, STAND = OUTLINES[package] body_l, body_w, lead_w, height, t, span = (mid(v) for v in (BL, BW, LW, HT, LT, SPAN)) gull = style == "gull" # Flat leads lie on the board and the body sits on them; a gull-wing package's body stands off the board. bottom = mid(STAND) if gull else 0.0 model = Model() model.box("body", body_l, body_w, height - bottom, at=(0, 0, (height + bottom) / 2), op="new", body="body_body", name="Body") model.box("band", BAND_W * body_l, body_w, BAND_T, at=(-body_l / 2 + (BAND_IN + BAND_W / 2) * body_l, 0, height + BAND_T / 2), op="new", body="band_body", name="Cathode band") arm_z = height / 2 - t / 2 leads = [] rooms = [] for tag, side in (("cathode", -1), ("anode", 1)): tip = side * span / 2 if gull: # The lead's side section (x, z): into the body at arm_z, out past its end, down the leg, and out along the foot to the tip. inner = side * (body_l / 2 - INTO) leg = tip - side * mid(FOOT) section = [(inner, arm_z), (inner, arm_z + t), (leg + side * t, arm_z + t), (leg + side * t, t), (tip, t), (tip, 0.0), (leg, 0.0), (leg, arm_z)] rooms.append((inner, side * body_l / 2, arm_z, arm_z + t)) else: # A flat strip on the board from the tip to its inner end under the body. inner = tip - side * mid(FOOT) if FOOT else side * (body_l / 2 - INTO) section = [(inner, 0.0), (tip, 0.0), (tip, t), (inner, t)] rooms.append((inner, side * body_l / 2, 0.0, t)) # The XZ plane's normal is -Y: offset -lead_w / 2 puts it on the lead's +Y side, and the extrusion runs across the lead to -Y. model.plane(f"{tag}_plane", on="XZ", offset=-lead_w / 2, name="Leads") with model.sketch(f"{tag}_sketch", on=f"{tag}_plane", name="Leads") as sk: sk.polyline(f"{tag}_section", section, closed=True) model.extrude(f"{tag}_lead", f"{tag}_sketch", distance=lead_w, op="new", body=f"{tag}_body", name="Leads") leads.append(f"{tag}_body") # Cut the leads' room out of the body, so that no solids overlap. with model.sketch("room_sketch", on="cathode_plane", name="Room for the leads") as sk: for i, (a, b, z0, z1) in enumerate(rooms): sk.rect(f"room_{i}", (min(a, b), z0), (max(a, b), z1)) model.extrude("room", "room_sketch", distance=lead_w, op="cut", body="body_body", name="Room for the leads") # Materials, for looks and a rough mass: the moulding is epoxy compound, mostly silica filler (density about 1.9 to 2.0), ptfe (2.07) the # nearest in the material list; the leads are tin-plated copper alloy, copper; the band is marking ink, shown in ptfe. model.material("ptfe", bodies=["body_body"], color="#26282b") model.material("ptfe", bodies=["band_body"], color="#c8c8c4") model.material("copper", bodies=leads, color="#c9ccd1") result = model.result()