Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/fn/sot457.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,12 @@ const generateSot457Elements = (
const pin1Position = getCcwSot457Coords({ pitch, width, pinNumber: 1 })
const triangleHeight = params.wave ? 1 : 0.5
const triangleWidth = params.wave ? 0.7 : 0.3
pin1Position.x -= params.wave ? padWidth : padWidth * 1.7
// Place the marker outboard of pad 1's actual edge. Offsetting by a multiple
// of the pad *width* instead let the triangle land on the pad whenever pl and
// pw are set independently (e.g. `sot457_w2_pl1.5_pw0.6`, where it overlapped
// by 0.005mm).
const pin1PadOuterEdgeX = pin1Position.x - padLength / 2
pin1Position.x = pin1PadOuterEdgeX - triangleHeight / 2 - 0.2 - 0.05 / 2

const pin1Indicator: PcbSilkscreenPath = {
type: "pcb_silkscreen_path",
Expand Down
30 changes: 26 additions & 4 deletions src/fn/tssop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ export const tssop = (
? parameters.w - length.parse("0.15mm")
: parameters.w

/** Distance from the origin to the inner edge of the pad columns. */
let padInnerHalfX = Number.POSITIVE_INFINITY
let padOuterHalfY = 0
for (let i = 0; i < parameters.num_pins; i++) {
const { x, y } = getTssopCoords({
num_pins: parameters.num_pins,
Expand All @@ -75,6 +78,8 @@ export const tssop = (
pl: parameters.pl,
legsoutside: parameters.legsoutside,
})
padInnerHalfX = Math.min(padInnerHalfX, Math.abs(x) - parameters.pl / 2)
padOuterHalfY = Math.max(padOuterHalfY, Math.abs(y) + parameters.pw / 2)
pads.push(rectpad(i + 1, x, y, parameters.pl, parameters.pw, cornerRadius))
}

Expand All @@ -83,9 +88,26 @@ export const tssop = (
}

const m = Math.min(1, parameters.p / 2)
const sw =
parameters.w - (parameters.legsoutside ? 0 : parameters.pl * 2) - 0.2
const sh = (parameters.num_pins / 2 - 1) * parameters.p + parameters.pw + m
const silkscreenStrokeWidth = parameters.silkscreen_stroke_width ?? 0.1
// Inset the body outline from the pad edges by IPC's silk-to-pad clearance
// plus half the stroke. The previous flat `- 0.2` was a total inset of 0.1
// per side, which is less than the stroke half-width alone once the pads
// reach the body (e.g. `tssop10_w3mm_p0.5mm` overlapped by 0.025mm).
const silkPadClearance = 0.2 + silkscreenStrokeWidth / 2
// Derive both from the pads that were actually placed, rather than from `w`.
// Fine-pitch parts shift the pads inward (`wForPads`), so a width-based
// formula drifts from the real copper — that drift is what put the outline on
// the pads for `tssop10_w3mm_p0.5mm`.
const sw = Math.min(
parameters.w - (parameters.legsoutside ? 0 : parameters.pl * 2) - 0.2,
(padInnerHalfX - silkPadClearance) * 2,
)
// The outline's horizontal runs pass above and below the outermost pads, so
// the height needs the same clearance the width gets.
const sh = Math.max(
(parameters.num_pins / 2 - 1) * parameters.p + parameters.pw + m,
(padOuterHalfY + silkPadClearance) * 2,
)
const silkscreenRefText: SilkscreenRef = silkscreenRef(
0,
sh / 2 + 0.4,
Expand All @@ -96,7 +118,7 @@ export const tssop = (
layer: "top",
pcb_component_id: "",
pcb_silkscreen_path_id: "silkscreen_path_1",
stroke_width: parameters.silkscreen_stroke_width ?? 0.1,
stroke_width: silkscreenStrokeWidth,
route: [
{ x: -sw / 2, y: -sh / 2 },
{ x: -sw / 2, y: sh / 2 },
Expand Down
2 changes: 1 addition & 1 deletion tests/__snapshots__/sot457.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/__snapshots__/sot457_wave.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading