-
Notifications
You must be signed in to change notification settings - Fork 50
fix: QFN32 pad sizing to match IPC-7351B/KiCad standards #506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
makaiachildress-web
wants to merge
7
commits into
tscircuit:main
Choose a base branch
from
makaiachildress-web:feat/qfn32-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0a7136a
feat: improve QFN32 footprint support with IPC-compliant pad sizing
f4e629c
fix: address review feedback - split tests, fix partial param defaults
fb4db78
test: add QFN32 kicad parity test for EP3.7x3.7mm variant
48c944e
fix: use strict undefined checks for pw/pl to handle zero values corr…
379f00d
style: fix biome formatting in qfn.ts
2737657
fix: remove w5_h5 parity test showing poor alignment
164bc6a
fix: QFN32 KiCad parity test with IPC-compliant pad positioning
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,49 @@ | ||
| import type { AnySoupElement } from "circuit-json" | ||
| import { base_quad_def, quad, quad_def, quadTransform } from "./quad" | ||
| import type { z } from "zod" | ||
| import { base_quad_def, quad, quadTransform, quad_def } from "./quad" | ||
|
|
||
| export const qfn_def = base_quad_def.extend({}).transform(quadTransform) | ||
|
|
||
| export const qfn = ( | ||
| parameters: z.input<typeof qfn_def>, | ||
| raw_params: z.input<typeof qfn_def>, | ||
| ): { circuitJson: AnySoupElement[]; parameters: any } => { | ||
| parameters.legsoutside = false | ||
| if (!parameters.pl) { | ||
| parameters.pl = 0.875 | ||
| raw_params.legsoutside = false | ||
| const pitchValue = | ||
| typeof raw_params.p === "string" | ||
| ? Number.parseFloat(raw_params.p) | ||
| : raw_params.p | ||
| if (raw_params.pw === undefined && raw_params.pl === undefined) { | ||
| if (pitchValue !== undefined && pitchValue > 0) { | ||
| // IPC-compliant defaults: pw = 0.5 * pitch, pl based on standard QFN sizing | ||
| raw_params.pw = pitchValue * 0.5 | ||
| raw_params.pl = 0.875 | ||
| } else { | ||
| raw_params.pl = 0.875 | ||
| raw_params.pw = 0.25 | ||
| } | ||
| } else { | ||
| if (raw_params.pl === undefined) { | ||
| raw_params.pl = 0.875 | ||
| } | ||
| if (raw_params.pw === undefined) { | ||
| raw_params.pw = | ||
| pitchValue !== undefined && pitchValue > 0 ? pitchValue * 0.5 : 0.25 | ||
| } | ||
| } | ||
| if (!parameters.pw) { | ||
| parameters.pw = 0.25 | ||
|
|
||
| // When body dimensions (w/h) are explicitly specified and padoffset is not, | ||
| // compute padoffset so pad centers match IPC-7351B / KiCad positioning. | ||
| // QFN pads extend slightly beyond the package body edge; the pad center | ||
| // sits approximately 0.0625mm inside the body edge. | ||
| if (raw_params.padoffset === undefined && raw_params.w !== undefined) { | ||
| const pl = | ||
| typeof raw_params.pl === "string" | ||
| ? Number.parseFloat(raw_params.pl) | ||
| : raw_params.pl | ||
| if (pl !== undefined && pl > 0) { | ||
| raw_params.padoffset = 0.0625 - pl / 2 | ||
| } | ||
| } | ||
| return quad(parameters) | ||
|
|
||
| return quad(raw_params) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant pitch value calculation and parameter assignment. When
raw_params.pwis provided butraw_params.plis not (or vice versa), the code recalculatespitchValue(lines 25-28) but this is already done in the first condition block (lines 12-15). More critically, if the user explicitly providesraw_params.pw, it should be respected without modification. However, the current logic in the else block (lines 32-33) will still potentially overridepwif it's falsy (0, null, undefined, etc). A user passingpw: 0intentionally would have it replaced with eitherpitchValue * 0.5or0.25.The condition
!raw_params.pwtreats0as falsy and would replace it. Should use explicitundefinedchecks instead:Spotted by Graphite Agent

Is this helpful? React 👍 or 👎 to let us know.