"""Surface-mount diode in a MELF package (MELF DO-213AB, MiniMELF SOD-80 or MicroMELF), by Vishay's package drawings. Lying on the XY plane (the board) with its axis along X and centred on the origin in X and Y: the body between two metal end caps, and the cathode band on the body at the -X end. Each end cap is its own solid. Dimensions from Vishay's drawings; see the README.""" from steve import Model package = "MiniMELF" # MELF (DO-213AB, plastic), MiniMELF (SOD-80) or MicroMELF # package: (other name, body section, length, end cap diameter, end cap length, body across, body across the corners), ranges (min, max) in # mm; 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)": # MELF DO-213AB (PLASTIC) page 33 (drawing S8-V-3453.03-001, 13 May 2009): body D1 2.41 to 2.67, end caps D2 = D1 + 0 to 0.2 (here # 2.41 to 2.87, whose middle is D1's middle + 0.1), end caps 0.46 to 0.56 long, 4.7 to 5.2 long; # MiniMELF (SOD-80) page 37 (drawing 6.560-5005.01-4, rev. 8, 07 Jun 2006): end caps 1.4 to 1.6 across and 0.47 max. long (the only # value given, used as is), 3.3 to 3.7 long; # MicroMELF page 35 (drawing 6.560-5007.01-4, rev. 13, 07 Jun 2006): end caps 1.1 to 1.2 across and 0.15 to 0.25 long, 1.8 to 2.0 long; # the glass is a rounded square, 0.6 from the axis to its flat ("surface plan") sides, so 1.2 across them, and under 1.35 across the # corners (1.35 used). OUTLINES = { "MELF": ("DO-213AB", "round", (4.7, 5.2), (2.41, 2.87), (0.46, 0.56), (2.41, 2.67), None), "MiniMELF": ("SOD-80", "round", (3.3, 3.7), (1.4, 1.6), (0.47, 0.47), None, None), "MicroMELF": ("", "square", (1.8, 2.0), (1.1, 1.2), (0.15, 0.25), (1.2, 1.2), (1.35, 1.35)), } # Proportions, for looks (the drawings show these but don't dimension them): the glass body of the MiniMELF is GLASS of its end caps' # diameter; the cathode band runs from the -X end cap BAND of the way along the body. GLASS = 0.92 BAND = 0.2 def mid(pair): return (pair[0] + pair[1]) / 2 other, section, LEN, CAP_D, CAP_L, ACROSS, CORNERS = OUTLINES[package] length, cap_d, cap_l = mid(LEN), mid(CAP_D), mid(CAP_L) across = mid(ACROSS) if ACROSS else GLASS * cap_d # The part rests on whichever is lower: the end caps or the body (MicroMELF's flat glass sides). axis_z = max(cap_d, across) / 2 inside = length / 2 - cap_l band = BAND * 2 * inside model = Model() # Each cylinder starts at `at` and runs along +X. for tag, side in (("cathode", -1), ("anode", 1)): model.cylinder(f"{tag}_cap", cap_d / 2, cap_l, at=(-length / 2 if side < 0 else inside, 0, axis_z), direction=(1, 0, 0), op="new", body=f"{tag}_cap_body", name="End caps") if section == "round": model.cylinder("band", across / 2, band, at=(-inside, 0, axis_z), direction=(1, 0, 0), op="new", body="band_body", name="Cathode band") model.cylinder("body", across / 2, 2 * inside - band, at=(-inside + band, 0, axis_z), direction=(1, 0, 0), op="new", body="body_body", name="Body") else: # A square across the flats with its corners rounded to the given size across the corners: the corner radius r makes the diagonal # 2 * (h * sqrt(2) - r * (sqrt(2) - 1)) for half-width h. h = across / 2 r = (h * 2 ** 0.5 - mid(CORNERS) / 2) / (2 ** 0.5 - 1) for tag, x0, x1 in (("band", -inside, -inside + band), ("body", -inside + band, inside)): model.plane(f"{tag}_plane", on="YZ", offset=x0, name="Body") with model.sketch(f"{tag}_sketch", on=f"{tag}_plane", name="Body") as sk: for i, (sy, sz) in enumerate(((1, 1), (-1, 1), (-1, -1), (1, -1))): sk.arc(f"{tag}_corner_{i}", (sy * (h - r), axis_z + sz * (h - r)), r, 90 * i, 90 * i + 90) sk.line(f"{tag}_top", (h - r, axis_z + h), (-h + r, axis_z + h)) sk.line(f"{tag}_left", (-h, axis_z + h - r), (-h, axis_z - h + r)) sk.line(f"{tag}_bottom", (-h + r, axis_z - h), (h - r, axis_z - h)) sk.line(f"{tag}_right", (h, axis_z - h + r), (h, axis_z + h - r)) model.extrude(tag, f"{tag}_sketch", distance=x1 - x0, op="new", body=f"{tag}_body", name="Cathode band" if tag == "band" else "Body") # Materials, for looks and a rough mass. MELF's body is moulded epoxy over a glass body (Vishay GL41 data sheet), ptfe (2.07) the nearest # to a silica-filled epoxy (about 1.9 to 2.0) in the material list; MiniMELF's and MicroMELF's bodies are glass, soda-lime glass; the end # caps are plated metal, copper; the band is marking ink, shown in ptfe. if package == "MELF": model.material("ptfe", bodies=["body_body"], color="#2b2d30") model.material("ptfe", bodies=["band_body"], color="#c8c8c4") else: model.material("glass-soda-lime", bodies=["body_body"], color="#c0602a") model.material("ptfe", bodies=["band_body"], color="#1d1d1f") model.material("copper", bodies=["cathode_cap_body", "anode_cap_body"], color="#c9ccd1") result = model.result()