← Commit history
Merge PR #556: Lead cooling: a DPAK whose tab is pin 1 is still a tab; unnumbered copper is no terminal (follow-up to #115) (fix/lead-cooling-tab-pin1 -> main) merge
Showing changes introduced by the merge (against its first parent).
2 files changed
+35−11
crates/aiflow-analyze/src/lead_cooling.rs+34−10@@ -48,25 +48,28 @@ pub fn preliminary(reference: &str, h: &Value) -> Value { } /// Refuse lead cooling for a part that has an exposed pad: its heat goes into that pad's net.-/// Two-terminal parts are their leads; with three or more pads, the one largest pad is a tab when it-/// is at least three times the median of the others. The lands of one pad number (a split exposed-/// pad, an exposed pad with its via pads) count as one pad. Two or more pads of about the same size-/// at the top (the next under 80 % of the largest is not reached) are not a tab: they are power leads,-/// and the heat leaves through each of them (an eFuse with an IN bar and an OUT bar, a dual part with a-/// pad per die), which one tabNet cannot describe; the Fields solve judges such a part through its leads.+/// Two-terminal parts (two lands or fewer) are their leads. Otherwise the lands of one pad number (a+/// split exposed pad, an exposed pad with its via pads, a DPAK tab that is pin 1) count as one pad, and+/// the one largest pad is a tab when it is at least three times the median of the others. Unnumbered+/// copper (a ring round a mounting hole) is no terminal: it is neither a lead nor a tab. Two or more+/// pads of about the same size at the top (the next at 80 % of the largest or more) are not a tab: they+/// are power leads, and the heat leaves through each of them (an eFuse with an IN bar and an OUT bar, a+/// dual part with a pad per die), which one tabNet cannot describe; the Fields solve judges such a part+/// through its leads. pub fn check_footprint(b: &Board, reference: &str) -> Result<(), String> { let pads: Vec<_> = b.pads.iter().filter(|p| p.reference == reference).collect(); if pads.is_empty() { return Err(format!("{reference} (cooling \"leads\") has no pads on the board")); } let area = |p: &aiflow_board::Pad| p.size.0 * p.size.1;- // (number, net, area): the lands of one numbered pad summed+ if pads.len() < 3 { return Ok(()); }+ // (number, net, area): the lands of one numbered pad summed; unnumbered copper is left out let mut groups: Vec<(String, String, f64)> = Vec::new();- for p in &pads {- match groups.iter_mut().find(|g| !p.name.is_empty() && g.0 == p.name) {+ for p in pads.iter().filter(|p| !p.name.is_empty()) {+ match groups.iter_mut().find(|g| g.0 == p.name) { Some(g) => g.2 += area(p), None => groups.push((p.name.clone(), p.net.clone(), area(p))), } }- if groups.len() < 3 { return Ok(()); }+ if groups.len() < 2 { return Ok(()); } groups.sort_by(|a, z| z.2.total_cmp(&a.2)); let (big, second) = (&groups[0], groups[1].2); if second >= 0.8 * big.2 { return Ok(()); }@@ -167,6 +170,27 @@ mod tests { assert!(e.contains("exposed pad (6 on GND"), "{e}"); } + #[test]+ fn a_tab_that_is_pin_one_is_still_a_tab() {+ // KiCad's TO-252-2_TabPin1 and TO-263-2_TabPin1: the tab and lead 1 share the number 1, lead 2 is+ // the only other terminal. Two numbers, three lands: the tab is still an exposed pad.+ let dpak = "(pad \"1\" smd rect (at -2.28 4.8) (size 1.4 5.0) (layers \"F.Cu\") (net 1 \"GND\")) (pad \"1\" smd rect (at 0 -2.4) (size 7.0 7.0) (layers \"F.Cu\") (net 1 \"GND\")) (pad \"2\" smd rect (at 2.28 4.8) (size 1.4 5.0) (layers \"F.Cu\") (net 2 \"A\"))";+ let e = check_footprint(&board(dpak), "U1").unwrap_err();+ assert!(e.contains("exposed pad (1 on GND") && e.contains("declare tabNet GND"), "{e}");+ // a two-terminal part drawn with two lands per terminal is still its leads+ let split = "(pad \"1\" smd rect (at -2 -0.5) (size 1 0.8) (layers \"F.Cu\") (net 1 \"GND\")) (pad \"1\" smd rect (at -2 0.5) (size 1 0.8) (layers \"F.Cu\") (net 1 \"GND\")) (pad \"2\" smd rect (at 2 -0.5) (size 1 0.8) (layers \"F.Cu\") (net 2 \"A\")) (pad \"2\" smd rect (at 2 0.5) (size 1 0.8) (layers \"F.Cu\") (net 2 \"A\"))";+ assert!(check_footprint(&board(split), "U1").is_ok());+ }++ #[test]+ fn unnumbered_copper_is_neither_a_lead_nor_a_tab() {+ // KiCad's PowerMacro_M234_WithHole: an unnumbered copper ring round the screw hole nearly as large as+ // the tab must not read as a second power bar+ let pm = "(pad \"\" thru_hole circle (at 0 -6) (size 5.5 5.5) (drill 3.2) (layers \"*.Cu\")) (pad \"1\" smd rect (at -4 4) (size 3 3.5) (layers \"F.Cu\") (net 2 \"A\")) (pad \"2\" smd rect (at 0 4) (size 3 3.5) (layers \"F.Cu\") (net 2 \"A\")) (pad \"3\" smd rect (at 0 0) (size 7 5) (layers \"F.Cu\") (net 1 \"GND\")) (pad \"4\" smd rect (at 4 4) (size 3 3.5) (layers \"F.Cu\") (net 2 \"A\"))";+ let e = check_footprint(&board(pm), "U1").unwrap_err();+ assert!(e.contains("exposed pad (3 on GND"), "{e}");+ }+ #[test] fn a_split_exposed_pad_is_one_pad() { // an exposed pad drawn as four equal lands with one number (and a via pad) is one tab, not four leads
docs/lead-cooled-parts.md+1−1@@ -18,5 +18,5 @@ Most parts that warm up have no exposed tab: LEDs, inductors, small leaded ICs. - **Junction limit:** a `tjMaxC` on a lead-cooled part needs `thetaJcKPerW` (the datasheet's junction-to-board figure for the package) and `thetaSource`. The screen then checks ambient (`ambientC`, default 25 C) plus the solved rise plus thetaJcKPerW times watts against it. - **Refused:** - an explicit `cooling: "leads"` together with a `tabNet`, a `tabPad` or `packageCooling`;- - a footprint with an exposed pad (with three or more pads, the one largest at least three times the median of the others; the lands of one pad number count as one pad). Give that part its real `tabNet`. Two or more pads of about the same size at the top (the next at 80 % of the largest or more), like an eFuse's IN and OUT bars, are power leads, not a tab: one tabNet cannot describe them, so the part stays lead-cooled and the Fields solve judges it.+ - a footprint with an exposed pad (with three or more lands, the one largest pad at least three times the median of the others; the lands of one pad number count as one pad, so a DPAK whose tab is pin 1 is still a tab, and unnumbered copper such as a ring round a mounting hole is left out). Give that part its real `tabNet`. Two or more pads of about the same size at the top (the next at 80 % of the largest or more), like an eFuse's IN and OUT bars, are power leads, not a tab: one tabNet cannot describe them, so the part stays lead-cooled and the Fields solve judges it. - **A part with an exposed tab** still needs its `tabNet`: the exposed-pad check above catches one that was left out.