Debian Codegraph @

texmf-dist/doc/latex/circuit-macros/examples/Rectifiers.m4

raw
1 .PS
2 # Rectifiers.m4
3 cct_init
4
5 tmax = 3.5
6 period = tmax/1.75
7 eamp = 0.5
8 omega = twopi_/period
9 ed = eamp/6
10 r = 0.95
11
12 # For DC voltages
13 ted = asin(ed/eamp)/twopi_*period
14 npts = 40; sum = 0
15 for i=0 to npts do {
16 t = ted+(period/2-2*ted)*i/npts
17 sum += (eamp*cos(omega*t-pi_/2) - ed)*r }
18
19 define(`Sine',`Cosine(eamp,omega,`$1',-pi_/2)')
20 define(`axis',`line thick 0.4 right tmax chop -tmax*0.04 chop 0')
21
22 Threephase: [ linethick_(1)
23 Ai: axis ; "$N_o$" ljust
24 EOrig: Ai.start+(tmax*0.04,0)
25 E1: sinusoid(eamp,omega,-pi_/2,-ted,tmax) with .Origin at EOrig
26 E2: sinusoid(eamp,omega,-pi_/2-twopi_/3,-ted,tmax) with .Origin at EOrig
27 E3: sinusoid(eamp,omega,-pi_/2+twopi_/3,-ted,tmax) with .Origin at EOrig
28 "$e_1$" at EOrig+(period/3,eamp*0.8) ljust above
29 "$e_2$" at EOrig+(2*period/3,eamp*0.8) ljust above
30 "$e_3$" at EOrig+(period,eamp*0.8) ljust above
31
32 Ad: axis with .end at Ai.end+(0,-eamp*2.1); "$N_o$" ljust
33 DOrig: Ad.start+(tmax*0.04,0)
34 Id: axis with .end at Ad.end+(0,-eamp*1.2); "${}0$" ljust
35 IOrig: Id.start+(tmax*0.04,0)
36
37 for i=1 to 11 by 2 do {
38 tl = max(0,period/2-i*period/6)
39 tr = min(period/2,tmax-(i*period/6-period/2))
40 sinusoid(eamp,omega,-pi_/2,tl,tr,thick 0.4 dashed) \
41 with .Origin at DOrig+(i*period/6-period/2,0)
42 tl = max(period/12,-(i*period/6-period/2+period/12) )
43 tr = period/2-period/12
44 S1: sinusoid(eamp*r,omega,-pi_/2,tl,tr) \
45 with .Origin at DOrig+(i*period/6-period/2,0)+(0,-ed*r); round(at S1.End)
46 S2: sinusoid(eamp*r,omega,-pi_/2,tl,tr) \
47 with .Origin at IOrig+(i*period/6-period/2,0)+(0,-ed*r); round(at S2.End)
48 }
49 "$e_1$" at DOrig+(period/3,eamp*0.8) ljust above
50 "$e_2$" at DOrig+(2*period/3,eamp*0.8) ljust above
51 "$e_3$" at DOrig+(period,eamp*0.8) ljust above
52
53 "$e_L$" at DOrig+(period/4,eamp*0.8) below
54 "$i_L$" at IOrig+(period/6,eamp*0.6) rjust above
55
56 vEd = r*eamp*cos(pi_/12)/(5*pi_/12) - r*ed
57 VEd: axis with .end at Ad.end+(0,vEd); "$E_D$" ljust
58 IEd: axis with .end at Id.end+(0,vEd); "$I_D$" ljust
59 ]
60
61 Cct3:[
62 No: dot; "$N_o$" at last [].s below rjust
63 E2: No+(Rect_(dimen_,60))
64 E3: No+(Rect_(dimen_,-60))
65 E1: No+(-dimen_,0)
66 inductor(from No to E2,W); round; "$e_2$" ljust
67 inductor(from No to E3,W); round; "$e_3$" ljust
68 inductor(from E1 to No,W); round(at E1); "$e_1$" at E1 above
69 D3: diode(down_ from E3); b_current(i_3,rjust); llabel(,,D_3)
70 line from E1 to (E1.x,D3.start.y+dimen_/3) then right_ (E3.x-E1.x)/2 \
71 then down_ dimen_/3
72 D1: diode(down_); b_current(i_1,rjust); llabel(,,D_1); dot
73 line from E2 left_ E2.x-E1.x+dimen_/3 then down_ E2.y-E3.y \
74 then to 2 between D3.start and D1.start; corner
75 D2: diode(down_); b_current(i_2,rjust); llabel(,,D_2)
76 { line from D2.end to D3.end }
77 arrowline(from D1.end down_ elen_/2); rlabel(,i_L)
78 resistor(right_ elen_); rlabel(+,e_L,-); llabel(,R)
79 line to (Here,No) then to No
80 ] with .e at Threephase.w-(0.5,0)
81
82 Fullwave: [
83 linethick_(1)
84 Ai: axis ; "$N_o$" ljust
85 EOrig: Ai.start+(tmax*0.05,0)
86 E1: sinusoid(eamp,omega,-pi_/2,-ted,tmax) with .Origin at EOrig
87 "$e_1$" at EOrig+(period/3,eamp*0.8) ljust above
88 E2: sinusoid(eamp,omega, pi_/2,-ted,tmax) with .Origin at EOrig
89 "$e_2$" at EOrig+(period*5/6,eamp*0.8) ljust above
90
91 Ad: axis with .end at Ai.end+(0,-eamp*2.1); "$N_o$" ljust
92 DOrig: Ad.start+(tmax*0.05,0)
93 Id: axis with .end at Ad.end+(0,-eamp*1.2); "${}0$" ljust
94 IOrig: Id.start+(tmax*0.05,0)
95
96 for i=0 to 3 do {
97 if i<3 then { tf = period/2 } else { tf = Ad.end.x-(DOrig.x+3*period/2) }
98 sinusoid(eamp,omega,-pi_/2,0,tf,thick 0.4 dashed) \
99 with .Origin at DOrig+(i*period/2,0)
100 line from DOrig+(i*period/2-ted,0) right 2*ted
101 line from IOrig+(i*period/2-ted,0) right 2*ted
102 if i<3 then {tf = period/2-ted } else {tf = Ad.end.x-(DOrig.x+3*period/2) }
103 Ed: sinusoid(eamp*r,omega,-pi_/2,ted,tf) \
104 with .Origin at DOrig+(i*period/2,-ed*r)
105 Ed: sinusoid(eamp*r,omega,-pi_/2,ted,tf) \
106 with .Origin at IOrig+(i*period/2,-ed*r)
107 }
108 "$e_1$" at DOrig+(period/6,eamp*0.9) rjust above
109 "$e_2$" at DOrig+(period/6+period/2,eamp*0.9) rjust above
110 "$e_L$" at DOrig+(period/4,eamp*0.8) below
111 "$i_L$" at IOrig+(period/6,eamp*0.6) rjust above
112
113 vEd = sum/(period/2/(period/2-2*ted)*npts)
114 VEd: axis with .end at Ad.end+(0,vEd); "$E_D$" ljust
115 IEd: axis with .end at Id.end+(0,vEd); "$I_D$" ljust
116 ] with .sw at Threephase.nw+(0,0.5)
117
118 Cct2:[
119 T: transformer(right_ elen_,R,8,AW,8)
120 line up elen_/2 from T.P1
121 gap(right_ elen_)
122 { sinusoid(0.08,omega*8,-pi_/2,0,twopi_/(omega*8)) with .c at last [] }
123 line to T.P2
124 line from T.S1 to (T.P1,T.S1) then down elen_/2
125 D1: diode(down_ elen_*3/4); rlabel(,D_1)
126 line from T.S2 to (T.P2,T.S2) then to (T.P2,D1.start)
127 D2: diode(down_ elen_*3/4); rlabel(,D_2)
128 corner; line to D1.end; corner
129 dot(at 0.5 between D1.end and D2.end)
130 arrowline(down elen_/2); rlabel(,i_L)
131 resistor(right_ elen_); rlabel(+,e_L,-); llabel(,R)
132 line to (Here,T.TS)-(0,elen_/2) then left Here.x-T.TS.x then to T.TS
133 {"$N_o$" at T.TS-(0,elen_/2) below }
134 thinlines_
135 move to T.TS-(0,0.1)
136 { arrow to (T.P1,Here) chop 0.05 "$e_1$" below }
137 { arrow to (T.P2,Here) chop 0.05 "$e_2$" below }
138 linethick_(1)
139 ] at (Cct3,Fullwave)
140
141 Halfwave: [
142 linethick = 1
143 Ai: axis ; "$N_o$" ljust
144 EOrig: Ai.start+(tmax*0.05,0)
145 Ei: sinusoid(eamp,omega,-pi_/2,0,tmax) with .Origin at EOrig
146 "$e_i$" at EOrig+(period/3,eamp*0.8) ljust above
147
148 Ad: axis with .end at Ai.end+(0,-eamp*1.75); "$N_o$" ljust
149 DOrig: Ad.start+(tmax*0.05,0)
150 sinusoid(eamp,omega,-pi_/2,0,period/2,thick 0.4 dashed) with .Origin at DOrig
151 sinusoid(eamp,omega,-pi_/2,0,period/2,thick 0.4 dashed) \
152 with .Origin at DOrig+(period,0)
153 "$e_i$" at DOrig+(period/5,eamp*0.9) rjust above
154
155 line from Ad.start to DOrig+(ted,0)
156 Ed: sinusoid(eamp*r,omega,-pi_/2,ted,period/2-ted) \
157 with .Origin at DOrig+(0,-ed*r)
158 "$e_L$" at DOrig+(period/3,eamp*0.6) below
159 line from Ed.End right period/2+2*ted
160 Ed2: sinusoid(eamp*r,omega,-pi_/2,ted,period/2-ted) \
161 with .Origin at DOrig+(period,-ed*r)
162 line from Ed2.End to Ad.end
163
164 vEd = sum/(period/(period/2-2*ted)*npts)
165 VEd: axis with .end at Ad.end+(0,vEd); "$E_D$" ljust above
166
167 Id: axis with .end at Ad.end+(0,-eamp*1.0); "${}0$" ljust
168 IOrig: Id.start+(tmax*0.05,0)
169 line from Id.start to IOrig+(ted,0)
170 Sd: sinusoid(eamp*r,omega,-pi_/2,ted,period/2-ted) \
171 with .Origin at IOrig+(0,-ed*r)
172 "$i_L$" at IOrig+(period/3,eamp*0.7) above
173 line from Sd.End right period/2+2*ted
174 Sd2: sinusoid(eamp*r,omega,-pi_/2,ted,period/2-ted) \
175 with .Origin at IOrig+(period,-ed*r)
176 line from Sd2.End to Id.end
177 IEd: axis with .end at Id.end+(0,vEd); "$I_D$" ljust above
178 ] with .sw at Fullwave.nw+(0,0.5)
179
180 Cct1:[ diode(down_ elen_); b_current(i_L,rjust,O,E); rlabel(D)
181 resistor(right_ elen_); rlabel(+,e_L,-); llabel(,R)
182 line up elen_
183 { "$N_o$" ljust below }
184 gap(left_ elen_); rlabel(-,e_i,+)
185 ] at (Cct3,Halfwave)
186
187
188
189 .PE