| 1 |
divert(-1) |
| 2 |
libcct.m4 |
| 3 |
|
| 4 |
* Circuit_macros Version 11.0, copyright (c) 2026 J. D. Aplevich under * |
| 5 |
* the LaTeX Project Public Licence in file Licence.txt. The files of * |
| 6 |
* this distribution may be redistributed or modified provided that this * |
| 7 |
* copyright notice is included and provided that modifications are clearly * |
| 8 |
* marked to distinguish them from this distribution. There is no warranty * |
| 9 |
* whatsoever for these files. * |
| 10 |
|
| 11 |
define(`libcct_') |
| 12 |
ifdef(`libgen_',,`include(libgen.m4)divert(-1)') |
| 13 |
|
| 14 |
`============================================================================== |
| 15 |
HINTS: |
| 16 |
|
| 17 |
THE ARGUMENTS of circuit elements are optional; if omitted, default values |
| 18 |
are assumed. |
| 19 |
|
| 20 |
TWO-TERMINAL ELEMENTS are constructed as follows, with variations: |
| 21 |
|
| 22 |
# Draw the initial invisible line (default length rp_len), and set the |
| 23 |
# direction cosines: |
| 24 |
eleminit_(`$1') |
| 25 |
|
| 26 |
# Element body height and width |
| 27 |
define(`m4v',...)define(`m4h',...) |
| 28 |
|
| 29 |
# Visible lines: |
| 30 |
{ line to rvec_(rp_len/2-m4h/2,0) |
| 31 |
# The body drawn within a block: |
| 32 |
{[ element body lines ] with .internal position at Here } |
| 33 |
line to rvec_(rp_len/2-m4h/2,0) } |
| 34 |
|
| 35 |
# Some elements overlay a block to define the body size. |
| 36 |
{[box invis ht_ m4v wid_ m4h ] at rvec_(rp_len/2,0)} |
| 37 |
|
| 38 |
# The final invisible line: |
| 39 |
line to rvec_(rp_len,0) invis |
| 40 |
|
| 41 |
A side effect of the eleminit_ macro is to change the current drawing angle. |
| 42 |
|
| 43 |
NON-TWO-TERMINAL ELEMENTS are usually constructed within a block: |
| 44 |
|
| 45 |
set dimension parameters |
| 46 |
[ set size and direction from the initial linespec argument if any |
| 47 |
set orientation (left or right) |
| 48 |
draw internal elements |
| 49 |
define internal locations |
| 50 |
] |
| 51 |
|
| 52 |
If there is a linespec argument, it determines orientation |
| 53 |
but not the placement of the element, since [] blocks are placed |
| 54 |
as if they were boxes. |
| 55 |
|
| 56 |
============================================================================== |
| 57 |
|
| 58 |
DEBUGGING: The statement |
| 59 |
print "`$0'($@)" ; |
| 60 |
inserted into a macro will display the macro name and current arguments |
| 61 |
provided the arguments do not contain double quotes. The line |
| 62 |
`# $0'($@) will write a comment containing the same information into the |
| 63 |
.pic output. Similarly, the m4 macro m4msg( text ) will display the |
| 64 |
text during m4 processing. |
| 65 |
|
| 66 |
============================================================================== |
| 67 |
CUSTOMIZATIONS: |
| 68 |
|
| 69 |
The non-two-terminal circuit elements enclosed in [] blocks allow |
| 70 |
a final argument not shown in the argument list. The last argument is |
| 71 |
expanded just before exit from the [] block to allow custom additions |
| 72 |
to the elements. |
| 73 |
|
| 74 |
Subcomponents of some circuit elements are drawn selectively according |
| 75 |
to a "dna_" string and a sequence of calls to sc_draw(`dna_',arg2,arg3,arg4). |
| 76 |
If the second argument of sc_draw is a substring of the first, it is deleted |
| 77 |
from the first and the third argument is expanded, otherwise the fourth |
| 78 |
argument (which may be null) is expanded. |
| 79 |
|
| 80 |
============================================================================== |
| 81 |
This file redefines default arrow dimensions and the dotrad_ macro. |
| 82 |
==============================================================================' |
| 83 |
|
| 84 |
`capacitor( linespec,chars,R,height,wid ) |
| 85 |
Arg2 chars: |
| 86 |
[d]F or blank: flat plates; d=hatched fill |
| 87 |
[d]C = polarized, curved plate; d=variable |
| 88 |
CP = constant phase |
| 89 |
E = polarized rectangular plates |
| 90 |
K = filled rectangular plates |
| 91 |
M = rectangular plates |
| 92 |
N = one rectangular plate |
| 93 |
P = alternate polarized |
| 94 |
+ = polarity sign to right of drawing dir |
| 95 |
+L =polarity sign to left |
| 96 |
arg3 = R: reversed orientation |
| 97 |
arg4 = height (defaults F: dimen_/3; |
| 98 |
C,P: dimen_/4; E,K: dimen_/5) |
| 99 |
arg5 = wid (defaults F: height*0.3; |
| 100 |
C,P: height*0.4; E,K: height) ' |
| 101 |
define(`capacitor', |
| 102 |
`ifelse(`$3',R,`reversed(`capacitor',`$1',`$2',,shift(shift(shift($@))))', |
| 103 |
`eleminit_(`$1') |
| 104 |
define(`dna_',`ifelse(`$2',,F,`$2')')dnl |
| 105 |
{ sc_draw(`dna_',F, |
| 106 |
`define(`m4cht',`ifelse(`$4',,`dimen_/3',`($4)')')dnl |
| 107 |
define(`m4cwd',`ifelse(`$5',,`m4cht*0.3',`($5)')')dnl |
| 108 |
line to rvec_(rp_len/2-m4cwd/2,0) |
| 109 |
{line from rvec_(0,-m4cht/2) \ |
| 110 |
to rvec_(0,m4cht/2)} |
| 111 |
ifelse(m4a,d,`for_(1,3,1,{line from rvec_(0,m4cwd*(m4x-5/2)) \ |
| 112 |
to rvec_(m4cwd,m4cwd*(m4x-3/2))})') |
| 113 |
move to rvec_(m4cwd,0) |
| 114 |
{line from rvec_(0,-m4cht/2) \ |
| 115 |
to rvec_(0,m4cht/2)} |
| 116 |
line to rvec_(rp_len/2-m4cwd/2,0) ') |
| 117 |
sc_draw(`dna_',CP, |
| 118 |
`define(`m4cht',`ifelse(`$4',,`dimen_/3',`($4)')')dnl |
| 119 |
define(`m4cwd',`ifelse(`$5',,`m4cht*0.8',`($5)')')dnl |
| 120 |
line to rvec_(rp_len/2,0) |
| 121 |
{line from rvec_(-m4cwd/2,m4cht/2) to Here \ |
| 122 |
then to rvec_(-m4cwd/2,-m4cht/2) } |
| 123 |
{line from rvec_(0,m4cht/2) to rvec_(m4cwd/2,0) \ |
| 124 |
then to rvec_(0,-m4cht/2) } |
| 125 |
line from rvec_(m4cwd/2,0) to rvec_(rp_len/2,0) |
| 126 |
') |
| 127 |
sc_draw(`dna_',C, |
| 128 |
`define(`m4cht',`ifelse(`$4',,`dimen_/4',`($4)')')dnl |
| 129 |
define(`m4cwd',`ifelse(`$5',,`m4cht*0.4',`($5)')')dnl |
| 130 |
define(`m4cr',`dimen_*0.25')dnl |
| 131 |
line to rvec_(rp_len/2-m4cwd/2,0) |
| 132 |
{line from rvec_(0,-m4cht/2) \ |
| 133 |
to rvec_(0,m4cht/2)} |
| 134 |
{arc cw ifelse(m4a,d,-> wid lthick*4 ht lthick*5) \ |
| 135 |
from rvec_(m4cwd,-m4cht/2) \ |
| 136 |
to rvec_(m4cwd,m4cht/2) \ |
| 137 |
with .c at rvec_(m4cwd+sqrt((m4cr)^2-(m4cht/2)^2),0) } |
| 138 |
line from last arc.c+vec_(-m4cr,0) \ |
| 139 |
to rvec_(rp_len/2+m4cwd/2,0) ') |
| 140 |
sc_draw(`dna_',P, |
| 141 |
`define(`m4cht',`ifelse(`$4',,`dimen_/4',`($4)')')dnl |
| 142 |
define(`m4cwd',`ifelse(`$5',,`m4cht*0.4',`($5)')')dnl |
| 143 |
define(`m4cr',`dimen_*0.25')dnl |
| 144 |
line to rvec_(rp_len/2-m4cwd/2,0) |
| 145 |
{line from rvec_(m4cwd,-m4cht/2) \ |
| 146 |
to rvec_(0,-m4cht/2) \ |
| 147 |
then to rvec_(0,m4cht/2) \ |
| 148 |
then to rvec_(m4cwd,m4cht/2) } |
| 149 |
{line from rvec_(m4cwd*2/3,-m4cht*3/8) \ |
| 150 |
to rvec_(m4cwd*2/3,m4cht*3/8)} |
| 151 |
line from rvec_(m4cwd*2/3,0) \ |
| 152 |
to rvec_(rp_len/2+m4cwd/2,0) ') |
| 153 |
sc_draw(`dna_',E, |
| 154 |
`define(`m4cht',`ifelse(`$4',,`dimen_/5',`($4)')')dnl |
| 155 |
define(`m4cwd',`ifelse(`$5',,`m4cht',`($5)')')dnl |
| 156 |
define(`m4cs',`(m4cwd/3.2)')dnl |
| 157 |
line to rvec_(rp_len/2-m4cwd/2,0) |
| 158 |
m4linethicktemp = linethick; thinlines_ |
| 159 |
{ lbox(m4cs,m4cht) } |
| 160 |
move to rvec_(m4cwd,0) |
| 161 |
{ifsvg(`lbox(-m4cs,m4cht,fill_(0))',`m4fshade(m4fill,lbox(-m4cs,m4cht))')} |
| 162 |
linethick_(m4linethicktemp) |
| 163 |
line to rvec_(rp_len/2-m4cwd/2,0) ') |
| 164 |
sc_draw(`dna_',M, |
| 165 |
`define(`m4cht',`ifelse(`$4',,`dimen_/5',`($4)')')dnl |
| 166 |
define(`m4cwd',`ifelse(`$5',,`m4cht',`($5)')')dnl |
| 167 |
define(`m4cs',`(m4cwd/3.2)')dnl |
| 168 |
line to rvec_(rp_len/2-m4cwd/2,0) |
| 169 |
m4linethicktemp = linethick; thinlines_ |
| 170 |
{ lbox(m4cs,m4cht) } |
| 171 |
move to rvec_(m4cwd,0) |
| 172 |
{ lbox(-m4cs,m4cht) } |
| 173 |
linethick_(m4linethicktemp) |
| 174 |
line to rvec_(rp_len/2-m4cwd/2,0) ') |
| 175 |
sc_draw(`dna_',K, |
| 176 |
`define(`m4cht',`ifelse(`$4',,`dimen_/5',`($4)')')dnl |
| 177 |
define(`m4cwd',`ifelse(`$5',,`m4cht',`($5)')')dnl |
| 178 |
define(`m4cs',`(m4cwd/3.2)')dnl |
| 179 |
line to rvec_(rp_len/2-m4cwd/2,0) |
| 180 |
{ifsvg(`lbox(m4cs,m4cht,fill_(0))',`m4fshade(m4fill,lbox(m4cs,m4cht))')} |
| 181 |
move to rvec_(m4cwd,0) |
| 182 |
{ifsvg(`lbox(-m4cs,m4cht,fill_(0))',`m4fshade(m4fill,lbox(-m4cs,m4cht))')} |
| 183 |
line to rvec_(rp_len/2-m4cwd/2,0) ') |
| 184 |
sc_draw(`dna_',N, |
| 185 |
`define(`m4cht',`ifelse(`$4',,`dimen_/5',`($4)')')dnl |
| 186 |
define(`m4cwd',`ifelse(`$5',,`m4cht*2/3',`($5)')')dnl |
| 187 |
define(`m4cs',`(m4cwd/3.2*3/2)')dnl |
| 188 |
line to rvec_(rp_len/2-m4cwd/2,0) |
| 189 |
{ lbox(m4cs,m4cht) } |
| 190 |
move to rvec_(m4cwd,0) |
| 191 |
{line from rvec_(0,m4cht/2) to rvec_(0,-m4cht/2) } |
| 192 |
line to rvec_(rp_len/2-m4cwd/2,0) ') |
| 193 |
} |
| 194 |
ifinstr(`$2',+L, |
| 195 |
`{ move to rvec_(rp_len/2-m4cwd/2-m4cht/3,m4cht/3) |
| 196 |
{line thick 0.5 from rvec_(m4cht/6,0) \ |
| 197 |
to rvec_(-m4cht/6,0)} |
| 198 |
line thick 0.5 from rvec_(0,m4cht/6) \ |
| 199 |
to rvec_(0,-m4cht/6)}', |
| 200 |
`$2',+, |
| 201 |
`{ move to rvec_(rp_len/2-m4cwd/2-m4cht/3,-m4cht/3) |
| 202 |
{line thick 0.5 from rvec_(m4cht/6,0) \ |
| 203 |
to rvec_(-m4cht/6,0)} |
| 204 |
line thick 0.5 from rvec_(0,m4cht/6) \ |
| 205 |
to rvec_(0,-m4cht/6)}') |
| 206 |
{[box invis ht_ m4cht wid_ m4cwd ] at rvec_(rp_len/2,0)} |
| 207 |
line to rvec_(rp_len,0) invis ')') |
| 208 |
|
| 209 |
`resistor( linespec, cycles, chars, cycle wid ) |
| 210 |
chars: AC: complex element |
| 211 |
E: ebox |
| 212 |
ES: ebox with slash |
| 213 |
EX: ebox with full-size X |
| 214 |
F: FDNR (freq-dependent neg resistor) |
| 215 |
Q: offset |
| 216 |
H: squared |
| 217 |
LD: light dependent |
| 218 |
LDE: light dependent ebox |
| 219 |
N: IEEE (default) |
| 220 |
B: not burnable |
| 221 |
T: thermistor |
| 222 |
V: varistor variant |
| 223 |
R: to right of drawing direction |
| 224 |
Alternative: resistor( linespec, keys ) |
| 225 |
keys: type=chars; as above |
| 226 |
wdth=expr; body width |
| 227 |
cycles=expr; |
| 228 |
lgth=expr; default cycles*wdth |
| 229 |
body=attributes; box body |
| 230 |
env=attributes; envelope ' |
| 231 |
define(`resistor',`eleminit_(`$1') |
| 232 |
pushkeys_(`$2',`type:ifelse(`$3',,N,`$3',R,N,`$3'):N; |
| 233 |
wdth:ifelse(`$4',,(dimen_/6),`($4)'); |
| 234 |
cycles:ifinstr(`$2',=,3,ifelse(`$2',,3,(`$2'))); |
| 235 |
lgth:(m4`'cycles)*(m4`'wdth); |
| 236 |
body::N; env::N;') |
| 237 |
if m4lgth > rp_len then { eleminit_(to rvec_(m4lgth,0)) } |
| 238 |
M4S: last line.start; M4E: last line.end; M4C: last line.c |
| 239 |
pushdef(`m4ng',sc_draw(`m4type',R,-))dnl |
| 240 |
ifelse( |
| 241 |
m4type,N, # Default resistor: |
| 242 |
`pushdef(`m4nN',`eval(2*m4cycles)') m4Rh=m4lgth/m4nN/2 |
| 243 |
{ line from M4S to M4C+vec_(-m4nN*m4Rh,0)\ |
| 244 |
for_(2,m4nN,2, |
| 245 |
`then to M4C+vec_(eval(2*m4x-3-m4nN)*m4Rh, m4wdth/2) \ |
| 246 |
then to M4C+vec_(eval(2*m4x-1-m4nN)*m4Rh,-m4wdth/2) \')dnl |
| 247 |
then to M4C+vec_(m4nN*m4Rh, 0) \ |
| 248 |
then to M4E # Maybe replace for obtuse directions: |
| 249 |
[box invis ht_ m4wdth wid_ m4lgth] at 2nd last line.c |
| 250 |
popdef(`m4nN')}', |
| 251 |
m4type,Q, |
| 252 |
`pushdef(`m4nN',`eval(2*m4cycles)') m4Rh=m4lgth/m4nN/2 |
| 253 |
{ line from M4S to M4C+vec_(-m4nN*m4Rh,0)\ |
| 254 |
for_(2,m4nN,2, |
| 255 |
`then to M4C+vec_(eval(2*m4x-2-m4nN)*m4Rh, m4ng`'m4wdth) \ |
| 256 |
then to M4C+vec_(eval(2*m4x-m4nN)*m4Rh,0) \')dnl |
| 257 |
then to M4C+vec_(m4nN*m4Rh, 0) \ |
| 258 |
then to M4E |
| 259 |
[box invis ht_ m4wdth wid_ m4lgth] at M4C + vec_(0,m4ng`'m4wdth/2) |
| 260 |
popdef(`m4nN')}', |
| 261 |
m4type,ES, |
| 262 |
`ebox(`$1',lgth=m4lgth;wdth=ifinstr(`$2',wdth=,m4wdth,dimen_/5);body=m4body) |
| 263 |
{line from last line.c+vec_( dimen_/2*0.3, m4ng`'dimen_/5/2) \ |
| 264 |
to last line.c+vec_(-dimen_/2*0.3,ifelse(m4ng,-,,-)dimen_/5/2)}', |
| 265 |
m4type,EX, |
| 266 |
`ebox(`$1',lgth=m4lgth;wdth=ifinstr(`$2',wdth=,m4wdth,dimen_/5);body=m4body) |
| 267 |
{line from last line.c+vec_( m4lgth/2, m4wdth/2) \ |
| 268 |
to last line.c+vec_(-m4lgth/2,-m4wdth/2)} |
| 269 |
{line from last line.c+vec_(-m4lgth/2, m4wdth/2) \ |
| 270 |
to last line.c+vec_( m4lgth/2,-m4wdth/2)}', |
| 271 |
m4type,F, |
| 272 |
`pushdef(`m4cht',ifinstr(`$2',hght=,m4hght,dimen_/3))dnl |
| 273 |
pushdef(`m4cwd',ifinstr(`$2',wdth=,m4wdth,m4cht*0.9))dnl |
| 274 |
{line to rvec_(rp_len/2-m4cwd/2,0) |
| 275 |
{[for i=0 to m4cycles do {line from vec_(i*m4cwd/m4cycles,0) \ |
| 276 |
to vec_(i*m4cwd/m4cycles,m4cht)}] at M4C} |
| 277 |
line from rvec_(m4cwd,0) to rvec_(rp_len/2+m4cwd/2,0) |
| 278 |
popdef(`m4cht',`m4cwd')}', |
| 279 |
m4type,H, |
| 280 |
`pushdef(`m4nH',`eval(2*m4cycles-1)') m4Rh=m4lgth/m4nH |
| 281 |
pushdef(`m4v',m4ng`'ifinstr(`$2',hght=,m4hght,m4Rh*7/6))dnl |
| 282 |
{ line from M4S to M4C+vec_(-m4nH/2*m4Rh,0)\ |
| 283 |
for_(1,m4cycles,1, |
| 284 |
`then to M4C+vec_(((m4x-1)*2-m4nH/2)*m4Rh,m4v) \ |
| 285 |
then to M4C+vec_(((m4x-1)*2+1-m4nH/2)*m4Rh,m4v) \ |
| 286 |
then to M4C+vec_(((m4x-1)*2+1-m4nH/2)*m4Rh,0) \ |
| 287 |
ifelse(m4x,m4cycles,, |
| 288 |
`then to M4C+vec_((m4x*2-m4nH/2)*m4Rh,0)') \') then to M4E |
| 289 |
[move from M4C+vec_(-m4nH/2*m4Rh,0) to M4C+vec_(m4nH/2*m4Rh,m4v) \ |
| 290 |
then to M4C+vec_(m4nH/2*m4Rh,m4v) then to M4C+vec_(-m4nH/2*m4Rh,0)] \ |
| 291 |
at M4C+vec_(0,m4v/2) popdef(`m4nH',`m4v') }', |
| 292 |
m4type,LD, |
| 293 |
`Circle: circle diam m4lgth at M4C m4env |
| 294 |
em_arrows(N,rp_ang*rtod_-45 ifelse(m4ng,-,+90),Circle.rad) \ |
| 295 |
with .Head at M4C+vec_(Rect_(Circle.rad,135 ifelse(m4ng,-,+90))) |
| 296 |
resistor(from M4S to M4E,wdth=m4wdth*3/4) |
| 297 |
[box invis wid Circle.diam ht Circle.diam] at Circle ', |
| 298 |
m4type,LDE, |
| 299 |
`Circle: circle diam m4lgth at M4C m4env |
| 300 |
em_arrows(N,rp_ang*rtod_-45 ifelse(m4ng,-,+90),Circle.rad) \ |
| 301 |
with .Head at M4C+vec_(Rect_(Circle.rad,135 ifelse(m4ng,-,+90))) |
| 302 |
ebox(from M4S to M4E,lgth=Circle.diam*3/4;wdth=Circle.diam*3/8;body=m4body) |
| 303 |
[box invis wid Circle.diam ht Circle.diam] at Circle ', |
| 304 |
m4type,T, |
| 305 |
`{ tl=m4lgth/2+m4wdth; move to M4C |
| 306 |
Env: spline ifdpic(ctension_) from rvec_(ifdpic(0,-tl*3/40),m4wdth*4/3)\ |
| 307 |
to rvec_( tl/3,m4wdth*4/3) then to rvec_( tl,m4wdth*8/9) \ |
| 308 |
then to rvec_( tl,-m4wdth*8/9) then to rvec_( tl/3,-m4wdth*4/3) \ |
| 309 |
then to rvec_(-tl/3,-m4wdth*4/3) then to rvec_(-tl,-m4wdth*8/9) \ |
| 310 |
then to rvec_(-tl,m4wdth*8/9) then to rvec_(-tl/3,m4wdth*4/3) \ |
| 311 |
then to rvec_(ifdpic(0,tl*3/40),m4wdth*4/3) m4env } |
| 312 |
ifinstr(`$2',=, |
| 313 |
`resistor(`$1',patsubst(`$2',type=T),`$3',`$4')', |
| 314 |
`resistor(`$1',`$2',patsubst(`$3',T),`$4')') |
| 315 |
[box invis wid_ 2*tl ht_ m4wdth*8/3] at M4C ', |
| 316 |
m4type,V, |
| 317 |
`{line to rvec_(max(0,rp_len/2-m4lgth/2),0) |
| 318 |
pushdef(`m4Vline',line to rvec_(0,ifelse(m4ng,-,,-)`'m4lgth/4) \ |
| 319 |
then to rvec_(m4lgth,m4ng`'m4lgth/4) \ |
| 320 |
then to rvec_(m4lgth,0) then to Here)dnl |
| 321 |
{[ifelse(m4body,,`m4fshade(m4fill,m4Vline)',`m4Vline m4body')] at M4C } |
| 322 |
line from rvec_(m4lgth,0) to rvec_(max(0,rp_len/2+m4lgth/2),0) |
| 323 |
popdef(`m4Vline') } ', |
| 324 |
m4type,B, |
| 325 |
`ifinstr(`$2',=, |
| 326 |
`resistor(`$1',patsubst(`$2',type=B),`$3',`$4')', |
| 327 |
`resistor(`$1',`$2',patsubst(`$3',B),`$4')') |
| 328 |
m4lbwd = last [].wid_+lthick*2; m4lbht = last [].ht_+lthick*2 |
| 329 |
[lbox(m4lbwd+lthick*4,m4lbht+lthick*4,thick linethick/2) m4body] at M4C |
| 330 |
[lbox(m4lbwd,m4lbht,thick 0.4 m4body)] at M4C', |
| 331 |
m4type,AC, |
| 332 |
`ebox(`$1',lgth=m4lgth;wdth=ifinstr(`$2',wdth=,m4wdth,dimen_/5);body=m4body) |
| 333 |
{ ACsymbol(at last [],m4wdth*3.5/4,m4wdth/2,R) |
| 334 |
[] wid 2nd last [].wid ht 2nd last [].ht at 2nd last [] } ') |
| 335 |
ifelse(m4type,E, |
| 336 |
`ebox(`$1',lgth=m4lgth;wdth=ifinstr(`$2',wdth=,m4wdth,dimen_/5);body=m4body)') |
| 337 |
line invis from M4S to M4E') |
| 338 |
popdef(`m4type',`m4wdth',`m4cycles',`m4body',`m4env',`m4lgth',`m4ng')dnl |
| 339 |
') |
| 340 |
|
| 341 |
`potentiometer(linespec, cycles, |
| 342 |
fractional pos, length, fractional pos, length,...) |
| 343 |
Resistor in a block, tapped at fractional positions |
| 344 |
with specified (possibly negative) arrow lengths. |
| 345 |
Taps are labelled T1, T2, ...' |
| 346 |
define(`potentiometer',`[R: resistor(`$1',`$2') |
| 347 |
define(`m4n',`ifelse(`$2',,3,(`$2'))')dnl |
| 348 |
Start: R.start; End: R.end; C: R.c |
| 349 |
m4pot_arrows(1,ifelse(`$3',,0.5,`$3'),ifelse(`$4',,`dimen_*5/12',`$4'), |
| 350 |
shift(shift(shift(shift($@)))))] ') |
| 351 |
define(`m4pot_arrows',`ifelse(`$2',,,`FrP: C+vec_((`$2'-0.5)*m4n*dimen_/6,0) |
| 352 |
T`$1': FrP + vec_(0,ifelse(`$3',,`dimen_*5/12',`$3')) |
| 353 |
x = (`$2')*4*m4n+1; x = (int(x)%4)+(x-int(x)) |
| 354 |
{arrow from T`$1' to FrP+vec_(0,dimen_/12*(1-(x-2)*sign(x-2)))} |
| 355 |
m4pot_arrows(incr($1),shift(shift(shift($@))))')') |
| 356 |
|
| 357 |
`KelvinR(cycles,[R],cycle wid) |
| 358 |
IEEE resistor with kelvin taps added' |
| 359 |
define(`KelvinR',`[ |
| 360 |
M4R: resistor(,`$1',,`$3') |
| 361 |
Start: M4S; End: M4E; C: M4C |
| 362 |
pushdef(`m4ng',`ifinstr(`$2',R,-)')dnl |
| 363 |
m4Kelw = ifelse(`$3',,dimen_/6,`($3)') |
| 364 |
m4KelN = 2*ifelse(`$1',,3,(`$1')) |
| 365 |
{ dot(at C+vec_(-m4KelN*m4Kelw/4,0),lthick) |
| 366 |
line to C+vec_((-m4KelN-1)*m4Kelw/4,m4ng`'m4Kelw/2) \ |
| 367 |
then to C+vec_((-m4KelN-1)*m4Kelw/4,m4ng`'m4Kelw) |
| 368 |
T1: Here |
| 369 |
dot(at C+vec_(m4KelN*m4Kelw/4,0),lthick) |
| 370 |
line to C+vec_((m4KelN+1)*m4Kelw/4,m4ng`'m4Kelw/2) \ |
| 371 |
then to C+vec_((m4KelN+1)*m4Kelw/4,m4ng`'m4Kelw) |
| 372 |
T2: Here } |
| 373 |
`$4' popdef(`m4ng') ]') ') |
| 374 |
|
| 375 |
`FTcap(chars) |
| 376 |
Feed-through capacitor; composite element |
| 377 |
derived from a two-terminal element. |
| 378 |
Defined points: .Start, .End, .C |
| 379 |
chars: A|B|C|D element type' |
| 380 |
define(`FTcap',`[ define(`FTctyp',`ifelse(`$1',,A,`$1')')dnl |
| 381 |
ifelse(FTctyp,A, |
| 382 |
`capacitor(to vec_(dimen_*2/3,0)) |
| 383 |
Start: last line.start; End: last line.end; C: last line.c |
| 384 |
Conductor: line from C+vec_(0,dimen_/3) to C+vec_(0,-dimen_/3) |
| 385 |
T1: last line.start; T2: last line.end', |
| 386 |
FTctyp,B, |
| 387 |
`capacitor(to vec_(dimen_*2/3,0),C) |
| 388 |
Start: last line.start; End: last line.end; C: last line.c |
| 389 |
r = last arc.rad-hlth |
| 390 |
T1: (0.5 between 2nd line.end and last arc.c-vec_(r,0)) + vec_(0,dimen_/3) |
| 391 |
T2: T1+(0,-dimen_*2/3) |
| 392 |
Conductor: line from T1 to T2', |
| 393 |
FTctyp,C, |
| 394 |
`line to vec_(dimen_*2/3,0) |
| 395 |
Start: last line.start; End: last line.end; C: last line.c |
| 396 |
rp_a = rp_ang |
| 397 |
capacitor(from C to C-vec_(0,dimen_/10),C) |
| 398 |
point_(rp_a) |
| 399 |
line from last line.end to last line.end-vec_(0,dimen_/3) |
| 400 |
T: Here', |
| 401 |
FTctyp,D, |
| 402 |
`Start: Here |
| 403 |
capacitor(to rvec_(dimen_/3,0),C) |
| 404 |
C: Here |
| 405 |
{ line to rvec_(0,-dimen_/3); T: Here } |
| 406 |
End: rvec_(dimen_/3,0) |
| 407 |
rp_a = rp_ang |
| 408 |
capacitor(from End to Here,C) |
| 409 |
point_(rp_a)') |
| 410 |
`$2' ]') |
| 411 |
|
| 412 |
`addtaps([ahead | type=ahead;name=Name], |
| 413 |
fractional pos, length, fractional pos, length,...) |
| 414 |
ahead = blank or one of . - <- -> <-> |
| 415 |
Tap names are Tap1, Tap2, ... or |
| 416 |
Name1, Name2, ... if specified' |
| 417 |
define(`addtaps',` |
| 418 |
ifelse(`$2',,`undefine(`m4tap_x')popdef(`m4type',`m4name')', |
| 419 |
`ifdef(`m4tap_x',`define(`m4tap_x',incr(m4tap_x))', |
| 420 |
`define(`m4tap_x',1) dnl 1st time through |
| 421 |
M4tap_w: last [].w_; M4tap_e: last [].e_ |
| 422 |
pushkeys_(`$1',type::N; name:Tap:N)dnl |
| 423 |
ifelse(m4type,,`ifinstr(`$1',=,,`poppushdef(`m4type',`$1')')')dnl |
| 424 |
M4tap_xy: (last [].wid_,last [].ht_)') |
| 425 |
{define(`m4tapl',`ifelse(`$3',,`dimen_/3',`$3')')dnl |
| 426 |
move to (`$2' between M4tap_w and M4tap_e) + vec_(0,sign(m4tapl)*M4tap_xy.y/2) |
| 427 |
ifinstr(m4type,.,`{dot(,lthick)}');dnl |
| 428 |
line ifelse(m4type,.,,m4type,-,,m4type) to rvec_(0,m4tapl) |
| 429 |
m4name`'m4tap_x: Here } |
| 430 |
addtaps(,shift(shift(shift($@))))')') |
| 431 |
|
| 432 |
`tapped(`two-terminal element', . | <- | -> | <-> , |
| 433 |
fractional pos, length, fractional pos, length,...) |
| 434 |
Draw the two-terminal element and taps in a [] block' |
| 435 |
define(`tapped',`[ $1 |
| 436 |
Start: last line.start; End: last line.end; C: last line.c |
| 437 |
addtaps(shift($@)) ]') |
| 438 |
|
| 439 |
`shielded(`two-terminal element',L|U, line attributes ) |
| 440 |
L= shield left half (wrt drawing direction) |
| 441 |
R= shield right half (default both halves)' |
| 442 |
define(`shielded',`[ $1 |
| 443 |
Start: last line.start; End: last line.end; C: last line.c |
| 444 |
W: last line.c - vec_(last [].wid_/2+dimen_/8,0) |
| 445 |
E: last line.c + vec_(last [].wid_/2+dimen_/8,0) |
| 446 |
NW: last [].nw_ + vec_(-dimen_/8,dimen_/8) |
| 447 |
NE: last [].ne_ + vec_(dimen_/8,dimen_/8) |
| 448 |
SE: last [].se_ + vec_(dimen_/8,-dimen_/8) |
| 449 |
SW: last [].sw_ + vec_(-dimen_/8,-dimen_/8) |
| 450 |
ifinstr(`$2',L,`line from W to NW then to NE then to E dashed `$3'', |
| 451 |
`$2',R,`line from W to SW then to SE then to E dashed `$3'', |
| 452 |
`line from W to NW then to NE then to SE then to SW then to W dashed `$3'') |
| 453 |
`$4']') |
| 454 |
|
| 455 |
`b_current( label, above_|below_, O[ut], |
| 456 |
S[tart]|E[nd], frac ) |
| 457 |
Branch current for last-drawn element. The arrowhead |
| 458 |
is drawn frac (default 2/3) of the way between |
| 459 |
the line end and element body.' |
| 460 |
define(`b_current', |
| 461 |
`define(`m4y',`ifelse(`$5',,2/3,`($5)')')dnl |
| 462 |
define(`m4v',`ifinstr(`$4',E, |
| 463 |
`ifinstr(`$3',O,-)',`ifinstr(`$3',O,,-)')arrowht')dnl |
| 464 |
define(`m4h',`(rp_len-last [].wid_)/2') |
| 465 |
{ move to last line.start+vec_(ifinstr(`$4',E,`rp_len-')dnl |
| 466 |
ifinstr(`$3',O,`(m4h-arrowht)*m4y',`(m4h*m4y+arrowht/3)'),0) |
| 467 |
arrow <- m4c_l to rvec_(m4v,0) ifelse(`$1',,, |
| 468 |
`m4lstring(`$1',"sp_`iflatex(`$ `$1'$',`$1')'sp_") \ |
| 469 |
ifelse(`$2',,`above_',`$2')')}') |
| 470 |
|
| 471 |
`larrow( label, <-, separation ) |
| 472 |
Arrow alongside the left of the last-drawn |
| 473 |
element' |
| 474 |
define(`larrow',`define(`m4h',`min(lin_leng(last line),linewid)/2')dnl |
| 475 |
define(`m4v',`ifelse(`$3',,`5pt__',`($3)')')dnl |
| 476 |
{arrow `$2' from last [].n_+vec_(-m4h,m4v) \ |
| 477 |
to last [].n_+vec_(m4h,m4v) \ |
| 478 |
m4lstring(`$1',"sp_`iflatex(`$ `$1'$',` $1')'sp_") above_}') |
| 479 |
|
| 480 |
`rarrow( label, <-, separation ) |
| 481 |
Arrow alongside the right of the last-drawn |
| 482 |
element' |
| 483 |
define(`rarrow',`define(`m4h',`min(lin_leng(last line),linewid)/2')dnl |
| 484 |
define(`m4v',`ifelse(`$3',,`5pt__',`($3)')')dnl |
| 485 |
{arrow `$2' from last [].s_+vec_(-m4h,-m4v) \ |
| 486 |
to last [].s_+vec_(m4h,-m4v) \ |
| 487 |
m4lstring(`$1',"sp_`iflatex(`$ `$1'$',` $1')'sp_") below_}') |
| 488 |
|
| 489 |
`inductor( linespec, W|L, cycles, M|P|K[n], |
| 490 |
loop wid ) |
| 491 |
W=wide arcs (default narrow); L=looped arcs |
| 492 |
arg3= integer (number of loops) |
| 493 |
arg4= M[n]=metal core |
| 494 |
P[n]=(ferrite) powder core (dashed lines) |
| 495 |
K[n]=long-dashed core lines |
| 496 |
n=integer (default 2 lines) |
| 497 |
arg5 loop wid defaults W,L: dimen_/5, |
| 498 |
other: dimen_/8' |
| 499 |
define(`inductor',`eleminit_(`$1') |
| 500 |
define(`m4hlw',`ifelse(`$5',,`dimen_/10',`($5)/2')')dnl half loop wid |
| 501 |
define(`m4n',`ifelse(`$3',,4,`$3')')dnl |
| 502 |
ifelse(`$2',W, `define(`m4wd',((2*m4n-2)*m4c2t+2*m4ct)*m4hlw)', |
| 503 |
`$2',L, `define(`m4wd',(m4n+1)*m4hlw)', |
| 504 |
`define(`m4ht',`ifelse(`$5',,`dimen_/16',(`$5')/2)')dnl half other loop wid |
| 505 |
define(`m4wd',m4n*m4ht*2)')dnl |
| 506 |
{ line to rvec_((rp_len-m4wd)/2,0) |
| 507 |
{M4coil: [ S: Here; |
| 508 |
ifelse(`$2',W,`define(`m4ht',`(1+m4st)*m4hlw')dnl |
| 509 |
define(`m4dp',`(m4s2t-m4st)*m4hlw') round |
| 510 |
arc cw from Here to rvec_(vscal_(m4hlw,m4ct+m4c2t,m4st-m4s2t)) \ |
| 511 |
with .c at rvec_(vscal_(m4hlw,m4ct,m4st)); round |
| 512 |
for m4i=3 to m4n do { arc cw from Here to rvec_(vscal_(m4hlw,2*m4c2t,0)) \ |
| 513 |
with .c at rvec_(vscal_(m4hlw,m4c2t,m4s2t)); round } |
| 514 |
arc cw from Here to rvec_(vscal_(m4hlw,m4ct+m4c2t,m4s2t-m4st)) \ |
| 515 |
with .c at rvec_(vscal_(m4hlw,m4c2t,m4s2t)); round ', |
| 516 |
`$2',L,`define(`m4ht',`m4hlw*10/8')define(`m4dp',`m4hlw/2')dnl |
| 517 |
round; spline ifdpic(0.55) to rvec_(0,m4ht) \ |
| 518 |
for_(1,m4n,1,`\ |
| 519 |
then to rvec_((m4x+0.3)*m4hlw, m4ht) \ |
| 520 |
then to rvec_((m4x+0.3)*m4hlw,-m4dp) \ |
| 521 |
then to rvec_((m4x-0.3)*m4hlw,-m4dp) \ |
| 522 |
then to rvec_((m4x-0.3)*m4hlw, m4ht) \')\ |
| 523 |
then to rvec_(m4wd,m4ht) \ |
| 524 |
then to rvec_(m4wd,0); round ', |
| 525 |
`define(`m4dp',0)dnl |
| 526 |
ifelse(ifpstricks(T)`'ifmpost(T)`'ifpgf(T)`'ifsvg(T),T, |
| 527 |
`define(`m4y')',`undefine(`m4y')')dnl |
| 528 |
ifdef(`m4y',`{line to rvec_(0,-hlth)};') |
| 529 |
for m4i=1 to m4n do { |
| 530 |
arc cw from Here to rvec_(m4ht*2,0) with .c at rvec_(m4ht,0) |
| 531 |
ifdef(`m4y',`{line to rvec_(0,-hlth)}') } ') ] with .S at Here } |
| 532 |
ifelse(ifinstr(`$4',M,T,`$4',P,T,`$4',K,T),T, |
| 533 |
`define(`m4nL',ifelse(len(`$4'),1,2,substr(`$4',1)))dnl |
| 534 |
define(`m4hs',`(dimen_/24+(m4nL-1)*dimen_/16)')dnl |
| 535 |
{ m4m_core(M4coil.S+vec_(m4wd/2,0), m4wd, m4ht+dimen_/24, dimen_/16, |
| 536 |
ifinstr( `$4',P,`dashed m4wd/(2*m4n+1)', |
| 537 |
`$4',K,`dashed m4wd/(2*m4n+1)*3'), m4nL) |
| 538 |
[ box invis wid M4coil.wid ht M4coil.ht at M4coil |
| 539 |
M: move from M4Core`'m4nL.start to M4Core`'m4nL.end ] \ |
| 540 |
with .M.c at M4Core`'m4nL.c }') |
| 541 |
line from rvec_(m4wd,0) to rvec_((rp_len+m4wd)/2,0) } |
| 542 |
line to rvec_(rp_len,0) invis ') |
| 543 |
`m4m_core(bottom center, length, ht offset, |
| 544 |
separation, linetype, nlines) |
| 545 |
nlines=lines for the metal core' |
| 546 |
define(`m4m_core',`for_(1,`$6',1,`{M4Core`'m4x: line \ |
| 547 |
from `$1'+vec_(-(`$2')/2,`$3'+(`$4')*(m4x-1)) \ |
| 548 |
to `$1'+vec_( (`$2')/2,`$3'+(`$4')*(m4x-1)) `$5''})') |
| 549 |
define(`m4ct',`Cos(25)')define(`m4st',`Sin(25)') |
| 550 |
define(`m4c2t',`Cos(50)')define(`m4s2t',`Sin(50)') |
| 551 |
|
| 552 |
`transformer( linespec, L|R, np, |
| 553 |
[A|M[n]|P[n]|K[n]][W|L][D1|D2|D12|D21], ns ) |
| 554 |
2-winding transformer or choke: |
| 555 |
np = number of primary arcs |
| 556 |
ns = number of secondary arcs |
| 557 |
A = air core; |
| 558 |
M[n] = metal core (default); n=number of lines |
| 559 |
P[n] = powder (dashed) core |
| 560 |
K[n] = long dashed core |
| 561 |
W = wide windings; L = looped windings |
| 562 |
D1: phase dots at P1 and S1 ends; D2: dots |
| 563 |
at P2 and S2 ends; D12: dots at P1 and S2 |
| 564 |
ends; D21: dots at P2 and S1 ends' |
| 565 |
define(`transformer', `[ P1: Here define(`m4drt',m4_dir_) |
| 566 |
define(`m4WL',`ifinstr(`$4',W,W,`$4',L,L)')dnl |
| 567 |
define(`m4np',`ifelse(`$3',,4,(`$3'))')dnl |
| 568 |
define(`m4ns',`ifelse(`$5',,4,(`$5'))')dnl |
| 569 |
ifelse(`$1',,`mvw = max(\ |
| 570 |
ifelse(m4WL,W,`dimen_/5*((m4np-1)*m4c2t+m4ct)',`m4np*dimen_/8'),dimen_*2/3) |
| 571 |
move to P1+vec_(mvw,0)', |
| 572 |
move `$1' ) |
| 573 |
P2: Here |
| 574 |
TP: 0.5 between P1 and P2 |
| 575 |
L1: inductor(from ifelse(`$2',R,`P2 to P1',`P1 to P2'),m4WL,`$3') |
| 576 |
define(`m4WP',m4wd)dnl |
| 577 |
define(`m4t',`ifelse(m4WL,W,((2*m4ns-2)*m4c2t+2)*m4hlw,m4WL,L,(m4ns+1)*m4hlw, |
| 578 |
m4ns*m4ht*2)')dnl |
| 579 |
ifinstr(`$4',A, |
| 580 |
`move to last line.c+vec_(0,m4ht*ifelse(m4WL,W,3,m4WL,L,3,4))', |
| 581 |
`define(`m4LL',`regexp(`$4',[MPK]\([0-9][0-9]*\),\1)')dnl |
| 582 |
define(`m4nL',`ifelse(m4LL,,2,m4LL)')dnl |
| 583 |
m4m_core(rvec_(-(rp_len/2),0), max(m4wd,m4t), m4ht+dimen_/12, dimen_/8, |
| 584 |
ifinstr( `$4',P,`dashed m4wd/(2*m4n+1)', |
| 585 |
`$4',K,`dashed m4wd/(2*m4n+1)*3'), m4nL) |
| 586 |
move to last line.c+vec_(0,m4ht+dimen_/12) ') |
| 587 |
TS: Here |
| 588 |
S2: rvec_( ifelse(`$2',R,-)(ifelse(`$5',,rp_len/2,m4t/2)), 0 ) |
| 589 |
S1: 2 between S2 and Here |
| 590 |
L2: inductor(from ifelse(`$2',R,`S1 to S2',`S2 to S1'),m4WL,`$5') |
| 591 |
rpoint_(from P1 to P2) define(`m4WS',m4wd) |
| 592 |
ifinstr(`$4',D1, |
| 593 |
`m4trdot(P1,P2,-,m4WP,ifelse(`$2',R,-),D1:) |
| 594 |
ifinstr(`$4',D12,`m4trdot(S1,S2, ,m4WS,ifelse(`$2',R,,-),D2:)', |
| 595 |
`m4trdot(S1,S2,-,m4WS,ifelse(`$2',R,,-),D2:)')', |
| 596 |
`$4',D2, |
| 597 |
`m4trdot(P1,P2,,m4WP,ifelse(`$2',R,-),D1:) |
| 598 |
ifinstr(`$4',D21,`m4trdot(S1,S2,-,m4WS,ifelse(`$2',R,,-),D2:)', |
| 599 |
`m4trdot(S1,S2, ,m4WS,ifelse(`$2',R,,-),D2:)')') |
| 600 |
m4xpand(m4drt`'_) |
| 601 |
`$6' ]') |
| 602 |
define(`m4trdot',`{`$6'dot(at (0.5 between `$1' and `$2') \ |
| 603 |
+vec_(`$3'((`$4')/2+m4hlw),`$5'dimen_/16), dotrad_/2)}') |
| 604 |
|
| 605 |
`delay( linespec, width, attributes or keys ) |
| 606 |
keys: |
| 607 |
wdth=expr; |
| 608 |
lgth=expr; |
| 609 |
type=A|S; |
| 610 |
body=attributes; e.g. shaded ' |
| 611 |
define(`delay',`eleminit_(`$1') |
| 612 |
pushkeys_(`$3',`wdth:ifelse(`$2',,delay_rad_*2,`$2'); lgth:m4`'wdth*5/6; |
| 613 |
type:A:N; body::N;') dnl |
| 614 |
ifinstr(`$3',=,,`ifelse(m4body,,`poppushdef(`m4body',`$3')')')dnl |
| 615 |
ifelse(m4type,S,`popdef(`m4lgth',`m4wdth')dnl |
| 616 |
pushkeys_(`$3',`lgth:dimen_*6/5; wdth:m4`'lgth/4')')dnl |
| 617 |
{ line to rvec_(rp_len/2-m4lgth/2,0) |
| 618 |
{ifelse(m4type,A,`[ W: Here |
| 619 |
line from rvec_(m4wdth/3,-m4wdth/2) to rvec_(0,-m4wdth/2) \ |
| 620 |
then to rvec_(0,m4wdth/2) then to rvec_(m4wdth/3,m4wdth/2) m4body |
| 621 |
arc cw to rvec_(0,-m4wdth) with .c at rvec_(0,-m4wdth/2) m4body ]', |
| 622 |
m4type,S, |
| 623 |
`rotbox(m4lgth,m4wdth,m4body,r=m4wdth/2, |
| 624 |
{rotbox(m4wdth/4,m4wdth,) with .W at rvec_(-m4lgth+m4wdth/2,0)})')\ |
| 625 |
with .W at Here } |
| 626 |
line from rvec_(m4lgth,0) to rvec_(rp_len/2+m4lgth/2,0) } |
| 627 |
line to rvec_(rp_len,0) invis dnl |
| 628 |
popdef(`m4wd',`m4wdth',`m4type',`m4body') ') |
| 629 |
|
| 630 |
`xtal( linespec, keys ) (2-terminal crystal) |
| 631 |
keys: |
| 632 |
type=N (default) or R (round); |
| 633 |
type N keys: |
| 634 |
lgth=expr; (body length) |
| 635 |
wdth=expr; (body width) |
| 636 |
bxwd=expr; (body inner box width) |
| 637 |
box= box attributes; (shaded ...) |
| 638 |
type R keys: |
| 639 |
outerdiam=expr; |
| 640 |
innerdiam=expr; |
| 641 |
outer= outer circle attributes; (dotted ...) |
| 642 |
inner= inner circle attributes; (shaded ...)' |
| 643 |
define(`xtal',`eleminit_(`$1') pushkey_(`$2',type,N,N) |
| 644 |
ifelse(m4type,R,`pushkeys_(`$2',`outerdia:dimen_/3;innerdia:m4`'outerdia*0.4; |
| 645 |
outer::N; inner::N;') define(`m4wd',m4outerdia) ', |
| 646 |
`pushkeys_(`$2',`wdth:dimen_/4; lgth:m4wdth*2/3; bxwd:m4lgth/2; box::N;')dnl |
| 647 |
define(`m4wd',m4lgth) ') |
| 648 |
{ line to rvec_(rp_len/2-m4wd/2,0) |
| 649 |
{[ Orig: Here; ifelse(m4type,R, |
| 650 |
`{circle diam m4outerdia at rvec_(m4outerdia/2,0) m4outer} |
| 651 |
{circle diam m4innerdia at rvec_(m4outerdia/2,0) m4inner} |
| 652 |
popdef(`m4type',`m4outerdia',`m4innerdia',`m4outer',`m4inner') ', |
| 653 |
`{line from rvec_(0,-m4wdth/3) \ |
| 654 |
to rvec_(0,m4wdth/3)} |
| 655 |
{ move to rvec_(m4lgth/2-m4bxwd/2,0) |
| 656 |
line to rvec_(0,m4wdth/2) \ |
| 657 |
then to rvec_(m4bxwd,m4wdth/2) \ |
| 658 |
then to rvec_(m4bxwd,-m4wdth/2) \ |
| 659 |
then to rvec_(0,-m4wdth/2) \ |
| 660 |
then to Here m4box } |
| 661 |
move to rvec_(m4lgth,0) |
| 662 |
{line from rvec_(0,-m4wdth/3) \ |
| 663 |
to rvec_(0,m4wdth/3)} |
| 664 |
popdef(`m4type',`m4wdth',`m4lgth',`m4bxwd',`m4box')') ] with .Orig at Here} |
| 665 |
line from rvec_(m4wd,0) to rvec_(rp_len/2+m4wd/2,0) } |
| 666 |
line to rvec_(rp_len,0) invis ') |
| 667 |
|
| 668 |
`source( linespec, chars, |
| 669 |
diameter, R, attributes, body name) |
| 670 |
chars: |
| 671 |
AC = AC source; |
| 672 |
B = bulb; |
| 673 |
F = fluorescent; |
| 674 |
G = generator; |
| 675 |
H = step function; |
| 676 |
I = current source; |
| 677 |
i = alternate current source; |
| 678 |
ii = double arrowhead current source; |
| 679 |
ti = truncated-bar current source; |
| 680 |
dci = DC current source; |
| 681 |
L = lamp; |
| 682 |
N = neon; NA = neon 2; NB = neon 3; |
| 683 |
P = pulse; |
| 684 |
Q = charge; |
| 685 |
R = ramp; |
| 686 |
S[C[r]|E[r]] = sinusoid; |
| 687 |
SC = quarter arc; SE = arc; r = right orientation; |
| 688 |
T = triangle; |
| 689 |
U = square-wave; |
| 690 |
V = voltage source; |
| 691 |
v = alternate voltage source; |
| 692 |
tv = truncated bar voltage source; |
| 693 |
dcv = DC voltage source; |
| 694 |
X = interior X; |
| 695 |
other = custom interior label or waveform; |
| 696 |
arg 4: R = reversed polarity; |
| 697 |
arg 5 modifies the circle with e.g., color or fill |
| 698 |
arg 6 names the body [] block' |
| 699 |
define(`source',`ifelse(`$4',R, |
| 700 |
`reversed(`source',`$1',`$2',`$3',,shift(shift(shift(shift($@)))))', |
| 701 |
`eleminit_(`$1') |
| 702 |
define(`m4h',ifelse(`$3',,`sourcerad_',`($3)/2'))dnl |
| 703 |
ifelse( |
| 704 |
`$2',G,`m4_sourceGQ(`$6',$@)', |
| 705 |
`$2',Q,`m4_sourceGQ(`$6',$@)', |
| 706 |
`{ line to rvec_(rp_len/2-m4h,0) |
| 707 |
move to rvec_(m4h,0) |
| 708 |
{ Src_C: circle rad m4h ifelse(`$2',dci,invis) `$5' at Here } |
| 709 |
ifelse(`$2',,, |
| 710 |
`$2',F,`{ line from rvec_(-m4h,0) \ |
| 711 |
to rvec_(-m4h/2,0)} |
| 712 |
{ line from rvec_(-m4h/2,-m4h/2) \ |
| 713 |
to rvec_(-m4h/2,m4h/2)} |
| 714 |
{ line from rvec_(m4h/2,-m4h/2) \ |
| 715 |
to rvec_(m4h/2,m4h/2)} |
| 716 |
{ line from rvec_(m4h,0) \ |
| 717 |
to rvec_(m4h/2,0)}', |
| 718 |
`$2',I,`{arrow from rvec_(-m4h*3/4,0) \ |
| 719 |
to rvec_(m4h*3/4,0)}', |
| 720 |
`$2',dci,`{arrow from rvec_(-m4h*3/4,0) \ |
| 721 |
to rvec_(m4h*3/4,0)} |
| 722 |
ifdef(`dcigapangle_',,`define(`dcigapangle_',20)')dnl |
| 723 |
{arc from Src_C+vec_(Rect_(m4h,270+dcigapangle_/2)) \ |
| 724 |
to Src_C+(Rect_(m4h,90-dcigapangle_/2)) with .c at Src_C} |
| 725 |
{arc from Src_C+vec_(Rect_(m4h,90+dcigapangle_/2)) \ |
| 726 |
to Src_C+(Rect_(m4h,270-dcigapangle_/2)) with .c at Src_C} ', |
| 727 |
`$2',ti,`{line thick 2*linethick from rvec_(0,-m4h) \ |
| 728 |
to rvec_(0,m4h) chop m4h/4}', |
| 729 |
`$2',ii,`{line from rvec_(-m4h,0) \ |
| 730 |
to rvec_(m4h,0)} |
| 731 |
{line thick 1.2*linethick from rvec_(m4h/12,-m4h*0.45) \ |
| 732 |
to rvec_(m4h*5/6,0) \ |
| 733 |
then to rvec_(m4h/12,m4h*0.45)} |
| 734 |
{line thick 1.2*linethick from rvec_(-m4h*3/4,-m4h*0.45) \ |
| 735 |
to Here \ |
| 736 |
then to rvec_(-m4h*3/4,m4h*0.45)}', |
| 737 |
`$2',i,`{line from rvec_(0,-m4h) \ |
| 738 |
to rvec_(0,m4h)}', |
| 739 |
`$2',B,`{line from rvec_(-m4h,0) \ |
| 740 |
to rvec_(-m4h*2/3,0) |
| 741 |
round |
| 742 |
arc ccw to rvec_(m4h*12/12,0) with .c at rvec_(m4h*12/24,0) |
| 743 |
arc ccw to rvec_(-m4h*2/3,0) with .c at rvec_(-m4h*1/3,0) |
| 744 |
arc ccw to rvec_(m4h*12/12,0) with .c at rvec_(m4h*12/24,0) |
| 745 |
round |
| 746 |
line to rvec_(m4h/3,0)}', |
| 747 |
`$2',H,`{ line from Here+(-m4h/2,-m4h/3) \ |
| 748 |
to Here+(0,-m4h/3) \ |
| 749 |
then to Here+(0,m4h/3) \ |
| 750 |
then to Here+(m4h/2,m4h/3) }', |
| 751 |
`$2',L,`{line from rvec_(-m4h,0) \ |
| 752 |
to rvec_(-m4h/4,0) |
| 753 |
round |
| 754 |
spline to rvec_(m4h/12,m4h*2/3) \ |
| 755 |
then to rvec_(m4h*5/12,m4h*2/3) \ |
| 756 |
then to rvec_(m4h/2,0) |
| 757 |
round |
| 758 |
line to rvec_(m4h*3/4,0)}', |
| 759 |
`$2',NA,`{ line from rvec_(-m4h,0) \ |
| 760 |
to rvec_(-m4h/5,0) |
| 761 |
{ line to rvec_(0,m4h) with .c at Here } } |
| 762 |
{ line from rvec_(m4h,0) \ |
| 763 |
to rvec_(m4h/5,0) |
| 764 |
{ line to rvec_(0,m4h) with .c at Here } } |
| 765 |
{ dot(at rvec_(-m4h/2,-m4h/2)) } ', |
| 766 |
`$2',dcv,`{ line to rvec_(0,m4h) with .c at rvec_(-m4h/5,0) } |
| 767 |
{ line to rvec_(0,m4h) with .c at rvec_(m4h/5,0) } ', |
| 768 |
`$2',NB,`{ line from rvec_(-m4h,0) \ |
| 769 |
to rvec_(-m4h/2,0) |
| 770 |
{ line to rvec_(0,m4h) with .c at Here } } |
| 771 |
{ line from rvec_(m4h,0) \ |
| 772 |
to rvec_(m4h/2,0) |
| 773 |
{ dot(,,1) } } |
| 774 |
{ dot(at rvec_(0,-m4h/2)) } ', |
| 775 |
`$2',N,`{ {line from rvec_(-m4h,0) \ |
| 776 |
to rvec_(-m4h/2,0)} |
| 777 |
for_(70,250,180, |
| 778 |
`{ line from rvec_(Rect_(m4h/2,-m4x)) \ |
| 779 |
to rvec_(Rect_(m4h/2,m4x)) |
| 780 |
round } |
| 781 |
{ arc cw from rvec_(Rect_(m4h/2,m4x)) \ |
| 782 |
to rvec_(Rect_(m4h/2,-m4x)) \ |
| 783 |
with .c at Here |
| 784 |
round }') |
| 785 |
{line from rvec_(m4h/2,0) \ |
| 786 |
to rvec_(m4h,0)}}', |
| 787 |
`$2',V,`{"ifsvg(-,`\scriptsize$-$')" at rvec_(-m4h/2,0) ifsvg(+(0,textht/10))} |
| 788 |
{"ifsvg(svg_small(+),`\scriptsize$+$')" \ |
| 789 |
at rvec_( m4h/2,0) ifsvg(+(0,textht/10))}', |
| 790 |
`$2',tv,`{line thick 2*linethick from rvec_(-m4h,0) \ |
| 791 |
to rvec_(m4h,0) chop m4h/4}', |
| 792 |
`$2',v,`{line from rvec_(-m4h,0) \ |
| 793 |
to rvec_(m4h,0)}', |
| 794 |
`$2',AC,`{ACsymbol(,,,AR)}', |
| 795 |
`$2',P,`{ line from Here+(-m4h/2,-m4h/4) \ |
| 796 |
to Here+(-m4h/4,-m4h/4) \ |
| 797 |
then to Here+(-m4h/4,m4h/4) \ |
| 798 |
then to Here+(m4h/4,m4h/4) \ |
| 799 |
then to Here+(m4h/4,-m4h/4) \ |
| 800 |
then to Here+(m4h/2,-m4h/4) }', |
| 801 |
`$2',U,`{ line from Here+(-m4h/2,0) \ |
| 802 |
to Here+(-m4h/2,m4h/3) \ |
| 803 |
then to Here+(0,m4h/3) \ |
| 804 |
then to Here+(0,-m4h/3) \ |
| 805 |
then to Here+(m4h/2,-m4h/3) \ |
| 806 |
then to Here+(m4h/2,0) }', |
| 807 |
`$2',R,`{ line from Here+(-m4h*2/3,-m4h/3) \ |
| 808 |
to Here+(m4h/3,m4h/2) \ |
| 809 |
then to Here+(m4h/3,-m4h/3) }', |
| 810 |
`$2',SCr,`{ arc cw from rvec_(-m4h,0) \ |
| 811 |
to rvec_(0,-m4h) \ |
| 812 |
with .c at rvec_(-m4h,-m4h) }', |
| 813 |
`$2',SC,`{ arc from rvec_(-m4h,0) \ |
| 814 |
to rvec_(0,m4h) \ |
| 815 |
with .c at rvec_(-m4h,m4h) }', |
| 816 |
`$2',SEr,`{ arc cw from Cintersect(Here,m4h,rvec_(0,-2*m4h),1.8*m4h,R) \ |
| 817 |
to Cintersect(Here,m4h,rvec_(0,-2*m4h),1.8*m4h) \ |
| 818 |
with .c at rvec_(0,-2*m4h) }', |
| 819 |
`$2',SE,`{ arc from Cintersect(Here,m4h,rvec_(0,2*m4h),1.8*m4h) \ |
| 820 |
to Cintersect(Here,m4h,rvec_(0,2*m4h),1.8*m4h,R) \ |
| 821 |
with .c at rvec_(0,2*m4h) }', |
| 822 |
`$2',S,`{ACsymbol(,,,R)}', |
| 823 |
`$2',T,`{ line from Here+(-m4h*3/4,-m4h/4) \ |
| 824 |
to Here+(-m4h/4,m4h/4) \ |
| 825 |
then to Here+(m4h/4,-m4h/4) \ |
| 826 |
then to Here+(m4h*3/4,m4h/4) }', |
| 827 |
`$2',X,`define(`m4v',`m4h/sqrt(2)')dnl |
| 828 |
{line from rvec_(-m4v,m4v) \ |
| 829 |
to rvec_(m4v,-m4v)} |
| 830 |
{line from rvec_(-m4v,-m4v) \ |
| 831 |
to rvec_(m4v,m4v)}', |
| 832 |
`{$2}' ) |
| 833 |
line from rvec_(m4h,0) \ |
| 834 |
to rvec_(rp_len/2,0)} |
| 835 |
{ifelse(`$6',,,`$6':)[box invis ht_ m4h*2 wid_ m4h*2] at rvec_(rp_len/2,0)}') |
| 836 |
line to rvec_(rp_len,0) invis ')') |
| 837 |
`Internal to source macro:' |
| 838 |
define(`m4_sourceGQ', |
| 839 |
`m4sh = m4h*3/4 |
| 840 |
m4sv = sqrt((m4h)^2-m4sh^2) |
| 841 |
{ line to rvec_(rp_len/2-(m4h+m4sh),0) |
| 842 |
{ifelse(`$1',,,`$1':)[ Cx: rvec_(m4h,0) |
| 843 |
ifelse(`$6',,, |
| 844 |
`{circle invis rad m4h `$6' with .c at Cx} |
| 845 |
{circle invis rad m4h `$6' with .c at Cx+vec_(m4sh*2,0)}') |
| 846 |
L: Cx+vec_(m4sh, m4sv) |
| 847 |
R: Cx+vec_(m4sh,-m4sv) |
| 848 |
M1: Cx-vec_(m4h/6,0) |
| 849 |
C1: circle rad m4h with .c at Cx `$5' |
| 850 |
C2: ifelse(`$3',G,`circle rad m4h',`arc rad m4h from R to L') \ |
| 851 |
`$5' with .c at C1 +vec_(m4sh*2,0) |
| 852 |
M2: C2+vec_(m4h/6,0) |
| 853 |
] at rvec_(m4h+m4sh,0)} |
| 854 |
line from rvec_((m4h+m4sh)*2,0) \ |
| 855 |
to rvec_(rp_len/2+(m4h+m4sh),0) } ') |
| 856 |
|
| 857 |
`indicator( source arg1-arg6, keys ) |
| 858 |
keys: |
| 859 |
len=expr; |
| 860 |
ray=attributes; ' |
| 861 |
define(`indicator',`source($@) pushdef(`m4s',`last [].wid*5/8') |
| 862 |
pushkeys_(`$7',`len:last [].wid/2; ray::N;')dnl |
| 863 |
for ta=45 to 315 by 90 do {{ line from last []+vec_(Rect_(m4s,ta)) \ |
| 864 |
to last []+vec_(Rect_(m4s+m4len,ta)) m4ray }} |
| 865 |
popdef(`m4len',`m4ray',`m4s') ') |
| 866 |
|
| 867 |
`ttmotor( linespec, string, diameter, brushwid, brushht )' |
| 868 |
define(`ttmotor',`eleminit_(`$1') |
| 869 |
pushdef(`m4r',ifelse(`$3',,`sourcerad_',`($3)/2'))dnl |
| 870 |
pushdef(`m4w',ifelse(`$4',,`sourcerad_/4',`($4)'))dnl |
| 871 |
pushdef(`m4h',ifelse(`$5',,`sourcerad_/2',`($5)'))dnl |
| 872 |
pushdef(`m4cr',`(m4r-sqrt(max(m4r*m4r-m4h*m4h/4,0)))')dnl |
| 873 |
{ line to rvec_(max(rp_len/2-m4r-m4w,0),0) |
| 874 |
{[{ line from rvec_(m4w+m4cr,m4h/2) \ |
| 875 |
to rvec_(0,m4h/2) \ |
| 876 |
then to rvec_(0,-m4h/2) \ |
| 877 |
then to rvec_(m4w+m4cr,-m4h/2) } |
| 878 |
{ TTM_C: circle rad m4r \ |
| 879 |
at rvec_(m4w+m4r,0) ifelse(`$2',,,`m4lstring($2,"$2")') } |
| 880 |
move to rvec_((m4w+m4r)*2,0) |
| 881 |
{ line from rvec_(-m4w-m4cr,m4h/2) \ |
| 882 |
to rvec_(0,m4h/2) \ |
| 883 |
then to rvec_(0,-m4h/2) \ |
| 884 |
then to rvec_(-m4w-m4cr,-m4h/2) }] at rvec_(m4r+m4w,0)} |
| 885 |
line from rvec_((m4w+m4r)*2,0) to rvec_(max(rp_len/2+m4r+m4w,0), 0) } |
| 886 |
line invis to rvec_(rp_len,0) popdef(`m4r',`m4w',`m4h',`m4cr') ') |
| 887 |
|
| 888 |
`consource( linespec ,V|I|tv|v|ti|i|P, R, |
| 889 |
attributes ) |
| 890 |
Controlled source |
| 891 |
Arg3: |
| 892 |
V= voltage |
| 893 |
I= current |
| 894 |
v= voltage type 2 |
| 895 |
tv= voltage type 3 |
| 896 |
i= current type 2 |
| 897 |
ti= current type 3 |
| 898 |
P= proximity sensor |
| 899 |
arg 4 can be used to modify the body with e.g. |
| 900 |
color, fill, or ;internal symbols |
| 901 |
e.g. consource(,,,; "S" at C)' |
| 902 |
define(`consource',`ifelse(`$3',R, |
| 903 |
`reversed(`consource',`$1',`$2',,shift(shift(shift($@))))', |
| 904 |
`eleminit_(`$1') |
| 905 |
{line to rvec_(rp_len/2-csdim_,0) |
| 906 |
{[ N: rvec_(csdim_,csdim_) |
| 907 |
S: rvec_(csdim_,-csdim_) |
| 908 |
E: rvec_(2*csdim_,0) |
| 909 |
W: Here; C: rvec_(csdim_,0) |
| 910 |
{line to N then to E then to S then to W `$4'} |
| 911 |
ifelse(`$2',I, |
| 912 |
`{arrow to E chop csdim_/4}', |
| 913 |
`$2',ti, |
| 914 |
`{line thick 2*linethick from N to S chop csdim_/4}', |
| 915 |
`$2',i, |
| 916 |
`{line from N to S}', |
| 917 |
`$2',V, |
| 918 |
`{"iflatex(`\scriptsize$-$',-)" \ |
| 919 |
at rvec_(csdim_*0.5,0) ifsvg(+(0,textht/10))} |
| 920 |
{"iflatex(`\scriptsize$+$',+)" \ |
| 921 |
at rvec_(csdim_*1.5,0) ifsvg(+(0,textht/10))}', |
| 922 |
`$2',tv, |
| 923 |
`{line thick 2*linethick to E chop csdim_/4} ', |
| 924 |
`$2',v, |
| 925 |
`{line to E} ', |
| 926 |
`$2',P, |
| 927 |
`{ Proxim(2*csdim_) at rvec_(csdim_,0) }') ] with .W at Here} |
| 928 |
line from last [].E to rvec_(rp_len/2+csdim_,0)} |
| 929 |
line to rvec_(rp_len,0) invis ')') |
| 930 |
|
| 931 |
`geiger( linespec, r, diameter, R, attributes, body name) |
| 932 |
Arguments as for source except arg2 r = right orientation ' |
| 933 |
define(`geiger',`pushdef(`m4h',ifelse(`$3',,`sourcerad_',`($3)/2'))dnl |
| 934 |
pushdef(`m4R',`ifelse(`$4',R,+180)')dnl |
| 935 |
source(`$1',F,shift(shift($@))) |
| 936 |
{dot(at rvec_(-rp_len/2,0)+vec_(Rect_(m4h*2/3,ifelse(`$2',r,,-)110 m4R)))} |
| 937 |
{"iflatex($+$,+)" at rvec_(-rp_len/2,0) \ |
| 938 |
+vec_(Rect_(m4h*3/2,ifelse(`$2',r,,-)30 m4R))} |
| 939 |
{em_arrows(ND,rp_ang*rtod_ ifelse(`$2',r,+,-)135 m4R,m4h) with .Head \ |
| 940 |
at rvec_(-rp_len/2,0)+vec_(Rect_(m4h*5/4,ifelse(`$2',r,-)45 m4R))} dnl |
| 941 |
popdef(`m4h',`m4R') ') |
| 942 |
|
| 943 |
`Proxim(size, U|D|L|R|degrees, attributes) |
| 944 |
Proximity symbol |
| 945 |
Arg2 default: current direction' |
| 946 |
define(`Proxim',`[ |
| 947 |
define(`m4prwid',`ifelse(`$1',,(dimen_/2),`($1)')')dnl |
| 948 |
setdir_(ifelse(`$2',,`ifdef(`m4a_',rp_ang*rtod_,0)',`$2')) |
| 949 |
M4PRN: rvec_(0, m4prwid/2) |
| 950 |
M4PRE: rvec_(m4prwid/2,0) |
| 951 |
M4PRS: rvec_(0,-m4prwid/2) |
| 952 |
M4PRW: rvec_(-m4prwid/2,0) |
| 953 |
{ line from 1/2 between M4PRN and M4PRE to M4PRE then to M4PRS \ |
| 954 |
then to M4PRW then to M4PRN then to 1/2 between M4PRN and M4PRE `$3' } |
| 955 |
{ line from 1/4 between M4PRW and M4PRN to 1/4 between M4PRE and M4PRN } |
| 956 |
{ line from 1/4 between M4PRW and M4PRS to 1/4 between M4PRE and M4PRS } |
| 957 |
`$4'; resetdir_ ]') |
| 958 |
|
| 959 |
`Magn(len, ht, U|D|L|R|degrees) |
| 960 |
Magnetic relay action symbol' |
| 961 |
define(`Magn',`[ |
| 962 |
define(`m4mawi2',`ifelse(`$1',,(dimen_/4),`(($1)/2)')')dnl |
| 963 |
define(`m4mah2',`ifelse(`$2',,(dimen_/8),`(($2)/2)')')dnl |
| 964 |
setdir_(ifelse(`$3',,`ifdef(`m4a_',rp_ang*rtod_,0)',`$3')) |
| 965 |
m4fshade(0, line from vec_( 0, m4mah2) \ |
| 966 |
to vec_( m4mawi2, m4mah2) \ |
| 967 |
then to vec_( m4mawi2,-m4mah2) \ |
| 968 |
then to vec_( m4mawi2/2,-m4mah2) \ |
| 969 |
then to vec_( m4mawi2/2,0) \ |
| 970 |
then to vec_(-m4mawi2/2,0) \ |
| 971 |
then to vec_(-m4mawi2/2,-m4mah2) \ |
| 972 |
then to vec_(-m4mawi2,-m4mah2) \ |
| 973 |
then to vec_(-m4mawi2, m4mah2) \ |
| 974 |
then to vec_( 0, m4mah2)) |
| 975 |
`$4'; resetdir_ ]') |
| 976 |
|
| 977 |
`battery( linespec, n, R ) |
| 978 |
Arg 3: reversed polarity' |
| 979 |
define(`battery',`ifelse(`$3',R, |
| 980 |
`reversed(`battery',`$1',`$2',,shift(shift(shift($@))))', |
| 981 |
`eleminit_(`$1') |
| 982 |
define(`m4n',`ifelse(`$2',,1,(`$2'))')define(`m4cs',`dimen_/12')dnl |
| 983 |
define(`m4wd',`m4cs*(m4n*2-1)')define(`m4ht',`dimen_/2')dnl |
| 984 |
{ line to rvec_(rp_len/2-m4wd/2,0) |
| 985 |
for m4i = 0 to 2*(m4n-1) by 2 do { |
| 986 |
{ line from rvec_(m4i*m4cs,m4ht/4) \ |
| 987 |
to rvec_(m4i*m4cs,-m4ht/4) } |
| 988 |
{ line from rvec_((m4i+1)*m4cs,m4ht/2) \ |
| 989 |
to rvec_((m4i+1)*m4cs,-m4ht/2) } } |
| 990 |
line from rvec_(m4wd,0) \ |
| 991 |
to rvec_(rp_len/2+m4wd/2,0) } |
| 992 |
{[box invis ht_ m4ht wid_ m4wd] at rvec_(rp_len/2,0)} |
| 993 |
line to rvec_(rp_len,0) invis ')') |
| 994 |
|
| 995 |
`ebox(linespec, length, ht, greyvalue, |
| 996 |
box attributes) |
| 997 |
Length and ht (of the element) are relative to |
| 998 |
the direction of linespec' |
| 999 |
Alternative: |
| 1000 |
`ebox(linespec, keys) |
| 1001 |
keys: |
| 1002 |
lgth=expr; wdth=expr; |
| 1003 |
text="centered text"; |
| 1004 |
box=box attributes; e.g. shaded "green" |
| 1005 |
body=box attributes; as above' |
| 1006 |
define(`ebox',`eleminit_(`$1') |
| 1007 |
{ifinstr(`$2',=, |
| 1008 |
`pushkeys_(`$2',`lgth:dimen_/2; wdth:dimen_/5; text::N; box::N; body::N') |
| 1009 |
line to rvec_(max(0,rp_len/2-m4lgth/2),0); M4ebC: rvec_(m4lgth/2,0) |
| 1010 |
lbox(m4lgth,m4wdth,m4box m4body) |
| 1011 |
ifelse(m4text,,,`{m4text at M4ebC};')', |
| 1012 |
`pushdef(`m4lgth',`ifelse(`$2',,dimen_/2,`$2')')dnl |
| 1013 |
pushdef(`m4wdth',`ifelse(`$3',,dimen_/5,`$3')')dnl |
| 1014 |
line to rvec_(max(0,rp_len/2-m4lgth/2),0) |
| 1015 |
ifelse(`$4',,`lbox(m4lgth,m4wdth,`$5')', |
| 1016 |
`m4fshade(`$4',lbox(m4lgth,m4wdth,`$5'))')') |
| 1017 |
line to rvec_(max(0,rp_len/2-m4lgth/2),0)} |
| 1018 |
{[ box invis ht_ m4wdth wid_ m4lgth ] at rvec_(rp_len/2,0)} |
| 1019 |
popdef(`m4wdth',`m4lgth')dnl |
| 1020 |
ifinstr(`$2',=,`popdef(`m4text',`m4box',`m4body')')dnl |
| 1021 |
line to rvec_(rp_len,0) invis ') |
| 1022 |
|
| 1023 |
`fuse( linespec, chars, wid, ht, attributes ) |
| 1024 |
chars dA|B|C|D|S|SB|HB|HC or dA (=D)' |
| 1025 |
define(`fuse',`eleminit_(`$1') |
| 1026 |
pushdef(`m4fusetype',`ifelse(`$2',,A,`$2',D,dA,`$2')')dnl |
| 1027 |
pushdef(`m4ht',ifelse(`$4',,`dimen_/5'ifinstr(`$2',H,*5/3),`($4)'))dnl |
| 1028 |
pushdef(`m4d',ifinstr(`$2',H,`m4ht/5',0))dnl |
| 1029 |
pushdef(`m4wd',ifelse(`$3',,`m4ht*2',`($3)'))dnl |
| 1030 |
{line to rvec_(max(0,rp_len/2-m4wd/2),0) |
| 1031 |
sc_draw(`m4fusetype',HB, |
| 1032 |
`{move to rvec_(m4d,0); lbox(m4wd-2*m4d,m4ht-2*m4d)} |
| 1033 |
{lbox(m4wd,m4ht,`$5')} |
| 1034 |
line to rvec_(m4wd+max(0,rp_len/2-m4wd/2),0)') |
| 1035 |
sc_draw(`m4fusetype',HC, |
| 1036 |
`{move to rvec_(m4d,0); {lbox(m4wd-2*m4d,m4ht-2*m4d,`$5')} |
| 1037 |
{line from rvec_((m4wd-2*m4d)/5,m4ht/2-m4d) \ |
| 1038 |
to rvec_((m4wd-2*m4d)/5,-m4ht/2+m4d)} |
| 1039 |
line from rvec_((m4wd-2*m4d)*4/5,m4ht/2-m4d) \ |
| 1040 |
to rvec_((m4wd-2*m4d)*4/5,-m4ht/2+m4d) } |
| 1041 |
{lbox(m4wd,m4ht)} |
| 1042 |
move to rvec_(m4wd,0); line to rvec_(max(0,rp_len/2-m4wd/2),0)') |
| 1043 |
sc_draw(`m4fusetype',A, |
| 1044 |
`arc cw to rvec_(m4ht,0) rad m4ht/2 with .c at rvec_(m4ht/2,0)dnl |
| 1045 |
ifelse(m4a,d,`; {dot(at last arc.start,,1)}') |
| 1046 |
arc ccw to rvec_(m4ht,0) rad m4ht/2 with .c at rvec_(m4ht/2,0) |
| 1047 |
line to rvec_(max(0,rp_len/2-m4wd/2),0)dnl |
| 1048 |
ifelse(m4a,d,`; dot(at last line.start,,1)')') |
| 1049 |
sc_draw(`m4fusetype',SB, |
| 1050 |
`{lbox(m4wd,m4ht,`$5')} |
| 1051 |
{line to rvec_(m4wd+max(0,rp_len/2-m4wd/2),0)} |
| 1052 |
{m4fshade(m4fill,lbox(m4wd/5,m4ht))} |
| 1053 |
move to rvec_(m4wd,0); line to rvec_(max(0,rp_len/2-m4wd/2),0)') |
| 1054 |
sc_draw(`m4fusetype',B, |
| 1055 |
`{lbox(m4wd,m4ht,`$5')} |
| 1056 |
line to rvec_(m4wd+max(0,rp_len/2-m4wd/2),0)') |
| 1057 |
sc_draw(`m4fusetype',C, |
| 1058 |
`{lbox(m4wd,m4ht,`$5')} |
| 1059 |
{line from rvec_(m4wd/5,-m4ht/2) \ |
| 1060 |
to rvec_(m4wd/5,m4ht/2)} |
| 1061 |
{line from rvec_(m4wd*4/5,-m4ht/2) \ |
| 1062 |
to rvec_(m4wd*4/5,m4ht/2)} |
| 1063 |
move to rvec_(m4wd,0); line to rvec_(max(0,rp_len/2-m4wd/2),0)') |
| 1064 |
sc_draw(`m4fusetype',S, |
| 1065 |
`{lbox(m4wd,m4ht,`$5')} |
| 1066 |
{m4fshade(m4fill,lbox(m4wd/5,m4ht))} |
| 1067 |
move to rvec_(m4wd,0); line to rvec_(max(0,rp_len/2-m4wd/2),0)') |
| 1068 |
} |
| 1069 |
{[box invis ht_ m4ht wid_ m4wd] at rvec_(rp_len/2,0)} |
| 1070 |
popdef(`m4wd',`m4d',`m4ht',`m4fusetype')dnl |
| 1071 |
line to rvec_(rp_len,0) invis ') |
| 1072 |
|
| 1073 |
`arrester( linespec, |
| 1074 |
[chars][D[L|R]], |
| 1075 |
body len[:arrowhead ht], |
| 1076 |
body ht[:arrowhead wid], |
| 1077 |
attributes ) |
| 1078 |
arg2 chars: |
| 1079 |
G= spark gap (default) |
| 1080 |
g= general (dots) |
| 1081 |
E= gas discharge |
| 1082 |
S= box enclosure |
| 1083 |
C= carbon block |
| 1084 |
A= electrolytic cell |
| 1085 |
H= horn gap |
| 1086 |
P= protective gap |
| 1087 |
s= sphere gap |
| 1088 |
F= film element |
| 1089 |
M= multigap |
| 1090 |
modifiers: |
| 1091 |
R= right orientation |
| 1092 |
L= left orientation |
| 1093 |
D= 3-terminal element for S, E only with |
| 1094 |
terminals A, B, G' |
| 1095 |
define(`arrester', |
| 1096 |
`define(`m4rdna',`patsubst(`$2',D\|L\|R)')dnl |
| 1097 |
ifelse(m4rdna,,`define(`m4rdna',G)')dnl |
| 1098 |
define(`m4rL',ifinstr(`$2',L,-))dnl |
| 1099 |
define(`m4rR',ifinstr(`$2',R,-))dnl |
| 1100 |
define(`m4aht',`(m4Rightstr(`$3',arrowht*2/3))')dnl |
| 1101 |
define(`m4awd',`(m4Rightstr(`$4', |
| 1102 |
ifelse(m4rdna,g,dotrad_*2,m4rdna,M,dotrad_*2,arrowwid*4/3)))')dnl |
| 1103 |
define(`m4wd',`(ifinstr( dnl body length |
| 1104 |
m4rdna,C,`m4Leftstr(`$3',dimen_/3)', |
| 1105 |
m4rdna,F,`m4Leftstr(`$3',dimen_/3)', |
| 1106 |
m4rdna,s,`m4Leftstr(`$3',dimen_/4)', |
| 1107 |
m4rdna,E,`m4Leftstr(`$3',dimen_*5/8)', |
| 1108 |
`m4Leftstr(`$3',dimen_/2)'))')dnl |
| 1109 |
define(`m4ht',`(ifinstr( dnl body height |
| 1110 |
Loopover_(`Z',`ifinstr(m4rdna,Z,T)',C,A,s),T,`m4Leftstr(`$4',dimen_/4)', |
| 1111 |
m4rdna,F,`m4Leftstr(`$4',dimen_/3)', |
| 1112 |
`m4Leftstr(`$4',dimen_/5)'))')dnl |
| 1113 |
ifinstr(`$2',D, |
| 1114 |
`[ define(`m4LL',m4rL)dnl |
| 1115 |
ifinstr(m4rdna,S, |
| 1116 |
`R: arrester(ifelse(`$1',,`to rvec_(m4wd*2,0)',`$1'),m4rdna, |
| 1117 |
shift(shift($@))) |
| 1118 |
Gb: line from R.c+vec_(0,m4LL m4ht/2) to R.c+vec_(0,m4LL (-m4ht*3/2)) |
| 1119 |
A: R.start; B: R.end; C: R.c; G: Here ', |
| 1120 |
m4rdna,E, |
| 1121 |
`R: arrester(ifelse(`$1',,`to rvec_(m4wd*8/5,0)',`$1'),m4rdna, |
| 1122 |
shift(shift($@))) |
| 1123 |
Gb: line from R.c+vec_(0,m4LL m4wd/8) to R.c+vec_(0,m4LL (-m4wd*3/4)) |
| 1124 |
A: R.start; B: R.end; C: R.c; G: Here ', |
| 1125 |
`M4ErrorMsg(`D argument of Arrester() applies to types S, E only!') ') |
| 1126 |
`$6' ]', |
| 1127 |
`eleminit_(`$1',elen_) dnl 2-terminal elements: |
| 1128 |
{line to rvec_(max(0,rp_len/2-m4wd/2),0) |
| 1129 |
{[ Orig: Here |
| 1130 |
ifinstr(m4rdna,G,` |
| 1131 |
{sarrow(to rvec_(m4aht,0),\ |
| 1132 |
wdth=m4awd;lgth=m4aht;head=shaded "black" `$5';)} |
| 1133 |
move to rvec_(m4wd,0) |
| 1134 |
sarrow(to rvec_(-m4aht,0),\ |
| 1135 |
wdth=m4awd;lgth=m4aht;head=shaded "black" `$5';)', |
| 1136 |
m4rdna,g, |
| 1137 |
`{dot(at rvec_(m4awd/2,0),rad=m4awd/2;circle=fill_(0) `$5')} |
| 1138 |
dot(at rvec_(m4wd-m4awd/2,0),rad=m4awd/2;circle=fill_(0) `$5')', |
| 1139 |
m4rdna,M, |
| 1140 |
`{dot(at rvec_(m4awd/2,0),rad=m4awd/2;circle=fill_(0) `$5')} |
| 1141 |
{dot(at rvec_(m4wd/2,0),rad=m4awd/2;circle=fill_(0) `$5')} |
| 1142 |
dot(at rvec_(m4wd-m4awd/2,0),rad=m4awd/2;circle=fill_(0) `$5')', |
| 1143 |
m4rdna,C, |
| 1144 |
`lbox(m4wd/3,m4ht,`$5'); move to rvec_(m4wd/3,0) |
| 1145 |
lbox(m4wd/3,m4ht,`$5')', |
| 1146 |
m4rdna,A, |
| 1147 |
`{line to rvec_(m4wd/4,0)} |
| 1148 |
for_(1,3,1,`line from rvec_(0,m4ht/2) to rvec_(m4wd/4,0) \ |
| 1149 |
then to rvec_(0,-m4ht/2); move to rvec_(m4wd/4,m4ht/2) |
| 1150 |
ifelse(m4x,3,,move to rvec_(m4wd/8,0))') ', |
| 1151 |
m4rdna,H, |
| 1152 |
`line to rvec_(m4ht,0); round |
| 1153 |
{arc ifelse(m4rR,-,,c)cw from Here to rvec_(-m4ht,m4rR m4ht) \ |
| 1154 |
with .c at rvec_(-m4ht,0)} |
| 1155 |
move to rvec_(m4wd-2*m4ht,0); round |
| 1156 |
{arc ifelse(m4rR,-,c)cw from Here to rvec_(m4ht,m4rR m4ht) \ |
| 1157 |
with .c at rvec_(m4ht,0)} |
| 1158 |
line to rvec_(m4ht,0)', |
| 1159 |
m4rdna,P,` |
| 1160 |
{sarrow(to rvec_(m4aht,0),wdth=m4awd;lgth=m4aht; `$5';)} |
| 1161 |
move to rvec_(m4wd,0) |
| 1162 |
sarrow(to rvec_(-m4aht,0),wdth=m4awd;lgth=m4aht; `$5';)', |
| 1163 |
m4rdna,s, |
| 1164 |
`{line to rvec_(m4ht/2*(sqrt(2)-1),0)} |
| 1165 |
{arc from rvec_(0,-m4ht/2) to rvec_(0,m4ht/2) \ |
| 1166 |
with .c at rvec_(-m4ht/2,0)} |
| 1167 |
move to rvec_(m4wd,0) |
| 1168 |
{arc from rvec_(0,m4ht/2) to rvec_(0,-m4ht/2) \ |
| 1169 |
with .c at rvec_(m4ht/2,0)} |
| 1170 |
{line to rvec_(-m4ht/2*(sqrt(2)-1),0)}', |
| 1171 |
m4rdna,F, |
| 1172 |
`{line from rvec_(0,m4ht/2) to rvec_(0,-m4ht/2)} |
| 1173 |
{line from rvec_(m4wd/2,m4ht/2) to rvec_(m4wd/2,-m4ht/2)} |
| 1174 |
line from rvec_(m4wd,m4ht/2) to rvec_(m4wd,-m4ht/2)', |
| 1175 |
m4rdna,S, |
| 1176 |
`{lbox(m4wd,m4ht,`$5')} |
| 1177 |
sarrow(to rvec_(m4wd/2,0),\ |
| 1178 |
wdth=m4awd;lgth=m4aht;head=shaded "black";) ', |
| 1179 |
m4rdna,E, |
| 1180 |
`{circle diam m4wd at rvec_(m4wd/2,0) `$5'} |
| 1181 |
{sarrow(to rvec_(m4wd*3/8,0),\ |
| 1182 |
wdth=m4awd;lgth=m4aht;head=fill_(0);)} |
| 1183 |
{sarrow(from rvec_(m4wd,0) to rvec_(m4wd*5/8,0),\ |
| 1184 |
wdth=m4awd;lgth=m4aht;head=fill_(0);)} |
| 1185 |
dot(at rvec_(m4wd*6/8,m4wd/4),dotrad_*2/3) ') |
| 1186 |
] with .Orig at Here } |
| 1187 |
line from rvec_(m4wd,0) to rvec_(max(0,rp_len/2+m4wd/2),0) } |
| 1188 |
line invis to rvec_(rp_len,0)') ') |
| 1189 |
|
| 1190 |
`memristor( linespec, wid, ht, attributes )' |
| 1191 |
define(`memristor',`eleminit_(`$1') |
| 1192 |
define(`m4ht',ifelse(`$3',,`dimen_/5',`($3)'))define(`m4htx',`m4ht/4')dnl |
| 1193 |
define(`m4wd',ifelse(`$2',,`dimen_/2',`($2)'))define(`m4wdx',`m4wd*4/25')dnl |
| 1194 |
{ line to rvec_(max(0,rp_len/2-m4wd/2),0) |
| 1195 |
{[lbox(m4wd,m4ht,`$4')] at rvec_(m4wd/2,0)} |
| 1196 |
line to rvec_(m4wdx,0) \ |
| 1197 |
then to rvec_(m4wdx,m4htx) \ |
| 1198 |
then to rvec_(m4wdx*2,m4htx) \ |
| 1199 |
then to rvec_(m4wdx*2,-m4htx) \ |
| 1200 |
then to rvec_(m4wdx*3,-m4htx) \ |
| 1201 |
then to rvec_(m4wdx*3,m4htx) \ |
| 1202 |
then to rvec_(m4wdx*4,m4htx) \ |
| 1203 |
then to rvec_(m4wdx*4,0) \ |
| 1204 |
then to rvec_(m4wdx*5,0) |
| 1205 |
m4fshade(m4fill,lbox(m4wd/4,m4ht)) |
| 1206 |
line to rvec_(max(0,rp_len/2-m4wd/2),0) } |
| 1207 |
line invis to rvec_(rp_len,0)') |
| 1208 |
|
| 1209 |
`pvcell( linespec, wid, ht, attributes )' |
| 1210 |
define(`pvcell',`eleminit_(`$1') |
| 1211 |
define(`m4wd',ifelse(`$2',,`dimen_/2',`($2)'))dnl |
| 1212 |
define(`m4ht',ifelse(`$3',,`dimen_/5',`($3)'))dnl |
| 1213 |
{ line to rvec_(max(0,rp_len/2-m4wd/2),0) |
| 1214 |
{[lbox(m4wd,m4ht,`$4')] at rvec_(m4wd/2,0)} |
| 1215 |
{line from rvec_(0,-m4ht/2) to rvec_(m4wd/3,0) then to rvec_(0,m4ht/2)} |
| 1216 |
move to rvec_(m4wd,0); line to rvec_(max(0,rp_len/2-m4wd/2),0) } |
| 1217 |
line invis to rvec_(rp_len,0)') |
| 1218 |
|
| 1219 |
`heater( linespec, nparts|keys, wid, ht, |
| 1220 |
boxspec|[E[R][T]] ) |
| 1221 |
If arg5 contains E, draws an |
| 1222 |
heatere(linespec,keys,[R][T]) otherwise a |
| 1223 |
heatert(linespec,nparts,wid,ht,boxspec)' |
| 1224 |
define(`heater',`ifinstr(`$5',E, |
| 1225 |
`heatere(`$1',`$2',`$5')', |
| 1226 |
`heatert($@)')') |
| 1227 |
|
| 1228 |
`heatere( linespec, keys, [R|T] ) |
| 1229 |
R: right orientation |
| 1230 |
T: truncates leads to the width of the body |
| 1231 |
keys: (for body) |
| 1232 |
lgth=expr; |
| 1233 |
wdth=expr; (default lgth*2/5) |
| 1234 |
cycles=expr; |
| 1235 |
line=attributes' |
| 1236 |
define(`heatere', |
| 1237 |
`pushkeys_(`$2',`lgth:dimen_/2; wdth:m4`'lgth*2/5; cycles:3; line::N;')dnl |
| 1238 |
ifinstr(`$3',R,`pushdef(`m4ng',-)pushdef(`m4cw')pushdef(`m4ccw',cw)', |
| 1239 |
`pushdef(`m4ng') pushdef(`m4cw',cw)pushdef(`m4ccw')')dnl |
| 1240 |
eleminit_(ifinstr(`$3',T,m4wdth,`$1')) |
| 1241 |
{ line to rvec_(rp_len/2-m4wdth/2,0); round |
| 1242 |
{[S: Here; r = m4lgth/(4*m4cycles+1) |
| 1243 |
arc m4cw m4line to rvec_(r,m4ng`'r) with .c at rvec_(r,0) |
| 1244 |
for i=1 to m4cycles do { arc m4ccw m4line to rvec_(0,m4ng`'2*r) \ |
| 1245 |
with .c at rvec_(0,m4ng`'r) |
| 1246 |
arc m4cw m4line to rvec_(0,m4ng`'2*r) with .c at rvec_(0,m4ng`'r) } |
| 1247 |
line m4line to rvec_(m4wdth-2*r,0) |
| 1248 |
for i=1 to m4cycles do {arc m4cw m4line to rvec_(0,m4ng`'(-2*r)) \ |
| 1249 |
with .c at rvec_(0,m4ng`'(-r)) |
| 1250 |
arc m4ccw m4line to rvec_(0,m4ng`'(-2*r)) with .c at rvec_(0,m4ng`'(-r)) } |
| 1251 |
arc m4cw m4line to rvec_(r,m4ng`'(-r)) with .c at rvec_(0,m4ng`'(-r)); round |
| 1252 |
] with .S at Here } |
| 1253 |
line from rvec_(m4wdth,0) to rvec_(rp_len/2+m4wdth/2,0) } |
| 1254 |
line invis to rvec_(rp_len,0)dnl |
| 1255 |
popdef(`m4lgth',`m4wdth',`m4cycles',`m4line',`m4ng',`m4cw',`m4ccw') ') |
| 1256 |
|
| 1257 |
`heatert(linespec, nparts|keys, wid,ht,boxspec) |
| 1258 |
keys: parts=expr; |
| 1259 |
lgth=expr; |
| 1260 |
wdth=expr; |
| 1261 |
box=attributes; |
| 1262 |
args 3-5 unused if any key is given |
| 1263 |
arg5= body attributes' |
| 1264 |
define(`heatert',`eleminit_(`$1') |
| 1265 |
ifelse(regexp(`$2',`parts=\|lgth=\|wdth=\|box='),-1, dnl not very elegant |
| 1266 |
`pushdef(`m4parts',ifelse(`$2',,4,`$2'))dnl |
| 1267 |
pushdef(`m4lgth',ifelse(`$3',,`dimen_/2',`($3)'))dnl |
| 1268 |
pushdef(`m4wdth',ifelse(`$4',,`dimen_/5',`($4)'))dnl |
| 1269 |
pushdef(`m4box',`$5')', |
| 1270 |
`pushkeys_(`$2',`parts:4; lgth:dimen_/2; wdth:dimen_/5; box::N')')dnl |
| 1271 |
{ line to rvec_(max(0,rp_len/2-m4lgth/2),0) |
| 1272 |
{[lbox(m4lgth,m4wdth,m4box)] at rvec_(m4lgth/2,0)} |
| 1273 |
for m4ix=1 to m4parts-1 do { |
| 1274 |
{line from rvec_(m4ix*m4lgth/(m4parts),m4wdth/2) \ |
| 1275 |
to rvec_(m4ix*m4lgth/(m4parts),-m4wdth/2) m4box}} |
| 1276 |
line from rvec_(m4lgth,0) \ |
| 1277 |
to rvec_(max(0,rp_len/2+m4lgth/2),0) } |
| 1278 |
line invis to rvec_(rp_len,0) popdef(`m4parts',`m4lgth',`m4wdth',`m4box')') |
| 1279 |
|
| 1280 |
`lamp(linespec,[R][T],attributes)' |
| 1281 |
define(`lamp',`pushdef(`m4ng',`ifinstr(`$2',R,-)')pushdef(`m4hw',`dimen_/10')dnl |
| 1282 |
pushdef(`m4dp',(m4ng`'m4hw/2))pushdef(`m4ht',(m4ng`'dimen_/8))dnl |
| 1283 |
eleminit_(ifinstr(`$2',T,m4hw*2,`$1')) |
| 1284 |
{ [ circle rad dimen_/5 `$3' ] at rvec_(rp_len/2,m4ng`'dimen_/3.2) } |
| 1285 |
{ line to rvec_(rp_len/2-m4hw,0) \ |
| 1286 |
then to rvec_(rp_len/2-m4hw,m4ng`'dimen_/3.2) |
| 1287 |
spline ifdpic(ctension_) to rvec_(0,m4ht) \ |
| 1288 |
then to rvec_(1.3*m4hw, m4ht) \ |
| 1289 |
then to rvec_(1.3*m4hw,-m4dp) \ |
| 1290 |
then to rvec_(0.7*m4hw,-m4dp) \ |
| 1291 |
then to rvec_(0.7*m4hw, m4ht) \ |
| 1292 |
then to rvec_(2*m4hw,m4ht) \ |
| 1293 |
then to rvec_(2*m4hw,0) |
| 1294 |
line to rvec_(0,-(m4ng`'dimen_/3.2)) \ |
| 1295 |
then to rvec_(rp_len/2-m4hw,-(m4ng`'dimen_/3.2)) } |
| 1296 |
line invis to rvec_(rp_len,0) popdef(`m4ng',`m4hw',`m4dp',`m4ht') ') |
| 1297 |
|
| 1298 |
`thermocouple(linespec, wid, ht, L|R [T]) |
| 1299 |
T=truncated leads; |
| 1300 |
R=right orientation' |
| 1301 |
define(`thermocouple',`pushdef(`m4wd',ifelse(`$2',,`dimen_/5',`($2)'))dnl |
| 1302 |
eleminit_(ifinstr(`$4',T,m4wd,`$1')) |
| 1303 |
pushdef(`m4ht',ifelse(`$3',,`dimen_/2',`($3)'))dnl |
| 1304 |
pushdef(`m4ths',`ifinstr(`$4',R,-)')dnl |
| 1305 |
{line to rvec_(max(0,rp_len/2-m4wd/2),0) \ |
| 1306 |
then to rvec_(max(0,rp_len/2-m4wd/2),m4ths`'(m4ht-m4wd/2)) \ |
| 1307 |
then to rvec_(rp_len/2,m4ths`'m4ht) \ |
| 1308 |
then to rvec_(max(0,rp_len/2-m4wd/2)+m4wd,m4ths`'(m4ht-m4wd/2)) \ |
| 1309 |
then to rvec_(max(0,rp_len/2-m4wd/2)+m4wd,0) \ |
| 1310 |
then to rvec_(rp_len,0)} |
| 1311 |
{ dot(at rvec_(rp_len/2,m4ths`'m4ht)) } |
| 1312 |
{[box invis ht_ m4ht wid_ m4wd] at rvec_(rp_len/2,m4ths`'m4ht/2)} |
| 1313 |
line to rvec_(rp_len,0) invis popdef(`m4wd',`m4ht',`m4ths')') |
| 1314 |
|
| 1315 |
`cbreaker( linespec, L|R, D|Th|TS, body name ) |
| 1316 |
circuit breaker to left or right of linespec, |
| 1317 |
D=with dots; Th=thermal; TS=squared thermal |
| 1318 |
Default body bounding box name is Br' |
| 1319 |
define(`cbreaker',`ifinstr(`$3',T, |
| 1320 |
`tbreaker($@)', |
| 1321 |
`mbreaker($@)')') |
| 1322 |
|
| 1323 |
define(`tbreaker',`eleminit_(`$1') define(`m4ho',0) |
| 1324 |
{ifinstr(`$3',TS, |
| 1325 |
`define(`m4h',`dimen_/5')define(`m4v',`m4h/2')define(`m4ho',`m4v/2')dnl |
| 1326 |
m4j = max(0,rp_len/2-m4h/2) |
| 1327 |
line to rvec_(m4j,0) \ |
| 1328 |
then to rvec_(m4j,ifelse(`$2',R,-)m4h/2) \ |
| 1329 |
then to rvec_(m4j+m4h,ifelse(`$2',R,-)m4h/2) \ |
| 1330 |
then to rvec_(m4j+m4h,0) \ |
| 1331 |
then to rvec_(m4j*2+m4h,0) ', |
| 1332 |
`define(`m4h',`dimen_*2/5')define(`m4v',`m4h/2')define(`m4ho',0)dnl |
| 1333 |
m4j = max(0,rp_len/2-m4h/2) |
| 1334 |
line to rvec_(m4j,0) |
| 1335 |
{round |
| 1336 |
arc cw to rvec_( m4h/4,0)+vec_(Rect_(m4h/4,-75)) with .c at rvec_( m4h/4,0)} |
| 1337 |
move to rvec_(m4h,0) |
| 1338 |
{round |
| 1339 |
arc cw to rvec_(-m4h/4,0)+vec_(Rect_(m4h/4,105)) with .c at rvec_(-m4h/4,0)} |
| 1340 |
line to rvec_(m4j,0) |
| 1341 |
') } |
| 1342 |
{ifelse(`$4',,Br,`$4'):[box invis ht_ m4v wid_ m4h ] at rvec_(rp_len/2,ifelse(`$2',R,-)m4ho) } |
| 1343 |
line to rvec_(rp_len,0) invis ') |
| 1344 |
|
| 1345 |
define(`mbreaker',`eleminit_(`$1') define(`m4R',`ifelse(`$2',R,-)') |
| 1346 |
define(`m4h',`dimen_/3') define(`m4cr',`((m4h+2*dimen_/32)*5/8)')dnl |
| 1347 |
define(`m4ht',`(m4cr-sqrt(m4cr^2-(m4h/2+dimen_/32)^2)+dimen_/16)')dnl |
| 1348 |
{line to rvec_(max(0,rp_len/2-m4h/2),0) |
| 1349 |
{ifelse(`$3',D,`dot(,,1) |
| 1350 |
move to rvec_(0,m4R`'dotrad_);')dnl |
| 1351 |
arc ifelse(`$2',R,c)cw from rvec_(-dimen_/32,m4R`'dimen_/16) \ |
| 1352 |
to rvec_(m4h+dimen_/32,m4R`'dimen_/16) rad m4cr \ |
| 1353 |
with .c at rvec_(m4h/2,m4R`'(m4ht-m4cr))} |
| 1354 |
{line from rvec_(m4h,0) \ |
| 1355 |
to rvec_(m4h+max(0,rp_len/2-m4h/2),0) |
| 1356 |
ifelse(`$3',D,`dot(at last line.start,,1)') } |
| 1357 |
ifelse(`$4',,Br,`$4'): [box invis ht_ m4ht ifelse(`$3',D,`+2*dotrad_') \ |
| 1358 |
wid_ m4h+dimen_/16] at rvec_(m4h/2,m4R`'(m4ht/2)) } |
| 1359 |
line to rvec_(rp_len,0) invis ') |
| 1360 |
|
| 1361 |
`jumper(linespec,chars|keys) |
| 1362 |
Two-terminal solder jumper with named body parts. |
| 1363 |
chars: character sequence normally beginning |
| 1364 |
with C and ending with D specifying the jumper |
| 1365 |
components and their attribs: C is first, D last, |
| 1366 |
E is empty (blank) gap, J is filled gap, B is |
| 1367 |
box component. |
| 1368 |
The components are named T1, T2, ... |
| 1369 |
e.g. CED is a simple open jumper (default); |
| 1370 |
CJD closed; CEBED three-contact open; |
| 1371 |
CJBED three-contact open and closed. |
| 1372 |
keys: |
| 1373 |
type=chars as above; |
| 1374 |
body=attributes; (e.g. fill_(0.5)) |
| 1375 |
wdth=expr; |
| 1376 |
name=chars; body name' |
| 1377 |
define(`jumper',`eleminit_(`$1') |
| 1378 |
pushkeys_(`$2',`type:m4typ:N; body:fill_(0):N; wdth:dimen_/5; name::N;')dnl |
| 1379 |
ifelse(m4type,m4typ, |
| 1380 |
`poppushdef(`m4type',`ifelse(`$2',,CED,`ifinstr(`$2',=,CED,`$2')')')')dnl |
| 1381 |
pushdef(`m4r',m4wdth/2) pushdef(`m4lgth',`m4r*len(m4type)')dnl |
| 1382 |
{ line to rvec_(rp_len/2-m4lgth/2,0) |
| 1383 |
{ line from rvec_(m4lgth,0) to rvec_(rp_len/2+m4lgth/2,0) } |
| 1384 |
{ifelse(m4name,,,m4name:) [ S: Here |
| 1385 |
for_(1,len(m4type),1,`define(`m4ch',`substr(m4type,decr(m4x),1)')dnl |
| 1386 |
T`'m4x: ifelse(m4ch,C, |
| 1387 |
`[ arc to rvec_(0,-m4wdth) with .c at rvec_(0,-m4r) m4body |
| 1388 |
round(,,m4body); L: line to rvec_(0,m4wdth) m4body; round(,,m4body) |
| 1389 |
] with .L.c at rvec_(m4r,0); move to last [].L.c ', |
| 1390 |
m4ch,J,`rotbox(m4r,m4r,m4body)', |
| 1391 |
m4ch,B,`rotbox(m4r,m4wdth,m4body)', |
| 1392 |
m4ch,E,`move to rvec_(m4r,0)', |
| 1393 |
m4ch,D,`[ arc to rvec_(0,m4wdth) with .c at rvec_(0,m4r) m4body |
| 1394 |
round(,,m4body); L: line to rvec_(0,-m4wdth) m4body; round(,,m4body) |
| 1395 |
] with .L.c at Here; move to T`'m4x.L.c+vec_(m4r,0)')') |
| 1396 |
] with .S at Here } } |
| 1397 |
line invis to rvec_(rp_len,0) undefine(`m4ch') dnl |
| 1398 |
popdef(`m4type',`m4body',`m4wdth',`m4name',`m4r',`m4lgth') ') |
| 1399 |
|
| 1400 |
`gap( linespec,fill,A ) |
| 1401 |
Gap with filled dots e.g. |
| 1402 |
gap(down_ linewid/2,1); rlabel(+,v_1,-) |
| 1403 |
A: chopped arrow between dots' |
| 1404 |
define(`gap',`eleminit_(`$1') |
| 1405 |
dot(,,ifelse(`$2',,0,`$2')); dot(at last line.end,,ifelse(`$2',,0,`$2')) |
| 1406 |
ifelse(`$3',A, |
| 1407 |
`{arrow from last line.start to last line.end chop dotrad_*3}') |
| 1408 |
{[box invis ht_ 0 wid_ min(rp_len,(dimen_*4/9+rp_len)/3)] at last line.c} |
| 1409 |
') |
| 1410 |
|
| 1411 |
`arrowline( linespec ) |
| 1412 |
line with midpoint arrowhead |
| 1413 |
e.g. arrowline(up 1 dotted); llabel(,I_2)' |
| 1414 |
define(`arrowline',`line ifelse(`$1',,`to rvec_(elen_,0)',`$1') |
| 1415 |
{ eleminit_(from last line.start to last line.end) } |
| 1416 |
{ arrow from last line.start to last line.end \ |
| 1417 |
chop lin_leng(last line)/2-arrowht/2 |
| 1418 |
[box invis ht_ arrowwid wid_ arrowht] at last line.c }') |
| 1419 |
|
| 1420 |
`ground( at position, T|stem length, N|F|S|L|P[A]|E, |
| 1421 |
D|U|L|R|degrees) |
| 1422 |
T=truncated stem; N=normal ground, |
| 1423 |
F=frame, S=signal, L=low-noise, P=protective, |
| 1424 |
E=European; PA=protective alternate |
| 1425 |
Down (default), Up, Left, Right, angle (deg)' |
| 1426 |
define(`ground',`box invis ht 0 wid 0 with .c ifelse(`$1',,`at Here',`$1') |
| 1427 |
define(`m4v',`dimen_/6')define(`m4h',`dimen_/16')dnl |
| 1428 |
{setdir_(ifelse(`$4',,-90,`$4')) |
| 1429 |
ifelse(`$2',,`line from last box.c to rvec_(dimen_/4,0)', |
| 1430 |
`$2',T,,`line from last box.c to rvec_(`$2',0)') |
| 1431 |
ifelse(`$3',F, |
| 1432 |
`{line from rvec_(dimen_/8,m4v-dimen_/12) \ |
| 1433 |
to rvec_(0,m4v) \ |
| 1434 |
then to rvec_(0,-m4v) \ |
| 1435 |
then to rvec_(dimen_/8,-m4v-dimen_/12)} |
| 1436 |
line to rvec_(dimen_/8,-dimen_/12)', |
| 1437 |
`$3',S, |
| 1438 |
`{line to rvec_(0,m4v) \ |
| 1439 |
then to rvec_(m4v*1.5,0) \ |
| 1440 |
then to rvec_(0,-m4v) \ |
| 1441 |
then to Here }', |
| 1442 |
`$3',Q, |
| 1443 |
`{shade(0,line to rvec_(0,m4v) \ |
| 1444 |
then to rvec_(m4v*1.5,0) \ |
| 1445 |
then to rvec_(0,-m4v) \ |
| 1446 |
then to Here) }', |
| 1447 |
`$3',L, |
| 1448 |
`{move to rvec_(m4h,0) |
| 1449 |
arc cw rad m4v*3/2 from rvec_(Rect_(m4v*3/2,-60)) \ |
| 1450 |
to rvec_(Rect_(m4v*3/2,60)) with .c at Here} |
| 1451 |
ground(,T,,`$4')', |
| 1452 |
`$3',PA, |
| 1453 |
`{Grnd_T: line to rvec_(0,m4v*1.6) \ |
| 1454 |
then to rvec_(5.5*m4h,0) \ |
| 1455 |
then to rvec_(0,-m4v*1.6) \ |
| 1456 |
then to Here} |
| 1457 |
ground(at rvec_(m4h,0),T,,`$4')', |
| 1458 |
`$3',P, |
| 1459 |
`{Grnd_C: circle rad m4v*3/2 at rvec_(m4h,0)} |
| 1460 |
ground(,T,,`$4')', |
| 1461 |
`$3',E, |
| 1462 |
`{line from rvec_(0,m4v*2/3) \ |
| 1463 |
to rvec_(0,-m4v*2/3) thick linethick*2}', |
| 1464 |
`{line from rvec_(0,m4v) \ |
| 1465 |
to rvec_(0,-m4v)} |
| 1466 |
{line from rvec_(m4h,dimen_/9) \ |
| 1467 |
to rvec_(m4h,-dimen_/9)} |
| 1468 |
line from rvec_(2*m4h,dimen_/14) \ |
| 1469 |
to rvec_(2*m4h,-dimen_/14)') |
| 1470 |
resetdir_} ') |
| 1471 |
|
| 1472 |
`antenna(at, position, T|stem length, A|D|F|L|P|S|T, |
| 1473 |
U|D|L|R|degrees) |
| 1474 |
arg2=T: truncate stem |
| 1475 |
arg3=A aerial, D dipole, F fork, L loop, |
| 1476 |
P phased, S diamond, T triangle |
| 1477 |
arg4=drawing direction ' |
| 1478 |
define(`antenna',`[ T: Here |
| 1479 |
define(`m4v',`dimen_/2')define(`m4h',`dimen_/12')dnl |
| 1480 |
define(`m4atype',ifelse(`$3',,A,`$3'))dnl |
| 1481 |
setdir_(ifelse(`$4',,90,`$4')) |
| 1482 |
ifelse( |
| 1483 |
m4atype,A, |
| 1484 |
`ifelse(`$2',,`move to rvec_(m4h*2,0)', `$2',T,, `move to rvec_(`$2',0)') |
| 1485 |
{ line from rvec_(m4v*3/4, m4v*sqrt(3)/4) to Here \ |
| 1486 |
then to rvec_(m4v*3/4,-m4v*sqrt(3)/4) } |
| 1487 |
line from rvec_(m4v*3/4,0) \ |
| 1488 |
to T', |
| 1489 |
m4atype,D, |
| 1490 |
`T1: rvec_(0,m4h); T2: rvec_(0,-m4h) |
| 1491 |
ifelse(`$2',,`move to rvec_(m4v,0)', `$2',T,, `move to rvec_(`$2',0)') |
| 1492 |
{ line from T1 to rvec_(0,m4h) \ |
| 1493 |
then to rvec_(0,m4h*3) } |
| 1494 |
{ line from T2 to rvec_(0,-m4h) \ |
| 1495 |
then to rvec_(0,-m4h*3) }', |
| 1496 |
m4atype,F, |
| 1497 |
`ifelse(`$2',,`move to rvec_(m4h*2,0)', `$2',T,, `move to rvec_(`$2',0)') |
| 1498 |
{ line from rvec_(m4v*3/4,m4v*sqrt(3)/4) \ |
| 1499 |
to rvec_(0,m4v*sqrt(3)/4) \ |
| 1500 |
then to rvec_(0,-m4v*sqrt(3)/4) \ |
| 1501 |
then to rvec_(m4v*3/4,-m4v*sqrt(3)/4)} |
| 1502 |
line from rvec_(m4v*3/4,0) \ |
| 1503 |
to T', |
| 1504 |
m4atype,L, |
| 1505 |
`T1: rvec_(0,m4h); T2: rvec_(0,-m4h) |
| 1506 |
ifelse(`$2',,`move to rvec_(m4h*2,0)', `$2',T,, `move to rvec_(`$2',0)') |
| 1507 |
line from T1 to rvec_(0,m4h) \ |
| 1508 |
then to rvec_(0,m4v/2) \ |
| 1509 |
then to rvec_(m4v-m4h,m4v/2) \ |
| 1510 |
then to rvec_(m4v-m4h,-m4v/2+m4h) \ |
| 1511 |
then to rvec_(m4h,-m4v/2+m4h) \ |
| 1512 |
then to rvec_(m4h,m4v/2-m4h) \ |
| 1513 |
then to rvec_(m4v,m4v/2-m4h) \ |
| 1514 |
then to rvec_(m4v,-m4v/2) \ |
| 1515 |
then to rvec_(0,-m4v/2) \ |
| 1516 |
then to rvec_(0,-m4h) \ |
| 1517 |
then to T2', |
| 1518 |
m4atype,P, |
| 1519 |
`ifelse(`$2',,`move to rvec_(m4h*2/3,0)', `$2',T,, `move to rvec_(`$2',0)') |
| 1520 |
line from T to Here |
| 1521 |
{ line from rvec_(0,-m4v/3) \ |
| 1522 |
to rvec_(0,m4v/3) } |
| 1523 |
{ line from rvec_(m4h,-m4v*2/3) \ |
| 1524 |
to rvec_(m4h,m4v*2/3) }', |
| 1525 |
m4atype,S, |
| 1526 |
`T1: rvec_(0,m4h); T2: rvec_(0,-m4h) |
| 1527 |
ifelse(`$2',,`move to rvec_(m4h*2,0)', `$2',T,, `move to rvec_(`$2',0)') |
| 1528 |
line from T1 to rvec_(0,m4h) \ |
| 1529 |
then to rvec_(m4v*3/4-m4h,m4v*3/4) \ |
| 1530 |
then to rvec_(2*m4v*3/4-m4h,0) \ |
| 1531 |
then to rvec_(m4v*3/4-m4h,-m4v*3/4) \ |
| 1532 |
then to rvec_(0,-m4h) \ |
| 1533 |
then to T2', |
| 1534 |
m4atype,T, |
| 1535 |
`ifelse(`$2',,`move to rvec_(m4h*2,0)', `$2',T,, `move to rvec_(`$2',0)') |
| 1536 |
line to rvec_(m4v*3/4,m4v*sqrt(3)/4) \ |
| 1537 |
then to rvec_(m4v*3/4,-m4v*sqrt(3)/4) \ |
| 1538 |
then to Here |
| 1539 |
line from rvec_(m4v*3/4,0) \ |
| 1540 |
to T') |
| 1541 |
`$5'; resetdir_ ] with .T ifelse(`$1',,`at Here',`$1') |
| 1542 |
move to last [].T') |
| 1543 |
|
| 1544 |
`r_stub(at position, keys ) # microstrip radial stub |
| 1545 |
keys: |
| 1546 |
dir=U|D|L|R|degrees; (default U) drawing direction |
| 1547 |
irad=expr; inner radius |
| 1548 |
orad=expr; outer radius |
| 1549 |
angle=expr; (degrees) sector angle |
| 1550 |
outline=outline attributes; (but not thickness) |
| 1551 |
fill=internal shade color; |
| 1552 |
stem=T[I]|stem attributes; T means no stem, |
| 1553 |
TI means no stem and no inner arc ' |
| 1554 |
define(`r_stub',`[ C: Here |
| 1555 |
pushkeys_(`$2',`dir:U:N; orad:dimen_*2/3; irad:m4`'orad/4; angle:75; |
| 1556 |
outline::N; fill::N; stem::N;') setdir_(m4dir) |
| 1557 |
Li: vec_(Rect_(m4irad,m4angle/2)); Lo: vec_(Rect_(m4orad,m4angle/2)) |
| 1558 |
Ro: vec_(Rect_(m4orad,-m4angle/2)); Ri: vec_(Rect_(m4irad,-m4angle/2)) |
| 1559 |
ifelse(m4fill,,,`arc from (Ri+Ro)/2 to (Li+Lo)/2 with .c at C \ |
| 1560 |
thick (m4orad-m4irad)/(1bp__) colored m4fill') |
| 1561 |
ifinstr(m4stem,TI,`move to Li', |
| 1562 |
`arc from Ri to Li with .c at C m4outline; round(,last arc.thick,m4outline)') |
| 1563 |
line to Lo m4outline; round(,last line.thick,m4outline) |
| 1564 |
arc cw to Ro with .c at C m4outline; round(,last arc.thick,m4outline) |
| 1565 |
line to Ri m4outline; ifinstr(m4stem,TI,,`round(,last line.thick,m4outline)') |
| 1566 |
ifinstr(m4stem,T,,`line from C to vec_(m4irad,0) patsubst(m4stem,TI+)') |
| 1567 |
`$3' popdef(`m4stem',`m4fill',`m4outline',`m4angle',`m4irad',`m4orad',`m4dir') |
| 1568 |
resetdir_ ] ifelse(`$1',,`with .C at Here',`$1') ') |
| 1569 |
|
| 1570 |
`heatsink(at position, keys, U|D|L|R|degrees) |
| 1571 |
keys: lgth=expr; hght=expr; fin=attributes; |
| 1572 |
base=attributes; fincount=expr; |
| 1573 |
Arg3: drawing direction (default: R)' |
| 1574 |
define(`heatsink',`[ setdir_(`$3',R) |
| 1575 |
pushkeys_(`$2',`lgth:dimen_*3/4; hght:m4`'lgth/3; fin::N; |
| 1576 |
base::N; fincount:6;')dnl |
| 1577 |
SW: (0,0); NW: vec_(0,m4hght); SE: vec_(m4lgth,0); NE: vec_(m4lgth,m4hght) |
| 1578 |
B: line from SW to SE m4base |
| 1579 |
T: line from SE+(NE-SE)/4 to SW+(NW-SW)/4 m4base |
| 1580 |
for i=0 to m4fincount-1 do { |
| 1581 |
move to (0.5+i)/m4fincount between T.end and T.start |
| 1582 |
line to Here+(NW-SW)*3/4 m4base m4fin } |
| 1583 |
`$4'; resetdir_ popdef(`m4lgth',`m4hght',`m4fin',`m4base',`m4fincount') |
| 1584 |
] ifelse(`$1',,`at Here',`$1')') |
| 1585 |
|
| 1586 |
`adjust(at position,keys) |
| 1587 |
Adjustment screw in a [] block |
| 1588 |
keys: |
| 1589 |
size=expr; |
| 1590 |
angle=degrees; slot angle |
| 1591 |
slotwid=expr; slot width |
| 1592 |
circle=attributes; shade, outline etc' |
| 1593 |
define(`adjust',`[ pushkeys_(`$2', |
| 1594 |
`size:dimen_/4; angle:60; circle::N; slotwid:m4`'size/3') |
| 1595 |
C: circle diam m4size at (0,0) m4circle |
| 1596 |
ap = asin(m4slotwid/m4size)*rtod_ |
| 1597 |
line from (Rect_(m4size/2,m4angle-ap)) to (Rect_(m4size/2,m4angle-180+ap)) |
| 1598 |
line from (Rect_(m4size/2,m4angle+180-ap)) to (Rect_(m4size/2,m4angle+ap)) |
| 1599 |
popdef(`m4size',`m4angle',`m4circle',`m4slotwid') |
| 1600 |
] ifelse(`$1',,`at Here',`$1') ') |
| 1601 |
|
| 1602 |
`switch( linespec,L|R,[O|C][D],L|B|D,attribs ) |
| 1603 |
Wrapper for bswitch, lswitch, dswitch |
| 1604 |
R=right orientation (default L=left) |
| 1605 |
if arg4=blank or L: |
| 1606 |
arg3 = [O|C][D][K][A] |
| 1607 |
D = circle at contact and hinge (dD = hinge |
| 1608 |
only, uD = contact only) |
| 1609 |
K=closed switch; |
| 1610 |
A=arrowhead on switch blade; |
| 1611 |
O=opening arrow; C=closing arrow |
| 1612 |
if arg4=B (button switch): arg3 = O|C |
| 1613 |
O=normally open; C=normally closed; |
| 1614 |
if arg4=D: arg3 = same as for dswitch and |
| 1615 |
arg5 is arg4 of dswitch GC or GX' |
| 1616 |
define(`switch',`ifelse( |
| 1617 |
`$4',, `lswitch(`$1',`$2',`$3')', |
| 1618 |
`$4',L,`lswitch(`$1',`$2',`$3')', |
| 1619 |
`$4',B,`bswitch(`$1',`$2',`$3')', |
| 1620 |
`$4',D,`define(`m4qna_',`$3')dnl |
| 1621 |
define(`m4rna_',W`'ifinstr(`$2',C,dBK,B)`'m4qna_)dnl |
| 1622 |
dswitch(`$1',`$2',m4rna_,`$5')')') |
| 1623 |
|
| 1624 |
`bswitch( linespec,L|R,chars ) pushbutton switch |
| 1625 |
R=right orientation (default L=left) |
| 1626 |
chars: O= normally open, C=normally closed' |
| 1627 |
define(`bswitch',`eleminit_(`$1') dnl |
| 1628 |
define(`m4h',`dimen_/3') define(`m4cs',`0.069186*dimen_')dnl (2.5pt) |
| 1629 |
define(`m4v',`ifelse(`$2',R,-m4cs,m4cs)')define(`dna_',`$3') dnl |
| 1630 |
{line to rvec_(rp_len/2-m4h/2,0) chop 0 chop m4cs} |
| 1631 |
{ Bsw_T1: circle rad m4cs at rvec_(rp_len/2-m4h/2,0); move to last circle |
| 1632 |
{ Bsw_T2: circle rad m4cs at rvec_(m4h,0) }; ifelse(`$4',,,`{`$4'}') |
| 1633 |
sc_draw(`dna_',C,dnl |
| 1634 |
`{ line from rvec_(-m4cs,-(m4v)) \ |
| 1635 |
to rvec_(m4h+m4cs,-(m4v)) } |
| 1636 |
{ line from rvec_(m4h/2,-(m4v)) \ |
| 1637 |
to rvec_(m4h/2,m4v*3) } |
| 1638 |
{[box invis ht_ 4*m4cs wid_ m4h+2*m4cs] at rvec_(m4h/2,m4v)}', |
| 1639 |
`{ line from rvec_(-m4cs,m4v*2.5) \ |
| 1640 |
to rvec_(m4h+m4cs,m4v*2.5) } |
| 1641 |
{ line from rvec_(m4h/2,m4v*2.5) \ |
| 1642 |
to rvec_(m4h/2,m4v*4.5) } |
| 1643 |
{[box invis ht_ 5.5*m4cs wid_ m4h+2*m4cs] at rvec_(m4h/2,m4v*1.75)}') |
| 1644 |
line from rvec_(m4h,0) \ |
| 1645 |
to rvec_(m4h/2+rp_len/2,0) chop m4cs chop 0 } |
| 1646 |
line to rvec_(rp_len,0) invis ') |
| 1647 |
|
| 1648 |
`lswitch( linespec,L|R,chars ) knife switch |
| 1649 |
R=right orientation (default L=left) |
| 1650 |
chars=[O|C][[ud]D][K][A] |
| 1651 |
D = circle at contact and hinge (dD = hinge |
| 1652 |
only, uD = contact only) |
| 1653 |
K=closed switch; |
| 1654 |
A=arrowhead on switch blade; |
| 1655 |
O=opening arrow; C=closing arrow' |
| 1656 |
define(`lswitch',`eleminit_(`$1') dnl |
| 1657 |
define(`m4v',`dimen_/4')define(`m4cs',`dimen_/4*Sin(10)')dnl |
| 1658 |
define(`dna_',`$3')define(`m4d',-1)define(`m4k',15)dnl |
| 1659 |
m4t1 = arrowht; m4t2 = arrowwid; |
| 1660 |
arrowht = dimen_/0.75*0.08; arrowwid = dimen_/0.75*0.053 |
| 1661 |
{line to rvec_(rp_len/2-dimen_/6,0) |
| 1662 |
sc_draw(`dna_',K,`define(`m4k',25)dnl |
| 1663 |
{{ifinstr(`$3',A,arrow m4c_l,line) \ |
| 1664 |
to LCtangent(Here,rvec_(dimen_/3,0),dotrad_,`$2') chop 0 chop -dotrad_} |
| 1665 |
line from rvec_(dimen_/3,0) to rvec_(dimen_/3,ifelse(`$2',R,-)dotrad_)}', |
| 1666 |
`{ifinstr(`$3',A,arrow m4c_l,line) \ |
| 1667 |
to rvec_(dimen_/4,ifelse(`$2',R,-)dimen_/4)}') |
| 1668 |
sc_draw(`dna_',C,`{ arc <- m4c_l ifelse(`$2',R,,`c')cw \ |
| 1669 |
from rvec_(Rect_(dimen_/4,ifelse(`$2',R,,-)m4k))\ |
| 1670 |
to rvec_(Rect_(dimen_/4,ifelse(`$2',R,-)60)) \ |
| 1671 |
with .c at rvec_(Rect_(-dimen_/4,ifelse(`$2',R,-)(60-m4k)/2)) }') |
| 1672 |
sc_draw(`dna_',O, `{ arc -> m4c_l ifelse(`$2',R,,`c')cw \ |
| 1673 |
from rvec_(Rect_(dimen_/4,ifelse(`$2',R,,-)10))\ |
| 1674 |
to rvec_(Rect_(dimen_/4,ifelse(`$2',R,-)75)) \ |
| 1675 |
with .c at rvec_(Rect_(-dimen_/4,ifelse(`$2',R,-)(75-10)/2)) }') } |
| 1676 |
{{line from rvec_(rp_len/2+dimen_/6,0) \ |
| 1677 |
to rvec_(rp_len,0) } |
| 1678 |
sc_draw(`dna_',D, |
| 1679 |
`ifelse(m4a,u,,`dot(at rvec_(rp_len/2-dimen_/6,0),,1)') |
| 1680 |
ifelse(m4a,d,,`dot(at last line.start,,1)')') } |
| 1681 |
{ [box invis ht_ dimen_/4+m4cs wid_ dimen_/3] \ |
| 1682 |
with .c at rvec_(rp_len/2,ifelse(`$2',R,-)(m4v-(m4cs))/2)} |
| 1683 |
arrowht = m4t1 ; arrowwid = m4t2; ifelse(`$4',,,`{`$4'}') |
| 1684 |
line to rvec_(rp_len,0) invis ') |
| 1685 |
|
| 1686 |
`dswitch(linespec, R, W[ud]B chars, attributes) |
| 1687 |
Comprehensive IEEE-IEC single-pole switch: |
| 1688 |
arg2=R: orient to the right of drawing dir |
| 1689 |
arg4 is a key-value sequence for the body of |
| 1690 |
GC and GX attributes in arg4: |
| 1691 |
GC keys: diam, circle |
| 1692 |
GX keys: lgth, wdth, box, text |
| 1693 |
arg 3: |
| 1694 |
blank means WB by default |
| 1695 |
B=contact blade open |
| 1696 |
Bc=contact blade closed |
| 1697 |
Bm= mirror blade |
| 1698 |
Bo=contact blade more widely open |
| 1699 |
dB=contact blade to the right of direction |
| 1700 |
C = external operating mechanism |
| 1701 |
Cb = circuit breaker function (IEC S00219) |
| 1702 |
Co = contactor function (IEC S00218) |
| 1703 |
D = circle at contact and hinge (dD = hinge |
| 1704 |
only, uD = contact only) |
| 1705 |
DI = Disconnector; isolator (IEC S00288) |
| 1706 |
E = emergency button |
| 1707 |
EL = early close (or late open) |
| 1708 |
LE = late close (or early open) |
| 1709 |
F = fused |
| 1710 |
GC = disk control mechanism, attribs: |
| 1711 |
diam=expr; circle=circle attribs; |
| 1712 |
GX = box control mechanism, attribs: |
| 1713 |
lgth=expr;wdth=expr;box=box attr; text=char; |
| 1714 |
H = time delay closing |
| 1715 |
uH = time delay opening |
| 1716 |
HH = time delay opening and closing |
| 1717 |
K=vertical closing contact line |
| 1718 |
use WdBK for a normally-closed switch |
| 1719 |
L = limit |
| 1720 |
M = maintained (latched) |
| 1721 |
MM = momentary contact on make |
| 1722 |
MR = momentary contact on release |
| 1723 |
MMR = momentary contact on make and release |
| 1724 |
O = hand operation button |
| 1725 |
P = pushbutton |
| 1726 |
Pr[T|M] = proximity [touch-sensitive or |
| 1727 |
magnetically controlled] |
| 1728 |
R = time-delay operating arm |
| 1729 |
Sd = Switch-disconnector |
| 1730 |
Th = thermal control linkage |
| 1731 |
Tr = tripping |
| 1732 |
W = baseline with gap |
| 1733 |
Y = pull switch |
| 1734 |
Z = turn switch' |
| 1735 |
define(`dswitch',`eleminit_(`$1') |
| 1736 |
define(`dna_',ifelse(`$3',,WB,`$3')`')dnl |
| 1737 |
define(`m4R',`ifelse(`$2',R,-)')define(`m4sc',`dimen_/24')dnl |
| 1738 |
M4CC: last line.c |
| 1739 |
sc_draw(`dna_',W, |
| 1740 |
`{ line from M4CC+vec_( 4*m4sc,0) to last line.end } |
| 1741 |
{ line to M4CC+vec_(-4*m4sc,0) }') |
| 1742 |
{[ tr_xy_init(,m4sc,m4R) |
| 1743 |
T: M4_xyO; B: T |
| 1744 |
sc_draw(`dna_',Bm, |
| 1745 |
`define(`m4c',ifelse(m4a,d,-))dnl |
| 1746 |
B: line from tr_xy(-4,0) \ |
| 1747 |
to tr_xy(5.0,m4c`'4.5) |
| 1748 |
line invis from B.start to B.end chop 0 chop -m4_xyU*5/4 |
| 1749 |
m4fshade(0,circle rad m4_xyU*5/4 at last line .end)') |
| 1750 |
sc_draw(`dna_',Bo, |
| 1751 |
`define(`m4c',ifelse(m4a,d,-))dnl |
| 1752 |
B: line from tr_xy(-4,0) \ |
| 1753 |
to tr_xy(4,m4c`'13/sqrt(3))') |
| 1754 |
sc_draw(`dna_',Bc, |
| 1755 |
`B: line from tr_xy(-4,0) \ |
| 1756 |
to tr_xy( 4,0)') |
| 1757 |
sc_draw(`dna_',B, |
| 1758 |
`define(`m4c',ifelse(m4a,d,-))dnl |
| 1759 |
B: line from tr_xy(-4,0) \ |
| 1760 |
to tr_xy(5.0,m4c`'4.5)') |
| 1761 |
sc_draw(`dna_',Cb, |
| 1762 |
`line from tr_xy(2,-2) to tr_xy(6, 2) |
| 1763 |
line from tr_xy(2, 2) to tr_xy(6,-2)') |
| 1764 |
sc_draw(`dna_',Co,`ifelse(m4R,-, |
| 1765 |
`arc ifelse(m4c,-,,c)cw from tr_xy(4,0) \ |
| 1766 |
to tr_xy(8,0) with .c at tr_xy(6,0)', |
| 1767 |
`arc ifelse(m4c,-,c)cw from tr_xy(4,0) \ |
| 1768 |
to tr_xy(8,0) with .c at tr_xy(6,0)') ') |
| 1769 |
sc_draw(`dna_',GC, |
| 1770 |
`pushkeys_(`$4',`diam:12*m4sc;circle::N;text::N')dnl |
| 1771 |
line from B.c to B.c+ta_xy(0,4) |
| 1772 |
GC: circle diam m4diam m4circle dnl |
| 1773 |
ifelse(m4text,,,`m4lstring(m4text,"m4text")') \ |
| 1774 |
at Here+ta_xy(0,m4diam/2/(m4sc)) popdef(`m4diam',`m4circle',`m4text')') |
| 1775 |
sc_draw(`dna_',GX, |
| 1776 |
`pushkeys_(`$4',`lgth:10*m4sc;wdth:10*m4sc;box::N;text::N')dnl |
| 1777 |
line from B.c to B.c+ta_xy(0,4) |
| 1778 |
GX: rotbox(m4lgth,m4wdth,m4box) at Here+ta_xy(0,m4lgth/2/(m4sc)) |
| 1779 |
ifelse(m4text,,,`m4lstring(m4text,"m4text") at GX.C') dnl |
| 1780 |
popdef(`m4lgth',`m4wdth',`m4box',`m4text')') |
| 1781 |
sc_draw(`dna_',C, |
| 1782 |
`T: B.c+ta_xy(0,ifelse(m4a,d,-)12) |
| 1783 |
C: line dashed from B.c to T ') |
| 1784 |
sc_draw(`dna_',DI, |
| 1785 |
`DI: line from tr_xy(4,2) to tr_xy(4,-2)') |
| 1786 |
sc_draw(`dna_',D, |
| 1787 |
`ifelse(m4a,u,,`dot(at tr_xy(-4,0),,1)') |
| 1788 |
ifelse(m4a,d,,`dot(at tr_xy(4,0),,1)')') |
| 1789 |
sc_draw(`dna_',EL, |
| 1790 |
`EL: line from 0.99 along_(B) to B.end \ |
| 1791 |
then to B.end + ta_xy(vperp(B,m4c`'2.5,R))') |
| 1792 |
sc_draw(`dna_',LE, |
| 1793 |
`LE: line from 0.99 along_(B) \ |
| 1794 |
to B.end \ |
| 1795 |
then to B.end + ta_xy(vperp(B,m4c`'2.5))') |
| 1796 |
sc_draw(`dna_',K, |
| 1797 |
`K: line from tr_xy(4,0) \ |
| 1798 |
to tr_xy(4,m4c`'5)') |
| 1799 |
sc_draw(`dna_',F, |
| 1800 |
`DT: 1/8 along_(B); DQ: 5/8 along_(B) |
| 1801 |
F: line from DT to DT + ta_xy(neg_(m4c)1/2,1) \ |
| 1802 |
then to DQ + ta_xy(neg_(m4c)1/2,1) \ |
| 1803 |
then to DQ + ta_xy(m4c`'1/2,-1) \ |
| 1804 |
then to DT + ta_xy(m4c`'1/2,-1) \ |
| 1805 |
then to DT ') |
| 1806 |
sc_draw(`dna_',L, |
| 1807 |
`DT: 11/16 along_(B) define(`m4e',ifelse(m4a,d,-)) |
| 1808 |
line from 5/16 along_(B) \ |
| 1809 |
to DT + ta_xy(neg_(m4e)1,ifelse(m4c,m4e,,-)2) \ |
| 1810 |
then to DT') |
| 1811 |
sc_draw(`dna_',Sd, |
| 1812 |
`dot(at tr_xy(4,0),m4_xyU*3/2,1) |
| 1813 |
line from tr_xy(4,2)+vec_(m4_xyU*3/2,0) \ |
| 1814 |
to tr_xy(4,-2)+vec_(m4_xyU*3/2,0)') |
| 1815 |
sc_draw(`dna_',Th, |
| 1816 |
`define(`m4t',ifelse(m4a,d,-))dnl |
| 1817 |
T: B.c+ta_xy(0,m4t`'12) |
| 1818 |
line from B.c to B.c+ta_xy(0,m4t`'4.5) \ |
| 1819 |
then to B.c+ta_xy(3,m4t`'4.5) \ |
| 1820 |
then to B.c+ta_xy(3,m4t`'7.5) \ |
| 1821 |
then to B.c+ta_xy(0,m4t`'7.5) \ |
| 1822 |
then to T ') |
| 1823 |
sc_draw(`dna_',Tr, |
| 1824 |
`m4angtmp = rp_ang; point_(lin_ang(B)) |
| 1825 |
DT1: 0.4 along_(B); DT2: 0.65 along_(B) |
| 1826 |
m4dTr = distance(DT1,DT2) |
| 1827 |
move to DT1+vec_(0,m4c`'m4dTr/2) |
| 1828 |
m4fshade(0,lbox(m4dTr,m4dTr)) |
| 1829 |
point_(m4angtmp) ') |
| 1830 |
sc_draw(`dna_',PrM, |
| 1831 |
`T: Proxim(dimen_/3) at B.c+ta_xy(0,ifelse(m4a,d,-)8) |
| 1832 |
line dashed dimen_/16 from B.c to T chop 0 chop dimen_/6 |
| 1833 |
Magn(dimen_/3,dimen_/6) at T+vec_(0,ifelse(m4a,d,-)dimen_/4)') |
| 1834 |
sc_draw(`dna_',MMR, |
| 1835 |
`line from tr_xy(6,1.16) \ |
| 1836 |
to tr_xy(4,0) \ |
| 1837 |
then to tr_xy(6,-1.16)') |
| 1838 |
sc_draw(`dna_',MM, |
| 1839 |
`MM: line from tr_xy(5,0) \ |
| 1840 |
to tr_xy(4,0) \ |
| 1841 |
then to tr_xy(6,1.16)') |
| 1842 |
sc_draw(`dna_',MR, |
| 1843 |
`MR: line from tr_xy(5,0) \ |
| 1844 |
to tr_xy(4,0) \ |
| 1845 |
then to tr_xy(6,-1.16)') |
| 1846 |
sc_draw(`dna_',M, |
| 1847 |
`define(`m4t',ifelse(m4a,d,-))dnl |
| 1848 |
T: B.c+ta_xy(0,m4t`'12) |
| 1849 |
line dashed 1.5*m4sc from B.c to B.c+ta_xy(0,m4t`'4.5) |
| 1850 |
line to B.c+ta_xy(-3,m4t`'6) \ |
| 1851 |
then to B.c+ta_xy(0,m4t`'7.5) |
| 1852 |
line dashed 1.5*m4sc to T ') |
| 1853 |
sc_draw(`dna_',O, |
| 1854 |
`line from T + ta_xy(-2.5,0) \ |
| 1855 |
to T + ta_xy(2.5,0) ') |
| 1856 |
sc_draw(`dna_',PrT, |
| 1857 |
`T: Proxim(dimen_/3) at B.c+ta_xy(0,ifelse(m4a,d,-)8) |
| 1858 |
line dashed dimen_/16 from B.c to T chop 0 chop dimen_/6 |
| 1859 |
line to rvec_(dimen_/4,0) with .c at T+vec_(0,ifelse(m4a,d,-)dimen_/6)') |
| 1860 |
sc_draw(`dna_',Pr, |
| 1861 |
`T: Proxim(dimen_/3) at B.c+ta_xy(0,ifelse(m4a,d,-)8) |
| 1862 |
line dashed dimen_/16 from B.c to T chop 0 chop dimen_/6 ') |
| 1863 |
sc_draw(`dna_',P, |
| 1864 |
`line from T + ta_xy(-2.5,-2.5) \ |
| 1865 |
to T + ta_xy(-2.5,0) \ |
| 1866 |
then to T + ta_xy(2.5,0) \ |
| 1867 |
then to T + ta_xy(2.5,-2.5) ') |
| 1868 |
sc_draw(`dna_',Y, |
| 1869 |
`line from T + ta_xy(-2.5,2.5) \ |
| 1870 |
to T + ta_xy(-2.5,0) \ |
| 1871 |
then to T + ta_xy(2.5,0) \ |
| 1872 |
then to T + ta_xy(2.5,2.5) ') |
| 1873 |
sc_draw(`dna_',Z, |
| 1874 |
`line from T + ta_xy(-2.5,-2.5) \ |
| 1875 |
to T + ta_xy(-2.5,0) \ |
| 1876 |
then to T + ta_xy(2.5,0) \ |
| 1877 |
then to T + ta_xy(2.5,2.5) ') |
| 1878 |
sc_draw(`dna_',R, |
| 1879 |
`define(`m4t',ifelse(m4a,d,-))dnl |
| 1880 |
DT: 5/12 along_(B); DQ: 7/12 along_(B) |
| 1881 |
line from DT to DT + ta_xy(0,m4t`'12) |
| 1882 |
line from DQ to DQ + ta_xy(0,m4t`'(neg_(m4c)sqrt(3)/2+12)) |
| 1883 |
T: 1/2 between Here and 2nd last line.end ') |
| 1884 |
sc_draw(`dna_',HH, |
| 1885 |
`arc ifelse(m4R,-,c)cw \ |
| 1886 |
from T+ta_xy(3,3/2) \ |
| 1887 |
to T+ta_xy(-3,3/2) with .c at T+ta_xy(0,4.0) |
| 1888 |
arc ifelse(m4R,,c)cw \ |
| 1889 |
from T+ta_xy(3,-3/2) \ |
| 1890 |
to T+ta_xy(-3,-3/2) \ |
| 1891 |
with .c at T+ta_xy(0,-4.0) ') |
| 1892 |
sc_draw(`dna_',H, |
| 1893 |
`define(`m4t',ifelse(m4a,d,-))dnl |
| 1894 |
arc ifelse(m4t,m4R,,c)cw \ |
| 1895 |
from T+ta_xy(3,m4t`'3/2) \ |
| 1896 |
to T+ta_xy(-3,m4t`'3/2) \ |
| 1897 |
with .c at T + ta_xy(0,m4t`'4.0) ') |
| 1898 |
sc_draw(`dna_',E, |
| 1899 |
`line from T + ta_xy(-2.5,0) \ |
| 1900 |
to T + ta_xy(2.5,0) |
| 1901 |
arc ifelse(m4R,-,,c)cw to last line.start with .c at T + ta_xy(0,-1.5) ') |
| 1902 |
] with .M4_xyO at M4CC } |
| 1903 |
line to rvec_(rp_len,0) invis ') |
| 1904 |
|
| 1905 |
`amp( linespec,size, attributes ) |
| 1906 |
Amplifier' |
| 1907 |
define(`amp',`eleminit_(`$1') define(`m4wd',`ifelse(`$2',,`dimen_',`($2)')')dnl |
| 1908 |
{line to rvec_(max(0,rp_len/2-m4wd/2),0) |
| 1909 |
{[ End: vec_(m4wd,0); line from End \ |
| 1910 |
to vec_(0,m4wd/2) \ |
| 1911 |
then to vec_(0,-m4wd/2) \ |
| 1912 |
then to End `$3'] with .End at rvec_(m4wd,0) } |
| 1913 |
line from rvec_(m4wd,0) to rvec_(max(m4wd,rp_len/2+m4wd/2),0) } |
| 1914 |
line to rvec_(max(rp_len,m4wd),0) invis ') |
| 1915 |
|
| 1916 |
`integrator( linespec,size,attributes )' |
| 1917 |
define(`integrator',`eleminit_(`$1') |
| 1918 |
define(`m4wd',`ifelse(`$2',,`dimen_',`($2)')')dnl |
| 1919 |
{[ In: Here |
| 1920 |
{line from rvec_(m4wd/4,m4wd/2) \ |
| 1921 |
to rvec_(0,m4wd/2) \ |
| 1922 |
then to rvec_(0,-m4wd/2) \ |
| 1923 |
then to rvec_(m4wd/4,-m4wd/2) `$3' } |
| 1924 |
line from rvec_(m4wd*5/4,0) \ |
| 1925 |
to rvec_(m4wd/4,m4wd/2) \ |
| 1926 |
then to rvec_(m4wd/4,-m4wd/2) \ |
| 1927 |
then to rvec_(m4wd*5/4,0) `$3' ; Out: Here ] with .In at Here} |
| 1928 |
{line from rvec_(m4wd*5/4,0) to rvec_(max(rp_len,m4wd*5/4),0) } |
| 1929 |
line to rvec_(max(rp_len,m4wd*5/4),0) invis ') |
| 1930 |
|
| 1931 |
`opamp(linespec, |
| 1932 |
- label, + label, size|keys, chars) |
| 1933 |
keys= lgth=expr; |
| 1934 |
wdth=expr; |
| 1935 |
body=attributes; |
| 1936 |
drawn as a []: |
| 1937 |
defined positions: |
| 1938 |
W, N, E, S, Out, E1, E2, In1, In2 |
| 1939 |
size: expr (default lgth equals wdth) |
| 1940 |
chars: |
| 1941 |
P: power connections V1,V2 |
| 1942 |
R: labels at In1,In2 swapped |
| 1943 |
T: truncated point ' |
| 1944 |
define(`opamp', |
| 1945 |
`[ pushdef(`m4dlgth',`ifinstr(`$4',=,dimen_,ifelse(`$4',,dimen_,`($4)'))')dnl |
| 1946 |
pushkeys_(`$4',`body::N; lgth:m4dlgth; wdth:m4`'lgth;')dnl |
| 1947 |
pushdef(`dna_',`$5')dnl |
| 1948 |
ifelse(`$1',,`lgt=elen_',`eleminit_(`$1'); lgt=max(rp_len,m4lgth)') |
| 1949 |
W: Here |
| 1950 |
N: vec_(0,m4wdth/2) |
| 1951 |
S: vec_(0,-m4wdth/2) |
| 1952 |
E: vec_(m4lgth,0) |
| 1953 |
C: vec_(m4lgth/2,0) |
| 1954 |
{ sc_draw(`dna_',T, |
| 1955 |
`line to N then to 0.75 between N and E \ |
| 1956 |
then to 0.75 between S and E then to S then to W m4body |
| 1957 |
line from 0.75 between W and E to E', |
| 1958 |
`line to N then to E then to S then to W m4body; move to E') |
| 1959 |
if lgt > m4lgth then { line to rvec_(lgt-m4lgth,0) } |
| 1960 |
Out: Here } |
| 1961 |
NE: vec_(m4lgth/2,m4wdth/4); E1: NE |
| 1962 |
SE: vec_(m4lgth/2,-m4wdth/4); E2: SE |
| 1963 |
In1: vec_(0,m4wdth/4) |
| 1964 |
In2: vec_(0,-m4wdth/4) |
| 1965 |
{ move to In`'ifinstr(dna_,R,2,1) |
| 1966 |
ifelse(`$2',,"iflatex(`{\scriptsize$-$}',-)" \ |
| 1967 |
at rvec_(4pt__,0) ifsvg(+(0,textht/10)),m4lstring(`$2',"`$2'"))} |
| 1968 |
{ move to In`'ifinstr(dna_,R,1,2) |
| 1969 |
ifelse(`$3',,"iflatex(`{\scriptsize$+$}',+)" \ |
| 1970 |
at rvec_(4pt__,0) ifsvg(+(0,textht/10)),m4lstring(`$3',"`$3'"))} |
| 1971 |
sc_draw(`dna_',P, |
| 1972 |
`{line from E1 to (vec_(m4lgth/2,m4wdth/4+m4wdth/8)); V1: Here} |
| 1973 |
{line from E2 to (vec_(m4lgth/2,-(m4wdth/4+m4wdth/8))); V2: Here}') |
| 1974 |
`$6' popdef(`m4dlgth',`dna_',`m4lgth',`m4wdth',`m4body')] ') |
| 1975 |
|
| 1976 |
`dac(width,height,nIn,nN,nOut,nS)' |
| 1977 |
define(`dac',`[ |
| 1978 |
define(`dac_ht',`ifelse(`$2',,(dimen_),`$2')')dnl |
| 1979 |
define(`dac_wd',`ifelse(`$1',,(dimen_+dac_ht/2),`$1')')dnl |
| 1980 |
In: Here |
| 1981 |
C: rvec_((dac_wd-dac_ht/2)/2,0) |
| 1982 |
NE: rvec_(dac_wd-dac_ht/2, dac_ht/2) |
| 1983 |
Out:rvec_(dac_wd,0) |
| 1984 |
SE: rvec_(dac_wd-dac_ht/2,-dac_ht/2) |
| 1985 |
NW: rvec_(0,dac_ht/2) |
| 1986 |
SW: rvec_(0,-dac_ht/2) |
| 1987 |
define(`m4dn',ifelse(`$3',,1,`eval($3)'))dnl |
| 1988 |
for_(1,m4dn,1,`In`'m4x: NW-vec_(0,dac_ht*(2*m4x-1)/(2*m4dn))')dnl |
| 1989 |
define(`m4dn',ifelse(`$4',,1,`eval($4)'))dnl |
| 1990 |
for_(1,m4dn,1,`N`'m4x: NW+vec_((dac_wd-dac_ht/2)*m4x/(m4dn+1),0)')dnl |
| 1991 |
define(`m4dn',ifelse(`$5',,1,`eval($5)'))dnl |
| 1992 |
for_(1,m4dn,1,`r = eval(2*m4x-1)/eval(m4dn*2) |
| 1993 |
Out`'m4x: Out-vec_(ifelse(eval((2*m4x-1)<m4dn),1,,-)dac_ht*(0.5-r), |
| 1994 |
dac_ht*(0.5-r))')dnl |
| 1995 |
define(`m4dn',ifelse(`$6',,1,`eval($6)'))dnl |
| 1996 |
for_(1,m4dn,1,`S`'m4x: SW+vec_((dac_wd-dac_ht/2)*m4x/(m4dn+1),0)')dnl |
| 1997 |
line to NW then to NE then to Out then to SE then to SW then to Here |
| 1998 |
`$7']') |
| 1999 |
|
| 2000 |
`adc(width,height,nIn,nN,nOut,nS)' |
| 2001 |
define(`adc',`[ |
| 2002 |
define(`adc_ht',`ifelse(`$2',,(dimen_),`$2')')dnl |
| 2003 |
define(`adc_wd',`ifelse(`$1',,(dimen_+adc_ht/2),`$1')')dnl |
| 2004 |
In: Here |
| 2005 |
C: rvec_(adc_ht/4+adc_wd/2,0) |
| 2006 |
NE: rvec_(adc_wd, adc_ht/2) |
| 2007 |
Out:rvec_(adc_wd,0) |
| 2008 |
SE: rvec_(adc_wd,-adc_ht/2) |
| 2009 |
NW: rvec_(adc_ht/2, adc_ht/2) |
| 2010 |
SW: rvec_(adc_ht/2,-adc_ht/2) |
| 2011 |
define(`m4dn',ifelse(`$3',,1,`eval($3)'))dnl |
| 2012 |
for_(1,m4dn,1,`r = eval(2*m4x-1)/eval(m4dn*2) |
| 2013 |
In`'m4x: In+vec_(ifelse(eval((2*m4x-1)<m4dn),1,,-)adc_ht*(0.5-r), |
| 2014 |
adc_ht*(0.5-r))')dnl |
| 2015 |
define(`m4dn',ifelse(`$4',,1,`eval($4)'))dnl |
| 2016 |
for_(1,m4dn,1,`N`'m4x: NW+vec_((adc_wd-adc_ht/2)*m4x/(m4dn+1),0)')dnl |
| 2017 |
define(`m4dn',ifelse(`$5',,1,`eval($5)'))dnl |
| 2018 |
for_(1,m4dn,1,`Out`'m4x: NE-vec_(0,adc_ht*(2*m4x-1)/(2*m4dn))')dnl |
| 2019 |
define(`m4dn',ifelse(`$6',,1,`eval($6)'))dnl |
| 2020 |
for_(1,m4dn,1,`S`'m4x: SW+vec_((adc_wd-adc_ht/2)*m4x/(m4dn+1),0)')dnl |
| 2021 |
line from Out to SE then to SW then to In then to NW then to NE then to Out |
| 2022 |
`$7']') |
| 2023 |
|
| 2024 |
`diode(linespec, |
| 2025 |
B|b|CR|D|F|G|L|LE[R]|P[R]|S|Sh|SI|T|U|V|v|w|Z|z| |
| 2026 |
chars,[R][E]) |
| 2027 |
Adding K to arg2 draws open arrowheads |
| 2028 |
Adding M draws a mid-arrowhead crossbar |
| 2029 |
Arg 3: R=reversed polarity, E=enclosure' |
| 2030 |
define(`diode', |
| 2031 |
`ifinstr(`$3',R, |
| 2032 |
`reversed(`diode',`$1',`$2',patsubst(`$3',R),shift(shift(shift($@))))', |
| 2033 |
`pushdef(`dma_',`$2')dnl |
| 2034 |
pushdef(`m4ahd',ifinstr(dma_,K,,f))dnl |
| 2035 |
ifinstr(dma_,M,`poppushdef(`m4ahd',m4ahd`'M)')dnl |
| 2036 |
poppushdef(`dma_',patsubst(dma_,`K\|M'))dnl |
| 2037 |
ifinstr(dma_,SI,`poppushdef(`dma_',`patsubst($2,SI)')dnl |
| 2038 |
sidac(`$1',ifelse(dma_`$3',,,env=dma_`$3'))', |
| 2039 |
`pushdef(`m4cts',`ifelse( |
| 2040 |
dma_,,LACR, |
| 2041 |
dma_,B,uLAZQuR, |
| 2042 |
dma_,b,uLAzoQuR, |
| 2043 |
dma_,CR,LACRrb, |
| 2044 |
dma_,D,LuAHdQR, |
| 2045 |
dma_,F,LFR, |
| 2046 |
dma_,G,uLAQuR, |
| 2047 |
dma_,LER,LdEACR, |
| 2048 |
dma_,LE,LuEACR, |
| 2049 |
dma_,L,LAcCR, |
| 2050 |
dma_,P,LuPACR, |
| 2051 |
dma_,PR,LdPACR, |
| 2052 |
dma_,Sh,LFcCR, |
| 2053 |
dma_,S,LASR, |
| 2054 |
dma_,T,LATR, |
| 2055 |
dma_,U,LA`'ifinstr(`$3',R,d,u)`'CR, |
| 2056 |
dma_,V,LACXdR, |
| 2057 |
dma_,v,LACvdR, |
| 2058 |
dma_,w,LAdvXdR, |
| 2059 |
dma_,Z,LAZR, |
| 2060 |
dma_,z,LAzR, |
| 2061 |
dma_)') |
| 2062 |
ifelse(dma_,Sh,`poppushdef(`m4ahd')', |
| 2063 |
dma_,L, `poppushdef(`m4ahd',xtract(m4ahd,M))') |
| 2064 |
eleminit_(`$1') |
| 2065 |
m4gen_d(m4cts,m4ahd) |
| 2066 |
ifinstr(`$3',E,`pushdef(`m4dh',`dimen_*0.7')pushdef(`m4dv',`m4dh')dnl |
| 2067 |
{ Diode_Env: circle diam m4dh at rvec_(rp_len/2,0) }') |
| 2068 |
pushdef(`m4dm', |
| 2069 |
`ifelse(dma_,S,`m4dv/4', |
| 2070 |
dma_,Z,`(m4dv/4-lthick/2)', |
| 2071 |
dma_,z,`(m4dv/4-lthick/2)', |
| 2072 |
dma_,v,`m4dv/4', |
| 2073 |
dma_,w,`m4dv/4', |
| 2074 |
0)')dnl |
| 2075 |
{ [ box invis ht_ m4dv+lthick*sqrt(3) wid_ m4dh+lthick + m4dm |
| 2076 |
] at rvec_(rp_len/2+m4dm/2,0) } |
| 2077 |
line invis to rvec_(rp_len,0) |
| 2078 |
ifinstr(`$3',E,`popdef(`m4dh',`m4dv')')popdef(`m4cts')')dnl |
| 2079 |
popdef(`dma_',`m4ahd')')') |
| 2080 |
|
| 2081 |
`m4gen_d(chars,[f][R][M][E]): |
| 2082 |
*This is an internal macro, subject to change* |
| 2083 |
*General: [u|d] for shift, R for orientation* |
| 2084 |
[u|d]A[c] arrowhead shifted up, down, or 0 |
| 2085 |
[u|d]F[c] arrowhead open-sided (Shockley) |
| 2086 |
[u|d]B bar (gate) at arrowhead centre |
| 2087 |
[u|d]BB long bar (gate) at arrowhead centre |
| 2088 |
[u|d]C vertical bar at right of arrowhead |
| 2089 |
u: with limiter bar on left; d on right |
| 2090 |
[u|d]D vertical bar at right of arrowhead |
| 2091 |
with bar at [top|bottom] |
| 2092 |
[u|d]E em_arrows out |
| 2093 |
[u|d]F half arrowhead shifted |
| 2094 |
G gate for scr(,B), label G |
| 2095 |
rb current regulator bars |
| 2096 |
H double-length vertical bars |
| 2097 |
[u]I bar for IGCT |
| 2098 |
[u]L left stem, uL = shortened |
| 2099 |
M mid-arrow crossbar |
| 2100 |
[d]N thyristor gate at anode, label Ga |
| 2101 |
d adds bar |
| 2102 |
[u|d]P em_arrows |
| 2103 |
[u|d]Q[c] shifted left arrowhead [centerline] |
| 2104 |
[u]R right stem, uR = shortened |
| 2105 |
S S-shape vertical bar |
| 2106 |
T T-diode vertical bar |
| 2107 |
W Thyristor gate from cathode, label G |
| 2108 |
X varicap diode-capacitor |
| 2109 |
[u|d]v varicap diode-capacitor curved plate |
| 2110 |
Y bilateral core |
| 2111 |
Z zener bar |
| 2112 |
z zener bar angled |
| 2113 |
zo zener bar outlined |
| 2114 |
arg 2: f= fill the arrowhead |
| 2115 |
M=arrowhead crossbar |
| 2116 |
R=right orientation |
| 2117 |
E=envelope flag ' |
| 2118 |
define(`m4gen_d',`{dnl |
| 2119 |
define(`m4dv',`dimen_/6')define(`m4dh',sqrt(3)*m4dv/2)dnl |
| 2120 |
define(`ddna_',`ifelse(`$1',,`LACR',`$1')')dnl |
| 2121 |
define(`ddf_',`ifelse(`$1',,f,`$2')')dnl |
| 2122 |
define(`m4tR',`ifinstr(`$2',R,(-1),1)')dnl |
| 2123 |
define(`m4dy',`lthick*(sqrt(3)-1)/2')dnl |
| 2124 |
M4_s: last line.start; M4_e: last line.end |
| 2125 |
sc_draw(`ddna_',L,dnl left stem, uL = shortened |
| 2126 |
`line from M4_s to 0.5 between M4_s and M4_e \ |
| 2127 |
chop 0 chop m4dh`'ifelse(m4a,,/2)') |
| 2128 |
dnl Elements drawn from left of body |
| 2129 |
sc_draw(`ddna_',E,dnl EM radiation arrows pointing out |
| 2130 |
`ifelse(m4a,d, |
| 2131 |
`{em_arrows(,rp_ang*rtod_-135) with .Tail at rvec_(-m4dh*0.3,-m4dv*0.8)}', |
| 2132 |
`{em_arrows(,rp_ang*rtod_+135) with .Tail at rvec_(-m4dh*0.3,m4dv*0.8)}')') |
| 2133 |
sc_draw(`ddna_',P,dnl EM radiation arrows |
| 2134 |
`ifelse(m4a,d, |
| 2135 |
`{em_arrows(,rp_ang*rtod_+45) with .Head at rvec_(-m4dh*0.3,-m4dv*0.8)}', |
| 2136 |
`{em_arrows(,rp_ang*rtod_-45) with .Head at rvec_(-m4dh*0.3, m4dv*0.8)}')') |
| 2137 |
sc_draw(`ddna_',G,dnl SCR gate |
| 2138 |
`{Gm: line to ifinstr(`$2',E,2,3/2) between Here and \ |
| 2139 |
rvec_(m4dh,ifelse(m4a,d,-)m4dv/2) ifinstr(`$2',E,`then to \ |
| 2140 |
rvec_(m4dh*2,ifelse(m4a,d,-)sqrt((4*dimen_/10)^2-(m4dh*2)^2))') |
| 2141 |
G: Here}') |
| 2142 |
sc_draw(`ddna_',F,dnl half arrowhead shifted up, down, or 0 |
| 2143 |
`sc_draw(`ddna_',Fc,`define(`m4Fc')')sc_draw(`ddna_',F,`undefine(`m4Fc')')dnl |
| 2144 |
define(`m4dn',`ifelse(m4a,u,m4dv/2,m4a,d,-m4dv/2,0)') |
| 2145 |
define(`m4dFline',`Gm: line from rvec_(0,m4tR*m4dn) \ |
| 2146 |
to rvec_(0,m4tR*(m4dn+m4dv/2)) \ |
| 2147 |
then to rvec_(m4dh-lthick/2,m4tR*m4dn) \ |
| 2148 |
then to rvec_(0,m4tR*m4dn)') |
| 2149 |
{ ifinstr(ddf_,f,`m4fshade(m4fill,m4dFline)',`m4dFline') |
| 2150 |
line to ifinstr(`$2',E, |
| 2151 |
`rvec_(0,-(m4tR*sqrt((dimen_*0.7/2)^2-(m4dh/2)^2)))', |
| 2152 |
`rvec_(0,-(m4tR*m4dv/2))') |
| 2153 |
G: Here } |
| 2154 |
ifdef(`m4Fc',`{line from rvec_(0,m4tR*m4dn) to rvec_(m4dh,m4tR*m4dn)}') |
| 2155 |
move to rvec_(m4dh,0) ') |
| 2156 |
ifinstr(ddna_,A,dnl Arrowhead shifted up, down, or 0 |
| 2157 |
`sc_draw(`ddna_',Ac,`define(`m4Ac')')sc_draw(`ddna_',A,`undefine(`m4Ac')')dnl |
| 2158 |
define(`m4dn',`ifelse(m4a,u,m4dv/2,m4a,d,-m4dv/2,0)')dnl |
| 2159 |
define(`m4dFline',`line from rvec_(0,m4dn) \ |
| 2160 |
to rvec_(0,m4dn+m4dv/2) \ |
| 2161 |
then to rvec_(m4dh-lthick/2,m4dn) \ |
| 2162 |
then to rvec_(0,m4dn-m4dv/2) \ |
| 2163 |
then to rvec_(0,m4dn)') |
| 2164 |
{ ifinstr(ddf_,f,`m4fshade(m4fill,m4dFline)',`m4dFline')} |
| 2165 |
ifdef(`m4Ac',`{line from rvec_(0,m4dn) to rvec_(m4dh,m4dn)}') |
| 2166 |
ifinstr(`$2',M,`{line from rvec_(m4dh/2,m4dn+m4dv/2) \ |
| 2167 |
to rvec_(m4dh/2,m4dn-m4dv/2)}') |
| 2168 |
move to rvec_(m4dh,0) ') |
| 2169 |
sc_draw(`ddna_',B,dnl Perp bar at arrowhead centre |
| 2170 |
`{ifelse(m4a,u,dnl from arrow edge or across the centre line |
| 2171 |
`Gm: line from rvec_(-m4dh/2, m4dv/4) \ |
| 2172 |
to ifinstr(`$2',E,`rvec_(-m4dh/2, dimen_*0.35)', |
| 2173 |
`rvec_(-m4dh/2, m4dv*5/4+m4dy)')', |
| 2174 |
m4a,d, |
| 2175 |
`Gm: line from rvec_(-m4dh/2,-m4dv/4) \ |
| 2176 |
to ifinstr(`$2',E,`rvec_(-m4dh/2,-dimen_*0.35)', |
| 2177 |
`rvec_(-m4dh/2,-m4dv*5/4-m4dy)')', |
| 2178 |
`Gm: line from rvec_(-m4dh/2,-m4dv/2-m4dy) \ |
| 2179 |
to rvec_(-m4dh/2, m4dv/2+m4dy) |
| 2180 |
G: Gm.c') |
| 2181 |
ifelse(m4a,,,G: last line.end) }') |
| 2182 |
sc_draw(`ddna_',C,dnl Vertical bar |
| 2183 |
`{ line from ifelse(m4a,d,`rvec_(m4dh/2,m4tR*(-m4dv/2-m4dy-m4dh/2)) to') dnl |
| 2184 |
rvec_(0,m4tR*(-m4dv/2-m4dy)) \ |
| 2185 |
to rvec_(0,m4tR*(m4dv/2+m4dy)) ifelse(m4a,u, |
| 2186 |
`to rvec_(m4dh/2,m4tR*(m4dv/2+m4dy+m4dh/2))') }') |
| 2187 |
sc_draw(`ddna_',D,dnl Vertical bar with horiz tail |
| 2188 |
`{ line from rvec_(0,m4tR*( m4dv/2+m4dy)) \ |
| 2189 |
to rvec_(0,m4tR*(-m4dv/2-m4dy)) \ |
| 2190 |
then to rvec_(m4dh/2,m4tR*(-m4dv/2-m4dy)) }') |
| 2191 |
m4gen_d2($@)dnl |
| 2192 |
m4gen_d3($@)dnl |
| 2193 |
`$3'}') dnl macro split to keep within m4 buffer size |
| 2194 |
define(`m4gen_d2',`dnl |
| 2195 |
dnl Elements drawn at right of body |
| 2196 |
sc_draw(`ddna_',rb,dnl Current regulator bars |
| 2197 |
`{line from rvec_(-m4dv/4,-m4dv/2-m4dy) \ |
| 2198 |
to rvec_( m4dv/4,-m4dv/2-m4dy)} |
| 2199 |
{line from rvec_(-m4dv/4,m4dv/2+m4dy) \ |
| 2200 |
to rvec_( m4dv/4,m4dv/2+m4dy)}') |
| 2201 |
sc_draw(`ddna_',H,dnl Double length double vertical bars |
| 2202 |
`{line from rvec_(0,-m4dv-m4dy) \ |
| 2203 |
to rvec_(0, m4dv+m4dy)} |
| 2204 |
{line from rvec_(-m4dh,-m4dv-m4dy) \ |
| 2205 |
to rvec_(-m4dh, m4dv+m4dy)} |
| 2206 |
move to rvec_(-m4dh,0)') |
| 2207 |
sc_draw(`ddna_',I,dnl Double length double vertical bars |
| 2208 |
`TA: rvec_(0,m4tR*(-m4dv/2)); TB: rvec_(-m4dh/2,m4tR*(-m4dv/4)); TC: Here |
| 2209 |
{line from TB to TA; mitre_(TB,TA,TC)} ') |
| 2210 |
sc_draw(`ddna_',N,dnl thyristor gate at anode, label Ga |
| 2211 |
`{TA: rvec_(-m4dh,-m4tR*m4dv/4); TB: rvec_(-m4dh*2,-m4tR*m4dv*3/4) |
| 2212 |
Gam: line from TA to TB ifinstr(`$2',E,`then to \ |
| 2213 |
rvec_(-m4dh*2,-m4tR*sqrt((dimen_*0.7/2)^2-(m4dh*3/2)^2))') |
| 2214 |
Ga: Here}; ifelse(m4a,d, |
| 2215 |
`TC: TB-TA; {[line to (-TC.y,TC.x)/2] at 2/3 between TA and TB} ')') |
| 2216 |
sc_draw(`ddna_',S,dnl S-shape vertical bar |
| 2217 |
`{line from rvec_(-m4dv/4,-m4dv/3) \ |
| 2218 |
to rvec_(-m4dv/4,-m4dv/2-m4dy) \ |
| 2219 |
then to rvec_(0,-m4dv/2-m4dy) \ |
| 2220 |
then to rvec_(0, m4dv/2+m4dy) \ |
| 2221 |
then to rvec_(m4dv/4,m4dv/2+m4dy) \ |
| 2222 |
then to rvec_(m4dv/4,m4dv/3)}') |
| 2223 |
sc_draw(`ddna_',T,dnl T-diode vertical bar |
| 2224 |
`{line from rvec_(-m4dv/4,-m4dv/2-m4dy) \ |
| 2225 |
to rvec_(0,-m4dv/2-m4dy) \ |
| 2226 |
then to rvec_(0, m4dv/2+m4dy) \ |
| 2227 |
then to rvec_(-m4dv/4,m4dv/2+m4dy)}') |
| 2228 |
sc_draw(`ddna_',v,dnl Variable capacitor curved plate |
| 2229 |
`ifelse(m4a,d,`define(`m4drad',`sqrt((m4dv/2+m4dy)^2+(m4dv)^2*3/4)')dnl |
| 2230 |
{arc cw from rvec_(-(m4drad-m4dv*sqrt(3)/2), m4dv/2+m4dy) \ |
| 2231 |
to rvec_(-(m4drad-m4dv*sqrt(3)/2),-m4dv/2-m4dy) \ |
| 2232 |
with .c at rvec_(-m4drad,0)}', |
| 2233 |
`{arc cw from rvec_(m4dv/3,-m4dv/2-m4dy) \ |
| 2234 |
to rvec_(m4dv/3, m4dv/2+m4dy) \ |
| 2235 |
with .c at rvec_(m4dv/3+m4dv*sqrt(3)/2,0)} |
| 2236 |
{line from rvec_(m4dv/3+m4dv*sqrt(3)/2-last arc.rad,0) \ |
| 2237 |
to rvec_(m4dv/4,0)}')') |
| 2238 |
sc_draw(`ddna_',W,dnl cathode gate |
| 2239 |
`TA: rvec_(0,m4tR*m4dv/4); TB: rvec_(m4dh,m4tR*m4dv*3/4); TC: TB-TA |
| 2240 |
TE: rvec_(m4dh,m4tR*sqrt((dimen_*0.7/2)^2-(m4dh*3/2)^2)) |
| 2241 |
{Gm: line from TA to TB ifinstr(`$2',E,`then to TE') ifelse(m4a,u, |
| 2242 |
`then to rvec_(m4dh,m4tR*m4dv/2) then to Here') |
| 2243 |
ifelse(m4a,d,`[line to (-TC.y,TC.x)/2] at 2/3 between TA and TB')} |
| 2244 |
G: ifinstr(`$2',E,TE,TB)') |
| 2245 |
sc_draw(`ddna_',X,dnl Variable capacitor plate |
| 2246 |
`{line from rvec_(m4dv/4,-m4dv/2-m4dy) \ |
| 2247 |
to rvec_(m4dv/4, m4dv/2+m4dy)}') |
| 2248 |
sc_draw(`ddna_',Z,dnl Zener bar |
| 2249 |
`{line from rvec_(-m4dv/4,-m4dv/2-m4dy) \ |
| 2250 |
to rvec_(0,-m4dv/2-m4dy) \ |
| 2251 |
then to rvec_(0, m4dv/2+m4dy) \ |
| 2252 |
then to rvec_(m4dv/4,m4dv/2+m4dy)}') |
| 2253 |
sc_draw(`ddna_',zo,dnl Outlined zener bar |
| 2254 |
`{line from rvec_(-m4dv/4,-m4dv/2-m4dy-lthick*2) \ |
| 2255 |
to rvec_( lthick*0.7,-m4dv/2-m4dy) \ |
| 2256 |
then to rvec_( lthick*0.7, m4dv/2+m4dy+lthick) } |
| 2257 |
{line from rvec_( m4dv/4, m4dv/2+m4dy+lthick*2) \ |
| 2258 |
to rvec_(-lthick*0.7, m4dv/2+m4dy) \ |
| 2259 |
then to rvec_(-lthick*0.7,-m4dv/2-m4dy-lthick) }') |
| 2260 |
sc_draw(`ddna_',z,dnl Zener bar |
| 2261 |
`{line from rvec_(-m4dv/4,-m4dv/2-m4dy) \ |
| 2262 |
to rvec_(0, -m4dv/3-m4dy) \ |
| 2263 |
then to rvec_(0, m4dv/3+m4dy) \ |
| 2264 |
then to rvec_( m4dv/4, m4dv/2+m4dy)}') |
| 2265 |
ifinstr(ddna_,Q,dnl left arrowhead |
| 2266 |
`sc_draw(`ddna_',Qc,`define(`m4Qc')')sc_draw(`ddna_',Q,`undefine(`m4Qc')')dnl |
| 2267 |
define(`m4dn',`ifelse(m4a,u,m4dv/2,m4a,d,-m4dv/2,0)')dnl |
| 2268 |
{move to rvec_(m4dh,0) |
| 2269 |
define(`m4dFline',`line from rvec_(0,m4dn) \ |
| 2270 |
to rvec_(0,m4dn+m4dv/2) \ |
| 2271 |
then to rvec_(-(m4dh-lthick/2),m4dn) \ |
| 2272 |
then to rvec_(0,m4dn-m4dv/2) \ |
| 2273 |
then to rvec_(0,m4dn) ') |
| 2274 |
ifinstr(ddf_,f,`m4fshade(m4fill,m4dFline)',`m4dFline')} |
| 2275 |
ifdef(`m4Qc',`{line from rvec_(0,m4dn) \ |
| 2276 |
to rvec_(-(m4dh-lthick/2),m4dn)}') |
| 2277 |
move to rvec_(m4dh,0)')dnl |
| 2278 |
') dnl macro split to keep within m4 buffer size |
| 2279 |
define(`m4gen_d3',`dnl |
| 2280 |
sc_draw(`ddna_',Y,dnl Bilateral switch |
| 2281 |
`define(`m4vt',`(m4tR*m4dv/2)')dnl |
| 2282 |
line from rvec_(0,-m4vt) to Here |
| 2283 |
define(`m4dFline',`line to rvec_(0,m4vt) \ |
| 2284 |
then to rvec_(2*m4dh,0) \ |
| 2285 |
then to rvec_(2*m4dh,-m4vt) then to Here ') |
| 2286 |
ifinstr(ddf_,f,`m4fshade(m4fill,m4dFline)',`m4dFline') |
| 2287 |
line from rvec_(2*m4dh,m4vt) to rvec_(2*m4dh,0) |
| 2288 |
{ Gm: line from rvec_(-m4dh,m4vt) \ |
| 2289 |
to ifinstr(`$2',E,`rvec_(-m4dh,-m4tR*dimen_*0.35)', |
| 2290 |
`rvec_(-m4dh,-m4tR*m4dv*5/4)') |
| 2291 |
G: Here }') |
| 2292 |
sc_draw(`ddna_',R,dnl right stem, uR = shortened |
| 2293 |
`line from 0.5 between M4_s and M4_e to M4_e \ |
| 2294 |
chop m4dh ifelse(m4a,,/2,m4a,d,/2+m4dv/4) chop 0') |
| 2295 |
') dnl |
| 2296 |
|
| 2297 |
`sidac( linespec, keys ) Silicon bilateral switch |
| 2298 |
(Silicon Diode for Alternating Current) |
| 2299 |
keys: |
| 2300 |
size= expr; |
| 2301 |
env= E|attributes; (envelope attributes |
| 2302 |
except for size; E=nonblank) |
| 2303 |
symbol= attributes; (e.g. outlined "red") |
| 2304 |
name= body name;' |
| 2305 |
define(`sidac',`pushkeys_(`$2', |
| 2306 |
`size:sourcerad_*2;env::N;symbol::N;name::N;')dnl |
| 2307 |
eleminit_(`$1') pushdef(`sid',m4size/4) |
| 2308 |
{line to rvec_(rp_len/2-sid,0)} |
| 2309 |
{line from rvec_(rp_len/2+sid,0) to 2nd last line.end} |
| 2310 |
{ifelse(m4name,,,m4name:) [ dnl |
| 2311 |
ifelse(m4env,,,`circle diam m4size at (0,0) patsubst(m4env,E)') |
| 2312 |
{line from vec_(-sid,-sid) to vec_(-sid,sid) \ |
| 2313 |
then to vec_(sid,-sid) then to vec_(sid,sid) m4symbol} |
| 2314 |
{T: line from vec_(0,-sid) to vec_(0,sid) m4symbol } ] at rvec_(rp_len/2,0)} |
| 2315 |
line invis to 3rd last line.end dnl |
| 2316 |
popdef(`m4size',`m4env',`m4symbol',`m4name',`sid') ') |
| 2317 |
|
| 2318 |
`em_arrows( type|keys,angle,length ) |
| 2319 |
type=N|I|E [D|T] |
| 2320 |
N=nonionizing, I=ionizing, E=simple; |
| 2321 |
D=dot on arrow stem; T=anchor tail |
| 2322 |
keys: type=chars as above; |
| 2323 |
lgth=expr; |
| 2324 |
sep=expr; arrow separation |
| 2325 |
angle=degrees; absolute direction' |
| 2326 |
define(`em_arrows',`[ |
| 2327 |
pushkeys_(`$1',`type:m4typ:N; angle:ifelse(`$2',,135,`($2)')*dtor_')dnl |
| 2328 |
ifelse(m4type,m4typ,`poppushdef(`m4type',`ifelse(`$1',,N,`$1')')')dnl |
| 2329 |
arrowhead = em_arrowhead |
| 2330 |
sc_draw(`m4type',N, |
| 2331 |
`pushkeys_(`$1',lgth:ifelse(`$3',,dimen_*0.46,`$3'); sep:em_arrowwid*9/8)dnl |
| 2332 |
{ A1: arrow m4c_l to rrot_(m4lgth,0,m4angle) wid em_arrowwid ht em_arrowht} |
| 2333 |
move to rrot_(0,-m4sep,m4angle) |
| 2334 |
{ A2: arrow m4c_l to rrot_(m4lgth,0,m4angle) wid em_arrowwid ht em_arrowht}') |
| 2335 |
sc_draw(`m4type',I, |
| 2336 |
`pushkeys_(`$1',lgth:ifelse(`$3',,dimen_*0.46,`$3'); sep:em_arrowwid*9/8)dnl |
| 2337 |
m4em_serp(A1) |
| 2338 |
move to rrot_(0,-m4sep,m4angle); m4em_serp(A2)') |
| 2339 |
sc_draw(`m4type',E, |
| 2340 |
`pushkeys_(`$1',lgth:ifelse(`$3',,dimen_*0.25,`$3'); sep:dimen_/8)dnl |
| 2341 |
{ A1: line to rrot_(m4lgth,0,m4angle) \ |
| 2342 |
then to rrot_(m4lgth-dimen_/18,dimen_/18,m4angle) } |
| 2343 |
move to rrot_(0,-m4sep,m4angle) |
| 2344 |
{ A2: line to rrot_(m4lgth,0,m4angle) \ |
| 2345 |
then to rrot_(m4lgth-dimen_/18,dimen_/18,m4angle) }') |
| 2346 |
sc_draw(`m4type',D,`dot(at A1.start); dot(at A2.start)') |
| 2347 |
sc_draw(`m4type',T,`m4em_anchor(A1.start); m4em_anchor(A2.start)') |
| 2348 |
Tail: 0.5 between A1.start and A2.start |
| 2349 |
Head: 0.5 between A1.end and A2.end |
| 2350 |
`$4' popdef(`m4typ',`m4type',`m4angle',`m4lgth',`m4sep') ]') |
| 2351 |
define(`m4em_serp',`{{`$1': line invis to rrot_(m4lgth,0,m4angle)} |
| 2352 |
for i=1 to (m4lgth-em_arrowht*3/4)/(em_arrowwid) do { |
| 2353 |
if i%2 then {define m4cw {cw}} else {define m4cw {ccw}} |
| 2354 |
arc m4cw to rrot_(em_arrowwid,0,m4angle) \ |
| 2355 |
with .c at rrot_((em_arrowwid)/2,0,m4angle) }; round |
| 2356 |
arrow m4c_l to `$1'.end wid em_arrowwid ht em_arrowht*3/4 }') |
| 2357 |
define(`m4em_anchor',`{ move to `$1' |
| 2358 |
{arc cw to rrot_(0,em_arrowwid/2,m4angle) \ |
| 2359 |
with .c at rrot_(0,em_arrowwid/4,m4angle)} |
| 2360 |
{arc to rrot_(0,-arrowwid/2,m4angle) \ |
| 2361 |
with .c at rrot_(0,-arrowwid/4,m4angle)}}') |
| 2362 |
|
| 2363 |
`thyristor(linespec, |
| 2364 |
DIAC|DIAC2|DIAC3|ETO|RCT|RCTA|GTO|GTOP|GTON| |
| 2365 |
GTS|IEC|IGCT|MTO|SBS|SCR|SCS|SIDAC|SUS| |
| 2366 |
Sch|Sch2 [chars]) |
| 2367 |
Composite element in [ ] block |
| 2368 |
(To place as two-terminal, see thyristor_t()). |
| 2369 |
chars: |
| 2370 |
K: use open arrowheads |
| 2371 |
E: adds envelope |
| 2372 |
R: right orientation |
| 2373 |
A: arrowhead |
| 2374 |
F: half arrowhead |
| 2375 |
U: centre line in arrowhead |
| 2376 |
B: bidirectional diode |
| 2377 |
H: perpendicular gate, endpoint G |
| 2378 |
N: anode gate, endpoint Ga |
| 2379 |
V: perpendicular gate at arrowhead centre' |
| 2380 |
define(`thyristor', |
| 2381 |
`pushdef(`m4thtype') foreach_(`M4T', |
| 2382 |
`ifelse(index(`$2',M4T),-1,,`poppushdef(`m4thtype',M4T)')dnl', |
| 2383 |
DIAC,DIAC2,DIAC3,ETO,RCT,RCTA,GTO,GTOP,GTON,GTS, |
| 2384 |
IEC,IGCT,MTO,SBS,SCR,SCS,SIDAC,SUS,Sch,Sch2)dnl |
| 2385 |
pushdef(`m4thx',patsubst(`$2',m4thtype))dnl delete the type code |
| 2386 |
pushdef(`m4thf',`ifinstr(m4thx,R,R)')dnl orientation |
| 2387 |
poppushdef(`m4thf',m4thf`'xtract(m4thx,E))dnl envelope |
| 2388 |
poppushdef(`m4thx',patsubst(m4thx,R\|E))dnl |
| 2389 |
pushdef(`m4thAc',xtract(m4thx,F,A))dnl centerline |
| 2390 |
poppushdef(`m4thAc',patsubst(m4thAc,F,Fc))dnl |
| 2391 |
poppushdef(`m4thAc',ifelse(m4thAc,,A,m4thAc)`'ifinstr(m4thx,U,c))dnl centerln |
| 2392 |
poppushdef(`m4thf',m4thf`'ifinstr(m4thx,F,,m4thx,K,,f))dnl fill |
| 2393 |
ifelse(m4thtype,, dnl no type code |
| 2394 |
`[pushdef(`m4thyd',`dimen_*0.7') eleminit_(`$1',m4thyd) |
| 2395 |
A: last line.start; K: last line.end; T1:A; T2:K |
| 2396 |
pushdef(`m4tha',`patsubst(patsubst(patsubst(patsubst(m4thx,UA,Ac),V,B), |
| 2397 |
H,ifinstr(m4thf,R,d,u)B),U,Ac)')dnl |
| 2398 |
ifelse(xtract(m4tha,A,F,Q),,`poppushdef(`m4tha',m4tha`'A)dnl |
| 2399 |
poppushdef(`m4thf',m4thf`'ifinstr(m4thx,K,,f))')dnl |
| 2400 |
ifelse(xtract(m4tha,B,G,H,N,W),,`poppushdef(`m4tha',m4tha`'W)')dnl |
| 2401 |
m4gen_d(LR`'ifinstr(m4tha,uC,u,m4tha,dC,d)`'C`'m4tha,m4thf) |
| 2402 |
ifinstr(m4thf,E,`Env: circle diam m4thyd with .c at rvec_(rp_len/2,0)') |
| 2403 |
`$3' popdef(`m4thyd',`m4tha') undefine(`m4dv',`m4dh') ]', |
| 2404 |
`ifelse(xtract(m4thtype,IEC,Sch,DIAC3),, |
| 2405 |
`[define(`m4thyd',`dimen_*0.7') eleminit_(`$1',m4thyd)dnl |
| 2406 |
`#' m4thtype |
| 2407 |
#m4msg(|`$2'|m4thtype|m4thx|m4thf|) |
| 2408 |
A: last line.start; K: last line.end; T1:A; T2:K |
| 2409 |
ifelse(m4thtype,DIAC,`ifinstr(m4thf,R, |
| 2410 |
`m4gen_d(LdG'xtract(m4thx,G)`dA`'m4thAc`'HuQ`'m4thAc`'R,m4thf)', |
| 2411 |
`m4gen_d( LG'xtract(m4thx,G)`uA`'m4thAc`'HdQ`'m4thAc`'R,m4thf)')', |
| 2412 |
m4thtype,DIAC2, |
| 2413 |
`m4gen_d(LdA`'m4thAc`'HuQ`'m4thAc`'R,m4thf,{move to rvec_(-rp_len/2,0) |
| 2414 |
Gm: line to rvec_(0,(m4dn+m4dv+lthick/2)*2) with .c at Here |
| 2415 |
G: Gm.`'ifinstr(m4thf,R,start,end)})', |
| 2416 |
m4thtype,ETO, |
| 2417 |
`m4gen_d(LCRW`'m4thAc,m4thf, |
| 2418 |
M4To: rvec_(-rp_len/2+m4dh*3/2,ifinstr(m4thf,R,,-)m4dv/3) |
| 2419 |
{line from Here to rvec_(m4dh*2/3,0) with .c at M4To} |
| 2420 |
{line from M4To to M4To+vec_(0,ifinstr(m4thf,R,,-)m4dv); Go: Here})', |
| 2421 |
m4thtype,RCT, |
| 2422 |
`pushdef(`m4nthf',`ifinstr(m4thf,R,patsubst(m4thf,R),m4thf`'R)')dnl |
| 2423 |
m4gen_d(LDRW`'m4thAc,m4nthf) popdef(`m4nthf')', |
| 2424 |
m4thtype,RCTA, `m4gen_d(LDRN`'m4thAc,m4thf)', |
| 2425 |
m4thtype,GTO, `m4gen_d(LCRuW`'m4thAc,m4thf)', |
| 2426 |
m4thtype,GTOP, `m4gen_d(LCRdW`'m4thAc,m4thf)', |
| 2427 |
m4thtype,GTON, `m4gen_d(LCRdN`'m4thAc,m4thf)', |
| 2428 |
m4thtype,GTS, `m4gen_d(LCRdW`'m4thAc,m4thf)', |
| 2429 |
m4thtype,IGCT, `m4gen_d(LCRdWI`'m4thAc,m4thf)', |
| 2430 |
m4thtype,MTO,`m4gen_d(LCRW`'m4thAc,m4thf, |
| 2431 |
M4To: rvec_(-rp_len/2+m4dh*3/4,ifinstr(m4thf,R,,-)(m4dv/3+m4dy)) |
| 2432 |
{line from M4To-vec_(0,m4dv/6) to M4To+vec_(0,m4dv/6)} |
| 2433 |
{line from M4To \ |
| 2434 |
to rvec_(-rp_len/2+m4dh*3/2,ifinstr(m4thf,R,,-)m4dv*3/4) ifinstr(m4thf,E, |
| 2435 |
`then to rvec_(-rp_len/2+m4dh*3/2, |
| 2436 |
ifinstr(m4thf,R,,-)sqrt((dimen_*0.7/2)^2-(m4dh*3/2)^2))'); Go: Here})', |
| 2437 |
m4thtype,SBS, `m4gen_d(uLYuR,patsubst(m4thf,f)) |
| 2438 |
{line from rvec_(rp_len/2+m4dh,0) to rvec_(rp_len/2-m4dh,0)} ', |
| 2439 |
m4thtype,SCR, `m4gen_d(LCRW`'m4thAc,m4thf)', |
| 2440 |
m4thtype,SCS, `m4gen_d(LCRWN`'m4thAc,m4thf)', |
| 2441 |
m4thtype,SIDAC, `m4gen_d(LCRE`'m4thAc,m4thf)', |
| 2442 |
m4thtype,SUS, `m4gen_d(LFR,m4thf)') |
| 2443 |
ifinstr(m4thf,E,`Env: circle diam m4thyd with .c at rvec_(rp_len/2,0)') |
| 2444 |
`$3']', |
| 2445 |
``#' m4thtype |
| 2446 |
ifelse(m4thtype,IEC,`bi_trans(`$1', |
| 2447 |
ifinstr(m4thf,R,,R),uEdCBUT,xtract(m4thf,E),A:E;K:C;G:T;`$3')', |
| 2448 |
m4thtype,Sch,`bi_trans(`$1', |
| 2449 |
ifinstr(m4thf,R,,R),uECBUdV,xtract(m4thf,E),A:E;K:C;G:T;`$3')', |
| 2450 |
m4thtype,Sch2,`bi_trans(`$1', |
| 2451 |
ifinstr(m4thf,R,,R),uEBUuT,xtract(m4thf,E), |
| 2452 |
C0: tr_xy(3,8); Cm: line from C0 to tr_xy(1.2,4) |
| 2453 |
{arrow from 3/4 between Cm.start and Cm.end \ |
| 2454 |
to 1/4 between Cm.start and Cm.end} |
| 2455 |
A:E;K:Cm.start;G:T;`$3')', |
| 2456 |
m4thtype,DIAC3,`bi_trans(`$1', |
| 2457 |
ifinstr(m4thf,R,,R),BdEdCBU,xtract(m4thf,E),A:E;K:C;G:B;`$3')')')dnl |
| 2458 |
popdef(`m4thtype',`m4thx',`m4thf',`m4thAc') ') ') |
| 2459 |
|
| 2460 |
`thyristor_t(linespec, thyristor chars], label) |
| 2461 |
A wrapper to place thyristor(linespec,...) |
| 2462 |
as a two-terminal element with arg3 |
| 2463 |
as label of the [] block (see also scr())' |
| 2464 |
define(`thyristor_t',`eleminit_(`$1') |
| 2465 |
M4_thyS: last line.start; M4_thyE: last line.end |
| 2466 |
ifelse(`$3',,,`$3:') thyristor(from M4_thyS to M4_thyE,`$2',`$4') \ |
| 2467 |
with .A at M4_thyS; line invis from M4_thyS to M4_thyE') |
| 2468 |
|
| 2469 |
`scr(linespec, [R][E][chars], label) and similar |
| 2470 |
Place thyristor as a two-term element with |
| 2471 |
arg 3 as label of the [] block' |
| 2472 |
define(`scr',`eleminit_(`$1'); M4_scrS: last line.start; M4_scrE: last line.end |
| 2473 |
ifelse(`$3',,,`$3:') thyristor(from M4_scrS to M4_scrE,SCR`'`$2',`$4') \ |
| 2474 |
with .A at M4_scrS; line invis from M4_scrS to M4_scrE') |
| 2475 |
define(`scs',`eleminit_(`$1'); M4_scsS: last line.start; M4_scsE: last line.end |
| 2476 |
ifelse(`$3',,,`$3:') thyristor(from M4_scsS to M4_scsE,SCS`'`$2',`$4') \ |
| 2477 |
with .A at M4_scsS; line invis from M4_scsS to M4_scsE') |
| 2478 |
define(`sus',`eleminit_(`$1'); M4_susS: last line.start; M4_susE: last line.end |
| 2479 |
ifelse(`$3',,,`$3:') thyristor(from M4_susS to M4_susE,SUS`'`$2',`$4') \ |
| 2480 |
with .A at M4_susS; line invis from M4_susS to M4_susE') |
| 2481 |
define(`sbs',`eleminit_(`$1'); M4_sbsS: last line.start; M4_sbsE: last line.end |
| 2482 |
ifelse(`$3',,,`$3:') thyristor(from M4_sbsS to M4_sbsE,SBS`'`$2',`$4') \ |
| 2483 |
with .A at M4_sbsS; line invis from M4_sbsS to M4_sbsE') |
| 2484 |
define(`gto',`eleminit_(`$1'); M4_gtoS: last line.start; M4_gtoE: last line.end |
| 2485 |
ifelse(`$3',,,`$3:') thyristor(from M4_gtoS to M4_gtoE,GTO`'`$2',`$4') \ |
| 2486 |
with .A at M4_gtoS; line invis from M4_gtoS to M4_gtoE') |
| 2487 |
define(`gts',`eleminit_(`$1'); M4_gtsS: last line.start; M4_gtsE: last line.end |
| 2488 |
ifelse(`$3',,,`$3:') thyristor(from M4_gtsS to M4_gtsE,GTS`'`$2',`$4') \ |
| 2489 |
with .A at M4_gtsS; line invis from M4_gtsS to M4_gtsE') |
| 2490 |
|
| 2491 |
`tgate( linespec, [B][R|L] ) Transmission gate |
| 2492 |
B= box form |
| 2493 |
L= left orientation' |
| 2494 |
define(`tgate',`[ eleminit_(`$1') pushdef(`m4tgm',ifinstr(`$2',L,-)) |
| 2495 |
A: last line.start |
| 2496 |
B: last line.end |
| 2497 |
C: last line.center |
| 2498 |
ifinstr(`$2',B, |
| 2499 |
`ebox(from A to B,,dimen_/5) |
| 2500 |
Gb: C+vec_(0,m4tgm`'dimen_/5/2) |
| 2501 |
L1: line from 2 between Gb and C to 4 between Gb and C', |
| 2502 |
`m4gen_d(uLAQuR) pushdef(`m4dv',`dimen_/6')pushdef(`m4dh',sqrt(3)*m4dv/2) |
| 2503 |
Circle: circle thick max(4pt__,linethick/2) rad m4dh/4 \ |
| 2504 |
at C+vec_(0,m4tgm`'m4dh/4*4/3) |
| 2505 |
L2: line from last circle+vec_(0,m4tgm`'m4dh/4) \ |
| 2506 |
to C+vec_(0,m4tgm`'m4dh*3/2) |
| 2507 |
Gb: Here |
| 2508 |
L3: line from C to C-vec_(0,m4tgm`'m4dh) popdef(`m4dv',`m4dh')') |
| 2509 |
G: Here |
| 2510 |
`$3' popdef(`m4tgm')]') |
| 2511 |
`ptrans( linespec, [R|L] ) Pass transistor |
| 2512 |
L= left orientation' |
| 2513 |
define(`ptrans',`[ eleminit_(`$1') define(`m4ptm',ifinstr(`$2',L,-)) |
| 2514 |
define(`m4pv',`dimen_/6')define(`m4pwd',m4pv*2)dnl |
| 2515 |
A: last line.start; Start: A |
| 2516 |
B: last line.end; End: B |
| 2517 |
C: last line.center |
| 2518 |
La1: line to rvec_(rp_len/2-m4pwd/2,0) |
| 2519 |
{ La2: line to rvec_(m4pwd,m4pv) \ |
| 2520 |
then to rvec_(m4pwd,neg_(m4pv)) \ |
| 2521 |
then to Here } |
| 2522 |
{ La3: line from rvec_(m4pwd,0) \ |
| 2523 |
to rvec_(0,m4pv) \ |
| 2524 |
then to rvec_(0,neg_(m4pv)) \ |
| 2525 |
then to rvec_(m4pwd,0) |
| 2526 |
Circle: circle thick max(4pt__,linethick/2) rad m4pv/4 \ |
| 2527 |
at C+vec_(0,m4ptm`'m4pv*5/6) |
| 2528 |
La4: line from last circle+vec_(0,m4ptm`'m4pv/4) \ |
| 2529 |
to C+vec_(0,m4ptm`'m4pv*2) |
| 2530 |
Gb:Here |
| 2531 |
La5: line from C-vec_(0,m4ptm`'m4pv/2) \ |
| 2532 |
to C-vec_(0,m4ptm`'m4pv*3/2) |
| 2533 |
G: Here } |
| 2534 |
La6: line from rvec_(m4pwd,0) \ |
| 2535 |
to B |
| 2536 |
`$3']') |
| 2537 |
`tline( linespec, wid, len ) Transmission line' |
| 2538 |
define(`tline',`eleminit_(`$1') |
| 2539 |
define(`m4v',`ifelse(`$2',,`dimen_/6',`($2)')')dnl |
| 2540 |
define(`m4h',`ifelse(`$3',,`dimen_*2/3',min(rp_len-m4v/2,`$3'))')dnl |
| 2541 |
{line from last line.c+vec_(m4h/2+m4v/4,0) \ |
| 2542 |
to last line.end} |
| 2543 |
{line to 2nd last line.c+vec_(-m4h/2,0); round |
| 2544 |
[ifdpic( |
| 2545 |
`line from rvec_(0,-m4v/2) \ |
| 2546 |
to rvec_(m4h,-m4v/2) |
| 2547 |
spline 0.5523 to rvec_(m4v/4,0) \ |
| 2548 |
then to rvec_(m4v/4,m4v) \ |
| 2549 |
to rvec_(0,m4v) |
| 2550 |
line to rvec_(-m4h,0) |
| 2551 |
spline 0.5523 to rvec_(-m4v/4,0) \ |
| 2552 |
then to rvec_(-m4v/4,-m4v) \ |
| 2553 |
then to rvec_(m4v/4,-m4v) \ |
| 2554 |
then to rvec_(m4v/4,0) \ |
| 2555 |
then to Here', |
| 2556 |
`line from rvec_(m4v/4,-m4v/2) \ |
| 2557 |
to rvec_(m4h-m4v/4,-m4v/2) |
| 2558 |
spline to rvec_(m4v/2,0) \ |
| 2559 |
then to rvec_(m4v/2,m4v) \ |
| 2560 |
then to rvec_(0,m4v) |
| 2561 |
line to rvec_(-m4h+m4v/2,0) |
| 2562 |
spline to rvec_(-m4v/2,0) \ |
| 2563 |
then to rvec_(-m4v/2,-m4v) \ |
| 2564 |
then to rvec_(0,-m4v)\ |
| 2565 |
then to Here \ |
| 2566 |
then to rvec_(-m4v/2,0) \ |
| 2567 |
then to rvec_(-m4v/2,-m4v)\ |
| 2568 |
then to rvec_(0,-m4v)')] with .c at rvec_(m4h/2,0) } |
| 2569 |
line to 3rd last line.end invis ') |
| 2570 |
|
| 2571 |
define(`m4_U',`dimen_/10') `Semiconductor grid size' |
| 2572 |
define(`m4_Aht',`m4_U*10/6') `Semiconductor arrowhead ht and wd' |
| 2573 |
define(`m4_Awd',`m4_U*10/9') |
| 2574 |
|
| 2575 |
`Bipolar transistor bi_tr(linespec, L|R, P, E)' |
| 2576 |
define(`bi_tr',`bi_trans(`$1',`$2',ifelse(`$3',P,u,d)EBCBU,`$4',`$5')') |
| 2577 |
|
| 2578 |
`Darlington(L|R, chars) |
| 2579 |
arg2: |
| 2580 |
E= envelope |
| 2581 |
P= p-type, |
| 2582 |
B1= internal base lead, |
| 2583 |
R1= Q1 bias resistor; E1= ebox, |
| 2584 |
R2= Q2 bias resistor; E2= ebox, |
| 2585 |
D= damper diode |
| 2586 |
Z= zener bias diode |
| 2587 |
This macro would be somewhat simpler if the |
| 2588 |
joints had not been mitred (using Along_ and |
| 2589 |
mitre_)' |
| 2590 |
define(`Darlington', `[ rpoint_(dimen_/10) define(`m4DR',`ifinstr(`$1',R,-)') |
| 2591 |
define(`m4Da',`$2') pushdef(`dimen_',((dimen_)*0.8))dnl Smaller internals |
| 2592 |
hp_ang = rp_ang |
| 2593 |
Q1: bi_trans(,`$1',ifinstr(m4Da,P,u,d)ECBU) |
| 2594 |
E: Q1.E |
| 2595 |
Q1B: line from Q1.Bulk.c to Q1.Bulk.c + vec_(0,m4DR`'m4_U) |
| 2596 |
Q2: bi_trans(,`$1',ifinstr(m4Da,P,u,d)EBCBU) with .E at Here |
| 2597 |
Mitre_(Q1B,Q2.Em0) |
| 2598 |
B: Q2.B |
| 2599 |
T: Q2.C+(Q2.Bulk.c.x-Q2.B.x,Q2.Bulk.c.y-Q2.B.y) |
| 2600 |
QC: intersect_(Q2.C,T,Q1.E,Q1.C) |
| 2601 |
C: QC |
| 2602 |
L1: line from Along_(Q2.Cm0,hlth) to Q2.C then to QC then to Q1.C \ |
| 2603 |
then to Along_(Q1.Cm0,hlth) |
| 2604 |
define(`m4DE1')sc_draw(`m4Da',E1,`define(`m4DE1',E)define(`m4Da',R1`'m4Da)') |
| 2605 |
define(`m4DE2')sc_draw(`m4Da',E2,`define(`m4DE2',E)define(`m4Da',R2`'m4Da)') |
| 2606 |
ifinstr(m4Da,E, |
| 2607 |
`Env: circle rad 7.75*m4_U at Q1.Bulk.c+vec_(1.5*m4_U,m4DR`'(-0.1*m4_U)) |
| 2608 |
line from Q1.E to Q1.E+vec_(-2.2*m4_U,0); E: Here |
| 2609 |
Mitre_(last line,Q1.Em0) |
| 2610 |
line from QC to QC+vec_(2.2*m4_U,0); C: Here |
| 2611 |
pushdef(`dotrad_',(dotrad_/2))dnl |
| 2612 |
ifelse(ifinstr(m4Da,B1,T,m4Da,R1,T,m4Da,R2,T),T,`dot(at Q2.E)') |
| 2613 |
ifelse(ifinstr(m4Da,R2,T,m4Da,Z,T),T, |
| 2614 |
`M4D1: dot(at Q2.Bulk.c+vec_(0,m4DR`'m4_U))') |
| 2615 |
ifelse(ifinstr(m4Da,B1,T,m4Da,R1,T),T,`ifinstr(m4Da,R2, |
| 2616 |
`M4D2: dot(at Q2.E+vec_(-m4_U,0))')') |
| 2617 |
ifinstr(m4Da,B1, |
| 2618 |
`ifinstr(m4Da,R1,`dot(at Q2.E-vec_(3*m4_U,0))') |
| 2619 |
B1: Q2.E+vec_(-3*m4_U,m4DR`'5.2*m4_U) |
| 2620 |
line from B1 to Q2.E+vec_(-3*m4_U,0); corner') |
| 2621 |
ifinstr(m4Da,Z,`dot(at QC+vec_(m4_U*3/2,0))') |
| 2622 |
dot(at QC) |
| 2623 |
ifinstr(m4Da,D,`dot(at Q1.E)') |
| 2624 |
ifinstr(m4Da,R1,`dot(at Q1.E-vec_(m4_U,0))') |
| 2625 |
popdef(`dotrad_')', |
| 2626 |
`ifinstr(m4Da,B1,`move to Q2.E-vec_(3*m4_U,0); line to rvec_(-m4_U,0) |
| 2627 |
B1: Here')') |
| 2628 |
ifelse(ifinstr(m4Da,B1,T,m4Da,R1,T,m4Da,R2,T),T, |
| 2629 |
`line from Q2.E to Q2.E-vec_(m4_U,0) |
| 2630 |
ifelse(ifinstr(m4Da,B1,T,m4Da,R1,T),T, |
| 2631 |
`line to rvec_(-2*m4_U,0) |
| 2632 |
ifinstr(m4Da,R1, |
| 2633 |
`line to rvec_(-m4_U,0); corner pushdef(`dimen_',((dimen_)*0.6)) |
| 2634 |
R1: resistor(to Q1.E+vec_(-m4_U/0.6,0),,m4DE1) popdef(`dimen_') |
| 2635 |
ifinstr(m4Da,E,,`corner;E: Here; line from Q1.E to E') |
| 2636 |
point_(hp_ang)')')') |
| 2637 |
ifinstr(m4Da,R2, |
| 2638 |
`line from M4D1 to M4D1+vec_(-4*m4_U,0); corner |
| 2639 |
pushdef(`dimen_',((dimen_)*0.6))dnl |
| 2640 |
R2: resistor(to M4D2,,m4DE2) popdef(`dimen_') |
| 2641 |
point_(hp_ang)') |
| 2642 |
ifinstr(m4Da,D, |
| 2643 |
`DE: Q1.E + vec_(m4_U*3/2,m4DR`'(-m4_U*3/2)) |
| 2644 |
DS: QC - vec_(m4_U*3/2,m4DR`'m4_U*3/2) |
| 2645 |
line from Q1.E to DE |
| 2646 |
line from QC to DS |
| 2647 |
mitre_(DS,DE,Q1.E) |
| 2648 |
mitre_(DE,DS,QC) |
| 2649 |
Diode: diode(ifinstr(m4Da,P,`from DS to DE',`from DE to DS')) |
| 2650 |
point_(hp_ang)') |
| 2651 |
ifinstr(m4Da,Z, |
| 2652 |
`ifinstr(m4Da,E,, |
| 2653 |
`line from QC to QC+vec_(m4_U*3/2,0); corner; C: Here') |
| 2654 |
move to Q2.Bulk.c+vec_(0,m4DR`'m4_U) |
| 2655 |
line to rvec_(2*m4_U,0) then to rvec_(4.5*m4_U,m4DR`'(-2*m4_U)) \ |
| 2656 |
then to rvec_(4.5*m4_U,m4DR`'(-2*m4_U-lthick/4)) |
| 2657 |
Zener: diode(ifinstr(m4Da,P,`to QC+vec_(m4_U*3/2,0)', |
| 2658 |
`from QC+vec_(m4_U*3/2,0) to Here'),Z) |
| 2659 |
point_(hp_ang)') |
| 2660 |
popdef(`dimen_') `$4' ]') |
| 2661 |
|
| 2662 |
`igbt(linespec, L|R, [L][[d]D]) |
| 2663 |
Arg 3: L = 2nd gate type, D = parallel diode, |
| 2664 |
dD = dotted connections' |
| 2665 |
define(`igbt',`bi_trans(`$1',`$2',ifinstr(`$3',L,,GH)CBUdE`$3',,`$4')') |
| 2666 |
|
| 2667 |
`Customizable bi_trans(linespec, L|R, chars, E) |
| 2668 |
chars |
| 2669 |
BU=bulk line |
| 2670 |
B=base line and label |
| 2671 |
uEn|dEn=emitters E0 to En |
| 2672 |
uE|dE=emitter line |
| 2673 |
Cn|uCn|dCn=collectors C0 to Cn (arrow u or d) |
| 2674 |
C|uC|dC=collector line (arrow u or d) |
| 2675 |
uT|dT=trigger line |
| 2676 |
uV|dV=trigger line at emitter |
| 2677 |
G=gate line and location |
| 2678 |
H=gate line |
| 2679 |
L=L-gate line and location |
| 2680 |
S=Schottky |
| 2681 |
[d]D=named parallel diode, d=connection dots' |
| 2682 |
define(`bi_trans', |
| 2683 |
`define(`m4R',`ifelse(`$2',R,-)')define(`dna_',`ifelse(`$3',,BCuEBU,`$3')')dnl |
| 2684 |
define(`m4n',0)define(`m4dE',)dnl |
| 2685 |
[ ifelse(`$1',,`tr_xy_init(,m4_U,m4R); E: tr_xy(-3,0); C: tr_xy(3,0)', |
| 2686 |
`eleminit_(`$1'); tr_xy_init(last line.c,m4_U,m4R) |
| 2687 |
E: last line.start; line from E to tr_xy(-3,0) \ |
| 2688 |
then to tr_xy(-3,0) + vec_( lthick*0.15,m4R`'lthick/3) |
| 2689 |
C: E+vec_(rp_len,0); line from C to tr_xy(3,0) \ |
| 2690 |
then to tr_xy( 3,0) + vec_(-lthick*0.15,m4R`'lthick/3)') |
| 2691 |
Bulk: line sc_draw(`dna_',BU,,invis) from tr_xy(-2,4) \ |
| 2692 |
to tr_xy(2,4) |
| 2693 |
sc_draw(`dna_',B, |
| 2694 |
`B: tr_xy(0,6.5); line from B to tr_xy(0,4)') |
| 2695 |
for_(1,8,1, |
| 2696 |
`sc_draw(`dna_',E`'m4x,`define(`m4n',m4x*1.5) define(`m4dE',m4a) |
| 2697 |
m4bi_Em(m4x,m4a,E) |
| 2698 |
line from tr_xy(-2,4) \ |
| 2699 |
to tr_xy(-2-m4n,4) |
| 2700 |
Bulk: line invis from tr_xy(-2-m4n,4) \ |
| 2701 |
to Bulk.end')') |
| 2702 |
sc_draw(`dna_',E, |
| 2703 |
`define(`m4dE',m4a) m4bi_Em(0,m4a,E)') |
| 2704 |
for_(1,8,1, |
| 2705 |
`sc_draw(`dna_',C`'m4x,`define(`m4n',m4x*1.5) |
| 2706 |
m4bi_Em(m4x,m4a,C) |
| 2707 |
line from tr_xy(2,4) \ |
| 2708 |
to tr_xy(2+m4n,4) |
| 2709 |
Bulk: line invis from Bulk.start to tr_xy(2+m4n,4)')') |
| 2710 |
sc_draw(`dna_',C, |
| 2711 |
`m4bi_Em(0,m4a,C)') |
| 2712 |
sc_draw(`dna_',S, |
| 2713 |
`Bulk: line invis from Bulk.start+ta_xy(-1,0) \ |
| 2714 |
to Bulk.end+ta_xy(1,0) |
| 2715 |
S1: line from Bulk.end+ta_xy(-1,0) \ |
| 2716 |
to Bulk.end \ |
| 2717 |
then to Bulk.end+ta_xy(0,-0.5) \ |
| 2718 |
then to Bulk.end+ta_xy(-0.5,-0.5) |
| 2719 |
S2: line from Bulk.start+ta_xy(1,0) \ |
| 2720 |
to Bulk.start \ |
| 2721 |
then to Bulk.start+ta_xy(0,0.5) \ |
| 2722 |
then to Bulk.start+ta_xy(0.5,0.5)') |
| 2723 |
sc_draw(`dna_',T, |
| 2724 |
`Tm: line from tr_xy(0,4) \ |
| 2725 |
to tr_xy(2/3,(4 ifelse(m4a,u,+,-)4/1.8*2/3)) |
| 2726 |
T: Here') |
| 2727 |
sc_draw(`dna_',V, |
| 2728 |
`Tm: line from tr_xy(0,4) \ |
| 2729 |
to tr_xy(-2/3,(4 ifelse(m4a,u,+,-)4/1.8*2/3)) |
| 2730 |
T: Here') |
| 2731 |
sc_draw(`dna_',G, |
| 2732 |
`G: tr_xy(0,6.5); line from G to tr_xy(0,4.7)') |
| 2733 |
sc_draw(`dna_',H, |
| 2734 |
`H1: line from tr_xy(-2,4.7) \ |
| 2735 |
to tr_xy(2,4.7)') |
| 2736 |
sc_draw(`dna_',L, |
| 2737 |
`G: tr_xy(-1.5,6.2); line from G to tr_xy(-1.5,4.7) \ |
| 2738 |
then to tr_xy(1.5,4.7)') |
| 2739 |
sc_draw(`dna_',D, |
| 2740 |
`D1: line from tr_xy(-5,0) \ |
| 2741 |
to tr_xy(-5,-4) |
| 2742 |
D2: line from tr_xy( 5,0) \ |
| 2743 |
to tr_xy( 5,-4) |
| 2744 |
ifelse(m4a,d,`dot(at tr_xy( 5,0)); dot(at tr_xy(-5,0))') |
| 2745 |
Diode: diode(ifelse(m4dE,d,from,to) tr_xy(-5,-4) \ |
| 2746 |
ifelse(m4dE,d,to,from) tr_xy( 5,-4)) |
| 2747 |
ifelse(m4dE,d,,rp_ang = rp_ang + pi_) |
| 2748 |
ifelse(`$1',,`E: tr_xy(-5,0); line from E to tr_xy(-3,0); |
| 2749 |
C: tr_xy(5,0); line from C to tr_xy(3,0)')') |
| 2750 |
ifinstr(`$4',E, |
| 2751 |
`A1: arc ifelse(`$2',R,c)cw from Bulk.end+ta_xy(-2,2.5) \ |
| 2752 |
to Bulk.end+ta_xy(-2,-5.5) with .c at Bulk.end+ta_xy(-2,-1.5) |
| 2753 |
L1: line to Bulk.start+ta_xy(2,-5.5) |
| 2754 |
A2: arc ifelse(`$2',R,c)cw to Bulk.start+ta_xy(2,2.5) \ |
| 2755 |
with .c at Bulk.start+ta_xy(2,-1.5) |
| 2756 |
L2: line to Bulk.end+ta_xy(-2,2.5)') |
| 2757 |
`$5'; manhattan ] ') |
| 2758 |
`emitters E0 ... En or collectors C0 ... Cn' |
| 2759 |
define(`m4bi_Em', |
| 2760 |
``$3'`$1': tr_xy(ifelse(`$3',E,-)(3+(`$1')*1.5),0) |
| 2761 |
`$3'm`$1': line from `$3'`$1' to tr_xy(ifelse(`$3',E,-)(1.2+(`$1')*1.5),4) |
| 2762 |
ifelse(`$2',,,`arrow m4c_l ht m4_Aht wid m4_Awd ifelse(`$2',d,<-) \ |
| 2763 |
from 1/4 between `$3'm`$1'.start and `$3'm`$1'.end \ |
| 2764 |
to 3/4 between `$3'm`$1'.start and `$3'm`$1'.end ') |
| 2765 |
ifelse(eval(`$1'>0),1,`m4bi_Em(eval(`$1'-1),`$2',`$3')')') |
| 2766 |
|
| 2767 |
`Unijunction transistor ujt(linespec, R,P,E) |
| 2768 |
Bulk and terminals B1, B2, E defined |
| 2769 |
arg 2: drawn to the right of curr direction |
| 2770 |
arg 3: P-channel, default N |
| 2771 |
arg 4: envelope' |
| 2772 |
define(`ujt', |
| 2773 |
`[ ifelse(`$1',,,`eleminit_($1)') |
| 2774 |
B1: Here |
| 2775 |
ifelse(`$1',,,`line to rvec_(rp_len/2-m4_U*2,0)') |
| 2776 |
Bl1: line to rvec_(0,ifelse(`$2',R,-)3.5*m4_U) |
| 2777 |
Bulk: line from rvec_(-m4_U*0.5,0) \ |
| 2778 |
to rvec_(m4_U*4.5,0) |
| 2779 |
Bl2: line from Bulk.end+vec_(-m4_U/2,0) \ |
| 2780 |
to Bulk.end+vec_(-m4_U/2,ifelse(`$2',R,,-)3.5*m4_U) ifelse(`$1',,,`\ |
| 2781 |
then to Bulk.c+vec_(rp_len/2,ifelse(`$2',R,,-)3.5*m4_U)') |
| 2782 |
B2: Here |
| 2783 |
E: Bulk.c+vec_(2*m4_U,ifelse(`$2',R,-)3.5*m4_U) |
| 2784 |
E1: line from E to Bulk.center |
| 2785 |
{arrow m4c_l from last line.ifelse(`$3',P,`end to 1',`start to 7')/8 \ |
| 2786 |
between last line.start and last line.end wid m4_Awd ht m4_Aht } |
| 2787 |
ifelse(`$4',E,dnl |
| 2788 |
`Env: circle rad 4*m4_U with .c at Bulk.c') |
| 2789 |
`$5'; manhattan ] ') |
| 2790 |
|
| 2791 |
`FETS: j_fet(linespec, R, P, E ) |
| 2792 |
e_fet(linespec, R, P, E|S ) |
| 2793 |
d_fet(linespec, R, P, E|S ) |
| 2794 |
c_fet(linespec, R, P ) |
| 2795 |
g_fet(linespec, R, P, shade spec ) |
| 2796 |
with terminals S, D, G. |
| 2797 |
arg 2: G pin drawn to right of curr direction |
| 2798 |
arg 3: P-channel, default N |
| 2799 |
arg 4: envelope or simplified' |
| 2800 |
define(`j_fet',`mosfet(`$1',`$2',ifelse(`$3',P,u,d)GSDF,`$4',`$5')') |
| 2801 |
`Enhancement-mode FET e_fet(linespec,R,P,S,E)' |
| 2802 |
define(`e_fet',`mosfet(`$1',`$2', |
| 2803 |
ifelse(`$4',S,`TFD'ifelse(`$3',P,u,d)S,`LEDSQ'ifelse(`$3',P,d,u)B), |
| 2804 |
`$4',`$5')') |
| 2805 |
`Depletion-mode FET d_fet(linespec,R,P,S,E)' |
| 2806 |
define(`d_fet',`mosfet(`$1',`$2', |
| 2807 |
ifelse(`$4',S,`TFDR'ifelse(`$3',P,u,d)S,`LFDSQ'ifelse(`$3',P,d,u)B), |
| 2808 |
`$4',`$5')') |
| 2809 |
`Simplified switching c_fet(linespec,R,P) |
| 2810 |
arg 3: negated G pin' |
| 2811 |
define(`c_fet',`mosfet(`$1',`$2',`ZSDF'ifelse(`$3',P,d)T,,`$4')') |
| 2812 |
|
| 2813 |
`Graphene FET g_fet(linespec,R,P,shadespec)' |
| 2814 |
define(`g_fet',`mosfet(`$1',`$2',ifinstr(`$3',P,d,u)SKTF,`$4',`$5') ') |
| 2815 |
|
| 2816 |
`Fe_fet(linespec,R,chars) FET with |
| 2817 |
superimposed ferroelectric symbol: |
| 2818 |
arg1, arg2, arg3 are as for mosfet' |
| 2819 |
define(`Fe_fet',`mosfet(`$1',`$2',ifelse(`$3',,SDFT,`$3'),, |
| 2820 |
variable(,NN,60,dimen_/3, |
| 2821 |
at (0.5 between S and D)+vec_(0,ifelse(`$2',R,-)4*m4_U)); `$4')') |
| 2822 |
|
| 2823 |
` The comprehensive mosfet(linespec,R,BDEFGHKLMPOQRSTXZ,E) |
| 2824 |
Every drawn component is controlled by a letter or letter pair in arg 3; |
| 2825 |
adding or changing elements is easily done by adding a test for a letter |
| 2826 |
or letter sequence. The modifiers u and d are optional: |
| 2827 |
udB: center bulk connection pin; u or d arrow |
| 2828 |
D: D pin and lead |
| 2829 |
E: dashed substrate |
| 2830 |
F: solid-line substrate |
| 2831 |
udG: G pin to substrate at source; u or d arrow |
| 2832 |
udH: G pin to substrate at center; u or d arrow |
| 2833 |
K: graphene hexagon |
| 2834 |
L: G pin to channel (kept for compatibility |
| 2835 |
for now; the same as dM below) |
| 2836 |
udM: G pin to channel center or |
| 2837 |
u: pin at drain end, d: pin at source end |
| 2838 |
udMn: gates G0 to Gn as above |
| 2839 |
dPy: parallel diode, d=reverse direction |
| 2840 |
dPz: parallel zener diode, d=reverse direction |
| 2841 |
O: connection dots on parallel diode |
| 2842 |
Q: connect B pin to S pin |
| 2843 |
R: thick channel |
| 2844 |
udS: S pin and lead; u or d arrow |
| 2845 |
dT: G pin to center of channel d: not circle |
| 2846 |
X: XMOSFET terminal |
| 2847 |
Z: simplified complementary MOS |
| 2848 |
arg 2: body drawn to right of curr direction |
| 2849 |
arg 4: envelope' |
| 2850 |
define(`mosfet', |
| 2851 |
`define(`m4R',`ifelse(`$2',R,-)')dnl right orientation flag |
| 2852 |
define(`dna_',`ifelse(`$3',,DSEdMuBQ,`$3')@')dnl |
| 2853 |
define(`m4s',ifinstr(dna_,Z,2.5,3.5))dnl size parameter |
| 2854 |
define(`m4hs',2.5)define(`m4hhx',m4hs*sqrt(3))dnl hex side len |
| 2855 |
define(`m4K',ifinstr(dna_,K,K))dnl |
| 2856 |
[ ifelse(`$1',, |
| 2857 |
`tr_xy_init(,m4_U,m4R); ifinstr(dna_,K, |
| 2858 |
`S: tr_xy(-m4hs,0); D: tr_xy(m4hs,0); W: S; E: D |
| 2859 |
tr_xy_init(tr_xy(0,m4hhx/2-m4s),m4_U,m4R)', |
| 2860 |
`S: tr_xy(-2,0); D: tr_xy(2,0)') ', |
| 2861 |
`eleminit_(`$1'); tr_xy_init(last line.c,m4_U,m4R) |
| 2862 |
ifinstr(dna_,K, |
| 2863 |
`S: last line.start; D: last line.end; |
| 2864 |
W: tr_xy(-m4hs,0); line from S to W |
| 2865 |
E: tr_xy( m4hs,0); line from D to E |
| 2866 |
tr_xy_init(tr_xy(0,m4hhx/2-m4s),m4_U,m4R)', |
| 2867 |
`S: last line.start; line from S to tr_xy(-2,0) \ |
| 2868 |
then to tr_xy(-2,0)+vec_(0,m4R`'lthick) |
| 2869 |
D: S+vec_(rp_len,0); line from D to tr_xy(2,0) \ |
| 2870 |
then to tr_xy(2,0)+vec_(0,m4R`'lthick)')') |
| 2871 |
sc_draw(`dna_',B, |
| 2872 |
`B: tr_xy(0,0); Bl: line from B to tr_xy(0,m4s) |
| 2873 |
ifelse(m4a,,,`arrow m4c_l ht m4_Aht wid m4_Awd ifelse(m4a,d,<-) \ |
| 2874 |
from tr_xy(0,m4s/2)-vec_(0,m4R`'m4_Aht/2) \ |
| 2875 |
to tr_xy(0,m4s/2)+vec_(0,m4R`'m4_Aht/2) ')') |
| 2876 |
sc_draw(`dna_',D, |
| 2877 |
`Dl: line from tr_xy(2,0) \ |
| 2878 |
to tr_xy(2,m4s)') |
| 2879 |
sc_draw(`dna_',E, |
| 2880 |
`Channel: line invis from tr_xy(-2.5,m4s) \ |
| 2881 |
to tr_xy(2.5,m4s) |
| 2882 |
line from tr_xy(-2.5,m4s) \ |
| 2883 |
to tr_xy(-1,m4s) |
| 2884 |
line from tr_xy(-0.5,m4s) \ |
| 2885 |
to tr_xy(0.5,m4s) |
| 2886 |
line from tr_xy(1,m4s) \ |
| 2887 |
to tr_xy(2.5,m4s)') |
| 2888 |
sc_draw(`dna_',F, |
| 2889 |
`Channel: line from ifinstr(dna_,Z, |
| 2890 |
`tr_xy(-2,m4s) \ |
| 2891 |
to tr_xy(2,m4s)', |
| 2892 |
`tr_xy(-2.5,m4s) \ |
| 2893 |
to tr_xy(2.5,m4s)')') |
| 2894 |
sc_draw(`dna_',G, |
| 2895 |
`G: tr_xy(-2,(m4s+3.5)) |
| 2896 |
ifelse(m4a,,`Gl: line from tr_xy(-2,m4s) \ |
| 2897 |
to G', |
| 2898 |
m4a,d,`Gl: arrow m4c_l from G to tr_xy(-2,m4s) ht m4_Aht wid m4_Awd', |
| 2899 |
m4a,u,`Gl: line from tr_xy(-2,m4s) \ |
| 2900 |
to G; arrow m4c_l ht m4_Aht wid m4_Awd \ |
| 2901 |
from tr_xy(-2,(m4s+3-m4_Aht/(m4_U))) \ |
| 2902 |
to tr_xy(-2,(m4s+3))')') |
| 2903 |
sc_draw(`dna_',H, |
| 2904 |
`G: tr_xy(0,(m4s+4)) |
| 2905 |
ifelse(m4a,,`Hl: line from tr_xy(0,m4s) \ |
| 2906 |
to G', |
| 2907 |
m4a,d,`Hl: arrow m4c_l from G to tr_xy(0,m4s) ht m4_Aht wid m4_Awd', |
| 2908 |
m4a,u,`Hl: line from tr_xy(0,m4s) \ |
| 2909 |
to G; arrow m4c_l ht m4_Aht wid m4_Awd \ |
| 2910 |
from tr_xy(0,(m4s+3-m4_Aht/(m4_U))) \ |
| 2911 |
to tr_xy(0,(m4s+3))')') |
| 2912 |
sc_draw(`dna_',K, |
| 2913 |
`NW: W+ta_xy( m4hs/2, m4hhx/2) |
| 2914 |
SW: W+ta_xy( m4hs/2,-m4hhx/2) |
| 2915 |
SE: E+ta_xy(-m4hs/2,-m4hhx/2) |
| 2916 |
NE: E+ta_xy(-m4hs/2, m4hhx/2) |
| 2917 |
Kl: line from NW \ |
| 2918 |
to W then to SW then to SE then to E then to NE then to NW `$4'') |
| 2919 |
sc_draw(`dna_',L, |
| 2920 |
`G: tr_xy(-2,(m4s+3.5)) |
| 2921 |
Ll: line from tr_xy(2,(m4s+1)) \ |
| 2922 |
to tr_xy(-2,(m4s+1)) \ |
| 2923 |
then to G') |
| 2924 |
for_(1,4,1, |
| 2925 |
`sc_draw(`dna_',M`'m4x,`m4mo_Mm(m4x,m4a,`$4',ifinstr(dna_,Z,2,2.5))')') |
| 2926 |
sc_draw(`dna_',M,`ifelse( |
| 2927 |
m4a,, `G: tr_xy(0,(m4s+4)) |
| 2928 |
Glh: line from tr_xy(2,(m4s+1)) \ |
| 2929 |
to tr_xy(-2,(m4s+1)) |
| 2930 |
Glv: line from tr_xy(0,(m4s+1)) \ |
| 2931 |
to G', |
| 2932 |
m4a,u,`G: tr_xy(2,(m4s+3.5)) |
| 2933 |
Gl: line from tr_xy(-2,(m4s+1)) \ |
| 2934 |
to tr_xy(2,(m4s+1)) \ |
| 2935 |
then to G', |
| 2936 |
m4a,d,`G: tr_xy(-2,(m4s+3.5)) |
| 2937 |
Gl: line from tr_xy(2,(m4s+1)) \ |
| 2938 |
to tr_xy(-2,(m4s+1)) \ |
| 2939 |
then to G')') |
| 2940 |
sc_draw(`dna_',Py,`pushdef(`m4pdd_mosfet')') |
| 2941 |
sc_draw(`dna_',Pz,`pushdef(`m4pdd_mosfet',Z)') |
| 2942 |
ifdef(`m4pdd_mosfet', |
| 2943 |
`define(`m4q',m4a)dnl |
| 2944 |
Diode: diode(ifelse(m4q,d,to,from) tr_xy(-2,-2) \ |
| 2945 |
ifelse(m4q,d,from,to) tr_xy( 2,-2),m4pdd_mosfet) |
| 2946 |
ifelse(m4q,d,rp_ang = rp_ang + pi_) |
| 2947 |
sc_draw(`dna_',O,`{dot(at tr_xy(-2,0)); dot(at tr_xy(2,0))}') |
| 2948 |
line from tr_xy(-2,0) \ |
| 2949 |
to tr_xy(-2,-2) \ |
| 2950 |
then to tr_xy(2,-2) \ |
| 2951 |
then to tr_xy(2,0) |
| 2952 |
popdef(`m4pdd_mosfet')') |
| 2953 |
sc_draw(`dna_',Q, |
| 2954 |
`Ql: line from tr_xy(0,0)+vec_(0,m4R`'lthick) \ |
| 2955 |
to tr_xy(0,0) \ |
| 2956 |
then to tr_xy(-2,0) \ |
| 2957 |
then to tr_xy(-2,0)+vec_(0,m4R`'lthick)') |
| 2958 |
sc_draw(`dna_',R, |
| 2959 |
`Rl: line thick 2*linethick from tr_xy(-2,m4s)\ |
| 2960 |
-vec_(0,m4R`'lthick*3/2) \ |
| 2961 |
to tr_xy(2,m4s)-vec_(0,m4R`'lthick*3/2) ') |
| 2962 |
sc_draw(`dna_',S,`ifelse(m4K,K, |
| 2963 |
`Sl: arrow m4c_l ht m4_Aht*2/3 wid m4_Awd \ |
| 2964 |
from ifelse(m4a,u,NW to W,W to NW)', |
| 2965 |
`Sl: line from tr_xy(-2,0) \ |
| 2966 |
to tr_xy(-2,m4s) |
| 2967 |
ifelse(m4a,,,`arrow m4c_l ht m4_Aht wid m4_Awd ifelse(m4a,d,<-) \ |
| 2968 |
from tr_xy(-2,m4s/2)-vec_(0,m4R`'m4_Aht/2) \ |
| 2969 |
to tr_xy(-2,m4s/2)+vec_(0,m4R`'m4_Aht/2) ')')') |
| 2970 |
sc_draw(`dna_',T, |
| 2971 |
`Tl: line from tr_xy(-2,(m4s+1)) \ |
| 2972 |
to tr_xy(2,(m4s+1)) |
| 2973 |
ifelse(m4a,d,`Nt: circle rad m4_U*2/3 with .c at tr_xy(0,(m4s+1+2/3))') |
| 2974 |
Gl: line from tr_xy(0,`(m4s+1'`ifelse(m4a,d,+4/3))') \ |
| 2975 |
to tr_xy(0,(m4s+4)); G: Here') |
| 2976 |
sc_draw(`dna_',X,dnl From Matteo Agostinelli |
| 2977 |
`B: tr_xy(0,0); Xv: line from B to tr_xy(0,m4s-1) |
| 2978 |
Xh: line from tr_xy(-1.5,m4s-1) \ |
| 2979 |
to tr_xy(1.5,m4s-1)') |
| 2980 |
ifelse(`$4',E,`Env: circle rad 4*m4_U with .c at tr_xy(0,m4s)') |
| 2981 |
`$5'; manhattan ] ') |
| 2982 |
define(`m4mo_Mm',dnl (m4n,m4a,[E]) |
| 2983 |
`define(`m4mo_d',`eval((`$1')*2+1)')dnl |
| 2984 |
for_(0,`$1',1, |
| 2985 |
`define(`m4moc',`ifelse(`$2',u, |
| 2986 |
` (`$4')-`$4'*4*m4x/m4mo_d',`-`$4'+`$4'*4*m4x/m4mo_d')')dnl |
| 2987 |
ifinstr(`$3',E, |
| 2988 |
`M4moM: move from tr_xy(m4moc,m4s) to tr_xy(m4moc,m4s+1) |
| 2989 |
G`'m4x: LCintersect(M4moM,tr_xy(0,m4s),4*m4_U,R)', |
| 2990 |
`G`'m4x: tr_xy(m4moc,m4s+4)') |
| 2991 |
Gm`'m4x: line from G`'m4x to tr_xy(m4moc,m4s+1) \ |
| 2992 |
then to tr_xy(m4moc`'ifelse(`$2',u,-,+)2*`$4'/m4mo_d,m4s+1) ') ') |
| 2993 |
|
| 2994 |
`Macro-internal coordinates adjusted for L|R' |
| 2995 |
define(`ta_xy',`vec_(vscal_(m4_xyU,`$1',ifelse(`$2',0,0,m4_xyS`($2)')))') |
| 2996 |
`Relative adjusted macro-internal coordinates' |
| 2997 |
define(`tr_xy',`M4_xyO+vec_(vscal_(m4_xyU,`$1',ifelse(`$2',0,0,m4_xyS`($2)')))') |
| 2998 |
`Initialize tr_xy_init(origin,unit,-)' |
| 2999 |
define(`tr_xy_init', |
| 3000 |
`M4_xyO: ifelse(`$1',,Here,`$1') |
| 3001 |
define(`m4_xyU',`$2')dnl |
| 3002 |
define(`m4_xyS',`$3')') |
| 3003 |
|
| 3004 |
`Extract substring plus preceding char if u or d' |
| 3005 |
define(`m4_dna',`define(`m4I_',index($1,`$2'))dnl |
| 3006 |
ifelse(m4I_,-1,`define(`m4t',0)',`define(`m4t',eval(m4I_+len($2)))dnl |
| 3007 |
define(`m4a',ifelse(substr($1,decr(m4I_),1),u,`define(`m4I_',decr(m4I_))'u, |
| 3008 |
substr($1,decr(m4I_),1),d,`define(`m4I_',decr(m4I_))'d))dnl |
| 3009 |
define(`$1',substr($1,0,m4I_)`'substr($1,m4t))')')dnl |
| 3010 |
|
| 3011 |
`Conditional subcomponent draw |
| 3012 |
sc_draw(dna string, substring, iftrue, iffalse)' |
| 3013 |
define(`sc_draw',`m4_dna(`$1',`$2')ifelse(m4I_,-1,`$4',`$3')') |
| 3014 |
|
| 3015 |
`(r|l|c)label( label, label, label, |
| 3016 |
relative position, block name ) |
| 3017 |
Element labels at the start, centre, and end |
| 3018 |
of the last [] block (or a named [] block) |
| 3019 |
in the current direction. Labels are |
| 3020 |
spaced and treated as math, but copied |
| 3021 |
literally if double quoted or defined |
| 3022 |
by sprintf. |
| 3023 |
Arg4 can be above, below, left, right |
| 3024 |
to supplement the default position. |
| 3025 |
Arg5 is the optional name of a [] block |
| 3026 |
and is last [] by default.' |
| 3027 |
`The hash (pound sign) is used in svg text so |
| 3028 |
we temporarily turn off comments for svg' |
| 3029 |
define(`rlabel',`ifsvg(`changecom(,)')dnl |
| 3030 |
m4label(`$1',`$2',`$3',.s_,below_,`$4',`$5')`'ifsvg(`changecom(`#',)')') |
| 3031 |
|
| 3032 |
define(`llabel',`ifsvg(`changecom(,)')dnl |
| 3033 |
m4label(`$1',`$2',`$3',.n_,above_,`$4',`$5')`'ifsvg(`changecom(`#',)')') |
| 3034 |
|
| 3035 |
define(`clabel',`ifsvg(`changecom(,)')dnl |
| 3036 |
m4label(`$1',`$2',`$3',,,`$4',`$5')`'ifsvg(`changecom(`#',)')') |
| 3037 |
labels at centre and both ends of an element `dimen_' long |
| 3038 |
define(`m4label',`dnl |
| 3039 |
ifelse(`$1',,, |
| 3040 |
`{m4lstring(`$1',"sp_`'iflatex(`$ `$1'$',`$1')`'sp_") \ |
| 3041 |
at ifelse(`$7',,last [],`$7').w_ $5 rjust_ $6};')dnl |
| 3042 |
ifelse(`$2',,, |
| 3043 |
`{m4lstring(`$2',"sp_`'iflatex(`$ `$2'$',`$2')`'sp_") \ |
| 3044 |
at ifelse(`$7',,last [],`$7')$4 $5 $6};')dnl |
| 3045 |
ifelse(`$3',,, |
| 3046 |
`{m4lstring(`$3',"sp_`'iflatex(`$ `$3'$',`$3')`'sp_") \ |
| 3047 |
at ifelse(`$7',,last [],`$7').e_ $5 ljust_ $6};')dnl |
| 3048 |
') |
| 3049 |
`dlabel(long,lateral,label,label,label,chars) |
| 3050 |
Labels for oblique or aligned elements |
| 3051 |
long, lateral: dispacement from center |
| 3052 |
with respect to drawing direction |
| 3053 |
chars: |
| 3054 |
X displacement is from the centre of the last |
| 3055 |
line rather than the centre of the last [] |
| 3056 |
L,R,A,B align labels ljust, rjust, above, |
| 3057 |
or below (absolute) respectively' |
| 3058 |
define(`dlabel',`ifsvg(`changecom(,)')dnl |
| 3059 |
define(`m4long_',`ifelse(`$1',,`dimen_',`($1)')')dnl |
| 3060 |
define(`m4lat_',`ifelse(`$2',,`10bp__',`($2)')')dnl |
| 3061 |
ifelse(`$3',,, |
| 3062 |
`{m4lstring(`$3',"iflatex(`$ `$3'$',` $3')") \ |
| 3063 |
at last ifinstr(`$6',X,line,[]).c+vec_(-m4long_,m4lat_) \ |
| 3064 |
ifinstr(`$6',L,ljust,`$6',R,rjust) dnl |
| 3065 |
ifinstr(`$6',A,above,`$6',B,below) };') dnl |
| 3066 |
ifelse(`$4',,, |
| 3067 |
`{m4lstring(`$4',"iflatex(`$ `$4'$',` $4')") \ |
| 3068 |
at last ifinstr(`$6',X,line,[]).c+vec_(0,m4lat_) \ |
| 3069 |
ifinstr(`$6',L,ljust,`$6',R,rjust) dnl |
| 3070 |
ifinstr(`$6',A,above,`$6',B,below) };') dnl |
| 3071 |
ifelse(`$5',,, |
| 3072 |
`{m4lstring(`$5',"iflatex(`$ `$5'$',` $5')") \ |
| 3073 |
at last ifinstr(`$6',X,line,[]).c+vec_(m4long_,m4lat_) \ |
| 3074 |
ifinstr(`$6',L,ljust,`$6',R,rjust) dnl |
| 3075 |
ifinstr(`$6',A,above,`$6',B,below) };') ifsvg(`changecom(`#',)')') |
| 3076 |
|
| 3077 |
`eleminit_( linespec, default length ) |
| 3078 |
compute element direction and length. |
| 3079 |
eleminit_ defines the position, length, |
| 3080 |
and angle of two-terminal elements. It calls |
| 3081 |
rpoint_ with its linespec or circuit-element |
| 3082 |
default. The rpoint_ macro draws the invisible |
| 3083 |
line determined by its argument, calculates the |
| 3084 |
length and angle, and gives the angle to the |
| 3085 |
point_ macro to set the rotation parameters used |
| 3086 |
by vec_ and rvec_.' |
| 3087 |
define(`eleminit_', |
| 3088 |
`rpoint_(ifelse(`$1',,`to rvec_(ifelse(`$2',,`elen_',`$2'),0)',`$1'))') |
| 3089 |
|
| 3090 |
`parallel_(`elementspec', `elementspec', ... |
| 3091 |
Parallel combination of two-terminal elements |
| 3092 |
in a [] block. Each elementspec is quoted and |
| 3093 |
of the form |
| 3094 |
[Sep=val;][Label:] element; [attributes] |
| 3095 |
where an attribute is of the form |
| 3096 |
[llabel(...);]|[rlabel(...);][b_current(...);] |
| 3097 |
Sep=val; in the first branch sets the default |
| 3098 |
separation of all branches to val; in a later |
| 3099 |
element Sep=val; applies only to that branch. |
| 3100 |
An element may have normal arguments but should |
| 3101 |
not change the drawing direction. |
| 3102 |
An argument may also be series_(args) or |
| 3103 |
parallel_(args) without attributes or quotes. |
| 3104 |
example: |
| 3105 |
define(`elen_',dimen_) setdir_(Down) |
| 3106 |
parallel_( |
| 3107 |
`resistor;llabel(,R);inductor(,W);llabel(,L)', |
| 3108 |
`capacitor;rlabel(,C)') |
| 3109 |
' |
| 3110 |
define(`parallel_', |
| 3111 |
`[ ifdef(`m4rp_ang',rp_ang = m4rp_ang;) pwid = 0 |
| 3112 |
stackargs_(`m4parR',$@) stackexec_(`m4parR',`m4parS')dnl |
| 3113 |
define(`m4br',0) define(`m4parsep',`m4sepdefault')dnl |
| 3114 |
stackdo_(`m4parS', |
| 3115 |
`define(`m4pel',m4parS) |
| 3116 |
pushkey_(m4pel,Sep,m4parsep)dnl |
| 3117 |
ifelse(m4br,0,`define(`m4parsep',m4Sep)')dnl |
| 3118 |
ifinstr(m4pel,Sep=,`define(`m4pel',substr(m4pel,eval(index(m4pel,;)+1)))') |
| 3119 |
E`'eval(m4br+1): [ |
| 3120 |
Start: Here |
| 3121 |
m4pel |
| 3122 |
End: Here |
| 3123 |
C: 0.5 between Start and End |
| 3124 |
] ifelse(m4br,0,,`with .C at C`'m4br-vec_(0,m4Sep)') |
| 3125 |
define(`m4br',incr(m4br))dnl |
| 3126 |
Start`'m4br: E`'m4br.Start; End`'m4br: E`'m4br.End; C`'m4br: E`'m4br.C |
| 3127 |
pwid = max(pwid,distance(Start`'m4br,End`'m4br)) |
| 3128 |
') |
| 3129 |
U: Vdiff_(End1,Start1) |
| 3130 |
d = vlength(U.x,U.y); if d==0 then { d=1 } else { d = 1/d } |
| 3131 |
Unit: Vsprod_(U,d) |
| 3132 |
line from C1-(Vsprod_(Unit,pwid/2)) to C`'m4br-(Vsprod_(Unit,pwid/2)) \ |
| 3133 |
chop -lthick/2 |
| 3134 |
Start: last line.c |
| 3135 |
line from C1+Vsprod_(Unit,pwid/2) to C`'m4br+Vsprod_(Unit,pwid/2) \ |
| 3136 |
chop -lthick/2 |
| 3137 |
End: last line.c; C: 0.5 between Start and End |
| 3138 |
for_(1,m4br,1,` |
| 3139 |
line from Start`'m4x to C`'m4x-Vsprod_(Unit,pwid/2) |
| 3140 |
line from End`'m4x to C`'m4x+Vsprod_(Unit,pwid/2)') |
| 3141 |
] with .Start at Here; move to last [].End |
| 3142 |
') |
| 3143 |
|
| 3144 |
define(`m4sepdefault',`dimen_') `Default separation in the parallel_ macro' |
| 3145 |
define(`m4lendefault',`dimen_') `Default length in the series_ macro' |
| 3146 |
|
| 3147 |
`series_(elementspec, elementspec, ... ) |
| 3148 |
Series combination in a [] block of elements |
| 3149 |
with shortened default length |
| 3150 |
An elementspec is of the form |
| 3151 |
[Label:] element; [attributes] |
| 3152 |
where an attribute is of the form |
| 3153 |
[llabel(...);]|[rlabel(...);][b_current(...);] |
| 3154 |
Internal points Start, End, and C are defined |
| 3155 |
automatically.' |
| 3156 |
define(`series_', |
| 3157 |
`[ pushdef(`elen_',m4lendefault)dnl |
| 3158 |
stackargs_(`m4serR',$@) stackexec_(`m4serR',`m4serS')dnl |
| 3159 |
ifdef(`m4rp_ang',rp_ang = m4rp_ang;) Start: Here |
| 3160 |
stackdo_(`m4serS',`m4serS |
| 3161 |
') End: Here; |
| 3162 |
C: 0.5 between Start and End |
| 3163 |
popdef(`elen_')] with .Start at Here; move to last [].End |
| 3164 |
') |
| 3165 |
|
| 3166 |
`reversed(`macro name in quotes', macro args) |
| 3167 |
reverse polarity of two-terminal element' |
| 3168 |
define(`reversed',`eleminit_(`$2') |
| 3169 |
$1(from last line.end to last line.start,shift(shift($@))) |
| 3170 |
rp_ht = -rp_ht; rp_wid = -rp_wid; rp_ang = rp_ang - pi_ |
| 3171 |
line invis to last line.start ') |
| 3172 |
|
| 3173 |
`resized(factor,`macro name in quotes',args) |
| 3174 |
multiply element body size by factor' |
| 3175 |
define(`resized',`pushdef(`dimen_',(dimen_)*(`$1'))dnl |
| 3176 |
$2(shift(shift($@))) popdef(`dimen_')') |
| 3177 |
|
| 3178 |
`variable(`element', type, [+|-]angle, |
| 3179 |
length, at position) |
| 3180 |
overlaid arrow or line on two-terminal element |
| 3181 |
to show variablility: |
| 3182 |
type = [A|P|L|[u]N|[u]NN][C|S] |
| 3183 |
A=arrow; P=preset; L=linear; N=nonlinear; |
| 3184 |
NN=symmetric nonlinear, u changes direction; |
| 3185 |
C=continuous; S=setpwise. |
| 3186 |
If arg3 begins with + or -, then the argument |
| 3187 |
(typically -45) is relative to the current |
| 3188 |
drawing angle. If arg5 is blank the symbol |
| 3189 |
is placed over the last []' |
| 3190 |
define(`variable',`$1 |
| 3191 |
{[ define(`dna_',ifelse($2,,A,$2)`')define(`m4sgn',regexp(`$3',^ *[+-]))dnl |
| 3192 |
ang = ifelse(m4sgn,-1,,rp_ang*rtod_) ifelse(`$3',,45,`$3') |
| 3193 |
define(`m4a2',`ifelse(m4sgn,0,rp_ang-pi_/2,0)') dnl |
| 3194 |
define(`m4a3',`ifelse(m4sgn,0,rp_ang,pi_/2)') dnl |
| 3195 |
define(`m4tip',`dimen_/8')dnl |
| 3196 |
T: (Rect_(ifelse(`$4',,`dimen_*0.8',`$4'),ang)) |
| 3197 |
sc_draw(`dna_',P,`Line: line to T; C: Line.c |
| 3198 |
[line to (Rect_(m4tip,ang-90))] at Line.end') |
| 3199 |
sc_draw(`dna_',L,`Line: line to T; C: Line.c') |
| 3200 |
sc_draw(`dna_',NN,`C: 1/2 between Here and T |
| 3201 |
ifelse(m4a,u,`Line: line from Here+(rect_(-m4tip,m4a3)) to Here \ |
| 3202 |
then to T then to T+(rect_( m4tip,m4a3))', |
| 3203 |
`Line: line from Here+(rect_(-m4tip,m4a2)) to Here \ |
| 3204 |
then to T then to T+(rect_( m4tip,m4a2))')') |
| 3205 |
sc_draw(`dna_',N,`C: 1/2 between Here and T |
| 3206 |
ifelse(m4a,u,`Line: line to T then to T+(rect_(m4tip,m4a3))', |
| 3207 |
`Line: line from T to Here \ |
| 3208 |
then to Here+(rect_(-m4tip,m4a2))')') |
| 3209 |
sc_draw(`dna_',A,`Line: arrow to T; C: Line.c') |
| 3210 |
sc_draw(`dna_',C,`move to T+(dimen_*0.10,-dimen_*0.06) |
| 3211 |
line to Here+(Rect_(m4tip,ang))') |
| 3212 |
sc_draw(`dna_',S,`move to T+(dimen_*0.10,-dimen_*0.12) |
| 3213 |
line up dimen_*0.06 then right dimen_*0.12 then up dimen_*0.06') |
| 3214 |
`$6'] with .C ifelse(`$5',,at last [].c,`$5') } ') |
| 3215 |
|
| 3216 |
`Line hopping over named ordered lines, |
| 3217 |
diverting left or right: |
| 3218 |
crossover(linespec, |
| 3219 |
[L|R][:line attributes], |
| 3220 |
line_name,line_name,...) |
| 3221 |
attributes are outlined "color" dotted ... |
| 3222 |
#define(`hoprad_',`dimen_/12')' |
| 3223 |
define(`crossover',`eleminit_(`$1') |
| 3224 |
define(`m4attribs',ifinstr(`$2',:,`patsubst(`$2',^.*:)'))dnl |
| 3225 |
define(`m4divert',`patsubst(`$2',:.*)')dnl |
| 3226 |
define(`m4_lt2',`ifelse(ifpstricks(T)`'ifmpost(T)`'ifpgf(T)`'ifsvg(T),T, |
| 3227 |
`hlth',0)')dnl |
| 3228 |
M4Start: last line.start; M4End: last line.end |
| 3229 |
Loopover_(`M4',`line m4attribs to intersect_(M4Start,M4End,M4.start,M4.end) \ |
| 3230 |
chop 0 chop hoprad_-m4_lt2 |
| 3231 |
ifelse(`m4_lt2',0,,`move to rvec_(-m4_lt2,0)') |
| 3232 |
arc m4attribs ifelse(m4divert,R,c)cw to rvec_(2*hoprad_,0) \ |
| 3233 |
with .c at rvec_(hoprad_,0) |
| 3234 |
ifelse(`m4_lt2',0,,`move to rvec_(-m4_lt2,0)')', shift(shift($@))) |
| 3235 |
line m4attribs to M4End ') |
| 3236 |
|
| 3237 |
`NPDT(npoles,chars) Double throw switch |
| 3238 |
chars: |
| 3239 |
R = right orientation' |
| 3240 |
define(`NPDT',`[define(`m4np',`ifelse(`$1',,1,`$1')')dnl |
| 3241 |
define(`m4xR',ifinstr(`$2',R,R))define(`m4SR',ifelse(m4xR,R,-))dnl |
| 3242 |
for_(1,m4np,1, |
| 3243 |
`{ L`'ifelse(eval(m4np>1),1,m4x): dot(at rvec_(-dimen_/3,0),,1) } |
| 3244 |
{ X: Here |
| 3245 |
T`'ifelse(eval(m4np>1),1,m4x): circle invis rad dotrad_ at X |
| 3246 |
lswitch(from X to X+vec_(dimen_/3,0),m4xR,D) |
| 3247 |
R`'ifelse(eval(m4np>1),1,m4x): circle invis rad dotrad_ at Here } |
| 3248 |
ifelse(eval(m4x<m4np),1,`move to rvec_(0,m4SR`'dimen_/2)') ') |
| 3249 |
ifelse(eval(m4np>1),1,`move to vec_(dimen_/6,m4SR`'dimen_/10) |
| 3250 |
DL: line dashed to rvec_(0,m4SR`'(m4np-3/4)*dimen_/2)') |
| 3251 |
`$3']') |
| 3252 |
|
| 3253 |
|
| 3254 |
`relay(npoles,chars,attributes) |
| 3255 |
arg1: Number of poles (max 10) |
| 3256 |
chars: |
| 3257 |
any of the relaycoil options and: |
| 3258 |
O = normally open |
| 3259 |
C = normally closed |
| 3260 |
P = three-position |
| 3261 |
none of above = double-throw (default) |
| 3262 |
L = drawn left (default) |
| 3263 |
R = drawn to right of drawing direction |
| 3264 |
Th = thermal ' |
| 3265 |
define(`relay',`[ define(`m4pm',`ifinstr(`$2',R,-)')dnl |
| 3266 |
Coil: relaycoil(`$2',,,,`$3') define(`m4rel',rcdna_) |
| 3267 |
V1: Coil.V1 |
| 3268 |
V2: Coil.V2 |
| 3269 |
sc_draw(m4rel,Th, |
| 3270 |
`{move to Coil #rvec_(-dimen_/8,0) |
| 3271 |
line from rvec_(-dimen_/20,dimen_/6) \ |
| 3272 |
to rvec_(-dimen_/20,dimen_/20) \ |
| 3273 |
then to rvec_(dimen_/20,dimen_/20) \ |
| 3274 |
then to rvec_(dimen_/20,-dimen_/20) \ |
| 3275 |
then to rvec_(-dimen_/20,-dimen_/20) \ |
| 3276 |
then to rvec_(-dimen_/20,-dimen_/6)}') |
| 3277 |
Cs: contacts(ifelse(`$1',,1,`$1'),D`'m4rel) with .O1 at Coil.B2 + \ |
| 3278 |
vec_(ifinstr(m4rel,P,-dimen_/5,0)+dimen_/4,m4pm`'(dimen_/4+dimen_/5)) |
| 3279 |
for_(1,ifelse(`$1',,1,`$1'),1, |
| 3280 |
`P`'m4x: Cs.P`'m4x |
| 3281 |
C`'m4x: Cs.C`'m4x |
| 3282 |
O`'m4x: Cs.O`'m4x') |
| 3283 |
`$4'] ') |
| 3284 |
|
| 3285 |
`contacts(npoles,chars) |
| 3286 |
chars: |
| 3287 |
P= three position |
| 3288 |
O|C= normally open, normally closed (default) |
| 3289 |
R= right orientation (default left) |
| 3290 |
I= open circles for contacts |
| 3291 |
T= T contacts |
| 3292 |
U= U contacts |
| 3293 |
D= dashed line across armatures' |
| 3294 |
`e.g. contacts(1,5,O)' |
| 3295 |
define(`contacts',`[ |
| 3296 |
define(`m4np',`ifelse(`$1',,1,`$1')')dnl |
| 3297 |
ifelse(eval(m4np>10),1,`define(`m4np',10)')dnl |
| 3298 |
for_(1,m4np,1, |
| 3299 |
`K`'m4x: contact(`$2') with .O at Here |
| 3300 |
P`'m4x: circle invis rad dotrad_ at last [].P |
| 3301 |
C`'m4x: last [].C |
| 3302 |
O`'m4x: last [].O |
| 3303 |
ifelse(m4x,m4np,,`move to last[].C+vec_(0,m4pm dimen_/4)')') |
| 3304 |
ifelse(eval(m4np>1),1,`ifinstr(`$2',D, |
| 3305 |
`DL: line dashed from K1.A.c to K`'m4np.A.c chop -dimen_/10')') |
| 3306 |
`$3'] ') |
| 3307 |
|
| 3308 |
`contact(chars [,R]) Relay contact switch |
| 3309 |
Arg 2 deprecated, kept for compatibility |
| 3310 |
chars: |
| 3311 |
O|C= normally open, normally closed (default) |
| 3312 |
I= open dots for contacts |
| 3313 |
X= filled dots |
| 3314 |
P= three position |
| 3315 |
R= right orientation (default left) |
| 3316 |
T= T contacts |
| 3317 |
U = line contact' |
| 3318 |
define(`contact',`[ dnl |
| 3319 |
define(`m4pm',`ifelse(ifinstr(`$1',R,R,`$2',R,R),R,-)')dnl |
| 3320 |
define(`m4dr',`dotrad_')define(`m4TL',dimen_/12)dnl |
| 3321 |
define(`m4fll',`ifinstr(`$1',X,,1)')dnl |
| 3322 |
P: dot(,m4dr,m4fll) |
| 3323 |
T: P+vec_(dimen_/2-dimen_/12,0) |
| 3324 |
ifinstr(`$1',P,`ifinstr( |
| 3325 |
`$1',I, |
| 3326 |
`{C: dot(at T+vec_(0,m4pm`'(dimen_/8+m4dr*2+lthick/2)),m4dr,m4fll)} |
| 3327 |
{O: dot(at T-vec_(0,m4pm`'(dimen_/8+m4dr*2+lthick/2)),m4dr,m4fll)} |
| 3328 |
A: line from P to ifinstr( |
| 3329 |
`$1',O,`(LCtangent(P,O,dotrad_+lthick/2)) chop m4dr chop -m4dr', |
| 3330 |
`$1',C,`(LCtangent(P,C,dotrad_+lthick/2,R)) chop m4dr chop -m4dr', |
| 3331 |
`P+vec_(dimen_/2,0) chop m4dr chop 0')', |
| 3332 |
`$1',U, |
| 3333 |
`{C: T+vec_(m4TL*2,m4pm`'(dimen_/6)) |
| 3334 |
line from C to C-vec_(2*m4TL,0)} |
| 3335 |
{O: T+vec_(m4TL*2,m4pm`'(-dimen_/6)) |
| 3336 |
line from O to O-vec_(2*m4TL,0)} |
| 3337 |
A: line from P to ifinstr( |
| 3338 |
`$1',O,`O-vec_(2*m4TL-dimen_/27,0) chop m4dr chop -m4dr', |
| 3339 |
`$1',C,`C-vec_(2*m4TL-dimen_/27,0) chop m4dr chop -m4dr', |
| 3340 |
`P+vec_(dimen_/2,0) chop m4dr chop 0')', |
| 3341 |
`$1',T, |
| 3342 |
`{CC: T+vec_(0,m4pm`'(dimen_/8+m4TL*2/3)) |
| 3343 |
C: line from CC+vec_(0,-m4TL) to CC+vec_(0,m4TL) } |
| 3344 |
{OO: T-vec_(0,m4pm`'(dimen_/8+m4TL*2/3)) |
| 3345 |
O: line from OO+vec_(0,-m4TL) to OO+vec_(0,m4TL) } |
| 3346 |
A: line from P to ifinstr( |
| 3347 |
`$1',O,`1/6 between O.end and O.start chop m4dr chop -m4dr', |
| 3348 |
`$1',C,`1/6 between C.start and C.end chop m4dr chop -m4dr', |
| 3349 |
`P+vec_(dimen_/2,0) chop m4dr chop 0')', |
| 3350 |
`{AC: arrow m4c_l <- ht dimen_/6 wid dimen_/6 \ |
| 3351 |
from T+vec_(0,m4pm`'dimen_/8) to T+vec_(0,m4pm`'dimen_*3/8) \ |
| 3352 |
then to T+vec_(dimen_/5,m4pm`'dimen_*3/8) |
| 3353 |
C: Here} |
| 3354 |
{AO: arrow m4c_l <- ht dimen_/6 wid dimen_/6 \ |
| 3355 |
from T-vec_(0,m4pm`'dimen_/8) to T+vec_(0,-(m4pm`'dimen_*3/8)) \ |
| 3356 |
then to T+vec_(dimen_/5,-(m4pm`'dimen_*3/8)) |
| 3357 |
O: Here} |
| 3358 |
A: line from P to ifinstr( |
| 3359 |
`$1',O,`AO.start chop m4dr chop -m4dr', |
| 3360 |
`$1',C,`AC.start chop m4dr chop -m4dr', |
| 3361 |
`P+vec_(dimen_/2,0) chop m4dr chop 0')') ', # end of P |
| 3362 |
`A: line from P to P+vec_(dimen_/2,0) chop m4dr chop 0 |
| 3363 |
define(`m4CO', |
| 3364 |
`ifinstr(`$1',C,`ifinstr(`$1',O,O)C',`ifinstr(`$1',O,O,OC)')')dnl |
| 3365 |
ifinstr(m4CO,C, |
| 3366 |
`move to T |
| 3367 |
ifinstr( |
| 3368 |
`$1',I, |
| 3369 |
`{ C: dot(at rvec_(0,m4pm`'(m4dr+lthick/2)),m4dr,m4fll) } |
| 3370 |
ifinstr(m4CO,O,,`O: Here')', |
| 3371 |
`$1',U, |
| 3372 |
`{C: T+vec_(m4TL*2,m4pm`'(dimen_/6)) |
| 3373 |
line from C to C-vec_(2*m4TL,0)} |
| 3374 |
ifinstr(m4CO,O,,`O: Here')', |
| 3375 |
`$1',T, |
| 3376 |
`CC: rvec_(0,m4pm`'(m4TL*2/3)) |
| 3377 |
{ C: line from CC+vec_(0,-m4TL) to CC+(0,m4TL) } |
| 3378 |
ifinstr(m4CO,O,,`O: T') ', |
| 3379 |
`{AC: arrow m4c_l <- ht dimen_/6 wid dimen_/6 \ |
| 3380 |
to rvec_(0,m4pm`'dimen_/4) \ |
| 3381 |
then to rvec_(dimen_/5,m4pm`'dimen_/4) |
| 3382 |
C: Here } |
| 3383 |
O:rvec_(dimen_/5,0)') ') |
| 3384 |
ifinstr(m4CO,O, |
| 3385 |
`move to T+vec_(0,-(m4pm`'dimen_/8)) |
| 3386 |
ifinstr( |
| 3387 |
`$1',I, |
| 3388 |
`{O: dot(at rvec_(0,m4pm`'(-m4dr*2)),m4dr,m4fll) } |
| 3389 |
ifinstr(m4CO,C,,`C: T ')', |
| 3390 |
`$1',U, |
| 3391 |
`{O: T+vec_(m4TL*2,m4pm`'(-dimen_/6)) |
| 3392 |
line from O to O-vec_(2*m4TL,0)} |
| 3393 |
ifinstr(m4CO,C,,`C: T ')', |
| 3394 |
`$1',T, |
| 3395 |
`{ OO: (rvec_(0,m4pm`'(-m4TL*2/3))) |
| 3396 |
O: line from OO+vec_(0,-m4TL) to OO+vec_(0,m4TL)} |
| 3397 |
ifinstr(m4CO,C,,`C: T ')', |
| 3398 |
`{AO: arrow m4c_l <- ht dimen_/6 wid dimen_/6 \ |
| 3399 |
to rvec_(0,-(m4pm`'dimen_/4)) \ |
| 3400 |
then to rvec_(dimen_/5,-(m4pm`'dimen_/4)) |
| 3401 |
O: Here } |
| 3402 |
ifinstr(m4CO,C,,`C: T+vec_(dimen_/5,0)') ') ') |
| 3403 |
') |
| 3404 |
`$3'] ') |
| 3405 |
|
| 3406 |
`relaycoil( chars, wid, ht, U|D|L|R|degrees, |
| 3407 |
attributes ) |
| 3408 |
chars: (see IEC 60617 S00305 - S00319) |
| 3409 |
X or default: external lines from A2 and B2 |
| 3410 |
AX external lines at positions A1,A3 |
| 3411 |
BX external lines at positions B1,B3 |
| 3412 |
NX no lines at positions A1,A2,A3,B1,B2,B3 |
| 3413 |
SO slow operating |
| 3414 |
SOR slow operating and release |
| 3415 |
SR slow release |
| 3416 |
S diagonal slash |
| 3417 |
HS high speed |
| 3418 |
NAC unaffected by AC current |
| 3419 |
AC AC current |
| 3420 |
ML mechanically latched |
| 3421 |
MR mechanically resonant |
| 3422 |
PC pulse counter |
| 3423 |
PO polarized |
| 3424 |
RM remanent |
| 3425 |
RH remanent |
| 3426 |
TH thermal |
| 3427 |
EL electronic' |
| 3428 |
define(`relaycoil',`[ ifelse(`$4',,,`setdir_(`$4')') |
| 3429 |
define(`m4wd',ifelse(`$2',,`dimen_/4',`($2)'))dnl |
| 3430 |
define(`m4ht',ifelse(`$3',,`dimen_/2',`($3)'))dnl |
| 3431 |
define(`m4LL',`ifinstr(`$4',NX,0,dimen_/3)')dnl |
| 3432 |
define(`rcdna_',ifinstr(`$1',AX,,`$1',BX,,`$1',X,,X)`$1')dnl |
| 3433 |
{ lbox( m4wd, m4ht, `$5' ) } |
| 3434 |
{ A1: rvec_(0,m4ht/4) |
| 3435 |
A2: Here; V1: A2 |
| 3436 |
A3: rvec_(0,-m4ht/4) } |
| 3437 |
{ B1: rvec_(m4wd,m4ht/4) |
| 3438 |
B2: rvec_(m4wd,0); V2: B2 |
| 3439 |
B3: rvec_(m4wd,-m4ht/4) } |
| 3440 |
sc_draw(`rcdna_',AX, |
| 3441 |
`{ line from A1 to A1+vec_(-dimen_/3,0); V1: Here |
| 3442 |
line from A3 to A3+vec_(-dimen_/3,0); V2: Here }') |
| 3443 |
sc_draw(`rcdna_',BX, |
| 3444 |
`{ line from B1 to B1+vec_( dimen_/3,0); V1: Here |
| 3445 |
line from B3 to B3+vec_( dimen_/3,0); V2: Here }') |
| 3446 |
sc_draw(`rcdna_',NX) |
| 3447 |
sc_draw(`rcdna_',X, |
| 3448 |
`{ line to rvec_(-dimen_/3,0); V1: Here |
| 3449 |
move to B2; line to rvec_(dimen_/3,0); V2: Here }') |
| 3450 |
sc_draw(`rcdna_',SOR, |
| 3451 |
`{ move to rvec_(0,-(m4ht*5/8)); {lbox(m4wd,m4ht/4)} |
| 3452 |
{line from rvec_(0,-m4ht/8) to rvec_(m4wd, m4ht/8)} |
| 3453 |
{line from rvec_(0, m4ht/8) to rvec_(m4wd,-m4ht/8)} |
| 3454 |
{move to rvec_(0,-(m4ht)*3/8); m4fshade(0,lbox(m4wd,m4ht/4))} |
| 3455 |
{move to rvec_(0,-(m4ht)/8) |
| 3456 |
{line to rvec_(0,-m4ht/8)} |
| 3457 |
{line from rvec_(m4wd,0) to rvec_(m4wd,-m4ht/8)}} }') |
| 3458 |
sc_draw(`rcdna_',SO, |
| 3459 |
`{ move to rvec_(0,-(m4ht*5/8)); {lbox(m4wd,m4ht/4)} |
| 3460 |
{line from rvec_(0,-m4ht/8) to rvec_(m4wd, m4ht/8)} |
| 3461 |
{line from rvec_(0, m4ht/8) to rvec_(m4wd,-m4ht/8)} }') |
| 3462 |
sc_draw(`rcdna_',SR, |
| 3463 |
`{ move to rvec_(0,-(m4ht*5/8)); m4fshade(0,lbox(m4wd,m4ht/4)) }') |
| 3464 |
sc_draw(`rcdna_',HS, |
| 3465 |
`{ move to rvec_(0,-(m4ht*5/8)); lbox(m4wd,m4ht/4) } |
| 3466 |
{ move to rvec_(m4wd/2,-(m4ht/2)); line to rvec_(0,-m4ht/4)} ') |
| 3467 |
sc_draw(`rcdna_',S, |
| 3468 |
`{ line from rvec_(0,m4ht/2) to rvec_(m4wd,-m4ht/2)}') |
| 3469 |
sc_draw(`rcdna_',NAC, |
| 3470 |
`{ m4fshade(0,lbox(m4wd/4,m4ht)) } |
| 3471 |
{ move to rvec_(m4wd*3/4,0); m4fshade(0,lbox(m4wd/4,m4ht)) } ') |
| 3472 |
sc_draw(`rcdna_',AC, |
| 3473 |
`{ move to rvec_(0,-(m4ht*3/4)); { lbox(m4wd,m4ht/2) } |
| 3474 |
move to rvec_(m4wd/2,0) |
| 3475 |
ifgpic( |
| 3476 |
`arc rad m4wd/3 cw from Here-(m4wd*2/3,0) \ |
| 3477 |
to Here with .c at Here-(m4wd/3,0) |
| 3478 |
arc rad m4wd/3 ccw from Here to Here+(m4wd*2/3,0) with .c \ |
| 3479 |
at Here+(m4wd/3,0)', |
| 3480 |
` sinusoid(m4wd/3,twopi_/(m4wd*2/3),pi_/2,-m4wd/3,m4wd/3) \ |
| 3481 |
with .Origin at Here ') }') |
| 3482 |
sc_draw(`rcdna_',ML, |
| 3483 |
`{ move to rvec_(0,-(m4ht*11/16)); { lbox(m4wd,m4ht*3/8) } |
| 3484 |
line from rvec_(0,m4ht*3/16) to rvec_(m4wd/2,-m4ht*3/16) \ |
| 3485 |
then to rvec_(m4wd,m4ht*3/16) } ') |
| 3486 |
sc_draw(`rcdna_',MR, |
| 3487 |
`{ move to rvec_(m4wd/2,m4ht/2) |
| 3488 |
{ m4tmp = rp_ang; dashline(to rvec_(0,m4ht*3/4),,m4ht*3/16,m4ht*3/32) |
| 3489 |
point_(m4tmp)} |
| 3490 |
move to rvec_(0,m4ht*3/8) |
| 3491 |
ifgpic( |
| 3492 |
`arc rad m4wd/2 cw from rvec_(-m4wd/2,0) \ |
| 3493 |
to Here with .c at rvec_(-m4wd/4,-m4wd/4) |
| 3494 |
arc rad m4wd/2 ccw from Here to rvec_(m4wd/2,0) with .c \ |
| 3495 |
at rvec_(m4wd/4,m4wd/4)', |
| 3496 |
`sinusoid(m4wd/6,twopi_/(m4wd),pi_/2,-m4wd/2,m4wd/2) \ |
| 3497 |
with .Origin at Here ') } ') |
| 3498 |
sc_draw(`rcdna_',PC, |
| 3499 |
`{ move to rvec_(0,m4ht/2+m4wd/2) |
| 3500 |
{ lbox(m4wd,m4wd) } |
| 3501 |
circle diam m4wd/2 at rvec_(m4wd/2,0) } ') |
| 3502 |
sc_draw(`rcdna_',PO, |
| 3503 |
`{ move to rvec_(0,-(m4ht*5/8)); { lbox(m4wd,m4ht/4) } |
| 3504 |
m4fshade(0, line to rvec_(0,m4ht/8) \ |
| 3505 |
then to rvec_(m4wd,m4ht/8) \ |
| 3506 |
then to rvec_(m4wd,-m4ht/8) \ |
| 3507 |
then to rvec_(m4wd*3/4,-m4ht/8) \ |
| 3508 |
then to rvec_(m4wd*3/4,0) \ |
| 3509 |
then to rvec_(m4wd/4,0) \ |
| 3510 |
then to rvec_(m4wd/4,-m4ht/8) \ |
| 3511 |
then to rvec_(0,-m4ht/8) \ |
| 3512 |
then to Here) } ') |
| 3513 |
sc_draw(`rcdna_',RM, |
| 3514 |
`{ move to rvec_(0,-(m4ht*5/8)); { lbox(m4wd,m4ht/4) } |
| 3515 |
line from rvec_(0,m4ht/8) to rvec_(m4wd,-m4ht/8) }') |
| 3516 |
sc_draw(`rcdna_',RH, |
| 3517 |
`{ move to rvec_(0,-(m4ht*11/16)); { lbox(m4wd,m4ht*3/8) } |
| 3518 |
line from rvec_(m4wd/4,m4ht/8) \ |
| 3519 |
to rvec_(m4wd/4,m4ht/32) \ |
| 3520 |
to rvec_(m4wd*3/4,-m4ht/32) \ |
| 3521 |
to rvec_(m4wd*3/4,-m4ht/8) }') |
| 3522 |
sc_draw(`rcdna_',TH, |
| 3523 |
`{ line to rvec_(m4wd/4,0) then to rvec_(m4wd/4,m4ht/4) \ |
| 3524 |
then to rvec_(m4wd*3/4,m4ht/4) \ |
| 3525 |
then to rvec_(m4wd*3/4,0) \ |
| 3526 |
then to rvec_(m4wd,0) }') |
| 3527 |
sc_draw(`rcdna_',EL, |
| 3528 |
`{ { line from rvec_(m4wd/4,0) to rvec_(m4wd*3/4,0) } |
| 3529 |
{ line from rvec_(m4wd*3/8,0) to rvec_(m4wd*3/16,m4ht*3/16) } |
| 3530 |
{ line from rvec_(m4wd*5/8,0) to rvec_(m4wd*13/16,m4ht*3/16) } |
| 3531 |
{ line from rvec_(m4wd/2,0) to rvec_(m4wd/2,-m4ht/4) } }') |
| 3532 |
`$6'] ') |
| 3533 |
|
| 3534 |
`reed(linespec,wid,ht,box attributes,[R][C]) |
| 3535 |
Enclosed two-terminal reed contact; |
| 3536 |
R=right orientation; |
| 3537 |
C=closed; |
| 3538 |
e.g. reed(,,dimen_/5,shaded "lightgreen"' |
| 3539 |
define(`reed',`eleminit_(`$1') |
| 3540 |
define(`m4wd',ifelse(`$2',,`dimen_*0.8',`($2)'))dnl |
| 3541 |
define(`m4ht',ifelse(`$3',,`dimen_*0.3',`($3)'))dnl |
| 3542 |
define(`m4ng',`ifinstr(`$5',R,-)')dnl |
| 3543 |
{line to rvec_(max(0,rp_len/2-m4wd/2),0) |
| 3544 |
{rotbox(m4wd,m4ht,$4,r=m4ht/2)} |
| 3545 |
{line to rvec_(m4wd*0.2,0) then to \ |
| 3546 |
rvec_(m4wd*0.6,m4ng`'ifinstr(`$5',C,lthick,m4ht/3))} |
| 3547 |
line from rvec_(m4wd*0.5,0) to rvec_(m4wd,0) |
| 3548 |
line to rvec_(max(0,rp_len/2-m4wd/2),0)} |
| 3549 |
{[box invis ht_ m4ht wid_ m4wd] at rvec_(rp_len/2,0)} |
| 3550 |
line to rvec_(rp_len,0) invis ') |
| 3551 |
|
| 3552 |
`ccoax(at location,M|F,diameter,attributes)' |
| 3553 |
define(`ccoax',`[define(`m4cd',ifelse(`$3',,`dimen_*0.4',`$3'))dnl |
| 3554 |
S: circle diam m4cd `$4' |
| 3555 |
C: circle diam m4cd/3 fill_(ifinstr(`$2',F,1,0)) at S |
| 3556 |
`$5'] with .c ifelse(`$1',,`at Here',`$1')') |
| 3557 |
|
| 3558 |
`tconn( linespec, chars|keys, wid) |
| 3559 |
terminal connector with head in a [] block |
| 3560 |
chars: |
| 3561 |
O=node (circle); OF=filled circle |
| 3562 |
> (default) | >> | < | << | A | AA | M |
| 3563 |
A or AA signify arc or double arc |
| 3564 |
M signifies male bar contact |
| 3565 |
arg3 is head width or circle diam |
| 3566 |
keys: |
| 3567 |
type=chars as above; |
| 3568 |
wdth=expr; head width; |
| 3569 |
lgth=expr; type M head length; |
| 3570 |
sep=expr; double head separation |
| 3571 |
head=attributes; except lgth, wdth' |
| 3572 |
define(`tconn',`eleminit_(`$1',dimen_*3/4) |
| 3573 |
pushkeys_(`$2', |
| 3574 |
`type:m4typ:N; lgth:m4nl; wdth:dimen_/6; sep:dimen_/8; head::N') |
| 3575 |
ifelse(m4type,m4typ,`poppushdef(`m4type',ifelse(`$2',,>,`$2'))')dnl |
| 3576 |
ifelse(m4lgth,(m4nl),`poppushdef(`m4lgth',ifelse(`$3',,(dimen_/2),`($3)/2'))') |
| 3577 |
M4Ss: last line.start; M4Se: last line.end |
| 3578 |
ifelse(ifinstr(m4type,0,O,`ifinstr(m4type,OF,O,m4type)'),O, |
| 3579 |
`{popdef(`m4wdth')pushdef(`m4wdth',ifelse(`$3',,dimen_/5,`$3'))dnl |
| 3580 |
line to last line.end chop 0 chop m4wdth |
| 3581 |
[circle diam m4wdth ifinstr(m4type,OF,`fill_(0)') m4head] \ |
| 3582 |
at rvec_(m4wdth/2,0)}', |
| 3583 |
m4type,AA, |
| 3584 |
`{line to last line.end chop 0 chop m4sep+m4wdth |
| 3585 |
[{A: arc from rvec_(0,m4wdth) to rvec_(0,-m4wdth) with .c at Here m4head} |
| 3586 |
arc from rvec_(m4sep,m4wdth) to rvec_(m4sep,-m4wdth) \ |
| 3587 |
with .c at rvec_(m4sep,0) m4head] with .A.c at rvec_(m4wdth,0) }', |
| 3588 |
m4type,A, |
| 3589 |
`{line to last line.end chop 0 chop m4wdth |
| 3590 |
[A:arc from rvec_(0,m4wdth) to rvec_(0,-m4wdth) with .c at Here m4head] \ |
| 3591 |
with .A.c at rvec_(m4wdth,0) }', |
| 3592 |
m4type,<<, |
| 3593 |
`{line to last line.end chop 0 chop m4sep+m4wdth |
| 3594 |
[S: Here; {line from rvec_(m4wdth,m4wdth) to S \ |
| 3595 |
then to rvec_(m4wdth,-m4wdth) m4head}; move to rvec_(m4sep,0) |
| 3596 |
line from rvec_(m4wdth,m4wdth) to Here then to rvec_(m4wdth,-m4wdth) \ |
| 3597 |
m4head ] with .S at Here }', |
| 3598 |
m4type,<, |
| 3599 |
`{line to last line.end chop 0 chop m4wdth |
| 3600 |
[S: Here; line from rvec_(m4wdth,m4wdth) to S \ |
| 3601 |
then to rvec_(m4wdth,-m4wdth) m4head] with .S at Here }', |
| 3602 |
m4type,>>, |
| 3603 |
`{line to last line.end chop 0 chop m4sep |
| 3604 |
[S: Here; {line from rvec_(-m4wdth,m4wdth) to S \ |
| 3605 |
then to rvec_(-m4wdth,-m4wdth) m4head}; move to rvec_(m4sep,0) |
| 3606 |
line from rvec_(-m4wdth,m4wdth) to Here then to rvec_(-m4wdth,-m4wdth) \ |
| 3607 |
m4head ] with .S at Here }', |
| 3608 |
m4type,M, |
| 3609 |
`{line to last line.end chop 0 chop m4lgth |
| 3610 |
[ S: Here; NW: rvec_(0,m4wdth/2); SW: rvec_(0,-m4wdth/2) |
| 3611 |
NE: rvec_(m4lgth,m4wdth/2); SE: rvec_(m4lgth,-m4wdth/2) |
| 3612 |
L: line thick 0 to NW then to NE then to SE then to SW then to Here \ |
| 3613 |
ifelse(m4head,,fill_(0),m4head) ] with .S at Here}', |
| 3614 |
`{line to last line.end |
| 3615 |
[S: Here; line from rvec_(-m4wdth,m4wdth) to S \ |
| 3616 |
then to rvec_(-m4wdth,-m4wdth) m4head ] with .S at Here }') |
| 3617 |
line invis to M4Se popdef(`m4type',`m4lgth',`m4wdth',`m4sep',`m4head') ') |
| 3618 |
|
| 3619 |
`Pconn( [-]n, U|D|L|R|degrees[:length], chars|keys ) |
| 3620 |
Multiple tconn connectors named T1 to Tn |
| 3621 |
in a [ ] block |
| 3622 |
Negative arg1: reverses contact pin numbers |
| 3623 |
n to 1 instead of 1 to n |
| 3624 |
chars as for tconn: |
| 3625 |
O=node (circle); OF=filled circle |
| 3626 |
> (default) | >> | < | << | A | AA | M |
| 3627 |
A or AA signify arc or double arc |
| 3628 |
M signifies male bar contact |
| 3629 |
keys as for tconn (plus pitch=): |
| 3630 |
type=chars as above; |
| 3631 |
wdth=expr; head width |
| 3632 |
lgth=expr; type M head length |
| 3633 |
sep=expr; double head separation |
| 3634 |
head=attributes; except lgth, wdth |
| 3635 |
pitch=expr; pin separation' |
| 3636 |
define(`Pconn',`[ |
| 3637 |
pushkeys_(`$3', `type:m4typ:N; lgth:dimen_/2; wdth:dimen_/6; |
| 3638 |
sep:dimen_/8; head::N; pitch:m4`'wdth*2') |
| 3639 |
ifelse(m4type,m4typ,`poppushdef(`m4type',ifelse(`$3',,M,`$3'))')dnl |
| 3640 |
setdir_(patsubst(`$2',:.*)) pushdef(`m4pinlen',`regexp(`$2',:\(.*\),\1)')dnl |
| 3641 |
pushdef(`m4m',`ifelse(index(`$1',-),0,-)')dnl |
| 3642 |
pushdef(`m4nn',`ifelse(`$1',,2,index(`$1',-),0,neg_(`$1'),`$1')')dnl |
| 3643 |
for_(1,m4nn,1,`T`'m4x: tconn(ifelse(m4pinlen,,,to rvec_(m4pinlen,0)), |
| 3644 |
ifinstr(`$3',=,`$3',m4type)) |
| 3645 |
ifelse(m4x,m4nn,,`move to T`'m4x.start-vec_(0,m4m`'m4pitch)') ') |
| 3646 |
popdef(`m4type',`m4lgth',`m4wdth',`m4sep',`m4head',`m4pitch',`m4m',`m4nn', |
| 3647 |
`m4pinlen') ]') |
| 3648 |
|
| 3649 |
`tbox( text,wid,ht,<|>|<>,attributes ) |
| 3650 |
Pointed terminal box. |
| 3651 |
text is placed at centre of rectangle in math mode |
| 3652 |
unless it starts with a double quote or sprintf |
| 3653 |
arg4= > point on right end (default) |
| 3654 |
< point on left end; <> both ends |
| 3655 |
Defaults: wid dimen_*2/3 ht dimen_/3 |
| 3656 |
type= eg dotted outlined "red" |
| 3657 |
eg tbox(`$V_2$', 30pt__, 15pt__,,fill_(0.9) )' |
| 3658 |
define(`tbox',`[ define(`m4td',`ifelse(`$4',,>,`$4')') |
| 3659 |
pushdef(`m4tw2',`ifelse(`$2',,(dimen_*0.4),`(($2)/2)')')dnl |
| 3660 |
pushdef(`m4th2',`ifelse(`$3',,(dimen_/6),`(($3)/2)')')dnl |
| 3661 |
N: vec_(0,m4th2) |
| 3662 |
NE: N+vec_(m4tw2 ifinstr(m4td,>,-m4th2),0) |
| 3663 |
E: vec_(m4tw2,0) |
| 3664 |
SE: NE+vec_(0,-m4th2*2) |
| 3665 |
NW: N-vec_(m4tw2 ifinstr(m4td,<,-m4th2),0) |
| 3666 |
W: vec_(-m4tw2,0) |
| 3667 |
SW: NW+vec_(0,-m4th2*2) |
| 3668 |
C: 0.5 between SW and NE |
| 3669 |
line from N to NE ifinstr(m4td,>,then to E) then to SE \ |
| 3670 |
then to SW ifinstr(m4td,<,then to W) then to NW then to N `$5' |
| 3671 |
move to C |
| 3672 |
ifelse(`$1',,,`m4lstring(`$1',`"iflatex(`$ `$1'$',` $1')"')') |
| 3673 |
`$6' popdef(`m4th2') popdef(`m4tw2') ]') |
| 3674 |
|
| 3675 |
`pconnex(R|L|U|D|degrees,chars,attributes) |
| 3676 |
arg1: drawing direction |
| 3677 |
chars: |
| 3678 |
R: right orientation |
| 3679 |
M|F: male, female |
| 3680 |
A[B]|AC: 115V 3-prong, B=box (default), C=circle |
| 3681 |
P: PC connector |
| 3682 |
D: 2-pin connector |
| 3683 |
G[B]|GC: 3-pin, B=default, C=circle |
| 3684 |
J: 110V 2-pin ' |
| 3685 |
define(`pconnex', |
| 3686 |
`[ define(`m4sgn',ifinstr(`$2',F,,-))define(`m4R_',ifinstr(`$2',R,-))dnl |
| 3687 |
setdir_(`$1') |
| 3688 |
define(`m4na_',`ifelse(`$2',,A,`$2')')dnl |
| 3689 |
ifinstr(m4na_,A,` |
| 3690 |
Base: ifinstr(m4na_,AC,`circle diam dimen_ `$3'', |
| 3691 |
`[lbox(dimen_,dimen_,`$3') ]') |
| 3692 |
N: m4pconpin(dimen_/12,dimen_*0.3,m4na_) \ |
| 3693 |
at Base+vec_(m4sgn`'(-dimen_*0.2),m4R_`'dimen_*0.15) |
| 3694 |
H: m4pconpin(dimen_/12,dimen_*0.25,m4na_) \ |
| 3695 |
at Base+vec_(m4sgn`'(dimen_*0.2),m4R_`'dimen_*0.15) |
| 3696 |
gd = dimen_/12 |
| 3697 |
G: [ifelse(ifgpic(T)`'ifinstr(m4na_,F,,T),TT, |
| 3698 |
`circle fill_(m4fill) rad gd at vec_(0,m4R_`'gd/2) |
| 3699 |
box fill_(m4fill) wid 2*gd ht gd at vec_(0,0)', |
| 3700 |
`arc ifinstr(m4na_,R,,c)cw rad gd from vec_(gd,m4R_`'gd/2) \ |
| 3701 |
to vec_(-gd,m4R_`'gd/2) with .c \ |
| 3702 |
at vec_(0,m4R_`'gd/2) ifinstr(m4na_,F,, |
| 3703 |
`ifdef(`r_',`shaded rgbstring(r_,g_,b_)',`fill_(m4fill)')') |
| 3704 |
line from vec_(-gd,m4R_`'gd/2) \ |
| 3705 |
to vec_(-gd,m4R_`'(-gd/2)) \ |
| 3706 |
then to vec_(gd,m4R_`'(-gd/2)) \ |
| 3707 |
then to vec_(gd,m4R_`'gd/2) ifinstr(m4na_,F,, |
| 3708 |
`ifdef(`r_',`shaded rgbstring(r_,g_,b_)',`fill_(m4fill)')')') |
| 3709 |
] at Base+vec_(0,m4R_`'(-dimen_*0.25))', |
| 3710 |
m4na_,P, |
| 3711 |
`wd = dimen_; hd = wd*3/4 |
| 3712 |
Base: [line to vec_(-wd/2,0) \ |
| 3713 |
then to vec_(-wd/2,-hd*2/3) \ |
| 3714 |
then to vec_(-wd/2+hd/3,-hd) \ |
| 3715 |
then to vec_(wd/2-hd/3,-hd) \ |
| 3716 |
then to vec_(wd/2,-hd*2/3) \ |
| 3717 |
then to vec_(wd/2,0) \ |
| 3718 |
then to Here `$3'] |
| 3719 |
N: m4pconpin(dimen_/12,dimen_*0.25,m4na_) \ |
| 3720 |
at Base+vec_(m4sgn`'(-dimen_*0.2),m4R_`'dimen_*0.15) |
| 3721 |
H: m4pconpin(dimen_/12,dimen_*0.25,m4na_) \ |
| 3722 |
at Base+vec_(m4sgn`'(dimen_*0.2),m4R_`'dimen_*0.15) |
| 3723 |
G: m4pconpin(dimen_/12,dimen_*0.20,m4na_) \ |
| 3724 |
at Base+vec_(0,m4R_`'(-dimen_*0.15))', |
| 3725 |
m4na_,D, |
| 3726 |
`wd = dimen_*1.2; hd = wd/2 |
| 3727 |
Base: [rotbox(wd,hd,,r=hd/2,`$3')] |
| 3728 |
H: m4pcrpin(dimen_/6,m4na_) at Base.c+vec_( (wd-hd)/2,0) |
| 3729 |
N: m4pcrpin(dimen_/6,m4na_) at Base.c+vec_(-(wd-hd)/2,0)', |
| 3730 |
m4na_,G, |
| 3731 |
`wd = dimen_*1.3; hd = dimen_*1.2 |
| 3732 |
Base: ifinstr(m4na_,GC,`circle diam wd', |
| 3733 |
`[line to vec_(wd/2,0) \ |
| 3734 |
then to vec_(wd/2,-hd*0.3) \ |
| 3735 |
then to vec_(hd*0.15,-hd) \ |
| 3736 |
then to vec_(-hd*0.15,-hd)\ |
| 3737 |
then to vec_(-wd/2,-hd*0.3) \ |
| 3738 |
then to vec_(-wd/2,0) \ |
| 3739 |
then to Here ]') |
| 3740 |
H: m4pconpin(dimen_*0.25,dimen_/8,m4na_) \ |
| 3741 |
at Base.c+vec_(-dimen_/3,dimen_*0.3) |
| 3742 |
N: m4pconpin(dimen_*0.25,dimen_/8,m4na_) \ |
| 3743 |
at Base.c+vec_( dimen_/3,dimen_*0.3) |
| 3744 |
G: m4pconpin(dimen_/8,dimen_*0.25,m4na_) \ |
| 3745 |
at Base.c+vec_(0,-dimen_/3)', |
| 3746 |
m4na_,J, |
| 3747 |
`wd = dimen_; hd = wd/2 |
| 3748 |
Base: [line to vec_(wd/2,0) \ |
| 3749 |
then to vec_(wd/2,hd) \ |
| 3750 |
then to vec_(-wd/2,hd) \ |
| 3751 |
then to vec_(-wd/2,0) \ |
| 3752 |
then to Here ] |
| 3753 |
H: m4pconpin(dimen_/12,dimen_*0.25,m4na_) at Base.c+vec_( wd/4,0) |
| 3754 |
N: m4pconpin(dimen_/12,dimen_*0.25,m4na_) at Base.c+vec_(-wd/4,0) |
| 3755 |
') |
| 3756 |
`$4' ; resetdir_ ]') |
| 3757 |
define(`m4pconpin',`[ifinstr(`$3',F,`lbox(`$1',`$2')', |
| 3758 |
`m4fshade(m4fill,lbox(`$1',`$2'))')]') |
| 3759 |
define(`m4pcrpin',`[ifinstr(`$2',F,`circle diam `$1'', |
| 3760 |
`m4fshade(m4fill,circle diam `$1')')]') |
| 3761 |
|
| 3762 |
`m4fshade(gray value,closed curve) internal' |
| 3763 |
ifelse(m4picprocessor,gpic, |
| 3764 |
`define(`m4fshade',`shade(ifelse(`$1',,0,`$1'),`$2')')', |
| 3765 |
m4postprocessor,xfig, |
| 3766 |
`define(`m4fshade',``$2' fill ifelse(`$1',,0,`$1')')', |
| 3767 |
`define(`m4fshade',``$2' dnl |
| 3768 |
ifdef(`r_',`shaded rgbstring(r_,g_,b_)',`fill ifelse(`$1',,0,`$1')')')') |
| 3769 |
|
| 3770 |
`Header(1|2,rows,wid,ht,type) |
| 3771 |
arg1: number of columns |
| 3772 |
arg2: pins per column |
| 3773 |
arg3,4: custom wid, ht |
| 3774 |
arg5: eg fill_(0.9)' |
| 3775 |
define(`Header', |
| 3776 |
`[define(`m4Hm',`ifelse(`$2',,2,`$2')')define(`m4Hn',`ifelse(`$1',,1,`$1')')dnl |
| 3777 |
define(`m4Hw',`ifelse(`$3',,`m4Hn*L_unit*3',`($3)')')dnl |
| 3778 |
define(`m4Hh',`ifelse(`$4',,`m4Hm*L_unit*3',`($4)')')dnl |
| 3779 |
Block: rotbox(m4Hw,m4Hh,`$5') |
| 3780 |
define(`m4Hct',1)dnl |
| 3781 |
for_(1,m4Hm,1, |
| 3782 |
`HeaderPin(Block.NW+vec_(L_unit*3/2,-(m4x-1/2)*m4Hh/m4Hm), |
| 3783 |
eval(m4Hct-1), P`'m4Hct,w) define(`m4Hct',incr(m4Hct)) |
| 3784 |
ifelse(m4Hn,2,`HeaderPin(Block.NE+vec_(-L_unit*3/2,-(m4x-1/2)*m4Hh/m4Hm), |
| 3785 |
1, P`'m4Hct,e) define(`m4Hct',incr(m4Hct))') ') |
| 3786 |
`$6' ]') |
| 3787 |
`HeaderPin(location,type,Picname, |
| 3788 |
n|e|s|w,length)' |
| 3789 |
define(`HeaderPin',`define(`m4Hpl',`ifelse(`$5',,`lg_plen*L_unit',`$5')')dnl |
| 3790 |
move to `$1' |
| 3791 |
line to ifelse(`$4',n,`rvec_(0,m4Hpl)', |
| 3792 |
`$4',e,`rvec_(m4Hpl,0)',`$4',s,`rvec_(0,-m4Hpl)',`rvec_(-m4Hpl,0)') |
| 3793 |
ifelse(`$3',,,`$3': Here) |
| 3794 |
ifelse(`$3',,,Pin`$3':) ifelse(`$2',0, |
| 3795 |
`rotbox(L_unit,L_unit,fill_(1))', |
| 3796 |
`circle diam L_unit fill_(1)') at last line.start ') |
| 3797 |
|
| 3798 |
`nport(box specs; other commands, |
| 3799 |
nw,nn,ne,ns, |
| 3800 |
space ratio,pin lgth,style,other commands) |
| 3801 |
Default is a standard-box twoport. Args 2 to 5 are |
| 3802 |
the number of ports to be drawn on w, n, e, s sides. |
| 3803 |
The port pins are named by side, number, and by a or b pin, |
| 3804 |
e.g. W1a, W1b, W2a, ... . Arg 6 specifies the ratio of |
| 3805 |
port width to interport space (default 2), and arg 7 is |
| 3806 |
the pin length. Set arg 8 to N to omit the dots on |
| 3807 |
the port pins. Arguments 1 and 9 allow customizations' |
| 3808 |
define(`nport',`[Box: box `$1' |
| 3809 |
r = ifelse(`$6',,2.0,`$6') |
| 3810 |
plg = ifelse(`$7',,`dimen_/4',`$7') |
| 3811 |
# `West side' |
| 3812 |
define(`m4n',`ifelse(`$2'`$3'`$4'`$5',,1,`$2',,0,`($2)')') |
| 3813 |
d = Box.ht/(m4n*(r+1)+1) |
| 3814 |
move to Box.nw+(0,-d); down_ |
| 3815 |
m4portpins(-plg,d*r,d,W,`$8') |
| 3816 |
# `North side' |
| 3817 |
define(`m4n',`($3)') |
| 3818 |
ifelse(`$3',,,`d = Box.wid/(m4n*(r+1)+1) |
| 3819 |
move to Box.nw+(d,0); right_ |
| 3820 |
m4portpins(plg,d*r,d,N,`$8')') |
| 3821 |
# `East side' |
| 3822 |
define(`m4n',`ifelse(`$2'`$3'`$4'`$5',,1,`$4',,0,`($4)')') |
| 3823 |
d = Box.ht/(m4n*(r+1)+1) |
| 3824 |
move to Box.ne+(0,-d); down_ |
| 3825 |
m4portpins(plg,d*r,d,E,`$8') |
| 3826 |
# `South side' |
| 3827 |
define(`m4n',`($5)') |
| 3828 |
ifelse(`$5',,,`d = Box.wid/(m4n*(r+1)+1) |
| 3829 |
move to Box.sw+(d,0); right_ |
| 3830 |
m4portpins(-plg,d*r,d,S,`$8')') |
| 3831 |
`$9' undefine(`m4n')]') |
| 3832 |
define(`m4portpins',`for_(1,m4n,1, |
| 3833 |
`{ if (`$1' != 0) then { line to rvec_(0,`$1') } |
| 3834 |
`$4'`'m4x`'a: ifelse(xtract(`$5',N),N,Here,`dot') } |
| 3835 |
move to rvec_(`$2',0) |
| 3836 |
{ if (`$1' != 0) then { line to rvec_(0,`$1') } |
| 3837 |
`$4'`'m4x`'b: ifelse(xtract(`$5',N),N,Here,`dot') } |
| 3838 |
ifelse(m4x,m4n,,`move to rvec_(`$3',0)')')') |
| 3839 |
|
| 3840 |
`gyrator(box specs,space ratio,pin lgth,style) |
| 3841 |
Gyrator two-port wrapper for nport |
| 3842 |
e.g. gyrator(ht boxwid invis,,0,N)' |
| 3843 |
define(`gyrator', |
| 3844 |
`define(`m4dna_',ifelse(xtract(`$4',V)`'xtract(`$4',H),,H`$4',`$4')`')dnl |
| 3845 |
sc_draw(`m4dna_',H, |
| 3846 |
`nport(ifelse(`$1',,wid boxht,`$1'),1,,1,,`$2',`$3',`$4', |
| 3847 |
line from (Box,W1a)+(-Box.wid/2,0) \ |
| 3848 |
left -Box.wid/4 then down W1a.y-W1b.y then right -Box.wid/4 |
| 3849 |
arcd(Box+(-Box.wid/4,0),(W1a.y-W1b.y)/3,-90,-270) |
| 3850 |
line from (Box,W1a)+(Box.wid/2,0) \ |
| 3851 |
left Box.wid/4 then down W1a.y-W1b.y then right Box.wid/4 |
| 3852 |
arcd(Box+(Box.wid/4,0),(W1a.y-W1b.y)/3,90,270) |
| 3853 |
`$5')')dnl |
| 3854 |
sc_draw(`m4dna_',V, |
| 3855 |
`nport(ifelse(`$1',,wid boxht,`$1'),,1,,1,`$2',`$3',`$4', |
| 3856 |
line from (N1a,Box)+(0,-Box.ht/2) \ |
| 3857 |
down -Box.ht/4 then right N1b.x-N1a.x then up -Box.ht/4 |
| 3858 |
arcd(Box+(0,-Box.ht/4),(N1b.x-N1a.x)/3,-90+90,-90+270) |
| 3859 |
line from (N1a,Box)+(0,Box.ht/2) \ |
| 3860 |
down Box.ht/4 then right N1b.x-N1a.x then up Box.ht/4 |
| 3861 |
arcd(Box+(0,Box.ht/4),(N1b.x-N1a.x)/3,90+90,90+270) |
| 3862 |
`$5')') ') |
| 3863 |
`proximity(linespec)' |
| 3864 |
define(`proximity',`consource(`$1',P)') |
| 3865 |
`nullator(linespec, wid, ht, attributes)' |
| 3866 |
define(`nullator',`eleminit_(`$1') |
| 3867 |
pushdef(`m4wd',ifelse(`$2',,`dimen_/2',`($2)'))dnl |
| 3868 |
pushdef(`m4ht',ifelse(`$3',,`dimen_/4',`($3)'))dnl |
| 3869 |
{line to rvec_(max(0,rp_len/2-m4wd/2),0) |
| 3870 |
move to rvec_(m4wd/2,0) |
| 3871 |
{ spline ifdpic(0.58) from rvec_(ifdpic(0,-m4wd/20),m4ht/2) \ |
| 3872 |
to rvec_(m4wd/20*3,m4ht/2) \ |
| 3873 |
then to rvec_(m4wd/2,m4ht/4) \ |
| 3874 |
then to rvec_(m4wd/2,-m4ht/4) \ |
| 3875 |
then to rvec_(m4wd/20*3,-m4ht/2) \ |
| 3876 |
then to rvec_(-m4wd/20*3,-m4ht/2) \ |
| 3877 |
then to rvec_(-m4wd/2,-m4ht/4) \ |
| 3878 |
then to rvec_(-m4wd/2,m4ht/4) \ |
| 3879 |
then to rvec_(-m4wd/20*3,m4ht/2) \ |
| 3880 |
then to rvec_(ifdpic(0,m4wd/20),m4ht/2) `$4' |
| 3881 |
} |
| 3882 |
line from rvec_(m4wd/2,0) \ |
| 3883 |
to rvec_(max(0,rp_len/2),0)} |
| 3884 |
{[box invis ht_ m4ht wid_ m4wd] at rvec_(rp_len/2,0)} |
| 3885 |
line to rvec_(rp_len,0) invis popdef(`m4wd',`m4ht') ') |
| 3886 |
`norator(linespec, wid, ht, attributes)' |
| 3887 |
define(`norator',`eleminit_(`$1') |
| 3888 |
pushdef(`m4wd',ifelse(`$2',,`dimen_/2',`($2)'))dnl |
| 3889 |
pushdef(`m4ht',ifelse(`$3',,`dimen_/4',`($3)'))dnl |
| 3890 |
{line to rvec_(max(0,rp_len/2-m4wd/2),0) |
| 3891 |
move to rvec_(m4wd/2,0) |
| 3892 |
for i=-1 to 1 by 2 do { { |
| 3893 |
spline to rvec_(i*m4wd/4,m4ht/2) \ |
| 3894 |
then to rvec_(i*m4wd/2,m4ht/2) \ |
| 3895 |
then to rvec_(i*m4wd/2,-m4ht/2) \ |
| 3896 |
then to rvec_(i*m4wd/4,-m4ht/2) \ |
| 3897 |
then to Here `$4' } } |
| 3898 |
line from rvec_(m4wd/2,0) \ |
| 3899 |
to rvec_(max(0,rp_len/2),0)} |
| 3900 |
{[box invis ht_ m4ht wid_ m4wd] at rvec_(rp_len/2,0)} |
| 3901 |
line to rvec_(rp_len,0) invis popdef(`m4wd',`m4ht') ') |
| 3902 |
|
| 3903 |
`ACsymbol(at position, len, ht, [n:][A]U|D|L|R|degrees, |
| 3904 |
attributes) |
| 3905 |
Arg4: drawing direction (default: current direction) |
| 3906 |
Arg4 contains A: use arcs instead of sinusoid |
| 3907 |
A convenience for drawing a stack of n 1-cycle |
| 3908 |
sinusoids (default 1) |
| 3909 |
e.g. source; ACsymbol(at last [])' |
| 3910 |
define(`ACsymbol',`[ Origin: Here |
| 3911 |
pushdef(`m4range',`ifelse(`$2',,(dimen_/3),`($2)')')dnl |
| 3912 |
pushdef(`m4ACd',`patsubst(ifinstr(`$4',:,`patsubst(`$4',.*:)',`$4'),A)')dnl |
| 3913 |
setdir_(ifelse(m4ACd,,`ifdef(`m4a_',rp_ang*rtod_,0)',m4ACd)) |
| 3914 |
Start: rvec_(-m4range/2,0) |
| 3915 |
End: rvec_( m4range/2,0) |
| 3916 |
pushdef(`m4n',`ifinstr(`$4',:,`eval(patsubst(`$4',:.*))',1)')dnl |
| 3917 |
pushdef(`m4amp',`ifelse(`$3',,`m4range/6',`($3)/2')')dnl |
| 3918 |
for_(1,m4n,1,`move to Origin+vec_(0,((m4n+1)/2-m4x)*m4range/3) |
| 3919 |
ifinstr(ifgpic(A,`$4'),A, |
| 3920 |
`{ S`'m4x: [ Origin: Here |
| 3921 |
{ arc ccw to rvec_(-m4range/2,0) \ |
| 3922 |
with .c at rvec_(-m4range/4,-max(m4range/4-m4amp,0)) } |
| 3923 |
{ arc ccw to rvec_( m4range/2,0) \ |
| 3924 |
with .c at rvec_( m4range/4, max(m4range/4-m4amp,0)) }] dnl |
| 3925 |
with .Origin at Here }', |
| 3926 |
`{ S`'m4x: sinusoid(m4amp,twopi_/m4range,pi_/2, |
| 3927 |
-m4range/2,m4range/2,`$5') with .Origin at Here } ')') |
| 3928 |
`$6'; resetdir_ popdef(`m4amp',`m4n',`m4ACd',`m4range')] dnl |
| 3929 |
with .Origin ifelse(`$1',,`at Here',`$1')') |
| 3930 |
|
| 3931 |
`Deltasymbol(at position, keys, U|D|L|R|degrees, |
| 3932 |
attributes) |
| 3933 |
keys: size=expr; |
| 3934 |
type=C|O (default C for Closed, O means open); |
| 3935 |
Arg3: drawing direction (default: Up)' |
| 3936 |
define(`Deltasymbol',`[ sq3 = sqrt(3) |
| 3937 |
pushkeys_(`$2',size:dimen_/10; type:C:N )dnl |
| 3938 |
setdir_(`$3',U) |
| 3939 |
ifinstr(m4type,C, |
| 3940 |
`line `$4' from vec_(vscal_(m4size,-sq3,0)) to \ |
| 3941 |
vec_(vscal_(m4size,-sq3,1)) then to Here \ |
| 3942 |
then to vec_(vscal_(m4size,-sq3,-1)) \ |
| 3943 |
then to vec_(vscal_(m4size,-sq3,0))', |
| 3944 |
`line `$4' from vec_(vscal_(m4size,-sq3/2,-1/2)) \ |
| 3945 |
to vec_(vscal_(m4size,-sq3,-1)) \ |
| 3946 |
then to vec_(vscal_(m4size,-sq3,1)) \ |
| 3947 |
then to vec_(vscal_(m4size,-sq3/2,1/2)) ') |
| 3948 |
C: vec_(vscal_(m4size,-(sq3+1/sq3)/2,0)); N: C |
| 3949 |
resetdir_ popdef(`m4size',`m4type') ] ifelse(`$1',,`at Here',`$1')') |
| 3950 |
|
| 3951 |
`Ysymbol(at position, keys, U|D|L|R|degrees, attributes) |
| 3952 |
keys: size=expr; type=G[L] (grounded, |
| 3953 |
L puts the ground on the left); |
| 3954 |
Arg3: drawing direction (default: Up)' |
| 3955 |
define(`Ysymbol',`[ sq3 = sqrt(3) |
| 3956 |
pushkeys_(`$2',`size:dimen_/10:; type::N')dnl |
| 3957 |
setdir_(`$3',U) |
| 3958 |
C: Here; N: C |
| 3959 |
line from vec_(vscal_(m4size,-2/sq3,0)) to C |
| 3960 |
{ line `$4' from vec_(vscal_(m4size,1/sq3,1)) to C \ |
| 3961 |
then to vec_(vscal_(m4size,1/sq3,-1)) } |
| 3962 |
ifelse(m4type,,,`line `$4' ifinstr(m4type,L,left_,right_) m4size*3/2 |
| 3963 |
corner(,`$4'); pushdef(`dimen_',m4size*4) ground popdef(`dimen_') ') |
| 3964 |
`$5'; resetdir_ popdef(`m4size',`m4type') ] ifelse(`$1',,`at Here',`$1')') |
| 3965 |
`Wyesymbol(at position, keys, U|D|L|R|degrees) |
| 3966 |
Synonym for Ysymbol' |
| 3967 |
define(`Wyesymbol',`Ysymbol($@)') |
| 3968 |
|
| 3969 |
`DCsymbol(at position, len, ht, U|D|L|R|degrees, |
| 3970 |
attributes) |
| 3971 |
Arg4: drawing direction (default: current direction)' |
| 3972 |
define(`DCsymbol',`[ |
| 3973 |
pushdef(`m4wid',`ifelse(`$2',,(dimen_/3),`($2)')')dnl |
| 3974 |
pushdef(`m4ht',`ifelse(`$3',,`(m4wid/5)',`($3)')') |
| 3975 |
setdir_(ifelse(`$4',,`ifdef(`m4a_',rp_ang*rtod_,0)',`$4')) |
| 3976 |
Origin: rvec_(m4wid/2, m4ht/2) |
| 3977 |
{line `$5' to rvec_(m4wid,0)} |
| 3978 |
dashline(from rvec_(0, m4ht) to rvec_(m4wid, m4ht),`$5',m4wid/4,m4wid/8) |
| 3979 |
`$6'; resetdir_ popdef(`m4ht',`m4wid') ] \ |
| 3980 |
with .Origin ifelse(`$1',,`at Here',`$1')') |
| 3981 |
|
| 3982 |
`n-terminal box |
| 3983 |
nterm(box specs; other commands, |
| 3984 |
nw,nn,ne,ns, |
| 3985 |
pin lgth,style,other commands) |
| 3986 |
The default is three-terminal. Args 2 to 5 are |
| 3987 |
the number of pins to be drawn on W, N, E, S sides. |
| 3988 |
The pins are named by side and number, e.g. W1, W2, N1, ... |
| 3989 |
Arg 6 is the pin length. Set arg 7 to N to omit the dots |
| 3990 |
on the pins. Arguments 1 and 8 allow customizations, e.g. |
| 3991 |
nterm(,,,,,,N, |
| 3992 |
"$a$" at Box.w ljust |
| 3993 |
"$b$" at Box.e rjust |
| 3994 |
"$c$" at Box.s above) ' |
| 3995 |
define(`nterm',`[Box: box ifelse(`$1',,wid dimen_ ht dimen_*2/3,`$1') |
| 3996 |
plg = ifelse(`$6',,`dimen_/4',`$6') |
| 3997 |
# `West side' |
| 3998 |
define(`m4n',`ifelse(`$2'`$3'`$4'`$5',,1,`$2',,0,`($2)')') |
| 3999 |
d = Box.ht/(m4n+1) |
| 4000 |
move to Box.nw+(0,-d); down_ |
| 4001 |
m4termpins(-plg,d,W,`$7') |
| 4002 |
# `North side' |
| 4003 |
define(`m4n',`($3)') ifelse(`$3',,, |
| 4004 |
`d = Box.wid/(m4n+1) |
| 4005 |
move to Box.nw+(d,0); right_ |
| 4006 |
m4termpins(plg,d,N,`$7')') |
| 4007 |
# `East side' |
| 4008 |
define(`m4n',`ifelse(`$2'`$3'`$4'`$5',,1,`$4',,0,`($4)')') |
| 4009 |
d = Box.ht/(m4n+1) |
| 4010 |
move to Box.ne+(0,-d); down_ |
| 4011 |
m4termpins(plg,d,E,`$7') |
| 4012 |
# `South side' |
| 4013 |
define(`m4n',`ifelse(`$2'`$3'`$4'`$5',,1,`$5',,0,`($5)')') |
| 4014 |
d = Box.wid/(m4n+1) |
| 4015 |
move to Box.sw+(d,0); right_ |
| 4016 |
m4termpins(-plg,d,S,`$7') |
| 4017 |
`$8' undefine(`m4n')]') |
| 4018 |
define(`m4termpins',`for_(1,m4n,1, |
| 4019 |
`{ if (`$1' != 0) then { line to rvec_(0,`$1') } |
| 4020 |
`$3'`'m4x: ifelse(xtract(`$4',N),N,Here,`dot') } |
| 4021 |
ifelse(m4x,m4n,,`move to rvec_(`$2',0)')')') |
| 4022 |
|
| 4023 |
`speaker(U|D|L|R|degrees, vert size, type, attributes) |
| 4024 |
type=H horn' |
| 4025 |
define(`speaker',`[setdir_($1,R) |
| 4026 |
pushdef(`m4v',`ifelse(`$2',,`dimen_/3',`($2)/4')')dnl |
| 4027 |
pushdef(`m4h',`m4v*sqrt(2)')dnl |
| 4028 |
ifelse(`$3',H, |
| 4029 |
`{H1: line from rvec_(m4h,m4v/2) \ |
| 4030 |
to rvec_(m4h*3/2,m4v*7/8) \ |
| 4031 |
then to rvec_(m4h*3/2,-m4v*7/8) \ |
| 4032 |
then to rvec_(m4h,-m4v/2) `$4'}', |
| 4033 |
`{H1: line from rvec_(m4h,m4v) \ |
| 4034 |
to rvec_(m4h*2,m4v*2) \ |
| 4035 |
then to rvec_(m4h*2,-m4v*2) \ |
| 4036 |
then to rvec_(m4h,-m4v) `$4'}') |
| 4037 |
{lbox(m4h,m4v*2,`$4')} |
| 4038 |
{Box: box invis ht_ m4v*2 wid_ m4h at rvec_(m4h/2,0)} |
| 4039 |
In1: rvec_(0,m4v/2) |
| 4040 |
In2: Here |
| 4041 |
In3: rvec_(0,-m4v/2) |
| 4042 |
In4: rvec_(m4h/4,m4v) |
| 4043 |
In5: rvec_(m4h*3/4,m4v) |
| 4044 |
In6: rvec_(m4h/4,-m4v) |
| 4045 |
In7: rvec_(m4h*3/4,-m4v) |
| 4046 |
`$5'; resetdir_ popdef(`m4v',`m4h') ]') |
| 4047 |
|
| 4048 |
`bell(U|D|L|R|degrees, vert size, attributes)' |
| 4049 |
define(`bell',`[setdir_($1,R) |
| 4050 |
pushdef(`m4h',`ifelse(`$2',,`dimen_/2',`($2)')')dnl |
| 4051 |
{lbox(m4h,m4h,`$3')} |
| 4052 |
{Box: box invis ht_ m4h wid_ m4h at rvec_(m4h/2,0)} |
| 4053 |
{Circle: circle diameter m4h at rvec_(m4h*3/2,0) `$3'} |
| 4054 |
In1: rvec_(0,m4h/4) |
| 4055 |
In2: Here |
| 4056 |
In3: rvec_(0,-m4h/4) |
| 4057 |
`$4'; resetdir_ popdef(`m4h') ]') |
| 4058 |
`microphone(A|U|D|L|R|degrees, vert size, |
| 4059 |
attributes) |
| 4060 |
Arg1= A, upright mic |
| 4061 |
Thanks to Arnold Knott' |
| 4062 |
define(`microphone',`ifinstr(`$1',A, |
| 4063 |
`[ pushdef(`m4sfact',`(ifelse(`$2',,dimen_,(`$2'))*8/5)') |
| 4064 |
circlerad = m4sfact/1000 |
| 4065 |
cspace = m4sfact/100 |
| 4066 |
bwd = m4sfact/10 |
| 4067 |
bht = m4sfact/4+bwd |
| 4068 |
Stand: line up m4sfact/5 |
| 4069 |
{ arc from Here+(-bwd,bwd) to Here+(bwd,bwd) with .c at Here+(0,bwd) |
| 4070 |
line up m4sfact/4-bwd from last arc.start |
| 4071 |
line up m4sfact/4-bwd from last arc.end } |
| 4072 |
Head: box rad bwd/2 ht bht wid bwd with .s at Here+(0,bwd/2) `$3' |
| 4073 |
Inner: box rad bwd/2 ht bht/2+bwd/2 wid bwd with .n at Head.n |
| 4074 |
move to Inner.s+(0,bwd/2) |
| 4075 |
for i=1 to 4 do { |
| 4076 |
for j=-1 to 1 do { |
| 4077 |
{ circle at Here+(3*j*cspace,(abs(j)-3)*cspace) } |
| 4078 |
if j != 0 then {{ circle at Here+(j*3/2*cspace,0) }} } |
| 4079 |
move up 5*cspace }; popdef(`m4sfact')]', |
| 4080 |
`[setdir_($1,R) |
| 4081 |
pushdef(`m4h',`ifelse(`$2',,`dimen_/2',`($2)')')dnl |
| 4082 |
{L1: line from rvec_(m4h,-m4h/2) \ |
| 4083 |
to rvec_(m4h,m4h/2)} |
| 4084 |
{Circle: circle diameter m4h at rvec_(m4h/2,0) `$3'} |
| 4085 |
In1: rvec_(m4h*(2-sqrt(3))/4,m4h/4) |
| 4086 |
In2: Here |
| 4087 |
In3: rvec_(m4h*(2-sqrt(3))/4,-m4h/4) |
| 4088 |
`$4'; resetdir_ popdef(`m4h') ]')') |
| 4089 |
|
| 4090 |
`buzzer(U|D|L|R|degrees, vert size,[C], |
| 4091 |
attributes)' |
| 4092 |
define(`buzzer',`[setdir_($1,R) |
| 4093 |
ifelse(`$3',, |
| 4094 |
`pushdef(`m4h',`ifelse(`$2',,`dimen_/2',`($2)')')dnl |
| 4095 |
{L1: line from rvec_(m4h,0) \ |
| 4096 |
to rvec_(m4h,m4h/2) \ |
| 4097 |
then to rvec_(0,m4h/2) \ |
| 4098 |
then to rvec_(0,-m4h/2) \ |
| 4099 |
then to rvec_(m4h,-m4h/2) \ |
| 4100 |
then to rvec_(m4h,0) `$4'} |
| 4101 |
{Box: box invis ht_ m4h wid_ m4h at rvec_(m4h/2,0)} |
| 4102 |
{L2: line from rvec_(m4h,m4h/2) \ |
| 4103 |
to rvec_(m4h,m4h/2)+vec_(Rect_(m4h,-75))} |
| 4104 |
In1: rvec_(0,m4h/4) |
| 4105 |
In2: Here |
| 4106 |
In3: rvec_(0,-m4h/4) popdef(`m4h')', |
| 4107 |
`$3',C,`pushdef(`m4h',`ifelse(`$2',,`(dimen_/3)',`(($2)/2)')')dnl |
| 4108 |
{Face: line from rvec_(m4h,-m4h) \ |
| 4109 |
to rvec_(m4h,m4h)} |
| 4110 |
{arc ccw from Face.end to Face.start with .c at Face.c `$4'} |
| 4111 |
In1: rvec_(m4h-sqrt(m4h^2-(m4h/3)^2),m4h/3) |
| 4112 |
In2: Here |
| 4113 |
In3: rvec_(m4h-sqrt(m4h^2-(m4h/3)^2),-m4h/3) popdef(`m4h') ') |
| 4114 |
`$5'; resetdir_ ]') |
| 4115 |
`earphone(U|D|L|R|degrees, size, [C][R], |
| 4116 |
attributes) |
| 4117 |
earphone pair if arg3 contains C' |
| 4118 |
define(`earphone',`[ setdir_($1,R) |
| 4119 |
pushdef(`m4h',`ifelse(`$2',,`dimen_',`($2)')')dnl |
| 4120 |
ifinstr(`$3',C, |
| 4121 |
`L: circle diam m4h*0.4 `$4' |
| 4122 |
R: circle diam m4h*0.4 at L+vec_(m4h,0) `$4' |
| 4123 |
C: 0.5 between L and R |
| 4124 |
N: C+(vscal_(m4h/2,Vperp(L,R))) |
| 4125 |
Lx: Cintersect(L,L.rad,C,m4h/2,`$3') |
| 4126 |
Rx: Cintersect(C,m4h/2,R,R.rad,`$3') |
| 4127 |
arc ifinstr(`$3',R,c)cw rad m4h/2 from Lx to Rx with .c at C', |
| 4128 |
`{lbox(m4h/3,m4h/2,`$4')} |
| 4129 |
{Box: box invis ht_ m4h/2 wid_ m4h/3 at rvec_(m4h/6,0)} |
| 4130 |
{L1: line thick 2*linethick from rvec_(m4h/3+lthick,-m4h/3) \ |
| 4131 |
to rvec_(m4h/3+lthick, m4h/3) } |
| 4132 |
In1: rvec_(0,m4h/8) |
| 4133 |
In2: Here |
| 4134 |
In3: rvec_(0,-m4h/8)') |
| 4135 |
`$5'; resetdir_ popdef(`m4h') ]') |
| 4136 |
|
| 4137 |
`Signal-flow graph macros: labeled node, |
| 4138 |
directed labeled chopped straight line, |
| 4139 |
directed labeled chopped arc, and a self |
| 4140 |
loop. All are contained in [] blocks.' |
| 4141 |
|
| 4142 |
`Signal-flow graph initialization macro |
| 4143 |
sfg_init(line len, node rad, arrowhd len, arrowhd wid)' |
| 4144 |
ifdef(`sfg_init',, |
| 4145 |
`define(`sfg_init',`cct_init |
| 4146 |
sfg_wid = ifelse(`$1',,`(linewid/0.75*(2.5+0.25)/4)',(`$1'))# default line len |
| 4147 |
sfg_rad = ifelse(`$2',,(0.25/4/2),(`$2')) # node radius |
| 4148 |
sfg_aht = ifelse(`$3',,(0.25/4),(`$3')) # arrow height (arrowhead length) |
| 4149 |
sfg_awid = ifelse(`$4',,`sfg_aht',(`$4')) # arrowhead width |
| 4150 |
')') |
| 4151 |
`sfgline(linespec, |
| 4152 |
text,sfgabove|sfgbelow|ljust|rjust, |
| 4153 |
attributes) |
| 4154 |
Draw a straight line with linespec, chopped by |
| 4155 |
node radius, with optional label' |
| 4156 |
define(`sfgline',`eleminit_(`$1',sfg_wid) |
| 4157 |
[ L1: line to rvec_(rp_len,0) chop sfg_rad `$4' |
| 4158 |
Start: last line.start |
| 4159 |
End: Here |
| 4160 |
move to last line.c |
| 4161 |
ifelse(ifinstr(`$4',->,T,`$4',<-,T),, |
| 4162 |
`{ arrow m4c_l ht sfg_aht wid sfg_awid from rvec_(-sfg_aht/2,0) \ |
| 4163 |
to rvec_(sfg_aht/2,0) `$4' }') |
| 4164 |
ifelse(`$2',,,`m4lstring(`$2',"iflatex(`$ `$2'$',` $2')") \ |
| 4165 |
ifelse(`$3',,`sfgabove',`$3')') |
| 4166 |
] with .Start at rvec_(sfg_rad,0) |
| 4167 |
move to last [].End |
| 4168 |
') |
| 4169 |
`Like above_ or below_ but adding extra space |
| 4170 |
to put text above or below arrowheads or nodes' |
| 4171 |
define(`sfgabove',`at Here+(0,sfg_awid/2) above') |
| 4172 |
define(`sfgbelow',`at Here+(0,-sfg_awid/2) below') |
| 4173 |
|
| 4174 |
`sfgnode(at pos,text,above_,circle attributes) |
| 4175 |
Node: a white circle, possibly labelled. The |
| 4176 |
default label position is inside if the |
| 4177 |
diameter is bigger than textht and textwid' |
| 4178 |
define(`sfgnode', |
| 4179 |
`[C: circle fill_(1) rad sfg_rad ifelse(`$4',,`thick 0.5',`$4')] with .c \ |
| 4180 |
ifelse(`$1',,`at rvec_(sfg_rad,0)',`$1') |
| 4181 |
move to last [].c |
| 4182 |
ifelse(`$2',,,`if 2*sfg_rad > Max(textwid,textht,10pt__) \ |
| 4183 |
then { {m4lstring(`$2',`"iflatex(`$ `$2'$',` $2')"') `$3'} } \ |
| 4184 |
else { { m4lstring(`$2',`"iflatex(`$ `$2'$',` $2')"') \ |
| 4185 |
ifelse(`$3',,`sfgabove',`$3')} }') |
| 4186 |
') |
| 4187 |
`sfgarc(linespec,label,above_,cw|ccw,sfact, |
| 4188 |
attributes) |
| 4189 |
An arc between nodes at the endpoints of the |
| 4190 |
linespec. The resulting positions Start, End, |
| 4191 |
C (arc center) and M (arc midpoint) are defined. |
| 4192 |
The fifth argument scales the arc height above |
| 4193 |
its chord.' |
| 4194 |
define(`sfgarc',`eleminit_(`$1',sfg_wid) |
| 4195 |
[ Start: Here |
| 4196 |
End: Start + vec_(rp_len,0) |
| 4197 |
chordht = (rp_len/sqrt(2)-rp_len/2)ifelse(`$5',,,`*($5)') |
| 4198 |
arcrd = (chordht^2+(rp_len)^2/4)/chordht/2 |
| 4199 |
C: 0.5 between Start and End; C: C+vec_(0,ifelse(`$4',ccw,,-)(arcrd-chordht)) |
| 4200 |
M: C + vec_( 0,ifelse(`$4',ccw,-)arcrd) |
| 4201 |
ifelse(ifinstr(`$1',->,T,`$1',<-,T),, |
| 4202 |
`arc `$6' -> m4c_l ifelse(`$4',ccw,ccw,cw) \ |
| 4203 |
from Cintersect(Start,sfg_rad,C,arcrd,ifelse(`$4',ccw,R)) \ |
| 4204 |
to Cintersect(C,arcrd,M,sfg_aht/2,ifelse(`$4',ccw,,R)) \ |
| 4205 |
ht sfg_aht wid sfg_awid with .c at C `$6' |
| 4206 |
arc m4c_l ifelse(`$4',ccw,ccw,cw) from M \ |
| 4207 |
to Cintersect(C,arcrd,End,sfg_rad,ifelse(`$4',ccw,R)) with .c at C `$6'', |
| 4208 |
`arc m4c_l patsubst(patsubst(`$1',.*<-,<-),->.*$,->) ifelse(`$4',ccw,ccw,cw)\ |
| 4209 |
from Cintersect(Start,sfg_rad,C,arcrd,ifelse(`$4',ccw,R)) \ |
| 4210 |
to Cintersect(C,arcrd,End,sfg_rad,ifelse(`$4',ccw,R)) with .c at C `$6'') |
| 4211 |
ifelse(`$2',,,`move to M; m4lstring(`$2',"iflatex(`$ `$2'$',` $2')") \ |
| 4212 |
ifelse(`$3',,`sfgabove',`$3')') |
| 4213 |
] with .Start at last line.start |
| 4214 |
move to last line.end |
| 4215 |
') |
| 4216 |
`sfgself(at position,U|D|L|R|degrees,label,above_,cw|ccw,sfact, |
| 4217 |
[-> | <- | <->], attributes) |
| 4218 |
A teardrop-shaped self-loop drawn at "angle" |
| 4219 |
degrees from "positon". The resulting Origin |
| 4220 |
and M (arc midpoint) are defined. The sixth |
| 4221 |
argument scales the loop. The seventh puts |
| 4222 |
the arrowhead at the beginning, end, or both' |
| 4223 |
define(`sfgself',`[ Origin: Here |
| 4224 |
setdir_(`$2',U) |
| 4225 |
d = ifelse(`$6',,,`($6)*') sfg_wid/2; d = d * max(1,sfg_rad/(0.3605*d)) |
| 4226 |
{ m4sfgselfcurve(-, `$8' \ |
| 4227 |
ifelse(`$5',ccw,`ifinstr(`$7',<-,<-)',`ifinstr(`$7',->,<-)')) |
| 4228 |
M: Here |
| 4229 |
ifelse(`$7',,`{ arrow `$8' m4c_l from rvec_(0,ifelse(`$5',cw,,-)sfg_aht/2) \ |
| 4230 |
to rvec_(0,ifelse(`$5',cw,-)sfg_aht/2) ht sfg_aht wid sfg_awid }') |
| 4231 |
ifelse(`$3',,,`{m4lstring(`$3',`"iflatex(`$ `$3'$',` $3')"') \ |
| 4232 |
ifelse(`$4',,`sfgabove',`$4')}') } |
| 4233 |
m4sfgselfcurve(, `$8' \ |
| 4234 |
ifelse(`$5',ccw,`ifinstr(`$7',->,<-)',`ifinstr(`$7',<-,<-)')) |
| 4235 |
resetdir_ ] with .Origin ifelse(`$1',,at Here,`$1') |
| 4236 |
move to last [].Origin |
| 4237 |
') |
| 4238 |
define(`m4sfgselfcurve',`spline `$2' m4c_l from rvec_(Rect_(sfg_rad,`$1'30)) \ |
| 4239 |
to rvec_(0.3*d,`$1'0.2*d) \ |
| 4240 |
then to rvec_(0.6*d,`$1'0.35*d) \ |
| 4241 |
then to rvec_(0.9*d,`$1'0.35*d) \ |
| 4242 |
then to rvec_(d,`$1'0.2*d) \ |
| 4243 |
then to rvec_(d,0)') |
| 4244 |
|
| 4245 |
`winding( L|R, winding diam, pitch, nturns, |
| 4246 |
core wid, "core color") |
| 4247 |
The complete spline is drawn in the current drawing |
| 4248 |
direction, then parts of it are overwritten with the |
| 4249 |
background color (default white). |
| 4250 |
Arg 1 contains R for right-handed winding.' |
| 4251 |
define(`winding',`[ pushdef(`m4rt',`ifinstr(`$1',R,-)') |
| 4252 |
w_diam = ifelse(`$2',,`dimen_',`$2') |
| 4253 |
pitch = abs(ifelse(`$3',,w_diam/4,`$3')) |
| 4254 |
nturns = int(abs(ifelse(`$4',,2,`$4'))) |
| 4255 |
core_w = ifelse(`$5',,w_diam*3/4,`$5') |
| 4256 |
W: spline from (0,0) to vec_(0,w_diam) \ |
| 4257 |
then to vec_(m4rt`'pitch/2,w_diam) \ |
| 4258 |
then to vec_(m4rt`'pitch/2,0) |
| 4259 |
for i=1 to nturns-1 do { |
| 4260 |
continue to vec_(m4rt`'i*pitch,0) \ |
| 4261 |
then to vec_(m4rt`'i*pitch,w_diam) \ |
| 4262 |
then to vec_(m4rt`'(i+1/2)*pitch,w_diam) \ |
| 4263 |
then to vec_(m4rt`'(i+1/2)*pitch,0) \ |
| 4264 |
} |
| 4265 |
if core_w > 0 then { |
| 4266 |
dx = sign(pitch)*(linethick+0.5)/2 bp__ |
| 4267 |
vx = pitch*min(core_w/w_diam/8+dx/pitch,0.25) |
| 4268 |
for i=0 to nturns-1 do { |
| 4269 |
line color ifelse(`$6',,rgbstring(1,1,1),`$6') \ |
| 4270 |
thick max(core_w/(1bp__)-linethick,0) \ |
| 4271 |
from vec_(m4rt`'(i*pitch-dx),w_diam/2) \ |
| 4272 |
to vec_(m4rt`'(i*pitch+vx),w_diam/2) |
| 4273 |
dx = vx } |
| 4274 |
} |
| 4275 |
T1: W.ifinstr(`$1',R,end,start); Start: T1 |
| 4276 |
T2: W.ifinstr(`$1',R,start,end); End: T2 |
| 4277 |
`$7' popdef(`m4rt') ]') |
| 4278 |
|
| 4279 |
`arcwinding( winding diam, startdeg, enddeg, nturns, |
| 4280 |
core centre rad, core wdth, "core color") |
| 4281 |
The complete spline is drawn, then parts of it are |
| 4282 |
overwritten with the background color (default |
| 4283 |
white). Negative arg5 puts winding ends at the outside. |
| 4284 |
Ex: W: arcwinding(1.2,-20,20,8, -1,0.8)' |
| 4285 |
define(`arcwinding',`[ C: Here |
| 4286 |
start_ang = ifelse(`$2',,67.5,`$2') |
| 4287 |
end_ang = ifelse(`$3',,112.5,`$3') |
| 4288 |
nturns = int(abs(ifelse(`$4',,(end_ang-start_ang)/10,`$4'))) |
| 4289 |
rad_ctr = ifelse(`$5',,`dimen_',`$5') |
| 4290 |
core_w = abs(ifelse(`$6',,rad_ctr/2,`$6')) |
| 4291 |
if rad_ctr < 0 then { start_ang += 180; end_ang += 180 } |
| 4292 |
w_diam = ifelse(`$1',,`core_w*3/2',`$1') |
| 4293 |
w_i=(rad_ctr-w_diam/2) |
| 4294 |
w_o=(rad_ctr+w_diam/2) |
| 4295 |
d_ang = (end_ang-start_ang)/(nturns-1/2) |
| 4296 |
W: spline from (Rect_(w_i,start_ang)) to (Rect_(w_o,start_ang)) \ |
| 4297 |
then to (Rect_(w_o,start_ang+d_ang/2)) \ |
| 4298 |
then to (Rect_(w_i,start_ang+d_ang/2)) |
| 4299 |
for i=1 to nturns-1 do { |
| 4300 |
continue to (Rect_(w_i,start_ang+i*d_ang)) \ |
| 4301 |
then to (Rect_(w_o,start_ang+i*d_ang)) \ |
| 4302 |
then to (Rect_(w_o,start_ang+(i+1/2)*d_ang)) \ |
| 4303 |
then to (Rect_(w_i,start_ang+(i+1/2)*d_ang)) |
| 4304 |
} |
| 4305 |
if core_w > 0 then { |
| 4306 |
da = abs(d_ang)/4 |
| 4307 |
for i=1 to nturns do { |
| 4308 |
arc color ifelse(`$7',,rgbstring(1,1,1),`$7') \ |
| 4309 |
thick max(core_w/(1bp__)-2*linethick,0) \ |
| 4310 |
from (Rect_(rad_ctr,start_ang+(i-1/2)*d_ang-da)) \ |
| 4311 |
to (Rect_(rad_ctr,start_ang+(i-1/2)*d_ang+da)) \ |
| 4312 |
with .c at C } |
| 4313 |
} |
| 4314 |
T1: W.start; Start: T1 |
| 4315 |
T2: W.end; End: T2 |
| 4316 |
`$8' ]') |
| 4317 |
|
| 4318 |
`tstrip(U|D|L|R|degrees, n, chars) |
| 4319 |
Terminal strip |
| 4320 |
n=integer number of terminals (default 4) |
| 4321 |
chars: |
| 4322 |
I invisible terminals |
| 4323 |
C circle terminals (default) |
| 4324 |
D dot terminals |
| 4325 |
O omitted internal lines |
| 4326 |
box=attributes; |
| 4327 |
wid=val; total strip width |
| 4328 |
ht=val; strip height ' |
| 4329 |
define(`tstrip',`[ setdir_(`$1') |
| 4330 |
define(`m4n',`ifelse(`$2',,4,`eval($2)')')dnl |
| 4331 |
ifelse(eval(m4n<1),1,`define(`m4n',1)')dnl |
| 4332 |
pushkeys_(`$3',`ht:dimen_/2; wid:m4n*m4`'ht*0.6; box::N;') |
| 4333 |
{Box: [shade(1,lbox(m4wid,m4ht,m4box))] } |
| 4334 |
bw = m4wid/(m4n) |
| 4335 |
ifinstr(`$3',O,,`for i=1 to m4n-1 do { |
| 4336 |
{move to rvec_(i*bw,-m4ht/2); line to rvec_(0,m4ht)}}') |
| 4337 |
for_(1,m4n,1,`{T`'m4x: ifinstr(`$3',I,`rvec_((m4x-0.5)*bw,0)', |
| 4338 |
`dot(at rvec_((m4x-0.5)*bw,0),,ifinstr(`$3',D,0,1))') |
| 4339 |
{L`'m4x: T`'m4x+vec_(0,m4ht/2)}; {R`'m4x: T`'m4x+vec_(0,-m4ht/2)} }') |
| 4340 |
`$4' popdef(`m4wid',`m4ht',`m4box') |
| 4341 |
resetdir_ ]') |
| 4342 |
|
| 4343 |
`jack(U|D|L|R|degrees, chars [;keys]) |
| 4344 |
Phone jack; arg1 sets drawing direction |
| 4345 |
chars: A sequence of letters L, S, C, each |
| 4346 |
possibly followed by M, B, MB, or BM, e.g. LLMSBM |
| 4347 |
L draws a long contac arm, M adds a Make contact, |
| 4348 |
B a Break contact, and MB or BM adds both |
| 4349 |
S similarly draws a short contact |
| 4350 |
C adds a central medium contact |
| 4351 |
also: |
| 4352 |
X=bring aux contacts to external dots |
| 4353 |
R=right jack orientation wrt to drawing direction |
| 4354 |
keys: dots=dot keys; (default circle=fill_(1)) |
| 4355 |
arrowht=expr; (dimen_/8) |
| 4356 |
sleeve=attributes; e.g. shaded "red" |
| 4357 |
sleeveht=expr; (4.5*arrowht) |
| 4358 |
sleevewid=expr; (sleeveht/6) |
| 4359 |
armlen=expr; len of long armature (dimen_*.75) ' |
| 4360 |
define(`jack',`[ setdir_(`$1') |
| 4361 |
pushkeys_(`$2',`dots:circle=fill_(1):N; |
| 4362 |
arm::N; armlen:dimen_*0.75; arrowht:dimen_/8; |
| 4363 |
sleeve::N; sleeveht:m4`'arrowht*4.5; sleevewid:m4`'sleeveht/6; ')dnl |
| 4364 |
pushdef(`dna_',`$2') pushdef(`rght',sc_draw(`dna_',R,-)1)dnl |
| 4365 |
pushdef(`m4extrn',sc_draw(`dna_',X,X)) pushdef(`m4vd',`dimen_/16')dnl |
| 4366 |
ifelse(dna_,,`define(`dna_',L)') |
| 4367 |
Sleeve: [lbox(m4sleevewid,m4sleeveht,m4sleeve)] |
| 4368 |
F: Sleeve+vec_(m4sleevewid/2,0) |
| 4369 |
Ctr: (2 between F and Sleeve)+vec_(-(m4armlen+m4vd), 0); |
| 4370 |
G: Sleeve+vec_(0,-m4sleeveht/2*(rght)); Sx: G+(Ctr-Sleeve) |
| 4371 |
H: 2 between G and Sleeve; Lx: H+(Ctr-Sleeve) |
| 4372 |
Q: Ctr; m4jcontacts(dna_,L,rght,,m4armlen) |
| 4373 |
Q: Ctr; m4jcontacts(dna_,C,rght,,m4armlen) |
| 4374 |
Q: Ctr; m4jcontacts(dna_,S,neg_(rght),,m4armlen) |
| 4375 |
ifelse(m4extrn,X,`ifelse(rght,-1, |
| 4376 |
`T: Sleeve + (Lx-Ctr)+((Between_(G,H,dimen_/6))-G) |
| 4377 |
line from H to T then to T+(Ctr-Sleeve); H: dot(,m4dots); ', |
| 4378 |
`T: Sleeve + (Sx-Ctr)+((Between_(H,G,dimen_/6))-H) |
| 4379 |
line from G to T then to T+(Ctr-Sleeve); G: dot(,m4dots); ')') |
| 4380 |
`$3'; resetdir_ popdef(`m4dots',`m4arm', `m4armlen', `m4arrowht', |
| 4381 |
`m4sleeve', `m4sleeveht', `m4sleevewid',`dna_', `rght', `m4extrn', `m4vd') |
| 4382 |
] ') |
| 4383 |
`m4jcontacts(dna_, L|S|C, 1|-1, blank|n, armlen)' |
| 4384 |
define(`m4jcontacts',`ifinstr(`$1',`$2', |
| 4385 |
`pushdef(`dna_',$1) pushdef(`m4code',regexp(dna_,$2\(M\|B\|MB\|BM\)?,\&))dnl |
| 4386 |
sc_draw(`dna_',m4code, |
| 4387 |
`pushdef(`armln',`ifelse(`$2',S,0.55/0.75*,`$2',C,0.65/0.75*)'`$5')dnl |
| 4388 |
pushdef(`connht',`ifelse($4,,3,ifelse(m4code,$2`'B,4.5,3))')dnl |
| 4389 |
$2`'x: Q ifelse(`$2',C,, |
| 4390 |
`+vec_(0,$3*ifelse(`$4',,m4sleeveht/2,connht*m4arrowht)); Q: $2`'x') |
| 4391 |
$2`'$4: dot(at Q,m4dots) |
| 4392 |
Armature: line chop last [].wid/2 chop 0 to rvec_(armln-2*m4vd,0) dnl |
| 4393 |
ifelse($4,,`then to rvec_(armln-m4vd,neg_(`$3')*m4vd) \ |
| 4394 |
then to rvec_(armln,0)') |
| 4395 |
Contact: Q+vec_(m4arrowht*2,0) |
| 4396 |
ifelse($4,,,`Connector: [lbox(m4vd,connht*m4arrowht,m4sleeve)] \ |
| 4397 |
at last []+vec_(armln-3*m4vd,neg_(`$3')*connht*m4arrowht/2)') |
| 4398 |
ifinstr(m4code,M,`$2`'M`'$4: Contact+vec_(0,`$3'*m4arrowht*1.9) |
| 4399 |
$2`'M`'$4`'A: arrow m4c_l <- ht m4arrowht wid m4arrowht \ |
| 4400 |
from Contact+vec_(0,`$3'*m4arrowht*0.4) \ |
| 4401 |
to $2`'M`'$4 ifelse(m4extrn,X,`then to $2`'$4+vec_(0,`$3'*m4arrowht*1.9) |
| 4402 |
$2`'M`'$4: dot(,m4dots)'); $2`'x: $2`'M`'$4') |
| 4403 |
ifinstr(m4code,B,`$2`'B`'$4: Contact+vec_(0,neg_(`$3')*m4arrowht*1.5) |
| 4404 |
$2`'B`'$4`'A: arrow m4c_l <- ht m4arrowht wid m4arrowht from Contact \ |
| 4405 |
to $2`'B`'$4 dnl |
| 4406 |
ifelse(m4extrn,X,`then to $2`'$4+vec_(0,neg_(`$3')*m4arrowht*1.5) |
| 4407 |
$2`'B`'$4:dot(,m4dots)')') |
| 4408 |
m4jcontacts(dna_,$2,$3,ifelse($4,,1,`incr($4)'),`$5') |
| 4409 |
popdef(`armln',`connht')') |
| 4410 |
popdef(`m4code',`dna_')')') |
| 4411 |
|
| 4412 |
`plug(U|D|L|R|degrees, chars) |
| 4413 |
Phone plug; arg1 sets drawing direction |
| 4414 |
chars: |
| 4415 |
2|3= two|three conductor |
| 4416 |
R= right orientation wrt drawing direction ' |
| 4417 |
define(`plug',`[ setdir_(`$1') |
| 4418 |
s=ifinstr(`$2',R,-1,1) |
| 4419 |
ght = ifinstr(`$2',3,`dimen_*0.5',`dimen_*0.4') |
| 4420 |
A: Here |
| 4421 |
AA: line to rvec_(dimen_*0.3,0) \ |
| 4422 |
then to rvec_(dimen_*0.3,s*ght/3) \ |
| 4423 |
then to rvec_(dimen_*0.7,s*ght/3); TA: dot(,,1) |
| 4424 |
ifinstr(`$2',3,` |
| 4425 |
C: A+vec_(0,s*ght/2) |
| 4426 |
TC: line from C to C+vec_(dimen_*0.6,0); TC: Here |
| 4427 |
B: 2 between A and C',`B: A+vec_(0,s*ght)') |
| 4428 |
BB: line from B to B+vec_(dimen_*0.3,0) \ |
| 4429 |
then to B+vec_(dimen_*0.3,-s*ght/3) \ |
| 4430 |
then to B+vec_(dimen_*0.6,-s*ght/3); TB: Here |
| 4431 |
`$3'; resetdir_ ]') |
| 4432 |
|
| 4433 |
`A dabble in quantum circuits: |
| 4434 |
SQUID(n,diameter,initial angle,cw|ccw) |
| 4435 |
Superconducting quantum interface device with |
| 4436 |
n junctions labeled J1, ... Jn placed around a |
| 4437 |
circle with initial angle -90 deg (by default) |
| 4438 |
with respect to the current drawing direction. The |
| 4439 |
default diameter is dimen_' |
| 4440 |
define(`SQUID', |
| 4441 |
`[ pushdef(`m4sqn',`ifelse(`$1',,2,`$1')')dnl |
| 4442 |
pushdef(`m4ssz',`ifelse(`$2',,`dimen_',`$2')')dnl |
| 4443 |
pushdef(`m4sof',`ifelse(`$3',,-90,`$3')')dnl |
| 4444 |
pushdef(`m4ssg',`ifelse(`$4',,+,`$4',ccw,+,-)(m4x-1)/(m4sqn)*360')dnl |
| 4445 |
pushdef(`m4sxlen',C.rad/4)dnl |
| 4446 |
C: circle diam m4ssz |
| 4447 |
for_(1,m4sqn,1, |
| 4448 |
`move to C+vec_(Rect_(C.rad,m4sof`'m4ssg)) |
| 4449 |
J`'m4x: Here |
| 4450 |
{ line from rvec_(Rect_(m4sxlen,m4sof`'m4ssg+45)) \ |
| 4451 |
to rvec_(Rect_(m4sxlen,m4sof`'m4ssg+225)) } |
| 4452 |
{ line from rvec_(Rect_(m4sxlen,m4sof`'m4ssg-45)) \ |
| 4453 |
to rvec_(Rect_(m4sxlen,m4sof`'m4ssg-225)) }') |
| 4454 |
`$5' popdef(`m4sqn',`m4ssz',`m4sof',`m4ssg',`m4sxlen') ]') |
| 4455 |
|
| 4456 |
`Ladder logic:' |
| 4457 |
`l_contact( linespec,keys ) |
| 4458 |
keys: |
| 4459 |
wid=expr; (default dimen_/6) |
| 4460 |
ht=expr; (default dimen_/3) |
| 4461 |
type=P|N|NC; (pos|neg|no contact|(def blank)' |
| 4462 |
define(`l_contact',`pushkeys_(`$2',wid:dimen_/4.5;ht:dimen_/3;type::N;)dnl |
| 4463 |
eleminit_(`$1') |
| 4464 |
{{line to rvec_(rp_len/2-m4wid/2,0)} |
| 4465 |
{line from rvec_(rp_len/2+m4wid/2,0) to rvec_(rp_len,0)} |
| 4466 |
[{line from Here to rvec_(0,m4ht)} |
| 4467 |
{line from rvec_(m4wid,0) to rvec_(m4wid,m4ht)} |
| 4468 |
ifelse(m4type,,, m4type,NC, |
| 4469 |
`{line from Here to rvec_(m4wid*1.5,m4ht/1.2) \ |
| 4470 |
with .c at rvec_(m4wid/2,m4ht/2)}', |
| 4471 |
`{"m4type" with .c at rvec_(m4wid/2,m4ht/2)}') ] \ |
| 4472 |
at rvec_(rp_len/2,0)} |
| 4473 |
line invis to rvec_(rp_len,0) popdef(`m4wid',`m4ht',`m4type') ') |
| 4474 |
|
| 4475 |
`l_coil( linespec,keys ) |
| 4476 |
keys: |
| 4477 |
size=expr; (default dimen_/3) |
| 4478 |
type=P|N|S|NC; (pos|neg|set latch|negated)' |
| 4479 |
define(`l_coil',`pushkeys_(`$2',size:sourcerad_*7/4;type::N;)dnl |
| 4480 |
eleminit_(`$1') |
| 4481 |
{line to rvec_(rp_len/2-m4size/2*5/4,0)} |
| 4482 |
{line from rvec_(rp_len/2+m4size/2*5/4,0) to rvec_(rp_len,0)} |
| 4483 |
{[ C1: vec_(-m4size/8,0); C2: vec_(m4size/8,0); Dx: Rect_(m4size/2,75) |
| 4484 |
arc from C1+vec_(-Dx.x,Dx.y) to C1-vec_(Dx.x,Dx.y) with .c at C1 |
| 4485 |
arc from C2+vec_(Dx.x,-Dx.y) to C2+vec_(Dx.x,Dx.y) with .c at C2 |
| 4486 |
ifelse(m4type,,, m4type,NC, |
| 4487 |
`{line from 1st arc.end to 2nd arc.end chop m4size/10}', |
| 4488 |
`{"m4type" with .c at (0,0)}') |
| 4489 |
] at rvec_(rp_len/2,0)} |
| 4490 |
line invis to rvec_(rp_len,0) popdef(`m4size',`m4type') ') |
| 4491 |
|
| 4492 |
`============================================================================== |
| 4493 |
Customizations: |
| 4494 |
The size and style parameters below can be |
| 4495 |
tweaked, and the cct_init macro modified.' |
| 4496 |
|
| 4497 |
Size and style parameters: |
| 4498 |
define(`dimen_',`linewid') `Default element body size unit' |
| 4499 |
|
| 4500 |
define(`sourcerad_',`(0.25*dimen_)') `Source element default radius' |
| 4501 |
define(`csdim_',`(0.3*dimen_)') `Controlled Source width/2' |
| 4502 |
define(`elen_',`(1.5*dimen_)') `Default element length' |
| 4503 |
define(`delay_rad_',`(0.35*dimen_)') `Delay elements' |
| 4504 |
define(`dotrad_',`(0.04*dimen_)') `Redefine dot size for circuits' |
| 4505 |
define(`m4fill',0) `Default fill for diode, fuse, ...' |
| 4506 |
define(`em_arrowwid',`(dimen_/9)') `em_arrows arrowhead width' |
| 4507 |
define(`em_arrowht',`(dimen_/7)') `em_arrows arrowhead ht' |
| 4508 |
define(`em_arrowhead',1) `em_arrows arrowhead style' |
| 4509 |
define(`hoprad_',`dimen_/12') `arc radius for crossover macro' |
| 4510 |
|
| 4511 |
right_ |
| 4512 |
divert(0)dnl |