master
John Lauer
AP2112K-3.3TRG1: datasheet-built SOT25 model (DS39724 Rev. 2-2 p.14; previous model exceeded max height) with Diodes' r…
4d12d76
#!/usr/bin/env python3
"""Datasheet-built 3D model of the Diodes SOT25 (SOT-23-5) package used by AP2112K-x.xTRG1.
Source: Diodes AP2112 datasheet DS39724 Rev. 2-2 (June 2017), p.14 'Package Outline Dimensions SOT25'.
Typical values used (mm): H=3.00 body length, B=1.60 body width, C=2.80 lead tip to tip, K=1.10 overall
body thickness (seating gap J excluded), J=0.05 standoff (body bottom above the seating plane), A=0.38 lead width, L=0.40 foot (flat) length, M=0.15 lead thickness,
N=0.75 parting line (lead centre) above the body bottom (read off the side view), D=0.95 pitch.
Frame: Adom/KiCad Z-up, seated on z=0, centred, body long axis on Y (same as the KiCad SOT-23-5 footprint),
pin 1 at (-x, +y) = KiCad pad 1 (-1.1375, -0.95) in the footprint's Y-down frame.
Undimensioned features (assumptions, recorded in provenance): body side draft 0.05 mm per face on the top
half and bottom half, square lead bends, no pin-1 mark on the body (Diodes' SOT25 marking drawing shows none)."""
import sys, cadquery as cq
H, B, C, K, J, A, L, M, N, D = 3.00, 1.60, 2.80, 1.10, 0.05, 0.38, 0.40, 0.15, 0.75, 0.95
out = sys.argv[1]
zp = J + N # parting line = lead centre, N above the body bottom
TOP = J + K # overall height 1.15 typ (1.40 max)
dr = 0.0 if "--simple" in sys.argv else 0.05 # draft inset at top and bottom faces (assumption)
def frustum(z0, z1, w0, l0, w1, l1):
return cq.Solid.makeLoft([cq.Wire.makePolygon([cq.Vector(-w0/2,-l0/2,z0),cq.Vector(w0/2,-l0/2,z0),cq.Vector(w0/2,l0/2,z0),cq.Vector(-w0/2,l0/2,z0)],close=True),
cq.Wire.makePolygon([cq.Vector(-w1/2,-l1/2,z1),cq.Vector(w1/2,-l1/2,z1),cq.Vector(w1/2,l1/2,z1),cq.Vector(-w1/2,l1/2,z1)],close=True)])
body = frustum(J, zp, B - 2*dr, H - 2*dr, B, H).fuse(frustum(zp, TOP, B, H, B - 2*dr, H - 2*dr)).clean()
xt = C / 2 # tip
xf = xt - L # foot inner end = vertical leg inner face
xin = B / 2 - 0.10 # lead starts inside the body
def lead(side, y):
s = 1 if side > 0 else -1
lt, lb = zp + M / 2, zp - M / 2
pts = [(xin, lb), (xin, lt), (xf + M, lt), (xf + M, M), (xt, M), (xt, 0), (xf, 0), (xf, lb)]
prof = cq.Workplane("XZ").polyline([(s*x, z) for x, z in pts]).close().extrude(A/2, both=True)
return prof.val().translate(cq.Vector(0, y, 0))
# pins: 1,2,3 on -x at y=+D,0,-D ; 4 at (+x,-D), 5 at (+x,+D)
pins = {1: (-1, D), 2: (-1, 0), 3: (-1, -D), 4: (1, -D), 5: (1, D)}
asm = cq.Assembly(name="AP2112K-3.3TRG1_SOT25")
asm.add(body, name="body", color=cq.Color(0.148, 0.145, 0.145))
for n, (sd, y) in pins.items():
asm.add(lead(sd, y), name=f"lead_{n}", color=cq.Color(0.824, 0.820, 0.781))
asm.save(out, "STEP")
c = cq.Compound.makeCompound([body] + [lead(*v) for v in pins.values()])
bb = c.BoundingBox()
print("bbox", round(bb.xmin,3), round(bb.xmax,3), round(bb.ymin,3), round(bb.ymax,3), round(bb.zmin,3), round(bb.zmax,3))