main
John Lauer
Screen stock TO-220 sink against board 18 without new PCB drills
2cb7065
"""Stock TO-220 sink envelope screen against the current PCB, not assembly acceptance."""
import hashlib,json,math
from pathlib import Path
import sexp
P=Path(__file__).resolve().parents[1]
board=P/'kicad/adom-custom-electronic-load.kicad_pcb'
a=json.loads((P/'mechanical/cooling-680-body-audit.json').read_text())
assert a['boardSha256']==hashlib.sha256(board.read_bytes()).hexdigest()
b=sexp.parse(board.read_text()); footprints=sexp.find(b,'footprint'); probes=[]
q=next(f for f in footprints if any(p[1:3]==['Reference','Q1'] for p in sexp.find(f,'property')))
x,y,theta=map(float,sexp.first(q,'at')[1:]);theta=math.radians(theta)
hole=next(p for p in sexp.find(q,'pad') if p[2]=='np_thru_hole')
u,v=map(float,sexp.first(hole,'at')[1:3]);hx=x+u*math.cos(theta)+v*math.sin(theta);hy=y-u*math.sin(theta)+v*math.cos(theta)
# Manufacturer inch dimensions: hole at (-.440,-.070) relative to sink center.
cx,cy=hx+.440*25.4,hy+.070*25.4;half=1.810*25.4/2
box=[cx-half,cy-half,cx+half,cy+half]
assert all(abs(box[i]-a['sinkEnvelopeMm'][j])<1e-6 for i,j in enumerate([0,1,3,4]))
for f in footprints:
props={p[1]:p[2]for p in sexp.find(f,'property')};ref=props['Reference']
if not ref.startswith('TP'):continue
px,py=map(float,sexp.first(f,'at')[1:3]);distance=math.hypot(max(box[0]-px,0,px-box[2]),max(box[1]-py,0,py-box[3]))
probes.append({'ref':ref,'x':px,'y':py,'distanceToSinkMm':distance,'clearanceFor2mmRadiusMm':distance-2})
result={'status':'nominal-stock-sink-candidate','acceptance':False,'boardSha256':a['boardSha256'],
'mpn':'680-125220','manufacturer':'Wakefield Thermal','sinkCenterXY': [cx,cy], 'sinkXY':box,
'heightMm':31.75,'existingQ1HoleXY':[hx,hy], 'existingPcbDrillMm':float(sexp.first(hole,'drill')[1]),
'stockSinkDeviceDrillMm':.140*25.4,'proposedAdditionalPcbDrills':0,
'fittedModelCount':a['coverage']['models'],'bodyConflicts':a['bodyIntersections'],
'probeChecks':probes,'probeConflicts':[p['ref']for p in probes if p['clearanceFor2mmRadiusMm']<0],
'nominalWasherCandidate':{'mpn':'7721-7PPSG','manufacturer':'Boyd','shoulderODMm':3.43,'boreMm':2.95,'shoulderLengthMm':.81,'flangeODMm':5.46,'flangeThicknessMm':1.02,'catalogScrew':'#4','qualification':'Nominal only: stem coverage, tolerances, screw/nut stack and tool access unresolved'},
'sources':{'sink':'https://wakefieldthermal.com/content/catalogs/2019_Catalog.pdf','sinkCatalogPrintedPage':75,'washer':'https://info.boydcorp.com/hubfs/Thermal/Air-Cooling/Boyd-Board-Level-Heatsinks-Catalog.pdf','washerCatalogPrintedPage':96},
'unresolved':['Exact manufacturer CAD and tab contact area','Sink hole location tolerances and drawing orientation verification','Electrical insulation, pad hole, shoulder coverage and clamp pressure','Fastener length, underside height and assembly tool access','Independent cradle support; never suspend fan/sink mass from transistor leads','Fan plenum, guard, cable restraint and connector mating/service envelopes','Installed airflow and physical thermal/fault qualification']}
(P/'mechanical/cooling-680-screen.json').write_text(json.dumps(result,indent=2)+'\n')
print(json.dumps({k:v for k,v in result.items() if k not in ['probeChecks','unresolved','sources']},indent=2))