feat(pcb): 555 승압(boost) SMPS 예제 — 회로도·기판 배치·시뮬레이션 설정 포함, 넷→회로도 연결선 자동 생성, 라벨/전원 기호 방향. 시뮬레이션: 555 방전 스위치 누설 수정(발진 정지 원인), 전력/로직레벨 MOSFET·쇼트키 모델 구분
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e617464813
commit
f9bb8f72ad
2 files changed
+103
-15
No files matched your search
+14
-7
@@ -45,6 +45,9 @@ const MODELS = {
|
||||
QNPN: '.model QNPN NPN(IS=6.734f XTI=3 EG=1.11 VAF=74.03 BF=416.4 NE=1.259 ISE=6.734f IKF=66.78m XTB=1.5 BR=.7371 NC=2 ISC=0 IKR=0 RC=1 CJC=3.638p MJC=.3085 VJC=.75 FC=.5 CJE=4.493p MJE=.2593 VJE=.75 TR=239.5n TF=301.2p ITF=.4 VTF=4 XTF=2 RB=10)',
|
||||
QPNP: '.model QPNP PNP(IS=1.41f XTI=3 EG=1.11 VAF=18.7 BF=180.7 NE=1.5 ISE=0 IKF=80m XTB=1.5 BR=4.977 NC=2 ISC=0 IKR=0 RC=2.5 CJC=9.728p MJC=.5776 VJC=.75 FC=.5 CJE=8.063p MJE=.3677 VJE=.75 TR=33.42n TF=179.3p ITF=.4 VTF=4 XTF=6 RB=10)',
|
||||
MN: '.model MN NMOS(LEVEL=1 VTO=2 KP=0.2 LAMBDA=0.01 CGSO=20p CGDO=5p)',
|
||||
MNLL: '.model MNLL NMOS(LEVEL=1 VTO=1.6 KP=25 LAMBDA=0.005 RD=8m RS=8m CGSO=1.5n CGDO=0.4n)',
|
||||
MNPWR: '.model MNPWR NMOS(LEVEL=1 VTO=3.5 KP=22 LAMBDA=0.005 RD=10m RS=10m CGSO=1.2n CGDO=0.3n)',
|
||||
DSCH: '.model DSCH D(IS=3.2u N=1.15 RS=0.06 CJO=110p BV=40)',
|
||||
MP: '.model MP PMOS(LEVEL=1 VTO=-2 KP=0.1 LAMBDA=0.01 CGSO=20p CGDO=5p)',
|
||||
};
|
||||
// 555/연산증폭기/78xx 는 거동 모델(매끄러운 수식 — 조건문은 전환 순간 시뮬레이션이 멈춘다)
|
||||
@@ -60,7 +63,7 @@ Rq q qd 1k
|
||||
Cq qd 0 1p
|
||||
Bout oi gnd V = 0.1 + v(q)*(v(vcc)-v(gnd)-1.8)
|
||||
Ro oi out 20
|
||||
Bdis disch gnd I = 0.5*(1+tanh(50*(0.5-v(q))))*v(disch,gnd)/10
|
||||
Bdis disch gnd I = 0.5*(1+tanh(200*(0.5-v(q))))*v(disch,gnd)/10
|
||||
.ends NE555`,
|
||||
OPAMP: `.subckt OPAMP inp inn out vcc vee
|
||||
Rin inp inn 1e8
|
||||
@@ -114,7 +117,7 @@ export function buildNetlist(project: PcbProject & { parts: SimPart[] }, spec: S
|
||||
const ctx: Ctx = { nodeOf, pads: padList };
|
||||
|
||||
const L: string[] = [];
|
||||
const need = { DGEN: false, DLED: false, QNPN: false, QPNP: false, MN: false, MP: false, NE555: false, OPAMP: false, REG: false };
|
||||
const need = { DGEN: false, DLED: false, DSCH: false, QNPN: false, QPNP: false, MN: false, MNLL: false, MNPWR: false, MP: false, NE555: false, OPAMP: false, REG: false };
|
||||
const partInfo: { ref: string; kind: string; elem?: string; r?: number; n1?: string; n2?: string }[] = [];
|
||||
|
||||
for (const part of project.parts) {
|
||||
@@ -140,18 +143,22 @@ export function buildNetlist(project: PcbProject & { parts: SimPart[] }, spec: S
|
||||
if (!kp || !ap) { warnings.push(`${tag}: 다이오드 핀을 찾지 못했습니다.`); continue; }
|
||||
const led = /LED/.test(`${upper} ${part.fp.toUpperCase()}`);
|
||||
if (/ZENER|\bZ[A-Z]*\d/.test(upper) && !led) warnings.push(`${tag}: 제너 다이오드는 일반 다이오드로 처리됩니다(항복 전압 미반영).`);
|
||||
const el = `D_${id}`; const model = led ? 'DLED' : 'DGEN'; need[model] = true;
|
||||
const schottky = !led && /1N58[1-4]\d|1N5711|SB\d|SS\d|BAT\d|MBR|SR\d|SCHOTTKY|B\d{3,4}\b/.test(upper);
|
||||
const el = `D_${id}`; const model = led ? 'DLED' : schottky ? 'DSCH' : 'DGEN'; need[model] = true;
|
||||
L.push(`${el} ${nodeOf(ref, ap)} ${nodeOf(ref, kp)} ${model}`);
|
||||
partInfo.push({ ref, kind: led ? 'LED' : 'D', elem: el });
|
||||
} else if (prefix === 'Q') {
|
||||
const isMos = !!(padOfName('G') && padOfName('D') && padOfName('S'));
|
||||
if (isMos) {
|
||||
const pm = /PMOS|P-CH|PCH|IRF9|IRF5\d\d\b|BS250|SI23|FQP\d+P/.test(upper);
|
||||
need[pm ? 'MP' : 'MN'] = true;
|
||||
const ll = !pm && /IRL[A-Z]?\d|LOGIC|RFP\d+L|IRLB|IRLZ|FDP\d+L|NTD\d+L|SI2\d/.test(upper);
|
||||
const pwr = !pm && !ll && /IRF[A-Z]?\d|IRFZ|STP\d|FQP\d|FDP\d|NTP\d|PSMN|AOT\d|IPP\d|RFP\d/.test(upper);
|
||||
const mdl = pm ? 'MP' : ll ? 'MNLL' : pwr ? 'MNPWR' : 'MN';
|
||||
need[mdl] = true;
|
||||
const d = nodeOf(ref, padOfName('D')!), g = nodeOf(ref, padOfName('G')!), s = nodeOf(ref, padOfName('S')!);
|
||||
L.push(`M_${id} ${d} ${g} ${s} ${s} ${pm ? 'MP' : 'MN'}`);
|
||||
L.push(`M_${id} ${d} ${g} ${s} ${s} ${mdl}`);
|
||||
partInfo.push({ ref, kind: pm ? 'PMOS' : 'NMOS' });
|
||||
warnings.push(`${tag}: MOSFET은 일반 모델(VTO=±2V)로 처리됩니다.`);
|
||||
warnings.push(`${tag}: ${ll ? '로직레벨 전력용' : pwr ? '전력용' : '소신호용 일반'} MOSFET 모델로 처리됩니다(부품 번호별 정확한 규격은 아님).`);
|
||||
} else {
|
||||
const pnp = /PNP|2N3906|2N2907|BC55[78]|BC32[5-8]|BD140|TIP4\d|MPSA92|2N5401/.test(upper);
|
||||
let e = padOfName('E'), b = padOfName('B'), c = padOfName('C');
|
||||
@@ -207,7 +214,7 @@ export function buildNetlist(project: PcbProject & { parts: SimPart[] }, spec: S
|
||||
const head = ['* homeclaw PCB 시뮬레이션'];
|
||||
for (const [net, node] of nodeNames) head.push(`* ${node} = ${sane(net)}`);
|
||||
const models: string[] = [];
|
||||
for (const k of ['DGEN', 'DLED', 'QNPN', 'QPNP', 'MN', 'MP'] as const) if (need[k]) models.push(MODELS[k]);
|
||||
for (const k of ['DGEN', 'DLED', 'DSCH', 'QNPN', 'QPNP', 'MN', 'MNLL', 'MNPWR', 'MP'] as const) if (need[k]) models.push(MODELS[k]);
|
||||
for (const k of ['NE555', 'OPAMP', 'REG'] as const) if (need[k]) models.push(SUBCKTS[k]);
|
||||
const netlist = [...head, ...L, ...models, '.options rshunt=1e12 reltol=1e-3'].join('\n') + '\n';
|
||||
return { netlist, warnings, nodeNames, parts: partInfo };
|
||||
|
||||
@@ -72,7 +72,7 @@ details{margin-bottom:6px}summary{cursor:pointer;font-weight:700;font-size:12.5p
|
||||
<header>
|
||||
<h1>🔌 PCB 제작</h1>
|
||||
<button class="btn" onclick="newProject(true)">새로 만들기</button>
|
||||
<button class="btn" onclick="loadSample()">예제</button>
|
||||
<select id="exsel" class="btn" style="width:auto" onchange="loadExample(this.value);this.value=''"><option value="">예제 ▾</option><option value="basic">기초: 핀헤더 + 저항 배선</option><option value="smps">555 승압 SMPS (5V→약 12V)</option></select>
|
||||
<button class="btn" onclick="saveFile()">💾 저장</button>
|
||||
<button class="btn" onclick="$('file').click()">📂 불러오기</button>
|
||||
<input type="file" id="file" accept=".json" style="display:none" onchange="loadFile(this)">
|
||||
@@ -102,6 +102,7 @@ details{margin-bottom:6px}summary{cursor:pointer;font-weight:700;font-size:12.5p
|
||||
<button class="btn" onclick="schMirror()" title="M">⇋ 반전</button>
|
||||
<button class="btn" onclick="schDelete()" title="Delete">🗑 삭제</button>
|
||||
<span class="sp"></span>
|
||||
<button class="btn" onclick="schAutoWires()" title="기판/예제의 연결을 선과 넷 이름으로 자동 생성">⚡ 연결선 자동 생성</button>
|
||||
<button class="btn" onclick="schFit()">⤢ 맞춤</button>
|
||||
</div>
|
||||
<div id="bar">
|
||||
@@ -220,8 +221,8 @@ function newProject(ask){
|
||||
P={board:{w:50,h:35},parts:[],nets:[],fps:{},rules:{...DEF_RULES},mill:{...DEF_MILL}};
|
||||
routed=null; gres=null; sel=null; pending=null; fitView(); syncUI(); changed(true);
|
||||
}
|
||||
function loadSample(){
|
||||
if(P&&P.parts.length&&!confirm('현재 작업을 예제로 바꿀까요?')) return;
|
||||
function loadSample(skipAsk){
|
||||
if(!skipAsk&&P&&P.parts.length&&!confirm('현재 작업을 예제로 바꿀까요?')) return;
|
||||
P={board:{w:40,h:30},parts:[
|
||||
{ref:'J1',fp:'HDR-1x4',x:7.62,y:7.62,rot:0},{ref:'J2',fp:'HDR-1x4',x:30.48,y:7.62,rot:0},{ref:'R1',fp:'RES-AX-7.62',x:15.24,y:22.86,rot:0}],
|
||||
nets:[{name:'A',pins:['J1-1','J2-1']},{name:'B',pins:['J1-2','J2-2']},{name:'C',pins:['J1-3','R1-1']},{name:'D',pins:['J2-3','R1-2']}],
|
||||
@@ -848,10 +849,15 @@ function drawSym(part,pos,isSel){
|
||||
if(part.value) stext(part.value,SX(b.x0),SY(b.y1)+Math.max(11,1.3*S),'left','#c8e6c9',Math.max(9,1.15*S));
|
||||
}
|
||||
function drawPower(pw,isSel){
|
||||
const c=sctx,S=sview.s,x=SX(pw.x),y=SY(pw.y),gnd=/^(gnd|vss|0v|agnd|dgnd|pgnd)$/i.test(pw.name),col=isSel?'#fff176':'#ff8a65';
|
||||
c.strokeStyle=col;c.lineWidth=Math.max(1.2,0.3*S*0.7);c.beginPath();
|
||||
if(gnd){c.moveTo(x,y);c.lineTo(x,y+2.0*S);c.moveTo(x-1.4*S,y+2.0*S);c.lineTo(x+1.4*S,y+2.0*S);c.moveTo(x-0.9*S,y+2.7*S);c.lineTo(x+0.9*S,y+2.7*S);c.moveTo(x-0.4*S,y+3.4*S);c.lineTo(x+0.4*S,y+3.4*S);c.stroke();stext(pw.name,x+1.9*S,y+2.4*S,'left',col,Math.max(9,1.1*S));}
|
||||
else{c.moveTo(x,y);c.lineTo(x,y-2.0*S);c.moveTo(x-1.3*S,y-2.0*S);c.lineTo(x+1.3*S,y-2.0*S);c.stroke();stext(pw.name,x,y-2.0*S-4,'center',col,Math.max(9,1.15*S));}
|
||||
const c=sctx,S=sview.s,gnd=/^(gnd|vss|0v|agnd|dgnd|pgnd)$/i.test(pw.name),col=isSel?'#fff176':'#ff8a65';
|
||||
const V={d:[0,1],u:[0,-1],l:[-1,0],r:[1,0]}, dir=pw.dir||(gnd?'d':'u'), vec=V[dir]||V.d;
|
||||
const base=gnd?[0,1]:[0,-1], th=Math.atan2(vec[1],vec[0])-Math.atan2(base[1],base[0]);
|
||||
c.save();c.translate(SX(pw.x),SY(pw.y));c.rotate(th);c.strokeStyle=col;c.lineWidth=Math.max(1.2,0.3*S*0.7);c.beginPath();
|
||||
if(gnd){c.moveTo(0,0);c.lineTo(0,2.0*S);c.moveTo(-1.4*S,2.0*S);c.lineTo(1.4*S,2.0*S);c.moveTo(-0.9*S,2.7*S);c.lineTo(0.9*S,2.7*S);c.moveTo(-0.4*S,3.4*S);c.lineTo(0.4*S,3.4*S);}
|
||||
else{c.moveTo(0,0);c.lineTo(0,-2.0*S);c.moveTo(-1.3*S,-2.0*S);c.lineTo(1.3*S,-2.0*S);}
|
||||
c.stroke();c.restore();
|
||||
const len=(gnd?3.6:2.0)*S, ex=SX(pw.x)+vec[0]*len, ey=SY(pw.y)+vec[1]*len, fs=Math.max(9,1.15*S);
|
||||
if(vec[0]===0) stext(pw.name,ex,vec[1]>0?ey+fs:ey-4,'center',col,fs); else stext(pw.name,ex+(vec[0]>0?4:-4),ey+4,vec[0]>0?'left':'right',col,fs);
|
||||
}
|
||||
function drawSch(){
|
||||
if(!P||tab!=='sch') return;
|
||||
@@ -864,7 +870,15 @@ function drawSch(){
|
||||
sctx.fillStyle='#6fcf6f';for(const j of sres.junctions){sctx.beginPath();sctx.arc(SX(j[0]),SY(j[1]),Math.max(2.5,0.5*S),0,7);sctx.fill();}
|
||||
for(const part of P.parts){const pos=sPos(part.ref);if(pos)drawSym(part,pos,ssel&&ssel.kind==='part'&&ssel.ref===part.ref);}
|
||||
P.sch.power.forEach((pw,i)=>drawPower(pw,ssel&&ssel.kind==='power'&&ssel.i===i));
|
||||
P.sch.labels.forEach((l,i)=>{const isSel=ssel&&ssel.kind==='label'&&ssel.i===i,x=SX(l.x),y=SY(l.y);sctx.strokeStyle=isSel?'#fff176':'#ffb74d';sctx.lineWidth=1.3;sctx.beginPath();sctx.moveTo(x,y);sctx.lineTo(x+0.8*S,y-0.9*S);sctx.lineTo(x+0.8*S+sctx.measureText(l.name).width+8,y-0.9*S);sctx.stroke();stext(l.name,x+0.9*S+2,y-0.9*S-2,'left',isSel?'#fff176':'#ffb74d',Math.max(9,1.15*S));});
|
||||
P.sch.labels.forEach((l,i)=>{
|
||||
const isSel=ssel&&ssel.kind==='label'&&ssel.i===i,x=SX(l.x),y=SY(l.y),col=isSel?'#fff176':'#ffb74d',fs=Math.max(9,1.15*S);
|
||||
sctx.font=fs+'px sans-serif';const tw=sctx.measureText(l.name).width,d=l.dir||'r';
|
||||
sctx.strokeStyle=col;sctx.lineWidth=1.3;sctx.beginPath();
|
||||
if(d==='r'){sctx.moveTo(x,y);sctx.lineTo(x+0.8*S,y-0.9*S);sctx.lineTo(x+0.8*S+tw+8,y-0.9*S);sctx.stroke();stext(l.name,x+0.9*S+2,y-0.9*S-2,'left',col,fs);}
|
||||
else if(d==='l'){sctx.moveTo(x,y);sctx.lineTo(x-0.8*S,y-0.9*S);sctx.lineTo(x-0.8*S-tw-8,y-0.9*S);sctx.stroke();stext(l.name,x-0.9*S-2,y-0.9*S-2,'right',col,fs);}
|
||||
else if(d==='u'){sctx.moveTo(x,y);sctx.lineTo(x,y-1.0*S);sctx.moveTo(x-tw/2-4,y-1.0*S);sctx.lineTo(x+tw/2+4,y-1.0*S);sctx.stroke();stext(l.name,x,y-1.0*S-3,'center',col,fs);}
|
||||
else{sctx.moveTo(x,y);sctx.lineTo(x,y+1.0*S);sctx.moveTo(x-tw/2-4,y+1.0*S);sctx.lineTo(x+tw/2+4,y+1.0*S);sctx.stroke();stext(l.name,x,y+1.0*S+fs,'center',col,fs);}
|
||||
});
|
||||
// 배선 중 미리보기
|
||||
if(wiring&&smouse){const last=wiring[wiring.length-1],p=smouse;sctx.strokeStyle='#fff176';sctx.setLineDash([5,4]);sctx.lineWidth=1.5;sctx.beginPath();sctx.moveTo(SX(wiring[0][0]),SY(wiring[0][1]));wiring.forEach(q=>sctx.lineTo(SX(q[0]),SY(q[1])));if(p[0]!==last[0]&&p[1]!==last[1])sctx.lineTo(SX(p[0]),SY(last[1]));sctx.lineTo(SX(p[0]),SY(p[1]));sctx.stroke();sctx.setLineDash([]);}
|
||||
if(smouse&&(smode==='wire'||smode==='label'||smode==='power')){sctx.strokeStyle='#fff';sctx.lineWidth=1;sctx.strokeRect(SX(smouse[0])-4,SY(smouse[1])-4,8,8);}
|
||||
@@ -982,6 +996,28 @@ function schDelete(){
|
||||
else if(ssel.kind==='part'){const ref=ssel.ref;if(!confirm(`${ref} 부품을 삭제할까요? (기판에서도 사라집니다)`))return;P.parts=P.parts.filter(p=>p.ref!==ref);delete P.sch.pos[ref];sel=null;P.nets.forEach(n=>n.pins=n.pins.filter(id=>!id.startsWith(ref+'-')));}
|
||||
ssel=null; if(schDriven()) schCommit(); else {schDerive();changed();}
|
||||
}
|
||||
|
||||
// 기판/예제의 연결(넷)을 회로도에 짧은 선 + 넷 이름(전원은 전원 기호)으로 자동 생성한다.
|
||||
function schFromNets(){
|
||||
ensureSch(); ensurePlaced(); schDerive(); const S=P.sch, pinGeo={}; let n=0;
|
||||
for(const part of P.parts){
|
||||
const pos=sPos(part.ref), g=partGfx(part); if(!pos||!g||g.loading) continue; const lay=layoutOf(g);
|
||||
g.units.forEach((u,i)=>u.pins.forEach(p=>{
|
||||
const id=part.ref+'-'+p.n; if(pinGeo[id]) return; const a=(p.angle+180)*Math.PI/180;
|
||||
const [x,y]=sxf(pos,p.x,p.y-lay.offs[i]), [x2,y2]=sxf(pos,p.x+Math.cos(a),p.y+Math.sin(a)-lay.offs[i]);
|
||||
pinGeo[id]={x:r2(x),y:r2(y),dx:Math.round(x2-x),dy:Math.round(y2-y)};
|
||||
}));
|
||||
}
|
||||
const done=new Set(sres.conn);
|
||||
for(const net of P.nets) for(const id of net.pins){
|
||||
const g=pinGeo[id]; if(!g||done.has(id)) continue; const L=5.08, e=[r2(g.x+g.dx*L),r2(g.y+g.dy*L)];
|
||||
S.wires.push({pts:[[g.x,g.y],e]});
|
||||
const gnd=/^(gnd|vss|0v|agnd|dgnd)$/i.test(net.name), sup=/^(vin|vout|vcc|vdd|[+-]\d)/i.test(net.name), dir=g.dx<0?'l':g.dx>0?'r':g.dy<0?'u':'d';
|
||||
(gnd||sup?S.power:S.labels).push({x:e[0],y:e[1],name:net.name,dir}); n++;
|
||||
}
|
||||
schCommit(); return n;
|
||||
}
|
||||
function schAutoWires(){ if(!P.nets.length){$('hint').innerHTML='<span class="warn">연결(넷)이 없습니다.</span>';return;} const n=schFromNets(); $('hint').textContent=`연결선 ${n}개를 만들었습니다. 부품 배치는 끌어서 정리하세요.`; schFit(); }
|
||||
function setTab(t){
|
||||
tab=t; $('t-pcb').classList.toggle('on',t==='pcb'); $('t-sch').classList.toggle('on',t==='sch');
|
||||
$('bar').style.display=t==='pcb'?'flex':'none'; $('sbar').style.display=t==='sch'?'flex':'none';
|
||||
@@ -990,6 +1026,51 @@ function setTab(t){
|
||||
else{resize();$('hint').textContent='부품을 왼쪽에서 눌러 추가 → 끌어서 배치 → 🔗 핀 연결 모드에서 핀을 차례로 클릭해 연결 → 오른쪽에서 자동 배선';}
|
||||
}
|
||||
|
||||
|
||||
// ───────────── 예제 ─────────────
|
||||
const EX_SMPS={
|
||||
board:{w:56,h:40},
|
||||
note:'555 타이머(약 50kHz, 듀티 약 58%)가 MOSFET 을 켜고 끄는 승압(boost) 컨버터입니다. 입력 5V → 출력 약 12V(시뮬레이션 12.1V, 시작 직후 약 22V까지 오버슈트 후 안정). 되먹임이 없는 개방 루프라 부하에 따라 출력이 변합니다(시뮬레이션: 220~470Ω 11.6V · 1kΩ 12V · 2.2kΩ 17V · 10kΩ 26V). 그래서 R4(470Ω)를 항상 연결해 두고, 출력 커패시터는 35V 이상을 쓰세요. 주파수 f≈1.44/((R1+2·R2)·C1), 듀티 D=(R1+R2)/(R1+2·R2).',
|
||||
parts:[
|
||||
{ref:'J1',fp:'TERM-2P',value:'VIN 5V',pcb:[7,24,90],sch:[20,62,0]},
|
||||
{ref:'J2',fp:'TERM-2P',value:'VOUT',pcb:[48,24,90],sch:[226,62,0]},
|
||||
{ref:'U1',fp:'kicad:Package_DIP:DIP-8_W7.62mm',sym:'Timer:NE555P',value:'NE555',pcb:[18.5,23,270],sch:[80,70,0]},
|
||||
{ref:'Q1',fp:'kicad:Package_TO_SOT_THT:TO-220-3_Vertical',sym:'Transistor_FET:IRLZ44N',value:'IRLZ44N',pcb:[31,23.5,90],sch:[148,78,0]},
|
||||
{ref:'D1',fp:'kicad:Diode_THT:D_DO-41_SOD81_P10.16mm_Horizontal',sym:'Diode:1N5819',value:'1N5819',pcb:[38,32.5,270],sch:[178,46,0]},
|
||||
{ref:'L1',fp:'kicad:Inductor_THT:L_Axial_L9.5mm_D4.0mm_P15.24mm_Horizontal_Fastron_SMCC',sym:'Device:L',value:'1m',pcb:[18.5,10,0],sch:[148,34,0]},
|
||||
{ref:'R1',fp:'kicad:Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_Horizontal',sym:'Device:R',value:'4.7k',pcb:[8.5,6,90],sch:[46,24,0]},
|
||||
{ref:'R2',fp:'kicad:Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_Horizontal',sym:'Device:R',value:'12k',pcb:[13.5,13.5,90],sch:[46,58,0]},
|
||||
{ref:'R3',fp:'kicad:Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_Horizontal',sym:'Device:R',value:'47',pcb:[41,17.5,180],sch:[122,62,90]},
|
||||
{ref:'R4',fp:'kicad:Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_Horizontal',sym:'Device:R',value:'470',pcb:[43,22,90],sch:[212,76,0]},
|
||||
{ref:'C1',fp:'kicad:Capacitor_THT:C_Disc_D5.0mm_W2.5mm_P5.00mm',sym:'Device:C',value:'1n',pcb:[16.5,28,180],sch:[46,94,0]},
|
||||
{ref:'C2',fp:'kicad:Capacitor_THT:C_Disc_D5.0mm_W2.5mm_P5.00mm',sym:'Device:C',value:'10n',pcb:[21,32,270],sch:[104,100,0]},
|
||||
{ref:'C3',fp:'kicad:Capacitor_THT:C_Disc_D5.0mm_W2.5mm_P5.00mm',sym:'Device:C',value:'100n',pcb:[26,27,90],sch:[104,32,0]},
|
||||
{ref:'C4',fp:'kicad:Capacitor_THT:CP_Radial_D6.3mm_P2.50mm',sym:'Device:C_Polarized',value:'22u',pcb:[48,31.5,270],sch:[196,76,0]}],
|
||||
nets:[
|
||||
{name:'VIN',pins:['J1-1','U1-8','U1-4','L1-1','C3-1','R1-1']},
|
||||
{name:'GND',pins:['J1-2','U1-1','C1-2','C2-2','C3-2','Q1-3','C4-2','R4-2','J2-2']},
|
||||
{name:'SW',pins:['L1-2','Q1-2','D1-2']},{name:'VOUT',pins:['D1-1','C4-1','R4-1','J2-1']},
|
||||
{name:'OUT555',pins:['U1-3','R3-1']},{name:'GATE',pins:['R3-2','Q1-1']},
|
||||
{name:'DIS',pins:['U1-7','R1-2','R2-1']},{name:'THR',pins:['U1-6','U1-2','R2-2','C1-1']},{name:'CTL',pins:['U1-5','C2-1']}],
|
||||
sim:{gnd:'GND',sources:[{type:'dc',pos:'VIN',dc:'5'}],analysis:{type:'tran',stop:'40m',step:'0.4u',fstart:'10',fstop:'100k',ppd:'20'},probes:['VOUT']}
|
||||
};
|
||||
async function loadExample(id){
|
||||
if(!id) return;
|
||||
if(P&&P.parts.length&&!confirm('현재 작업을 예제로 바꿀까요?')) return;
|
||||
if(id==='basic'){ loadSample(true); return; }
|
||||
const E=EX_SMPS;
|
||||
P={board:{...E.board},parts:E.parts.map(x=>({ref:x.ref,fp:x.fp,sym:x.sym,value:x.value,x:x.pcb[0],y:x.pcb[1],rot:x.pcb[2]})),nets:E.nets.map(n=>({name:n.name,pins:[...n.pins]})),fps:{},
|
||||
sch:{pos:Object.fromEntries(E.parts.map(x=>[x.ref,{x:x.sch[0],y:x.sch[1],rot:x.sch[2]||0,mir:!!x.sch[3]}])),wires:[],labels:[],power:[]},
|
||||
sim:JSON.parse(JSON.stringify(E.sim)),rules:{...DEF_RULES,trace:0.6,clearance:0.4},mill:{...DEF_MILL}};
|
||||
for(const k of Object.keys(P.parts[0])) if(P.parts[0][k]===undefined) delete P.parts[0][k];
|
||||
routed=null;gres=null;sel=null;pending=null;simRes=null;$('simpane').style.display='none';
|
||||
// 심볼 핀 이름(라벨 표시용)과 풋프린트를 불러온다
|
||||
await Promise.all(P.parts.filter(x=>x.sym).map(async part=>{try{const d=await api('/api/pcb/kicad/symbol?id='+encodeURIComponent(part.sym));part.pinNames={};for(const q of d.symbol.pins){const nm=clean(q.name);if(nm)part.pinNames[q.n]=nm;}}catch(e){}}));
|
||||
await registerFps(); syncUI(); fitView();
|
||||
setTab('sch'); await new Promise(r=>setTimeout(r,600)); schFromNets(); schFit();
|
||||
changed(); $('hint').innerHTML='<span class="ok">✔ 555 승압 SMPS 예제를 불러왔습니다.</span> '+esc(E.note);
|
||||
}
|
||||
|
||||
// ───────────── 시작 ─────────────
|
||||
(async function init(){
|
||||
try{FP=(await api('/api/pcb/footprints')).footprints;FPM=Object.fromEntries(FP.map(f=>[f.id,f]));}catch(e){$('lib').innerHTML=`<div class="note bad">${esc(e.message)}</div>`;}
|
||||
|
||||
Reference in new issue
Block a user