Debian Codegraph @

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

raw
1 .PS
2 # ColdControlDPV.m4
3 #https://www.researchgate.net/journal/Sensors-1424-8220/publication/361484962_Design_of_a_Smart_IoT-Based_Control_System_for_Remotely_Managing_Cold_Storage_Facilities/links/6806de36df0e3f544f442241/Design-of-a-Smart-IoT-Based-Control-System-for-Remotely-Managing-Cold-Storage-Facilities.pdf
4
5 log_init
6 sinclude(ics.m4)
7 sinclude(../ics.m4)
8
9
10 divert(-1)
11
12 define(`ESP8266',`[ Chip: box wid 9*lg_pinsep ht 16*lg_pinsep
13 foreach_(`x',`Pin`'eval(m4Lx+15): line from Chip.ne+(0,(m4Lx-16)*lg_pinsep) \
14 right pinlen "eval(m4Lx+15)" above; "x" rjust at last line.start',
15 3V3,GND,TX(GPIO1),RX(GPIO3),D8(GPIO15),D7(GPIO13),D6(GPIO12),
16 D5(GPIO14),GND,3V3,D4(GPIO2),D3(GPIO0),D2(GPIO4),D1(GPIO5),D0(GPIO16))
17 foreach_(`x',`Pin`'m4Lx: line from Chip.nw+(0,-m4Lx*lg_pinsep) \
18 left pinlen "m4Lx" above; "x" ljust at last line.start',
19 AO(ADC0),RSV,RSV,SD3(GPIO10),SD2(GPIO9),SD1(MOSI), CMD(CS),SDO(MISO),
20 CLK(SCLK),GND,3V3,EN,RST,GND,VIN) ]')
21
22 define(`LEDQ',`[ B:dot; resistor(up_ dimen_,,E); rlabel(,R)
23 diode(up_ dimen_/2 from Here+(0,-dimen_/5),L)
24 { em_arrows(,135,dimen_/3) with .Tail at last [].nw}; dot
25 {ground(,,S,0); "GND" at last line.s below ljust}
26 Q: bi_tr(up_ dimen_*5/4,,,E) with .E at Here; "BC547" at last [].e ljust
27 line from Q.B left_ dimen_/3
28 resistor(down_ to (Here,B),,E); llabel(,R); line to B
29 T: Q.C ]')
30
31 define(`Relay',`[ C: relaycoil(S,,,ifelse(`$2',,U,D))
32 B: box wid elen_ ht C.ht at C ifelse(`$2',,+,-)(elen_/4,0)
33 `"Relay"' at B.n above
34 ifelse(`$2',,`C1: 1/4 < B.nw, B.ne >; C2: 1/4 < B.sw, B.se >
35 S1: 5/6 < B.nw, B.ne >; S2: 5/6 < B.sw, B.se >
36 S: dswitch(ifinstr(`$1',R,`down_ from S1 to S2,R',`up_ from S2 to S1,'),WBCD)',
37 `C1: 3/4 < B.nw, B.ne >; C2: 3/4 < B.sw, B.se >
38 S1: 1/6 < B.nw, B.ne >; S2: 1/6 < B.sw, B.se >
39 S: dswitch(ifinstr(`$1',R,`up_ from S2 to S1,R',`down_ from S1 to S2,'),WBCD)')
40 "G5Q-1A" at 1/2<C2,S2> below ]')
41
42 define(`Fan',`[ C: circle at (0,0) ifelse(`$1',,,`diam `$1'')
43 arc from (Rect_(C.rad,-30)) to (Rect_(C.rad,210)) with .c at (0,-C.rad)
44 arc to (Rect_(C.rad,90)) with .c at (Rect_(C.rad,150))
45 arc to (Rect_(C.rad,-30)) with .c at (Rect_(C.rad,30)) ]')
46
47 define(`pins',`for_(1,`$1',1,
48 `ifinstr(`$2',L,`L`'m4x:line left_ del \
49 from ((m4x*2-1)/(2*(`$1')))<last box.nw, last box.sw>')
50 ifinstr(`$2',R,`R`'m4x:line right_ del \
51 from ((m4x*2-1)/(2*(`$1')))<last box.ne,last box.se>') ')')
52
53 define(`thermometer',`[ eleminit_(`$1')
54 tx = rp_len; ty = tx/6
55 {box ht_ ty rad ty/2 wid_ rp_len-ty}
56 {circle diam 2*ty fill_(0) at rvec_(rp_len-ty,0)}
57 {box ht_ last box.ht_ wid_ last box.wid_/4 \
58 at rvec_(rp_len-ty*5/2,0) fill_(0)}
59 for i=1 to 5 do {{ move to rvec_(ty*i/2,0)
60 line from rvec_(0,-ty/2) to Here }} ]')
61
62 define(`thsen',`[ B: box ht boxwid*5/6
63 pins(4,L)
64 "T svg_amp RH" above at B.n; "DHT22" below rjust at B.se
65 for j=1 to 5 do {
66 box wid B.wid/10 ht B.wid/15 at B.nw+((j-1/2)*B.wid/5,-(1/2)*B.ht/4)
67 for i=2 to 4 do {
68 box wid B.wid/10 ht B.wid/12 at B.nw+((j-1/2)*B.wid/5,-(i-1/2)*B.ht/4)
69 } } ]')
70
71 define(`S8',`[ B: box wid dimen_*3.2 ht dimen_*2
72 foreach_(`x',`move to B.nw-(0,(m4Lx-1/2)*B.ht/5)
73 ifelse(x,nul,,{"x" ljust}; L`'m4Lx: line left_ del)',
74 UART_R/T,UART_TXD,UART_RXD,nul,BCAL_IN)
75 foreach_(`x',`move to B.ne-(0,(m4Lx-1/2)*B.ht/5)
76 ifelse(x,nul,,{"x" rjust}; R`'m4Lx: line right_ del)',
77 ALARMLOC,nul,PWM_1KHZ,nul,DVCC_OUT) ]')
78
79 # `RC1602A rotated 90 deg'
80 define(`XC1602A_R',`[ Chip: box ht 6*lg_pinsep wid 14*lg_pinsep
81 foreach_(`xx',`pushdef(`x1',patsubst(xx,:.*)) pushdef(`x2',patsubst(xx,.*:))
82 Pin`'x1: line from Chip.ne-(m4Lx*lg_pinsep,0) up_ pinlen
83 svg_rot(90,"x1",at last line.c-(textoffset+textht/2,0))
84 svg_rot(90,"x2",at last line.start-(0,textht*(len(x2)+1/2)/2))',
85 4:RS,5:R/W,6:E,3:Vo) popdef(`x1',`x2')
86 line from Pin6.start-(textht/2+2bp__,textoffset) down_ textht*3/4
87 line from Pin5.start-(textht/2+2bp__,textoffset) down_ textht
88 foreach_(`xx',`Pin`'eval(m4Lx+6): line from Chip.ne-((m4Lx+5)*lg_pinsep,0) \
89 up_ pinlen
90 svg_rot(90,"eval(m4Lx+6)",at last line.c-(textoffset+textht/2,0))
91 svg_rot(90,"xx",at last line.start-(0,textht*(len(xx)+1/2)/2)) ',
92 DB0,DB1,DB2,DB3,DB4,DB5,DB6,DB7)
93 Pin1: line from Chip.w left_ pinlen
94 svg_rot(90,"1",with .s at Pin1)
95 svg_rot(90,"VSS",at Chip.w+(textht,0))
96 Pin2: line from Chip.e right_ pinlen
97 svg_rot(90,"2",at Pin2+(0,textht/2+textoffset))
98 svg_rot(90,"VDD",at Chip.e-(textht/2+textoffset,0))
99 foreach_(`xx',`pushdef(`x1',patsubst(xx,:.*))
100 pushdef(`x2',patsubst(xx,^[^:]*:\|:.*)) pushdef(`x3',patsubst(xx,.*:))
101 Pin`'x2: line from Chip.se-(x1*lg_pinsep,0) down_ pinlen
102 svg_rot(90,"x2",at last line.c-(textoffset+textht/2,0))
103 svg_rot(90,"x3",at last line.start+(0,textht*(len(x3)+1/2)/2))',
104 6:16:K,8:A:A1,9:K1:K) popdef(`x1',`x2',`x3')
105 Pin15: line from Chip.se-(7*lg_pinsep,0) down_ pinlen
106 svg_rot(90,"15",at last line.c-(textoffset+textht/2,0))
107 svg_rot(90,"A/VEE",at last line.start+(0,textht*5/2)) ]')
108
109 define(`Ammonia',`[ B: box; "MQ-3" at B.se rjust below
110 line left_ del then up_ del from 3/4<B.sw,B.nw>; "5 V" above
111 "VCC" at last line.start ljust
112 line left_ del from 1/4<B.sw,B.nw>
113 {"GND" at last line.start ljust}
114 ground(,,S); "GND" at last line.s ljust
115 C: circle diam B.ht*7/8 at B.e-(B.ht/2,0)
116 circle diam B.ht*5/8 at C
117 circle diam B.ht*3/8 at C
118 circle diam B.ht/4 at C
119 Out: 1/6<B.se,B.ne>; "out" at Out below ljust
120 "C`'svg_sub(2)H`'svg_sub(4)" at B.n+(0,2bp__) above ]')
121
122 divert(0)dnl
123 svg_font(sans-serif,8.5bp__)
124 #vg_rot_init(test)
125 svg_rot_init(ColdControlDPV)
126
127 define(`pinlen',`20bp__')
128 define(`lg_pinsep',(1.2*lg_pinsep))
129 del = lg_pinsep
130
131 ESP: ESP8266; `"ESP8266"' at ESP.Chip.se below rjust
132 line from ESP.Pin24.end right del then down ESP.Pin24.y-ESP.Pin16.y
133 ground(,,S); "GND" at last line.s below
134 dot(at ESP.Pin17.end+(del,0)); line to ESP.Pin17.end
135 "3.3 V" at ESP.Pin25.end ljust
136 LEQ1: LEDQ with .B at ESP.Chip.nw+(dimen_+del,dimen_/2)
137 line from LEQ1.B to (ESP.Pin30.end,LEQ1.B) then to ESP.Pin30.end
138 LEQ2: LEDQ with .B at ESP.Chip.ne+(del*3/2,dimen_/2+del)
139 line from LEQ2.B to (ESP.Pin29.end.x+del,LEQ1.B.y+del)
140 continue to (Here,ESP.Pin29) then to ESP.Pin29.end
141 line from LEQ1.T up 2*del then right_ ESP.Pin30.end.x-LEQ1.T.x +6*del \
142 then down_ del; right_
143 R1: Relay(R) with .C1 at Here
144 R2: Relay with .B.n at R1.B.s+(0,-dimen_)
145 line from R1.S.end to R2.S.end; dot(at last line.c); line right_ del
146 "220 V" ljust
147 line from R1.C.V1 to R2.C.V2; dot(at last line.c); line left_ del
148 "5 V" rjust
149 line from LEQ2.T right_ R2.C2.x-LEQ2.T.x-3*del
150 continue to (Here.x,R2.C2.y-del) then right_ R2.C2.x-Here.x then to R2.C2
151 line from R1.S1 up del then right_ 2*del
152
153 Hum: [F: Fan; box wid F.wid ht F.ht at F; pins(3,LR)] with .L1.end at Here
154 "Hum. unit" at Hum.s below
155 line from R2.S2 down del then right_ 2*del
156
157 Con: [B: box; pins(3,LR)
158 circle diam B.ht/3 with .n at 1/4 < B.nw, B.ne >
159 circle diam B.ht/3 with .n at 3/4 < B.nw, B.ne >
160 circle diam B.ht/3 with .s at 3/4 < B.sw, B.se >
161 circle diam B.ht/3 with .s at 1/4 < B.sw, B.se > ] \
162 with .L3.end at Here
163 "Control unit" at Con.s below
164
165 line from ESP.Pin23.end to (R2.w.x+4*del,ESP.Pin23.y)
166 T1: box wid boxht with .w at Here; "T1" at T1.e ljust "DS1822" ljust
167 "out" at T1.w ljust
168 T2: box wid boxht with .w at (T1.w,ESP.Pin28)
169 "T2" at T2.e ljust "DS1822" ljust; "out" at T2.w ljust
170 line from ESP.Pin26.end right del then up T2.w.y-ESP.Pin26.y then to T2.w
171 line from T2.s to T1.n; dot(at last line.c); ground(,,S,0)
172 "GND" at Here+(dimen_*5/6,0)
173 line from 1/4 <T2.nw,T2.sw> left del; "5 V" above
174 line from 1/4 <T1.nw,T1.sw> left del; "5 V" above
175
176 thermometer(up_ T2.ht*3/4) at 3/4<T2.w,T2.e>
177 thermometer(down_ T1.ht*3/4) at 3/4<T1.w,T1.e>
178
179 M1: thsen with .L2.start at (T1.w.x,ESP.Pin21.y-2*del)
180 ground(at M1.L4.end,,S); "GND" at last line.s below
181 "5 V" above at M1.L1.end
182 line from M1.L2.end left del
183 continue to (Here,ESP.Pin22) then to ESP.Pin22.end
184 M2: thsen with .n at M1.s+(0,-2*del)
185 ground(at M2.L4.end,,S); "GND" at last line.s below
186 "5 V" rjust at M2.L1.end
187 line from M2.L2.end left 2*del
188 continue to (Here,ESP.Pin21) then to ESP.Pin21.end
189
190 CO2: S8 with .B.nw at (M2.L1.end.x-2*del,M2.s.y-dimen_)
191 "G0" at CO2.s above; "G+" at CO2.n below
192 `"Senseair S8"' at CO2.B.se rjust below
193 line up del from CO2.n; "5 V" above
194 line down del from CO2.s; ground(,T,S); "GND" at last line.s below
195 line from CO2.R1.end up del
196 Spkr:speaker(U,dimen_*2/3) with .In1 at Here
197 "CO`'svg_sub(2)" at Spkr.n+(0,10bp__) "Alarm"
198 line down del*3/2 from Spkr.In3; ground(,T,S)
199 "GND" at last line.s below
200 line from CO2.L1.end to (CO2.L1.end,ESP.Pin20) then to ESP.Pin20.end
201 line from CO2.L2.end left del
202 continue to (Here,ESP.Pin19) then to ESP.Pin19.end
203 line from CO2.L3.end left 2*del
204 continue to (Here,ESP.Pin18) then to ESP.Pin18.end
205
206 # svg_rot(90,"X",at (ESP.Pin7.end.x+4*del,ESP.s.y))
207 LCD: XC1602A_R with .Pin14.start \
208 at (ESP.Pin7.end.x-4*del,ESP.s.y-dimen_-del*3/2)
209 {"LCD" at 1/2<LCD.Chip.sw,LCD.PinK1.start> below
210 `"RC1602A-GHW-ESX"' at LCD.Chip.se+(10bp__,0) rjust below}
211 RV: potentiometer(right_ dimen_) with .T1 at LCD.Pin15.end
212 {"RV" at RV.R.c+(0,-dimen_/12) below
213 "1" at RV.R.c+(dimen_/4,0) above ljust}
214 line from RV.End to (LCD.Pin2.end,RV.End); dot
215 line from LCD.Pin2.end to Here chop 0 chop -del; "5 V" ljust
216 line from RV.Start to (LCD.Pin1.end,RV.Start); dot
217 line from LCD.Pin1.end to Here; ground(,,S); "GND" at last line.s below
218
219 line from ESP.Pin27.end right_ 2*del;continue to (Here.x,LCD.Pin12.end.y+del)
220 continue to (LCD.Pin12,Here) then to LCD.Pin12.end
221 line from ESP.Pin11.end left del then down ESP.Pin11.y-ESP.s.y; "3.3 V" ljust
222 line from ESP.Pin15.end left del; dot
223 line from ESP.Pin10.end left 2*del then down ESP.Pin10.y-ESP.s.y
224 ground(,T,S); "GND" at last line.s below
225 line from ESP.Pin14.end left 2*del; dot
226 line from ESP.Pin9.end to (LCD.Pin13,ESP.Pin9) then to LCD.Pin13.end
227 line from ESP.Pin7.end to (LCD.Pin14,ESP.Pin7) then to LCD.Pin14.end
228
229 LEQ3: LEDQ with .B at (ESP.Pin1.end.x-del,LEQ1.B.y)
230 line from LEQ3.B to (LEQ3.B,ESP.Pin4) then to ESP.Pin4.end
231 R3: Relay(,R) with .se at LEQ3.Q.B-(2*del,0)
232 line from R3.C1 up del; continue to (LEQ3.T,Here) then to LEQ3.T
233 line from R3.S2 down_ del; "220 V" below
234 line from R3.C2 down_ del; "5 V" below
235 line from R3.S1 up_ del then left_ R3.S1.x-R3.w.x+del then down R3.ht+3*del
236 F1: Fan with .n at Here
237 ground(at F1.s,,S); "GND" at last line.s below
238 "Ventilation" at F1.e ljust "unit" ljust
239
240 line from ESP.Pin5.end left_ 7*del
241 A1: Ammonia with .Out at Here
242 A2: Ammonia with .Out at A1.Out-(0,dimen_*2)
243 line from A2.Out right_ del; continue to (Here,ESP.Pin6) then to ESP.Pin6.end
244
245 line from ESP.Pin8.end left_ 5*del; continue to (Here,ESP.s) \
246 then left_ del
247 LightS: [ B: box ht boxwid; "BH1750" at B.se rjust below
248 circle diam B.ht/5 at B.nw+(B.ht/5,-B.ht/5)
249 circle diam B.ht/5 at B.sw+(B.ht/5, B.ht/5)
250 foreach_(`x',
251 `Pin`'m4Lx: line right_ pinlen from B.se+(0,(m4Lx-1/2)*B.ht/5) "m4Lx" above
252 "x" at last line.start rjust',ADDR,SDA,SCL,GND,VCC)
253 ] with .Pin2.end at Here
254 {"Light" at LightS.B.n above}
255 line from LightS.Pin3.end to (LCD.Pin13,LightS.Pin3); dot
256 line from LightS.Pin5.end up del; "5 V" above
257 line from LightS.Pin4.end down LightS.Pin4.y-LightS.s.y
258 {dot(at (Here,LightS.Pin1))}
259 ground(,,S); "GND" at last line.s below
260
261 command "</g>"
262 .PE