| 1 |
.PS |
| 2 |
# UNODPV.m4 |
| 3 |
log_init |
| 4 |
include(icsDPV.m4) |
| 5 |
textoffset = 1.5bp__ |
| 6 |
svg_font(sans-serif,8.5bp__,textoffset) |
| 7 |
|
| 8 |
divert(-1) |
| 9 |
|
| 10 |
`Header([A][1|2], rows, wid, ht, |
| 11 |
boxspec, pinlen;pinsize) |
| 12 |
arg1: A= type A; number of columns |
| 13 |
arg2: pins per column |
| 14 |
arg3,4: custom wid, ht |
| 15 |
arg5: eg fill_(0.9)' |
| 16 |
define(`Header', |
| 17 |
`[ define(`m4tp',ifinstr(`$1',A,A))define(`m4Hq',patsubst(`$1',A))dnl |
| 18 |
define(`m4Hn',`ifelse(m4Hq,,1,m4Hq)')dnl |
| 19 |
define(`m4Hm',`ifelse(`$2',,2,`$2')')dnl |
| 20 |
define(`m4Hw',`ifelse(`$3',,`m4Hn*L_unit*3',`($3)')')dnl |
| 21 |
define(`m4Hh',`ifelse(`$4',,`m4Hm*L_unit*3',`($4)')')dnl |
| 22 |
ifinstr(`$6',;, |
| 23 |
`stacksplit_(`m4Jdr',`$6',;)dnl |
| 24 |
define(`m4Jps',ifelse(m4Jdr,,`L_unit',m4Jdr))popdef(`m4Jdr')dnl |
| 25 |
define(`m4Jpl',ifelse(m4Jdr,,`lg_plen*L_unit',m4Jdr))popdef(`m4Jdr') ', |
| 26 |
`define(`m4Jps',L_unit)dnl |
| 27 |
define(`m4Jpl',`ifelse(`$6',,lg_plen*L_unit,`$6')')')dnl |
| 28 |
Block: rotbox(m4Hw,m4Hh,`$5') |
| 29 |
ifelse(`m4tp',A,`pushdef(`L_unit',(linewid/6))') |
| 30 |
define(`m4Hct',1)dnl |
| 31 |
for_(1,m4Hm,1, |
| 32 |
`HeaderPin(Block.NW+vec_(m4Jps*3/2,-(m4x-1/2)*m4Hh/m4Hm), |
| 33 |
ifinstr(m4tp,A,1,eval(m4Hct-1)), |
| 34 |
P`'m4Hct, w, (m4Jpl+m4Jps);m4Jps) define(`m4Hct',incr(m4Hct)) |
| 35 |
ifelse(m4Hn, 2, `HeaderPin(Block.NE+vec_(-m4Jps*3/2,-(m4x-1/2)*m4Hh/m4Hm), |
| 36 |
1, P`'m4Hct, e, (m4Jpl+m4Jps);m4Hps) define(`m4Hct',incr(m4Hct))') ') |
| 37 |
ifelse(`m4Hq',A,`popdef(`L_unit')') |
| 38 |
`$7' ]') |
| 39 |
`HeaderPin(location, type, Picname, n|e|s|w, |
| 40 |
[length][;pinsize]) |
| 41 |
arg2: 0= square' |
| 42 |
define(`HeaderPin',` |
| 43 |
ifinstr(`$5',;, |
| 44 |
`stacksplit_(`m4Hdr',`$5',;)dnl |
| 45 |
define(`m4Hps',ifelse(m4Hdr,,`L_unit',m4Hdr))popdef(`m4Hdr')dnl |
| 46 |
define(`m4Hpl',ifelse(m4Hdr,,`lg_plen*L_unit',m4Hdr))popdef(`m4Hdr') ', |
| 47 |
`define(`m4Hps',L_unit)dnl |
| 48 |
define(`m4Hpl',`ifelse(`$5',,lg_plen*L_unit,`$5')')')dnl |
| 49 |
ifelse(`$1',,,`move to `$1';') |
| 50 |
ifelse(`$3',,,`$3':) line to ifelse( |
| 51 |
`$4',n,`rvec_(0,m4Hpl)', `$4',e,`rvec_(m4Hpl,0)', |
| 52 |
`$4',s,`rvec_(0,-m4Hpl)', `rvec_(-m4Hpl,0)') |
| 53 |
ifelse(`$3',,,Pin`$3':) ifelse(ifelse(`$2',,0,`$2'),0, |
| 54 |
`rotbox(m4Hps,m4Hps,fill_(1))', |
| 55 |
`circle diam m4Hps fill_(1)') at last line.start ') |
| 56 |
|
| 57 |
define(`ATMEGA16U2',`[ |
| 58 |
Chip: box wid 10*lg_pinsep ht 25*lg_pinsep |
| 59 |
foreach_(`x', |
| 60 |
`Arightpin(patsubst(x,;,`,'))', |
| 61 |
6;PD0, 7;PD1, 8;PD2, 9;PD3, 10;PD4, 11;PD5, 12;PD6, 13;PD7, |
| 62 |
131;nul, |
| 63 |
5;PC2, 26;PC4, 25;PC5, 23;PC6, 22;PC7, |
| 64 |
132;nul, |
| 65 |
133;nul, |
| 66 |
14;PB0, 15;PB1, 16;PB2, 17;PB3, 18;PB4, 19;PB5, 20;PB6, 21;PB7) |
| 67 |
foreach_(`x', |
| 68 |
`Aleftpin(patsubst(x,;,`,'))', |
| 69 |
33;PAD, |
| 70 |
100;nul, |
| 71 |
28;UGND, 29;D`'svg_it(+), 30;D`'svg_it(-), 31;UVCC, 27;UCAP, |
| 72 |
101;nul, 102;nul, |
| 73 |
3;GND, 4;VCC, 103;nul, |
| 74 |
104;nul, |
| 75 |
32;AVCC, |
| 76 |
105;nul, 106;nul, |
| 77 |
1;XTAL1, |
| 78 |
107;nul, |
| 79 |
2;XTAL2(PC0), |
| 80 |
108;nul, 109;nul) |
| 81 |
lg_pin(Pin109+(0,lg_pinsep),RESET,Pin24,wN,24,pinlen) |
| 82 |
]') |
| 83 |
define(`Aleftpin',`move to Chip.sw+(0,m4Lx*lg_pinsep) |
| 84 |
Pin`$1': ifelse(`$2',nul,Here,dnl |
| 85 |
`line left pinlen "`$1'" above |
| 86 |
"`$2'" ljust at last line.start')') |
| 87 |
define(`Arightpin',`move to Chip.se+(0,m4Lx*lg_pinsep) |
| 88 |
Pin`$1': ifelse(`$2',nul,Here,dnl |
| 89 |
`line right pinlen "`$1'" above |
| 90 |
"`$2'" rjust at last line.start')') |
| 91 |
|
| 92 |
define(`ATMEGA328P',`[ |
| 93 |
Chip: box wid 10*lg_pinsep ht 23*lg_pinsep |
| 94 |
foreach_(`x', |
| 95 |
`Arightpin(patsubst(x,;,`,'))', |
| 96 |
2;PD0, 3;PD1, 4;PD2, 5;PD3, 6;PD4, 11;PD5, 12;PD6, 13;PD7, |
| 97 |
100;nul, |
| 98 |
23;PC0, 24;PC1, 25;PC2, 26;PC3, 27;PC4, 28;PC5, |
| 99 |
101;nul, |
| 100 |
14;PB0, 15;PB1, 16;PB2, 17;PB3, 18;PB4, 19;PB5) |
| 101 |
foreach_(`x', |
| 102 |
`Aleftpin(patsubst(x,;,`,'))', |
| 103 |
201;nul, 202;nul, 203;nul, 204;nul, 205;nul, 206;nul, 207;nul, 208;nul, |
| 104 |
209;nul, |
| 105 |
8;GND, 7;VCC, |
| 106 |
301;nul, |
| 107 |
22;AGND, 20;AVCC, 21;AREF, |
| 108 |
302;nul, |
| 109 |
9;XTAL1, |
| 110 |
303;nul, |
| 111 |
10;XTAL2, |
| 112 |
304;nul, 305;nul) |
| 113 |
lg_pin(Pin305+(0,lg_pinsep),RESET,Pin1,wN,1,pinlen) |
| 114 |
]') |
| 115 |
|
| 116 |
define(`rswitch',`dswitch(`$1',,WBoDCP) |
| 117 |
DS: last line.start; DC: last line.c; DE: last line.end |
| 118 |
DL: DC-vec_(dimen_/6,0); DR: DC+vec_(dimen_/6,0) |
| 119 |
{{"1" at DL above rjust}; {"3" at DR above ljust} |
| 120 |
{ line from DL to DL-vec_(0,dimen_/6) chop dotrad_ chop 0 |
| 121 |
{"2" below rjust} |
| 122 |
continue to DS-vec_(0,dimen_/6) then to DS; dot } |
| 123 |
{ line from DR to DR+vec_(0,-dimen_/6) chop dotrad_ chop 0 |
| 124 |
{"4" below ljust} |
| 125 |
continue to DE+vec_(0,-dimen_/6) then to DE; dot } |
| 126 |
line from DC+vec_(dimen_/10,-dimen_/6) to DC+vec_(-dimen_/10,-dimen_/6) |
| 127 |
move to last line.c; line to rvec_(0,-dimen_/3) \ |
| 128 |
then to rvec_(-dimen_/3,-dimen_/3) |
| 129 |
{"5" below}} ') |
| 130 |
|
| 131 |
divert(0)dnl |
| 132 |
|
| 133 |
maxpswid = 20 |
| 134 |
maxpsht = 20 |
| 135 |
|
| 136 |
define(`pinlen',`30bp__') |
| 137 |
define(`lg_pinsep',(1.2*lg_pinsep)) |
| 138 |
del = lg_pinsep |
| 139 |
define(`pindiam',0.1) |
| 140 |
|
| 141 |
define(`egnd',`ground(,,E); "GND" at last line.c below') |
| 142 |
|
| 143 |
U3: ATMEGA16U2 |
| 144 |
`"ATMEGA16U2-MU(R)"' at U3.Chip.s below |
| 145 |
`"U3"' at U3.Chip.nw ljust above |
| 146 |
ZU4: ATMEGA328P with .Chip.nw at U3.Chip.sw+(-2.5,-10*del) |
| 147 |
`"ATMEGA328P-PU"' at ZU4.Chip.s below |
| 148 |
`"ZU4"' at ZU4.Chip.nw ljust above |
| 149 |
|
| 150 |
dot(at U3.Pin2.end) |
| 151 |
R1: resistor(down_ 2*lg_pinsep,,E) |
| 152 |
rlabel(,"R1" rjust "1M" rjust) |
| 153 |
dot |
| 154 |
dot(at R1.start-(2*del,0)) |
| 155 |
xtal(down_ 2*lg_pinsep) |
| 156 |
rlabel(,16,MHz); dot |
| 157 |
XT2: dot(at last line.start-(2*del,0)); { "XT2" at last [].n above } |
| 158 |
|
| 159 |
Br1: jumper(left_ from U3.Pin33.end to (XT2,U3.Pin33)) |
| 160 |
rlabel(1,,2); llabel(,GROUND) |
| 161 |
BRE: dot |
| 162 |
line to (Here,U3.Pin28) then to U3.Pin28.end |
| 163 |
{"UGND" at (Br1,Here) above} |
| 164 |
|
| 165 |
XT1: dot(at XT2-(del,R1.len)); { "XT1" at last [].n above } |
| 166 |
line from XT1 to U3.Pin1.end |
| 167 |
line from U3.Pin2.end to (XT1,XT2) |
| 168 |
C11: capacitor(left_ 3*del); rlabel(,C11); llabel(,22`'pF) |
| 169 |
C9: capacitor(from XT1 to (Here,XT1)); {"C9" "22`'pF" at last [].s+(0,-11bp__)} |
| 170 |
{ line to C11.end } |
| 171 |
dot |
| 172 |
G1: egnd |
| 173 |
line from XT1 down_ 3*del; continue to (G1,Here); dot(,,1) |
| 174 |
{"XT3" at last [].n above} |
| 175 |
dot(at Here+(0,-3/2*del),,1); {"XT4" at last [].n above} |
| 176 |
{ line to (XT2,Here) then to XT2 chop dotrad_ chop 0 } |
| 177 |
USBVCC: dot(at Here+(0,-7/2*del),,1) |
| 178 |
{"USBVCC" at last [].n-(3/2*del,0) above ljust} |
| 179 |
{ line to (Here,U3.Pin31) chop dotrad_ chop 0; continue to U3.Pin31.end } |
| 180 |
dot(at Here+(2*del,0),,1); {"VUCAP" at last [].e+(0,-5bp__) ljust} |
| 181 |
line to (Here,U3.Pin27) chop dotrad_ chop 0; dot |
| 182 |
line from U3.Pin27.end to (G1.x-4.5*del,U3.Pin27.y) |
| 183 |
C8: capacitor(down_ to (Here,Br1)); llabel(C8,,1`'svg_micro) |
| 184 |
Bus1: dot |
| 185 |
|
| 186 |
dot(at U3.Pin33.end) |
| 187 |
move to U3.Pin3.end; line to (Here,U3.Chip.s) |
| 188 |
G2: ground(,T,E); {"GND" at last line.c below } |
| 189 |
|
| 190 |
dot(at U3.Pin32.end) |
| 191 |
{line to U3.Pin4.end; dot} |
| 192 |
line left del; ground(,,E,U); {"svg_it(+)5 V" at last line.c above} |
| 193 |
|
| 194 |
line from U3.Pin4.end left_ 2*del |
| 195 |
capacitor(down_ 3*del); { llabel(C7,,100n) } |
| 196 |
G3: ground(,T,E); {"GND" at last line.c below } |
| 197 |
|
| 198 |
line from U3.Pin30.end to (G1.x-2*del,U3.Pin30.y); TD: Here |
| 199 |
continue to (Here,U3.Pin32) |
| 200 |
{ "RD`'svg_it(-)" above rjust }; continue left_ 1.5*del |
| 201 |
RN3A: resistor(left_ 3/2*dimen_,,E); rlabel(,22R RN3A) |
| 202 |
Dm: line left_ 7*del |
| 203 |
|
| 204 |
USB: [ K: box invis wid dimen_/2 ht 5*lg_pinsep |
| 205 |
"USB" rjust at K.e |
| 206 |
line thick 1.5 from K.nw to K.ne then to K.se then to K.sw |
| 207 |
foreach_(`x', |
| 208 |
`Pin`'m4Lx: K.ne-(0,m4Lx/5*K.ht) |
| 209 |
"x" at Pin`'m4Lx ljust above', |
| 210 |
1 XUSB, 2 D`'svg_it(-), 3 D`'svg_it(+), 4 UGND) |
| 211 |
P_1: K.sw; {"P$`1'" wid 15bp__ at P_1 below rjust} |
| 212 |
P_2: K.s; {"P$`2'" at P_2 below ljust} |
| 213 |
] with .Pin2 at Here; "X2" at USB.ne above rjust |
| 214 |
|
| 215 |
move to U3.Pin29.end |
| 216 |
line to (TD.x-del,Here.y); continue to (Here,Dm-(0,lg_pinsep)) |
| 217 |
{ "RD`'svg_it(+)" above rjust} |
| 218 |
continue to (RN3A.start,Here) |
| 219 |
RN3D: resistor(left_ 3/2*dimen_,,E); llabel(,22R RN3D) |
| 220 |
line to USB.Pin3 |
| 221 |
|
| 222 |
dot(at RN3A.end); line to (Here,RN3D) |
| 223 |
Z2: variable(`resistor(down_ to (Here,U3.Pin27),,E); rlabel(Z2)',NN) |
| 224 |
dot(at RN3D.end-(2*del,0)) |
| 225 |
Z1: variable(`resistor(to (Here,U3.Pin27),,E); rlabel(Z1)',NN) |
| 226 |
dot; line to (Z2,Here) |
| 227 |
move up Z1.len/4 from last line.c; "CG0603MLC-05E" "X 2" |
| 228 |
|
| 229 |
line down_ del from USB.P_1; continue to (USB.P_2,Here); dot |
| 230 |
line from USB.P_2 to (USB.P_2,Z1.end) then to Z1.end |
| 231 |
dot(at (USB.P_2,Here)+(3/2*del,0)); line to (Here,USBVCC) |
| 232 |
dot(,,1); {"USHIELD" at last [].n+(4bp__,0) above} |
| 233 |
|
| 234 |
L1: reversed(`inductor',down_ from Z1.end to (Z1,C8.end),W,,) |
| 235 |
rlabel(,L1); llabel("svg_thinsp`'BLM21" ljust); dot |
| 236 |
{ dot(at (Z2,Here)); line to (Here,U3.Pin28); dot(,,1) |
| 237 |
"UGND" at last [].n above } |
| 238 |
line from USB.Pin1 to (Z2,USB.Pin1) then up 2*del |
| 239 |
XUSB: dot(,,1); {"XUSB" at last [].n above} |
| 240 |
line from (Z1,USB.Pin3) to (Z1,XUSB); |
| 241 |
DP: dot(,,1); {"D`'svg_it(+)" at last [].n above} |
| 242 |
dot(at (DP,USB.Pin2)-(2*del,0)); line to (Here,XUSB) |
| 243 |
DM: dot(,,1); "D`'svg_it(-)" at last [].n above |
| 244 |
line from USB.Pin4 to (DM,USB.Pin4) then to (DM,BRE) then to BRE |
| 245 |
|
| 246 |
line from U3.Pin18.end right_ 3.5*del |
| 247 |
JP2: Header(A2,2,4*del,2*lg_pinsep,,0.2;pindiam) with .P3.end at Here |
| 248 |
"JP2" at JP2.Block.nw above ljust |
| 249 |
"2X2M - NM" at JP2.s below |
| 250 |
"1" at JP2.P3.end above ljust; "3" at JP2.P1.end above ljust |
| 251 |
"2" at JP2.P4.end above rjust; "4" at JP2.P2.end above rjust |
| 252 |
line from JP2.P1.end to (JP2.P1.end,U3.Pin19) then to U3.Pin19.end |
| 253 |
dot(at JP2.P1.end); line up 3.5*del |
| 254 |
TPPB5: dot(,,1); {"PB5" at last [].e ljust} |
| 255 |
TPPB4: dot(at TPPB5-(del*3/2,0),,1); {"PB4" at last [].w rjust} |
| 256 |
line to (Here,JP2.P3); dot |
| 257 |
line from JP2.P2.end to (JP2.P2.end,TPPB4) |
| 258 |
TPPB7: dot(,,1); {"PB7" at last [].w rjust} |
| 259 |
line from JP2.P4.end right del*3/2; continue to (Here,TPPB4) |
| 260 |
TPPB6: dot(,,1); {"PB6" at last [].n above} |
| 261 |
line from U3.Pin20.end right del then up del; continue to (TPPB6,Here); dot |
| 262 |
line from U3.Pin21.end up del; continue to (TPPB7,Here); dot |
| 263 |
|
| 264 |
ICSP1: Header(A2,3,4*del,2.5*lg_pinsep,,0.2;pindiam) \ |
| 265 |
with .P1.end at (JP2.P1.end,U3.Pin14) |
| 266 |
"ICSP1" at last [].Block.nw above ljust |
| 267 |
"3X2 M" at last [].Block.sw below ljust |
| 268 |
for_(1,5,2,`"m4x" at ICSP1.P`'m4x.end above ljust') |
| 269 |
for_(2,6,2,`"m4x" at ICSP1.P`'m4x.end above rjust') |
| 270 |
line from ICSP1.P1.end to (ICSP1.P1.end,U3.Pin17) then to U3.Pin17.end |
| 271 |
line from ICSP1.P3.end left del; continue to (Here,U3.Pin15) \ |
| 272 |
then to U3.Pin15.end |
| 273 |
|
| 274 |
dot(at U3.Pin24.end); |
| 275 |
RN1C: resistor(up_ 5*lg_pinsep,,E); rlabel(,10K,RN1C); llabel(5,,3) dot |
| 276 |
# D3: diode(up_ 5*lg_pinsep); rlabel(,,D3); dot |
| 277 |
line up_ 2*del; ground(,T,E,U); {"+5 V" at last line.w rjust} |
| 278 |
dot(at U3.Pin24.end-(del,0)); |
| 279 |
# RN1C: resistor(up_ D3.len,,E); llabel(,10K,RN1C) |
| 280 |
D3: diode(up_ RN1C.len); llabel(,,D3) |
| 281 |
line to (TPPB6.x+del,Here.y) |
| 282 |
continue to (Here,ICSP1.P2.end) then to ICSP1.P2.end |
| 283 |
line from ICSP1.P5.end down 2*del; continue to (TPPB6.x+2*del,Here.y) |
| 284 |
TRESET2: Here |
| 285 |
continue to (Here.x,D3.end.y+del) then to (RN1C.end.x-2*del,D3.end.y+del) |
| 286 |
continue to (Here,U3.Pin24) then to U3.Pin24.end |
| 287 |
G4: ground(at ICSP1.P6.end,,E); {"GND" at last line.c below } |
| 288 |
line from ICSP1.P4.end right del then up U3.Pin16.y-ICSP1.P4.y \ |
| 289 |
then to U3.Pin16.end |
| 290 |
dot(at ICSP1.P1.end); line left_ 2.5*del then down_ 5*del |
| 291 |
MISO2: dot(,,1); {"MISO2" at last [].s below } |
| 292 |
dot(at ICSP1.P3.end-(del,0)); line to (Here,MISO2) |
| 293 |
SCK2: dot(,,1); {"SCK2" at last [].s below ljust } |
| 294 |
dot(at TRESET2); line to (Here,SCK2) |
| 295 |
RESET2: dot(,,1); {"RESET2" wid 36bp__ at last [].s below } |
| 296 |
dot(at ICSP1.P4.end+(del,0)); line to (Here,RESET2) |
| 297 |
MOSI2: dot(,,1); {"MOSI2" at last [].s-(del,0) below } |
| 298 |
|
| 299 |
line right_ del from U3.Pin11.end then up_ del*3/2 |
| 300 |
TXLED: reversed(`diode',right_ elen_,LER) |
| 301 |
rlabel(,YELLOW); llabel(TX); dot |
| 302 |
{line up_ del; TPTXL: dot(,,1); "TXL" at last [].n above} |
| 303 |
RN2C: resistor(right_ elen_,,E); llabel(,1 K RN2C); rlabel(6,,3); dot |
| 304 |
line from U3.Pin10.end to (TXLED.start,U3.Pin10) |
| 305 |
RXLED: reversed(`diode',to (TXLED.end,Here),LER) |
| 306 |
rlabel(,YELLOW); llabel(RX); dot |
| 307 |
{line up_ del; dot(,,1); "RXL" at last [].n above} |
| 308 |
RN2B: resistor(right_ elen_,,E); llabel(,1 K RN2B); rlabel(7,,2) |
| 309 |
line to (Here,TPTXL); ground(,T,E,U); "+5 V" at last line.c above |
| 310 |
|
| 311 |
# ZU4 connections |
| 312 |
line left_ del*3/2 from ZU4.Pin7.end; dot |
| 313 |
{line up_ del; G4: ground(,T,E,U); "+5 V" at last line.c above } |
| 314 |
C6: capacitor(down dimen_); llabel(100n,,C6); dot |
| 315 |
{ dot(at ZU4.Pin8.end) }; dot(at (ZU4.Pin8.end,Here)) |
| 316 |
{ G4: ground(at Here+(0,-del),,E); {"GND" at last line.c below } |
| 317 |
line to ZU4.Pin22.end } |
| 318 |
line left_ Here.x-C6.x + dimen_*5/4 |
| 319 |
C10: capacitor(up_ C6.len); llabel(100n,,C10); dot |
| 320 |
{ line to (Here,ZU4.Pin20) then to ZU4.Pin20.end } |
| 321 |
# L2: ebox(right_ to C6.start,,,0.2); rlabel(,L2); llabel(,100`'svg_micro`'H) |
| 322 |
L2: inductor(right_ to C6.start,W); rlabel(,L2); llabel(,100`'svg_micro`'H) |
| 323 |
|
| 324 |
line left 2*del from ZU4.Pin9.end; PE: dot |
| 325 |
R2: resistor(up_ to (Here,ZU4.Pin10),,E); llabel(,R2); rlabel(,1 M); dot |
| 326 |
dot(at Here-(del*4.0,0)); { "XTAL2" above ljust } |
| 327 |
XTAL: xtal(down_ R2.len); llabel(16 MHz); dot; { "XTAL1" below ljust } |
| 328 |
pushdef(`dimen_',dimen_/2) |
| 329 |
capacitor(left_ del from 0.25 between XTAL.start and XTAL.end) |
| 330 |
capacitor(left_ del from 0.75 between XTAL.start and XTAL.end) |
| 331 |
popdef(`dimen_') |
| 332 |
line up XTAL.len/2 |
| 333 |
line left del from last line.c then down del |
| 334 |
G5: ground(,T,E); "GND" at last line.c below |
| 335 |
line down_ del from XTAL.end; dot(,,1); "XT1" at last [].s below |
| 336 |
line up del from XTAL.start; dot(,,1); "XT2" at last [].n above |
| 337 |
line from XTAL.start to ZU4.Pin10.end |
| 338 |
line from XTAL.end to ZU4.Pin9.end |
| 339 |
line left 2*del from ZU4.Pin1.end; dot |
| 340 |
# dot(at ZU4.Pin1.end) |
| 341 |
D2: diode(up_ dimen_); rlabel(,D2) |
| 342 |
dot(at D2.start-(2.5*del,0)) |
| 343 |
RN1D: resistor(up_ D2.len,,E); rlabel(10 K,,RN1D); dot |
| 344 |
{ line to D2.end } |
| 345 |
line up_ del; ground(,T,E,U); "+5 V" at last line.c above |
| 346 |
|
| 347 |
line from ZU4.Pin1.end to (RN1D-(1.5*del,0),ZU4.Pin1) then up 7*del |
| 348 |
continue to (ZU4.Chip.w,Here)+(del,0); BRB: dot |
| 349 |
{ line down_ 2*del; Br2: jumper(right_ dimen_) |
| 350 |
llabel(1,,2); rlabel(,RESET_EN); line up_ 2*del; dot } |
| 351 |
line right_ dimen_+del |
| 352 |
C5: capacitor(right_ dimen_); llabel(,C5); rlabel(100n); dot |
| 353 |
{ RN2D: resistor(down_ dimen_,,E); rlabel(,1 K); llabel(,RN2D) |
| 354 |
G6: ground(,T,E); "GND" at last line below } |
| 355 |
{ line up_ del; DTR: dot(,,1); "DTR" at last [].e ljust } |
| 356 |
line from U3.Pin13.end right del/2; continue to (Here,U3.Chip.s) \ |
| 357 |
then left+2*del; continue to (Here,BRB) then to C5.end |
| 358 |
TP2: Here; continue to C5.end |
| 359 |
|
| 360 |
line up 3*del from BRB |
| 361 |
TP1: dot #; line left BRB.x-RN1D.x |
| 362 |
RESET: rswitch( right_ dimen_ from (USB.e,Here)+(del/2,0)) |
| 363 |
{ "RESET" at RESET+(-del*1.7,1.0*del) above } |
| 364 |
line left del from RESET.start then down del |
| 365 |
G7: ground(,T,E); "GND" at last line.c below |
| 366 |
|
| 367 |
ICSP: Header(A2,3,4*del,2.5*lg_pinsep,,0.2;pindiam) \ |
| 368 |
with .Block.sw at ZU4.Pin19.end+(2*del,del*3) |
| 369 |
"ICSP" at ICSP.Block.nw above ljust |
| 370 |
"3X2 M" at ICSP.Block.sw below ljust |
| 371 |
for_(1,5,2,`"m4x" at ICSP.P`'m4x.end above ljust') |
| 372 |
for_(2,6,2,`"m4x" at ICSP.P`'m4x.end above rjust') |
| 373 |
dot(at ZU4.Pin19.end); line to (Here,ICSP.P3) then to ICSP.P3.end |
| 374 |
line from ZU4.Pin18.end right del; dot |
| 375 |
line to (Here,ICSP.P1) then to ICSP.P1.end |
| 376 |
move to ICSP.P5.end; line to (ZU4.Pin19.end,Here)-(del,0); |
| 377 |
continue to (Here,TP1); dot |
| 378 |
line from ICSP.P2.end up_ del; ground(,T,E,U); "+5 V" at last line.c above |
| 379 |
line from ICSP.P6.end down_ del; G9: ground(,T,E); "GND" at last line.c below |
| 380 |
move to ICSP.P4.end; line right_ del then down Here.y - ZU4.Pin17.y; dot |
| 381 |
# move to ICSP.P4.end; line right_ del then down Here.y - G9.y + del |
| 382 |
# continue to (ICSP.P1.end.x+del,Here.y) then down_ Here.y-ZU4.Pin17.y; dot |
| 383 |
|
| 384 |
line right_ from RESET.end to (U3.Chip.e+(12*del,0),TP1) |
| 385 |
POWER: Header(A1,8,1.5*del,7*lg_pinsep,,0.2;pindiam) with .P3.end at Here |
| 386 |
"POWER" wid 36bp__ at POWER.Block.nw above ljust |
| 387 |
"8X1F-H8.5" at POWER.Block.sw below ljust |
| 388 |
for_(1,8,1,`"m4x" at POWER.P`'m4x.end above ljust') |
| 389 |
line from POWER.P2.end left del/2 then down POWER.P2.y-POWER.P5.y ; dot |
| 390 |
line from POWER.P4.end left 2.5*del; "+3V3" above ljust |
| 391 |
dot(at POWER.P3.end-(del*1.5,0)); line up 2*del |
| 392 |
dot(,,1); "RESET" at last [].n above |
| 393 |
line from POWER.P5.end left 3.5*del then up 4*del; ground(,T,E,U) |
| 394 |
"+5 V" at last line.c above |
| 395 |
line left del*2 from POWER.P8.end; "VIN" above ljust |
| 396 |
line left del/2 from POWER.P7.end; dot |
| 397 |
line from POWER.P6.end to (Here,POWER.P6.end) then to Here+(0,-2.5*del) |
| 398 |
G10: ground(,T,E); "GND" at last line.c below |
| 399 |
|
| 400 |
right_ |
| 401 |
|
| 402 |
IOH: Header(A1,10,1.5*del,10*lg_pinsep,,0.2;pindiam) \ |
| 403 |
with .P10.end at ZU4.Pin14.end + (del*15,0) |
| 404 |
"IOH" at IOH.Block.nw above ljust |
| 405 |
"10X1F-H8.5" at IOH.Block.se below ljust |
| 406 |
for_(0,9,1,` |
| 407 |
{ "incr(m4x)" above ljust at IOH.P`'eval(10-m4x).end } |
| 408 |
move to IOH.P`'eval(10-m4x).start-(pindiam/2+dotrad_/2,0) |
| 409 |
ifelse(m4x,6,,`dot') |
| 410 |
move to IOH.P`'eval(10-m4x).end |
| 411 |
ifelse(eval(m4x<6),1,`line from ZU4.Pin`'eval(14+m4x).end to Here ') |
| 412 |
ifelse(m4x,6,,` line right del*4; dot(,pindiam/2,1) ') |
| 413 |
ifelse(eval(m4x<6),1,`"eval(8+m4x)" at last [].e ljust ')') |
| 414 |
"SCL" at last [].e ljust |
| 415 |
"SDA" at 3rd last [].e ljust |
| 416 |
"AREF" at 5th last [].e ljust |
| 417 |
|
| 418 |
AD: Header(A1,6,1.5*del,6*lg_pinsep,,0.2;pindiam) \ |
| 419 |
with .P6.end at (IOH.P10.end,ZU4.Pin23) #.end + (del*6,0) |
| 420 |
# with .P6.end at ZU4.Pin23.end + (del*6,0) |
| 421 |
"AD" at AD.Block.nw above ljust |
| 422 |
"6X1F-H8.5" at AD.Block.se below ljust |
| 423 |
for_(0,5,1,` |
| 424 |
dot(at AD.P`'eval(6-m4x).start-(pindiam/2+dotrad_/2,0)) |
| 425 |
line from ZU4.Pin`'eval(23+m4x).end \ |
| 426 |
to AD.P`'eval(6-m4x).end; {"incr(m4x)" above ljust} |
| 427 |
line right del*4; dot(,pindiam/2,1) |
| 428 |
"A`'m4x" at last [].e ljust ') |
| 429 |
|
| 430 |
IOL: Header(A1,8,1.5*del,8*lg_pinsep,,0.2;pindiam) \ |
| 431 |
with .P8.end at (AD.P1.end,ZU4.Pin2) |
| 432 |
"IOL" at IOL.Block.nw above ljust |
| 433 |
"8X1F-H8.5" at IOL.Block.sw ljust below |
| 434 |
for_(0,7,1,` |
| 435 |
dot(at IOL.P`'eval(8-m4x).start-(pindiam/2+dotrad_/2,0)) |
| 436 |
line from ZU4.Pin`'eval(ifelse(eval(m4x<5),1,2,6)+m4x).end \ |
| 437 |
to IOL.P`'eval(8-m4x).end; {"incr(m4x)" above ljust} |
| 438 |
line right del*4; dot(,pindiam/2,1) |
| 439 |
"m4x" at last [].e ljust ') |
| 440 |
|
| 441 |
line from ZU4.Pin21.end up RESET.y-ZU4.Pin21.y-del \ |
| 442 |
then right ICSP.P4.end.x-ZU4.Pin21.end.x + 2*del |
| 443 |
continue to (Here,IOH.P3)+(0,del*3/2); dot |
| 444 |
{ C4: capacitor(down_ 3.0*del); llabel(C4,,100n) |
| 445 |
{ ground(,T,E); "GND" at last line.e ljust} |
| 446 |
line from IOH.P4.end to (Here,IOH.P4); dot } |
| 447 |
line right del*3/2; continue to (Here,IOH.P3) then to IOH.P3.end |
| 448 |
|
| 449 |
line left del/2 from IOH.P2.end; continue to (Here,AD.P2); dot |
| 450 |
line left del*3/2 from IOH.P1.end; continue to (Here,AD.P1); dot |
| 451 |
|
| 452 |
# line right_ del*2 from U3.Pin9.end then down_ 5.5*lg_pinsep; dot |
| 453 |
line right_ del*2 from U3.Pin9.end then down_ 3.5*lg_pinsep; dot |
| 454 |
{ line right_ 2*del; dot(,,1); "RX" at last [].e ljust } |
| 455 |
line to (Here,RESET)-(0,del) |
| 456 |
RN4B: resistor(down_ dimen_,,E); llabel(7,"RN4B" ljust "1 K" ljust,2) |
| 457 |
line down_ del then left_ Here.x - IOH.P9.end.x + del*2.5 |
| 458 |
continue to (Here,ZU4.Pin2); dot |
| 459 |
|
| 460 |
line right_ del from U3.Pin8.end; dot |
| 461 |
{ line right_ 3*del; dot(,,1); "TX" at last [].e ljust } |
| 462 |
line to (Here,RN4B.start) |
| 463 |
RN4A: resistor(down_ dimen_,,E); rlabel(8,"RN4A" rjust "1 K" rjust,1) |
| 464 |
line to (IOH.P9.end,Here)-(del*3.5,0); continue to (Here,ZU4.Pin3); dot |
| 465 |
|
| 466 |
Pwr: [ |
| 467 |
Vin: line right 2*del "VIN" above |
| 468 |
RN1A: resistor(down_ dimen_*5/4,,E); rlabel(8, "RN1A" rjust "10 K" rjust ,1) |
| 469 |
CMP: dot |
| 470 |
RN1B: resistor(down_ dimen_*5/4,,E); rlabel(2, "RN1B" rjust "10 K" rjust ,7) |
| 471 |
B12: ground(,T,E); "GND" at last line below |
| 472 |
|
| 473 |
line right_ 2*del from CMP; dot |
| 474 |
{ line up_ 2*del; dot(,,1); "CMP" at last [].n above } |
| 475 |
line right_ del |
| 476 |
POA: opamp(,"+" ljust,"-" ljust) with .In1 at Here |
| 477 |
"U5A" at last [].n; "1" at POA.Out above rjust |
| 478 |
"3" at POA.In1 rjust above; "2" at POA.In2 rjust above |
| 479 |
line left_ del from POA.In2 then down_ del; "+3V3" below |
| 480 |
dot(at POA.Out); {line up_ 2*del; dot(,,1); "GATE" at last [].n above } |
| 481 |
T1: mosfet(down_ dimen_*1.5,R,dMdPyEDSQdB,) with .G at Here |
| 482 |
"T1" at T1 + (-dimen_/4,del*5/4) |
| 483 |
"FDN340P" at T1 + (0,-del*5/4) rjust |
| 484 |
# "USBVCC" at T1.D rjust |
| 485 |
dot(at T1.S); { line up_ 2*del; ground(,T,E,U); "+5 V" at last line above } |
| 486 |
] with .RN1B at (USB.e.x+del,RN1C.y-2*del) |
| 487 |
dot(at XUSB+(0,-del/2)) |
| 488 |
F1: fuse(right_ to (Pwr.T1.D,Here)); { "500 mA" ljust } |
| 489 |
{ "MF-MSMF050-2" at last [].sw below ljust } |
| 490 |
line to Pwr.T1.D |
| 491 |
|
| 492 |
line from Pwr.T1.S right_ 2.5*lg_pinsep |
| 493 |
{ U2:box ht 3*lg_pinsep wid 5*lg_pinsep with .nw at Here+(0,lg_pinsep/2) } |
| 494 |
{"1" above rjust}; {"IN" ljust} |
| 495 |
"LP2985-33DBVR" at U2.s below |
| 496 |
"U2" above ljust at U2.nw |
| 497 |
"3" above rjust at U2.w; line left del from U2.w then up_ lg_pinsep; dot |
| 498 |
"ON/svg_ol(OFF)" at U2.w ljust |
| 499 |
# line right_ textht*0.66*3 from U2.w+(textht*0.66*5,textht) |
| 500 |
U2P2: U2.w+(0,-lg_pinsep); "2" at U2P2 above rjust; "GND" at U2P2 ljust |
| 501 |
line from U2P2 left del then down_ del |
| 502 |
G15: ground(,T,E); "GND" at last line.c below |
| 503 |
U2P5: (U2.e.x,U2.e.y+lg_pinsep) |
| 504 |
"OUT" at U2P5 rjust; "5" at U2P5 above ljust |
| 505 |
line from U2P5 right 2*del "+3V3" below; dot |
| 506 |
{ line up_ del; dot(,,1); "3V3" at last [].n above } |
| 507 |
C3: capacitor(down_ to(Here,G15)); rlabel(,"C3" rjust "1`'svg_micro" rjust) |
| 508 |
ground(,T,E); "GND" at last line.c below |
| 509 |
"NC/FB" at (U2.e.x,U2P2.y) rjust |
| 510 |
|
| 511 |
"SCK" above ljust at Pwr.Vin + (0,4*del) |
| 512 |
line right_ 3*del |
| 513 |
U5B: opamp(,"+" ljust, "-" ljust) with .In1 at Here |
| 514 |
"5" at U5B.In1 above rjust; "6" at U5B.In2 above rjust |
| 515 |
"U5B" at last [].n; "7" at U5B.Out above rjust |
| 516 |
line from U5B.In2 left del then down del then right U5B.Out.x-U5B.In1.x+del |
| 517 |
TD2: dot |
| 518 |
dot(at U5B.Out); dot(at Here+(0,2*del),,1); "LCMD" at last [].e ljust |
| 519 |
line down_ from last [].s to TD2 |
| 520 |
RN2A: resistor(right_ dimen_*5/4,,E); llabel(8,"1K",1); rlabel(,RN2A) |
| 521 |
dot; {line up_ 2*del; dot(,,1); "LL" at last [].n above } |
| 522 |
diode(right_ dimen_*5/4,LE); rlabel(,YELLOW) |
| 523 |
line down_ dimen_/4; egnd |
| 524 |
|
| 525 |
X1:box ht 3*lg_pinsep wid 5*lg_pinsep with .w at (U2.x,U5B.y+del) |
| 526 |
"X1 DC21MMX" at X1.nw above ljust; "PWR SUPPLY" at X1.nw below ljust |
| 527 |
X1P1: 1/3 between X1.sw and X1.se; "1" at X1P1 rjust below |
| 528 |
X1P2: 2/3 between X1.sw and X1.se; "2" at X1P2 rjust below |
| 529 |
line down_ del from X1P1; dot; { egnd } |
| 530 |
line right X1.e.x+del - Here.x then up_ X1.e.y-Here.y then to X1.e |
| 531 |
"3" above ljust at X1.e |
| 532 |
line from X1P2 down del/2 then right X1.e.x+del*2 - X1P2.x \ |
| 533 |
then up X1.n.y - X1P2.y + del/2; dot |
| 534 |
{ line up_ 2*del; PWRIN: dot(,,1); "PWRIN" at last [].w rjust } |
| 535 |
D1: diode(right_ dimen_); llabel(,D1); rlabel(,M7); dot |
| 536 |
{ PC1: capacitor(down_ dimen_,C); llabel(,"PC1" ljust "47`'svg_micro" ljust) |
| 537 |
G16: egnd } |
| 538 |
{ line to (Here,PWRIN); dot(,,1); "VIN" at last [].e ljust } |
| 539 |
line right 3*del; { "3" above rjust } |
| 540 |
U1P1: Here |
| 541 |
U1: box ht 3*lg_pinsep wid 4*lg_pinsep with .nw at Here+(0,lg_pinsep/2) |
| 542 |
"IN" at U1P1 ljust; "OUT" at (U1.e,U1P1) rjust |
| 543 |
"1" below rjust at U1.s |
| 544 |
"U1" at U1.nw + (0,textht/dptextratio) above ljust \ |
| 545 |
"NCP1117ST50T3G" ljust |
| 546 |
line from U1.s to (U1.s,G16); egnd |
| 547 |
U1P4: (U1.e,U1P1); U1P2: U1P4+(0,-del) |
| 548 |
{ "4" at U1P4 above ljust }; { "2" at U1P2 above ljust }; |
| 549 |
line right_ 2*del from U1P4; dot; |
| 550 |
line from U1P2 to (Here,U1P2); dot; { line to (Here,U1P4) } |
| 551 |
{ PC2: capacitor(down_ to (Here,G16),C) |
| 552 |
llabel(,"PC2" ljust "47`'svg_micro" ljust); egnd } |
| 553 |
line right_ del*3/2 from (Here,U1P4); dot |
| 554 |
{ line to (Here,PWRIN); ground(,T,E,U); "+5V" at last line.c above } |
| 555 |
line right_ del*3/2; dot; { line to (Here,PC2.start) |
| 556 |
C2: capacitor(down_ to (Here,G16),C) |
| 557 |
llabel(,"C2" ljust "100`'svg_micro" ljust); egnd } |
| 558 |
{ line to (Here,PWRIN); dot(,,1); "5V" at last [].n above } |
| 559 |
line right_ del*3/2 then to (Here.x+del*3/2,PWRIN.y); dot(,,1) |
| 560 |
"5V1" at last [].n above |
| 561 |
|
| 562 |
|
| 563 |
|
| 564 |
command "</g>" |
| 565 |
.PE |