main
John Lauer
Review cumulative land candidates and correct complete STEP assembly clearance checks
ca3da55
"""Review Samsung C6 manufacturer reflow lands on an isolated cumulative candidate."""
from pathlib import Path
import copy,json,hashlib,shutil
import sexp
R=Path(__file__).resolve().parents[1];B=R/'checkpoints/precision-land-review-v2';O=R/'checkpoints/capacitor-library-review';src=B/'precision-land-candidate.kicad_pcb';S=sexp.Sym
for d in ['lib','3d']:shutil.copytree(B/d,O/d,dirs_exist_ok=True)
shutil.copy2(B/'fp-lib-table',O/'fp-lib-table')
for ext in ['kicad_pro','kicad_dru']:shutil.copy2(B/('precision-land-candidate.'+ext),O/('capacitor-land-candidate.'+ext))
b=sexp.parse(src.read_text());f=next(f for f in sexp.find(b,'footprint')if next(p[2]for p in sexp.find(f,'property')if p[1]=='Reference')=='C6');props={p[1]:p[2]for p in sexp.find(f,'property')};assert props['MPN']=='CL21A475KAQNNNG';name='C_0805_Samsung_CL21_2.00x1.25mm_Reflow';before=[]
for p in sexp.find(f,'pad'):
assert p[1]in ['1','2'];a=sexp.first(p,'at');sz=sexp.first(p,'size');before.append({'number':p[1],'at':a[1:],'size':sz[1:]});a[1:3]=[S('-.8'if p[1]=='1'else '.8'),S('0')];sz[1:]=[S('.825'),S('1.325')];p[3]=S('rect');p[:]=[v for v in p if not(isinstance(v,list)and v and v[0]=='roundrect_rratio')]
f[1]='Load:'+name;sexp.first(f,'descr')[1]='Samsung CL21,2.00x1.25mm +/-0.15; MLCC manual recommended reflow lands, gap0.775, span2.425, width1.325mm. Process qualification pending.'
lib=copy.deepcopy(f);lib[1]=name;lib[:]=[v for v in lib if not(isinstance(v,list)and v and(v[0]in ['at','uuid']or(v[0]=='property'and v[1]not in ['Reference','Value','Datasheet','Description'])))]
for p in sexp.find(lib,'property'):
if p[1]=='Reference':p[2]='REF**';sexp.first(p,'at')[1:]=[S('0'),S('-1.5'),S('0')]
if p[1]=='Value':p[2]=name
for p in sexp.find(lib,'pad'):
a=sexp.first(p,'at');a[1:]=a[1:3];p[:]=[v for v in p if not(isinstance(v,list)and v and v[0]in ['net','uuid'])]
(O/'lib/Load.pretty'/(name+'.kicad_mod')).write_text(sexp.dump(lib)+'\n')
for z in sexp.find(b,'zone'):z[:]=[v for v in z if not(isinstance(v,list)and v and v[0]=='filled_polygon')]
dst=O/'capacitor-land-candidate.kicad_pcb';dst.write_text(sexp.dump(b)+'\n')
for p in B.glob('*.kicad_sch'):
t=sexp.parse(p.read_text())
for sy in sexp.find(t,'symbol'):
pr={v[1]:v for v in sexp.find(sy,'property')}
if pr.get('Reference',[None,None,None])[2]=='C6':pr['Footprint'][2]='Load:'+name
(O/p.name).write_text(sexp.dump(t)+'\n')
x={'adopted':False,'sourceSha256':hashlib.sha256(src.read_bytes()).hexdigest(),'candidateSha256':hashlib.sha256(dst.read_bytes()).hexdigest(),'newChanges':['C6 only; inherits35unadopted resistor changes'],'reference':'C6','mpn':props['MPN'],'before':before,'after':{'padSizeMm':[.825,1.325],'centersXmm':[-.8,.8],'gapMm':.775,'outerSpanMm':2.425},'source':'Samsung MLCC Product Manual section5-4,2012metric +/-0.15mm row; family page confirms G packaging variant','sourceUrl':'https://product.samsungsem.com/mlcc/CL21A475KAQNNN.do','limits':'Library candidate only. Placement, traces, vias, nets and selected models unchanged. Native visual, netlist, DRC and physical process review remain required.'};(O/'selection-review.json').write_text(json.dumps(x,indent=2)+'\n');print('Prepared isolated C6 library variant; original board30 untouched')