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
4 changes: 3 additions & 1 deletion src/fn/msop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ const getMsopCoords = (pinCount: number, pn: number, w: number, p: number) => {
const half = pinCount / 2
const rowIndex = (pn - 1) % half
const col = pn <= half ? -1 : 1
const row = (half - 1) / 2 - rowIndex
// Pins are numbered counterclockwise: the left column runs top to bottom,
// the right column runs bottom to top
const row = col === -1 ? (half - 1) / 2 - rowIndex : rowIndex - (half - 1) / 2

return {
x: col * length.parse("2mm"),
Expand Down
4 changes: 3 additions & 1 deletion src/fn/son.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ export const getSonPadCoord = (
const half = num_pins / 2
const rowIndex = (pn - 1) % half
const col = pn <= half ? -1 : 1
const row = (half - 1) / 2 - rowIndex
// Pins are numbered counterclockwise: the left column runs top to bottom,
// the right column runs bottom to top
const row = col === -1 ? (half - 1) / 2 - rowIndex : rowIndex - (half - 1) / 2

return {
x: col * length.parse("1.4mm"),
Expand Down
13 changes: 13 additions & 0 deletions tests/msop.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,16 @@ test("msop16", () => {
const svgContent = convertCircuitJsonToPcbSvg(circuitJson)
expect(svgContent).toMatchSvgSnapshot(import.meta.path, "msop16")
})

test("msop8 pins are numbered counterclockwise", () => {
const circuitJson = fp.string("msop8").circuitJson() as any[]
const pad = (pin: string) =>
circuitJson.find(
(el) => el.type === "pcb_smtpad" && el.port_hints?.[0] === pin,
)
// Pins 1-4 run down the left side, pins 5-8 run up the right side,
// so pin 5 sits across from pin 4 and pin 8 across from pin 1
expect(pad("5").y).toBeCloseTo(pad("4").y)
expect(pad("8").y).toBeCloseTo(pad("1").y)
expect(pad("5").y).toBeLessThan(pad("8").y)
})
26 changes: 26 additions & 0 deletions tests/son.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,29 @@ test("son6", () => {
const svgContent = convertCircuitJsonToPcbSvg(circuitJson)
expect(svgContent).toMatchSvgSnapshot(import.meta.path, "son6")
})

test("son8 pins are numbered counterclockwise", () => {
const circuitJson = fp.string("son8").circuitJson() as any[]
const pad = (pin: string) =>
circuitJson.find(
(el) => el.type === "pcb_smtpad" && el.port_hints?.[0] === pin,
)
// Pins 1-4 run down the left side, pins 5-8 run up the right side,
// so pin 5 sits across from pin 4 and pin 8 across from pin 1
expect(pad("5").y).toBeCloseTo(pad("4").y)
expect(pad("8").y).toBeCloseTo(pad("1").y)
expect(pad("5").y).toBeLessThan(pad("8").y)
})

test("son6 pins are numbered counterclockwise", () => {
const circuitJson = fp.string("son6").circuitJson() as any[]
const pad = (pin: string) =>
circuitJson.find(
(el) => el.type === "pcb_smtpad" && el.port_hints?.[0] === pin,
)
// Pins 1-3 run down the left side, pins 4-6 run up the right side,
// so pin 4 sits across from pin 3 and pin 6 across from pin 1
expect(pad("4").y).toBeCloseTo(pad("3").y)
expect(pad("6").y).toBeCloseTo(pad("1").y)
expect(pad("4").y).toBeLessThan(pad("6").y)
})
Loading