Skip to content
Merged
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
29 changes: 16 additions & 13 deletions src/fn/sot23.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const sot23_5CourtyardOutline = [
export const sot23_def = base_def.extend({
fn: z.string(),
num_pins: z.number().default(3),
w: z.string().default("1.92mm"),
w: z.string().default("2.275mm"),
h: z.string().default("2.74mm"),
pl: z.string().default("1.325mm"),
pw: z.string().default("0.6mm"),
Expand Down Expand Up @@ -111,13 +111,13 @@ export const getCcwSot23Coords = (parameters: {
const { pn, w, h, pl, p } = parameters

if (pn === 1) {
return { x: -1.1375, y: p }
return { x: -w / 2, y: p }
}
if (pn === 2) {
return { x: -1.1375, y: -p }
return { x: -w / 2, y: -p }
}

return { x: 1.1375, y: 0 }
return { x: w / 2, y: 0 }
}

export const sot23_3 = (parameters: z.infer<typeof sot23_def>) => {
Expand All @@ -127,7 +127,7 @@ export const sot23_3 = (parameters: z.infer<typeof sot23_def>) => {
const pl = Number.parseFloat(parameters.pl)
const pw = Number.parseFloat(parameters.pw)
const p = Number.parseFloat(parameters.p)
const cornerRadius = Math.min(pl, pw) / 8
const cornerRadius = parameters.rounded ?? Math.min(pl, pw) / 8

for (let i = 0; i < parameters.num_pins; i++) {
const { x, y } = getCcwSot23Coords({
Expand Down Expand Up @@ -158,38 +158,41 @@ export const sot23_3 = (parameters: z.infer<typeof sot23_def>) => {
}

export const getCcwSot235Coords = (parameters: {
w: number
h: number
p: number
pn: number
}) => {
const { p, h, pn } = parameters
const { w, p, h, pn } = parameters
if (pn === 1) {
return { x: -1.1375, y: p }
return { x: -w / 2, y: p }
}
if (pn === 2) {
return { x: -1.1375, y: 0 }
return { x: -w / 2, y: 0 }
}
if (pn === 3) {
return { x: -1.1375, y: -p }
return { x: -w / 2, y: -p }
}
if (pn === 4) {
return { x: 1.1375, y: -p }
return { x: w / 2, y: -p }
}
if (pn === 5) {
return { x: 1.1375, y: p }
return { x: w / 2, y: p }
}
throw new Error("Invalid pin number")
}

export const sot23_5 = (parameters: z.infer<typeof sot23_def>) => {
const pads: AnyCircuitElement[] = []
const w = Number.parseFloat(parameters.w)
const h = Number.parseFloat(parameters.h)
const p = Number.parseFloat(parameters.p)
const pl = Number.parseFloat(parameters.pl)
const pw = Number.parseFloat(parameters.pw)
const cornerRadius = Math.min(pl, pw) / 8
const cornerRadius = parameters.rounded ?? Math.min(pl, pw) / 8
for (let i = 1; i <= parameters.num_pins; i++) {
const { x, y } = getCcwSot235Coords({
w,
h,
p,
pn: i,
Expand Down Expand Up @@ -222,7 +225,7 @@ export const sot23_5 = (parameters: z.infer<typeof sot23_def>) => {
stroke_width: 0.05,
}
const silkscreenRefText: SilkscreenRef = silkscreenRef(0, height + 0.3, 0.3)
const pin1Position = getCcwSot235Coords({ h, p, pn: 1 })
const pin1Position = getCcwSot235Coords({ w, h, p, pn: 1 })
pin1Position.x = pin1Position.x - pw * 1.5
const triangleHeight = 0.3 // Adjust triangle size as needed
const triangleWidth = 0.4 // Adjust triangle width as needed
Expand Down
1 change: 1 addition & 0 deletions tests/__snapshots__/C156283_sot25.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__/sot23_3_micrometer_units.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__/sot23_w3_h1.5_p0.95mm.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions tests/sot25.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,22 @@ test("sot25", () => {
const svgContent = convertCircuitJsonToPcbSvg(circuitJson)
expect(svgContent).toMatchSvgSnapshot(import.meta.path, "sot25")
})

test("C156283 SOT-25 uses its measured pad-row span", () => {
const circuitJson = fp
.string(
"sot25_w2.794mm_p0.9525mm_pw0.6223mm_pl1.1049mm_rounded0_pin1location(rightside,bottom)",
)
.circuitJson()
const pads = circuitJson.filter(
(element) =>
element.type === "pcb_smtpad" && element.shape === "rotated_rect",
)

expect(pads).toHaveLength(5)
expect(pads.every((pad) => pad.corner_radius === 0)).toBe(true)
expect(pads.every((pad) => Math.abs(pad.x) === 1.397)).toBe(true)

const svgContent = convertCircuitJsonToPcbSvg(circuitJson)
expect(svgContent).toMatchSvgSnapshot(import.meta.path, "C156283_sot25")
})
Loading