Debian Codegraph @

texmf-dist/doc/latex/circuit-macros/examples/dpv/EVplugsDPV.m4

raw
1 .PS
2 # EVplugs.m4
3 # https://en.wikipedia.org/wiki/CHAdeMO
4 # https://en.wikipedia.org/wiki/North_American_Charging_Standard
5 # https://tesla-cdn.thron.com/static/HXVNIC_North_American_Charging_Standard_Technical_Specification_TS-0023666_HFTPKZ.pdf?xseo=&response-content-disposition=inline%3Bfilename%3D%22North-American-Charging-Standard-Technical-Specification-TS-0023666.pdf%22
6
7 gen_init
8 divert(-1)
9
10 `EV_J1772(keys)
11 EV charging plug in a [] block
12 keys: wdth=expr; # plug width
13 diamLNP=expr; # diam of L1, N, PE
14 twdth=expr; # tab width
15 thgt=expr; # tab hght
16 thick=expr; # outer line thickness (pt)
17 thickin=expr; # inner line thickness (pt)
18 BG=attributes; # shaded gray etc
19 L1=attributes; # L1 attributes ...
20 N=attributes;
21 PE=attributes;
22 PP=attributes;
23 CP=attributes; '
24 define(`pEVskale',25.4) dnl default plug size (20 mm)
25 define(`EV_J1772',`[ pushkeys_(`$1', `wdth:20/pEVskale;
26 twdth:3.5/20*m4`'wdth; thgt:1.5/20*m4`'wdth; diamLNP:6/20*m4`'wdth;
27 thick:2; thickin:1.5; BG::N; L1::N; N::N; PE::N; PP::N; CP::N; ')
28 tang = atan2(m4twdth/2,m4wdth/2)*rtod_
29 TS: (Rect_(m4wdth/2,-90-tang)); TE: (Rect_(m4wdth/2,-90+tang))
30 Tab: line thick m4thick from TS down_ m4thgt \
31 then to TE-(0,m4thgt) then to TE m4BG
32 Arc: arc thick m4thick to TS with .c at (0,0) m4BG
33 round(at TS,last arc.thick); round(at TE,last arc.thick)
34 L1: circle diam m4diamLNP thick m4thickin at (Rect_(m4wdth/4,150)) m4L1
35 N: circle diam m4diamLNP thick m4thickin at (Rect_(m4wdth/4, 30)) m4N
36 PE: circle diam m4diamLNP thick m4thickin at (0,-m4wdth/4) m4PE
37 PP: circle diam m4diamLNP*0.55 thick m4thickin at (Rect_(m4wdth/3,210)) m4PP
38 CP: circle diam m4diamLNP*0.55 thick m4thickin at (Rect_(m4wdth/3,-30)) m4CP
39 `$2' popdef(`m4CP',`m4PP',`m4PE',`m4N',`m4L1',`m4BG',
40 `m4wdth',`m4diamLNP',`m4twdth',`m4thgt',`m4thick',`m4thickin') ]')
41
42 `EV_J3068(keys,shade)
43 EV charging plug in a [] block
44 keys: wdth=expr; # plug width
45 diamLNP=expr; # diam of L1, N, PE
46 twdth=expr; # tab width
47 thgt=expr; # tab hght
48 thick=expr; # outer line thickness (pt)
49 thickin=expr; # inner line thickness (pt)
50 BG=attributes; # shaded gray etc
51 L1|L2|L3=attributes; # pin attributes ...
52 N=attributes;
53 PE=attributes;
54 PP=attributes;
55 CP=attributes;
56 arg2= R:G:B background fill color '
57 define(`EV_J3068',`[ pushkeys_(`$1',
58 `wdth:25/pEVskale; diamLNP:m4`'wdth*0.25; thick:2; thickin:1.5;
59 BG::N; L1::N; L2::N; L3::N; N::N; PE::N; PP::N; CP::N; ')
60 C: Here
61 NE: C+(Rect_(m4wdth/2,45)); NW: C+(Rect_(m4wdth/2,135))
62 Ac: NE-(1,1)/sqrt(2)*m4diamLNP/2
63 Arc: arc thick m4thick from NW to NE with .c at C m4BG ifelse(`$2',,,
64 `shaded rgbstring(patsubst(`$2',:,`,'))
65 line invis from NE to Ac+(0,m4diamLNP/2) \
66 then to NW+(1,-1)/sqrt(2)*m4diamLNP/2 + (0,m4diamLNP/2) \
67 then to NW then to NE shaded rgbstring(patsubst(`$2',:,`,'))')
68 arc thick m4thick to Ac+(0,m4diamLNP/2) with .c at Ac m4BG
69 Top: line thick m4thick to (NW+NE-Ac, Here) m4BG
70 arc thick m4thick to NW with .c at Here+(0,-m4diamLNP/2) m4BG
71 PE: circle diam m4diamLNP thick m4thickin at C m4PE
72 PP: circle diam m4diamLNP*0.55 thick m4thickin at C+(Rect_(m4wdth/3,45)) m4PP
73 CP: circle diam m4diamLNP*0.55 thick m4thickin at C+(Rect_(m4wdth/3,135)) m4CP
74 L1: circle diam m4diamLNP thick m4thickin at C+(m4wdth*.3,0) m4L1
75 L2: circle diam m4diamLNP thick m4thickin at C+(Rect_(m4wdth*.3,-60)) m4L2
76 L3: circle diam m4diamLNP thick m4thickin at C+(Rect_(m4wdth*.3,-120)) m4L3
77 N: circle diam m4diamLNP thick m4thickin at C-(m4wdth*.3,0) m4N
78 `$3' popdef(`m4wdth',`m4diamLNP',`m4thick',`m4thickin',
79 `m4BG',`m4L1',`m4L2',`m4L3',`m4N',`m4PE',`m4PP',`m4CP') ]')
80
81 `EV_CCS1(J1772 keys,DC keys)
82 DC keys: wdth=expr; # DC socket width
83 hght=expr; # DC socket height
84 diamPM=expr; # diam of DC+, DC- circles
85 sep=expr; # separation of Jack and DC
86 thick=expr; # outer line thickness (pt)
87 thickin=expr; # inner line thickness (pt)
88 BG=attributes; # shaded gray etc
89 DCplus=attributes;
90 DCminus=attributes; '
91 define(`EV_CCS1',`[
92 J: EV_J1772(`$1')
93 pushkeys_(`$2',`wdth:J.wid:23.5/20; hght:J.wid*11/20; diamPM:m4`'hght*7/11;
94 sep:J.wid*3/30; thick:J.Arc.thick; thickin:J.PE.thick;
95 BG::N; DCplus::N; DCminus::N;')
96 DC: [ Box: box thick m4thick wid m4wdth ht m4hght rad m4hght/2 m4BG
97 DCplus: circle thick m4thickin diam m4diamPM at Box.w+(m4hght/2,0) m4DCplus
98 DCminus:circle thick m4thickin diam m4diamPM at Box.e-(m4hght/2,0) m4DCminus
99 ] with .n at J.s+(0,-m4sep)
100 popdef(`m4wdth',`m4hght',`m4diamPM',`m4sep',`m4thick',`m4thickin',`m4BG',
101 `m4DCplus',`m4DCminus')
102 ]')
103
104 `EV_CCS2(J3068 keys,shade,DC keys)
105 DC keys: wdth=expr; # DC socket width
106 hght=expr; # DC socket height
107 diamPM=expr; # diam of DC+, DC- circles
108 sep=expr; # separation of Jack and DC
109 thick=expr; # outer line thickness (pt)
110 thickin=expr; # inner line thickness (pt)
111 BG=attributes; # shaded gray etc
112 DCplus=attributes;
113 DCminus=attributes;
114 arg2= R:G:B background fill color '
115 define(`EV_CCS2',`[
116 J: EV_J3068(`$1',`$2')
117 pushkeys_(`$3',`wdth:J.wid:23.5/20; hght:J.wid*11/20; diamPM:m4`'hght*7/11;
118 sep:J.wid*3/30; thick:J.Arc.thick; thickin:J.PE.thick;
119 BG::N; DCplus::N; DCminus::N;')
120 DC: [ Box: box thick m4thick wid m4wdth ht m4hght rad m4hght/2 dnl
121 m4BG ifelse(`$2',,,`shaded rgbstring(patsubst(`$2',:,`,'))')
122 DCplus: circle thick m4thickin diam m4diamPM at Box.w+(m4hght/2,0) m4DCplus
123 DCminus:circle thick m4thickin diam m4diamPM at Box.e-(m4hght/2,0) m4DCminus
124 ] with .n at J.s+(0,-m4sep)
125 popdef(`m4wdth',`m4hght',`m4diamPM',`m4sep',`m4thick',`m4thickin',`m4BG',
126 `m4DCplus',`m4DCminus')
127 ]')
128
129 `EV_CHAdeMO(keys,shade)
130 EV charging plug in a [] block
131 keys: wdth=expr; # plug width
132 thick=expr; # outer line thickness (pt)
133 thickin=expr; # inner line thickness (pt)
134 BG=attributes; # background shaded gray etc
135 DCplus=|DCminusNS=|FG=|NC=|SS1=|DCP=|PP=|
136 CL=|CH=|SS2=attributes # pin attributes ...'
137 define(`EV_CHAdeMO',`[ pushdef(`m4sk',33/140/pEVskale) pushkeys_(`$1',
138 `wdth:140*m4sk; thick:m4`'wdth*9/140/(1bp__); thickin:m4`'thick*1.5/9;
139 BG::N; DCplus::N; DCminus::N;N::N;S::N;
140 FG::N; NC::N; SS1::N; DCP::N; PP::N; CL::N; CH::N; SS2::N')
141 C: circle thick m4thick diam m4wdth-m4thick bp__ m4BG
142 line thick m4thick*0.6 from C+(Rect_(C.rad+m4thick bp__*3/4,42)) \
143 to C+(Rect_(C.rad+m4thick bp__*3/4,50)) then left m4thick bp__ m4BG
144 line thick m4thick*0.6 from C+(Rect_(C.rad+m4thick bp__*3/4,138)) \
145 to C+(Rect_(C.rad+m4thick bp__*3/4,130)) then right m4thick bp__ m4BG
146 idiam = (m4wdth-m4thick bp__*2)*47/(27+47*2)
147 N: circle diam idiam thick m4thickin with .n at C.n-(0,m4thick bp__/2) m4N
148 S: circle diam idiam thick m4thickin with .s at C.s+(0,m4thick bp__/2) m4S
149 E: circle diam idiam thick m4thickin at Cintersect(N,N.diam,S,S.diam) m4DCminus
150 W: circle diam idiam thick m4thickin at Cintersect(S,S.diam,N,N.diam) m4DCplus
151 foreach_(`Z',
152 `line thick m4thickin up Z.diam*0.6 right Z.diam*0.6 with .c at Z
153 line thick m4thickin up Z.diam*0.6 left Z.diam*0.6 with .c at Z',N,S)
154 foreach_(`L',`L: circle diam idiam/4 thick linethick/2 \
155 at N+(Rect_(idiam/4,90*m4Lx)) m4xpand(m4`'L)',FG,NC,DCP,SS1)
156 foreach_(`L',`L: circle diam idiam/4 thick linethick/2 \
157 at S+(Rect_(idiam/4,90*m4Lx)) m4xpand(m4`'L)',PP,CL,SS2,CH)
158 `$3' popdef(`m4sk',`m4wdth',`m4thick',`m4thickin',`m4BG',
159 `m4DCplus',`m4DCminus',`m4N',`m4S',
160 `m4FG',`m4NC',`m4SS1',`m4DCP',`m4PP',`m4CL',`m4CH',`m4SS2') ]')
161
162 `EV_NAC(keys)
163 NAC (Tesla) charging plug in a [] block
164 keys: wdth=expr; # plug width
165 diamL=expr; # diam of L1, L2
166 BG=background attributes; # shaded "gray"
167 L1=attributes; # L1 attributes ...
168 L1inner=attributes; # inner circle...
169 L2=attributes; # L2 attributes ...
170 L2inner=attributes; # inner circle...
171 inner=attributes; # central object
172 Gnd=attributes;
173 Gndinner=attributes;
174 PP=attributes;
175 CP=attributes; '
176 define(`EV_NAC',`[ pushkeys_(`$1', `wdth:1.6; diamL:m4`'wdth*0.28; BG::N;
177 L1::N; L1inner::N; L2::N; L2inner::N; Gndinner::N; inner::N;
178 Gnd::N; PP::N; CP::N; ')
179 sN = 1/pEVskale*m4wdth/1.6 # drawing coord scale factor
180 tt = 8.5/160*m4wdth; # outer width
181 rt = (4^2+43^2)/(2*4)/4*sN; rb = (23^2+56.5^2)/(2*23)/4*sN # arc radii
182 Ct: (0,0.83*m4wdth-rt); Cb: (0,rb) # arc centres
183 ra = rb*0.45; ri = ra/4 # radii
184 NAC_fillet(Ct,-rt,Cb,-rb,ra,NW,Wt,Wb) # draw outer boundary
185 NE: (-NW.x,NW.y); Eb: (-Wb.x,Wb.y); Et: (-Wt.x,Wt.y)
186 m = 9; n = 0; P[n]: (0,0)
187 NAC_arc(m,Cb,rb,-pi_/2,langle(Cb,Eb))
188 NAC_arc(m,NE,ra,langle(NE,Eb),langle(NE,Et))
189 NAC_arc(m,Ct,rt,langle(Ct,Et),pi_/2)
190 fitcurve(P,n,shaded "lightgray" m4BG,-n)
191 pushdef(`m4EVs',`shaded graystring(1)')dnl # inner circles
192 L1: circle diam m4diamL at ( 21.5/2,23.75)*sN m4EVs m4L1
193 inLt = L1.rad/4/(1bp__)
194 L1i: circle thick inLt rad L1.rad-(inLt+L1.thick)/2 bp__ outlined "yellow" \
195 at L1 m4L1inner
196 L2: circle diam m4diamL at (-21.5/2,23.75)*sN m4EVs m4L2
197 L2i: circle thick inLt rad L2.rad-(inLt+L2.thick)/2 bp__ outlined "yellow" \
198 at L2 m4L2inner
199 Gnd: circle diam m4wdth/7 at (0,L1.y-15.92*sN) m4EVs m4Gnd
200 Gndi: circle thick Gnd.rad/4/(1bp__) rad Gnd.rad-(Gnd.rad/4/(1bp__)+ \
201 Gnd.thick)/2 bp__ outlined "green" at Gnd m4Gndinner
202 PP: circle diam Gnd.diam/2 at (-17/2*sN,L1.y-16.52*sN) m4EVs m4PP
203 CP: circle diam Gnd.diam/2 at ( 17/2*sN,L1.y-16.52*sN) m4EVs m4CP
204 rs = (15^2+50^2)/(2*15)/4*sN; Cs: (0,0.3*m4wdth-rs) # inner tri-shape
205 m = 9; n = 0; P[0]: Ct+(0,rt-tt)
206 NAC_fillet(L2,L2.rad+tt,Ct,-(rt-tt),ri,FW,Fb,Ft)
207 NAC_fillet(Cb,-(rb-tt),L2,L2.rad+tt,ri,GW,Gt,Gb)
208 NAC_fillet(Cs,rs,Cb,-(rb-tt),ri,SW,St,Sb)
209 NAC_arc(3,Ct,rt-tt,pi_/2,langle(Ct,Ft))
210 NAC_arc(m,FW,ri,langle(FW,Ft),NAC_ang(FW,Fb))
211 NAC_arc(m,L2,L2.rad+tt,langle(L2,Fb),langle(L2,Gb))
212 NAC_arc(m,GW,ri,NAC_ang(GW,Gb),NAC_ang(GW,Gt))
213 NAC_arc(m,Cb,rb-tt,NAC_ang(Cb,Gt),NAC_ang(Cb,Sb))
214 NAC_arc(m,SW,ri,NAC_ang(SW,Sb),NAC_ang(SW,St))
215 NAC_arc(m,Cs,rs,langle(Cs,St),pi_/2)
216 fitcurve(P,n,fill_(1) m4inner,-n)
217 popdef(`m4EVs',`m4CP',`m4PP',`m4Gnd',`m4inner',
218 `m4L2',`m4L2inner',`m4L1',`m4L1inner',`m4Gndinner',
219 `m4BG',`m4diamL',`m4wdth') `$2' ]')
220 define(`NAC_fillet', #( C1, r1, C2, r2, frad, Cf, T1, T2 )
221 ``$6': Cintersect(`$1',(abs(`$2')+sign(`$2')*(`$5')),
222 `$3',(abs(`$4')+sign(`$4')*(`$5')))
223 `$7': LCintersect(,`$6',`$5',ifelse(index(`$2',-),0,R),`$1',`$6')
224 `$8': LCintersect(,`$6',`$5',ifelse(index(`$4',-),0,R),`$3',`$6')')
225 define(`NAC_arc', #( m, C, rad, a0, af )
226 `m4a0 = `$4'; m4af = `$5'; for i=1 to `$1' do { n+=1
227 P[n]: `$2'+(rect_(`$3',(1-i/`$1')*m4a0+i/`$1'*m4af))
228 P[-n]: (-P[n].x,P[n].y) }')
229 define(`NAC_ang',`pmod(langle(`$1',`$2'),twopi_)')
230
231 divert(0)dnl
232
233 ifsvg(svg_font(sans-serif,6bp__))
234 iflatex(command "{\sf\scriptsize")
235 define(`EVsmall',`ifsvg(svg_small(`$1'),{\tiny `$1'})')
236 define(`EVtxt',`ifsvg(``$1'',`{patsubst(`$1',_,\\_)}')')
237 define(`EVk',`ifsvg(+(0,0.75bp__))')
238
239 [
240 P1: EV_J1772(BG=fill_(0.75); PE=fill_(1) "PE";L1=fill_(1) "L1";N=fill_(1) "N";
241 PP=fill_(1); CP=fill_(1);)
242 "EVsmall(PP)" at P1.PP EVk
243 "EVsmall(CP)" at P1.CP EVk
244
245 P2: EV_J3068(PE=shaded "green" "PE";\
246 L1=shaded "yellow" "L1";L2=shaded "yellow" "L2";L3=shaded "yellow" "L3";
247 N=fill_(1) "N";",
248 0.85:0.85:0.85) at P1+(15bp__,0) \
249 with .w at P1.e+(P1.wid/5,0)
250 "EVsmall(PP)" at P2.PP EVk
251 "EVsmall(CP)" at P2.CP EVk
252
253 P3: EV_CCS1(L1="L1";N="N";PE="PE",
254 DCplus="DC+";DCminus="DC-") with .w at P2.e+(P1.wid/5,0)
255 "EVsmall(PP)" at P3.J.PP EVk
256 "EVsmall(CP)" at P3.J.CP EVk
257
258 P4: EV_CCS2(L1="L1";L2="L2";L3="L3";N="N";PE="PE",0.85:0.85:0.85,
259 DCplus="DC+";DCminus="DC-") with .w at P3.e+(P1.wid/5,0)
260 "EVsmall(PP)" at P4.J.PP EVk
261 "EVsmall(CP)" at P4.J.CP EVk
262
263 P5: EV_CHAdeMO( BG=outlined "blue" fill_(0.8);
264 DCplus=shaded "red" "DC+";
265 DCminus=shaded "red" "DC-";
266 foreach_(`L',`L=fill_(1);',N,S)
267 FG=shaded "green";
268 foreach_(`L',`L=shaded "orange";',SS1,DCP,NC,PP,CH,SS2,CL)) \
269 with .w at P4.e+(P4.w.x-P3.e.x,0)
270 foreach_(`L',`"EVsmall(L)" at P5.L EVk',FG,NC,DCP,SS1,PP,CL,CH,SS2)
271
272 P6: EV_NAC(wdth=1) with .w at P5.e+(P5.wid/5,0)
273 foreach_(`L',`"EVtxt(`L'm4Lx)" at P6.L',L1,L2)
274 thinlines_
275 arrow <- from P6.Gnd.s down P6.ht/5; "EVtxt(Gnd)" below
276 arrow <- from P6.PP.sw down P6.ht/8 left P6.ht/8; "EVtxt(`PP')" rjust
277 arrow <- from P6.CP.se down P6.ht/8 right P6.ht/8; "EVtxt(`CP')" ljust
278 thicklines_
279
280 "EVtxt(`EV_CCS2')" at P4.s+(0,-10bp__)
281 "EVtxt(`EV_NAC')" at (P6,last "")
282 "EVtxt(`EV_CHAdeMO')" at (P5,last "")
283 "EVtxt(`EV_CCS1')" at (P3,last "")
284 "EVtxt(`EV_J3068')" at (P2,last "")
285 "EVtxt(`EV_J1772')" at (P1,last "")
286 ]
287
288 iflatex(command "}%")
289 ifsvg(command "</g>")
290 .PE