summaryrefslogtreecommitdiff
path: root/graphics/pgf/contrib/kblocks/kblocks-doc.tex
blob: 27daa38287215e1b4e708c3e2edd3950d4e91843 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
\documentclass[onecolumn,a4paper,10pt]{IEEEtran}


\usepackage{kblocks}
\usepackage{bm}
\usepackage{listings}

\usepackage{csquotes}

\newcommand*{\kblocks}{\relax~\textit{k}\textsc{blocks}}
\newcommand*{\Tikz}{
    Ti\textit{k}Z
}
\newcommand*{\TikzPGF}{\relax~{Ti\textit{k}Z/\textsc{pgf}}}
\newcommand*{\spacetweak}{\medskip\medskip}

\begin{document}

\lstset{
    keywordstyle=\color{magenta},
    numberstyle=\tiny\color{gray},
    stringstyle=\color{purple},
    basicstyle=\sffamily\bfseries\scriptsize,
    breakatwhitespace=false,
    breaklines=true,
    captionpos=b,
    keepspaces=true,
    numbers=left,
    numbersep=5pt,
    showspaces=false,
    showstringspaces=false,
    showtabs=false,
    tabsize=2
}

\title{\kblocks~Package}
\author{

\IEEEauthorblockN{
\textsc{Oluwasegun~Somefun}~(\textbf{oasomefun@futa.edu.ng}) \\
\footnotesize{\textsc{Department of Computer Engineering, Federal University of Technology, Akure, Nigeria}}
}

}

\markboth{\kblocks~Demo. Version~1.0. 13, October~2019};

\maketitle

\section{Introduction}
Welcome to the demo documentation of\kblocks. Desiring to typeset control block diagrams in \LaTeX~and dissatisfied with the other \LaTeX~macro packages that
can be found online, I thought: \textit{why not write my own macro package for this purpose}.

I wish to start with the question, \enquote{What is\kblocks?} The\kblocks~macro package is the product of using\TikzPGF~to
directly typeset beautiful control block diagrams and signal flow graphs in my Masters' dissertation and papers directly with \LaTeX.
Basically, it just defines a dedicated \enquote{kblock} environment and a number of macro commands to make drawing control block diagrams using\TikzPGF~ more structured and easier. In a sense, when you
use\kblocks~you \textit{program} or typeset graphics for control block diagrams, just as you “program” graphics in your document when you use
\LaTeX~using\TikzPGF.

The powerful options offered by\TikzPGF~often intimidates beginner users not ready to spend careful time learning about\TikzPGF. Like all
\LaTeX~packages,\TikzPGF~inherits the steep learning curve of \LaTeX, that is, no \textit{what you see is what you get}.
The\kblocks~macro reduces the length of this learning curve, by focusing the graphics theme on control block diagrams only.
Fortunately this documentation as it grows and gets to be improved, will come with a number of slowly-paced
tutorials, which will guide you on creating control block diagrams with\kblocks~without your having to read the\TikzPGF~manual.

My wish is that you do find it useful and helpful. Please, don't forget to share and like if you did.

I will readily welcome any e-mails for improvement or suggestion with respect to
using\kblocks~and making it useful for researchers, students and others involved in the applications and field of control theory.

\centering

\section{Demos}
\subsection{}\spacetweak
\begin{kblock}
  \kStartNode[$r$]{R1}
  \kPlusMinusDown{R1}{S1}{0cm}
  \kTFRight[0cm]{S1}{B1}{$\frac{1}{s}$}
  \kMarkNodeRight[0cm]{}{B1}{N1}
  \kOutRight{N1}{Y1}{$y$}{0cm}

  \kLinkVHHVAbove[0cm]{$1$}{N1}{S1}{0}{0}
  \kLinkVHHVBelow[0cm]{$1$}{N1}{S1}{0}{0}
  \kLink[]{R1}{S1}
  \kLink[$e$]{S1}{B1}
  \kLinkn[]{B1}{N1}
\end{kblock}

\begin{lstlisting}
\begin{kblock}
  \kStartNode[$r$]{R1}
  \kPlusMinusDown{R1}{S1}{0cm}
  \kTFRight[0cm]{S1}{B1}{$\frac{1}{s}$}
  \kMarkNodeRight[0cm]{}{B1}{N1}
  \kOutRight{N1}{Y1}{$y$}{0cm}

  \kLinkVHHVAbove[0cm]{$1$}{N1}{S1}{0}{0}
  \kLinkVHHVBelow[0cm]{$1$}{N1}{S1}{0}{0}
  \kLink[]{R1}{S1}
  \kLink[$e$]{S1}{B1}
  \kLinkn[]{B1}{N1}
\end{kblock}
\end{lstlisting}


\spacetweak

\subsection{}\spacetweak
\begin{kblock}
  \kStartNodec[$r$]{(0,5)}{R1}
  \kPlusMinusDown{R1}{S1}{0cm}
  \kTFRight[0.33cm]{S1}{B1}{$G\left( s \right)$}
  \kTFBelow[0cm]{B1}{B2}{$H\left( s \right)$}
  \kMarkNodeRight[0.2cm]{}{B1}{N1}
  \kOutRight{N1}{Y1}{$y$}{0}

  \kLinkVHTFHVBelow{$y$}{$\hat{y}$}{N1}{B2}{S1}{0}{0}{0}
  \kLink[]{R1}{S1}
  \kLink[$e$]{S1}{B1}
  \kLinkn[]{B1}{N1}

  \kCoverRect[blue]{B1}{0.5cm}{1.5cm}{1.8cm}{1.5cm}
  \kCoverTextRight{1cm}{0.5cm}{TX1}{Closed-loop system};
\end{kblock}

\begin{lstlisting}
\begin{kblock}
  \kStartNodec[$r$]{(0,5)}{R1}
  \kPlusMinusDown{R1}{S1}{0cm}
  \kTFRight[0.33cm]{S1}{B1}{$G\left( s \right)$}
  \kTFBelow[0cm]{B1}{B2}{$H\left( s \right)$}
  \kMarkNodeRight[0.2cm]{}{B1}{N1}
  \kOutRight{N1}{Y1}{$y$}{0}

  \kLinkVHTFHVBelow{$y$}{$\hat{y}$}{N1}{B2}{S1}{0}{0}{0}
  \kLink[]{R1}{S1}
  \kLink[$e$]{S1}{B1}
  \kLinkn[]{B1}{N1}

  \kCoverRect[blue]{B1}{0.5cm}{1.5cm}{1.8cm}{1.5cm}
  \kCoverTextRight{1cm}{0.5cm}{TX1}{Closed-loop system};
\end{kblock}
\end{lstlisting}
\spacetweak

\subsection{}\spacetweak

\begin{kblock}
  \kStartNodec[]{(5,-5)}{R1}
  \kTFRight{R1}{M1}{$\bm{\hat{m}$}\\\textbf{PID}\\\textbf{model}}
  \kOutDown[]{M1}{um}{$u_m$}{0}
  \kScaleDistX[1.5]
  \kTFRight{M1}{C1}{$\bm{K\left(y_m,y\right)}$\\\textbf{PID}\\\textbf{controller}}
  \kTFBelowRight{0cm}{0.2cm}{C1}{P1}{$\bm{P\left(s\right)}$\\\textbf{process}}

  \kLink[$r$]{R1}{M1}
  \kLink[$y_m$]{M1}{C1}
  \kLinkHV[$u$]{C1}{P1}{north}{0}
  \kLinkHV[$y$]{P1}{C1}{south}{0}
\end{kblock}

\begin{lstlisting}
\begin{kblock}
  \kStartNodec[]{(5,-5)}{R1}
  \kTFRight{R1}{M1}{$\bm{\hat{m}$}\\\textbf{PID}\\\textbf{model}}
  \kOutDown[]{M1}{um}{$u_m$}{0}
  \kScaleDistX[1.5]
  \kTFRight{M1}{C1}{$\bm{K\left(y_m,y\right)}$\\\textbf{PID}\\\textbf{controller}}
  \kTFBelowRight{0cm}{0.2cm}{C1}{P1}{$\bm{P\left(s\right)}$\\\textbf{process}}

  \kLink[$r$]{R1}{M1}
  \kLink[$y_m$]{M1}{C1}
  \kLinkHV[$u$]{C1}{P1}{north}{0}
  \kLinkHV[$y$]{P1}{C1}{south}{0}
\end{kblock}
\end{lstlisting}
\spacetweak

\subsection{}\spacetweak

\begin{kblock}
  \kStartNodec[]{(-5,-5)}{R1}
  \kTFRight{R1}{M1}{$\bm{\hat{m}$}\\\textbf{PID}\\\textbf{model}}
  \kOutDown[]{M1}{um}{$u_m$}{0}
  \kScaleDistX[1.75]
  \kTFRight{M1}{C1}{$\bm{K\left(y_m,y\right)}$\\\textbf{PID}\\\textbf{controller}}
  \kScaleDistX[1]
  \kTFBelow{C1}{P1}{$\bm{P\left(s\right)}$\\\textbf{process}}

  \kLink[$r$]{R1}{M1}
  \kLink[$y_m$]{M1}{C1}
  \kLinkHVHRight[0]{$u$}{C1}{P1}{0}{0}
  \kLinkHVHLeft[0.33]{$y$}{P1}{C1}{0}{-0.25}
\end{kblock}
\begin{lstlisting}
\begin{kblock}
  \kStartNodec[]{(-5,-5)}{R1}
  \kTFRight{R1}{M1}{$\bm{\hat{m}$}\\\textbf{PID}\\\textbf{model}}
  \kOutDown[]{M1}{um}{$u_m$}{0}
  \kScaleDistX[1.75]
  \kTFRight{M1}{C1}{$\bm{K\left(y_m,y\right)}$\\\textbf{PID}\\\textbf{controller}}
  \kScaleDistX[1]
  \kTFBelow{C1}{P1}{$\bm{P\left(s\right)}$\\\textbf{process}}

  \kLink[$r$]{R1}{M1}
  \kLink[$y_m$]{M1}{C1}
  \kLinkHVHRight[0]{$u$}{C1}{P1}{0}{0}
  \kLinkHVHLeft[0.33]{$y$}{P1}{C1}{0}{-0.25}
\end{kblock}
\end{lstlisting}
\spacetweak

\subsection{}\spacetweak

\begin{kblock}
    \kJumpCS{R}{$(0,0)$}

    \kJumpCSRight[-0.5cm]{R}{CR}{0}{3}
    \kJumpCSLeft[-0.5cm]{R}{CR}{0}{9}
    \kJumpCSAbove[-0.5cm]{R}{CR}{0}{12}
    \kJumpCSBelow[-0.5cm]{R}{CR}{0}{6}

    \kTFBelow{R}{C1}{\bfseries{PID}$\bm{(\cdot)}$}
    \kScaleDistX[0.67]
    \kTFBelow{C1}{P1}{$\bm{P(s)}$}
    \kScaleDistX[1]

    \kInLeft[0cm]{C1}{RI}{$r$}{0.1}

    \kMarkNodeLeft[0cm]{}{P1}{ON}
    \kLinkn[]{P1}{ON}
    \kOutLeft[-0.5cm]{ON}{Y}{$y$}{0}
    \kLinkVH[$y$]{ON}{C1}{west}{-0.1}

    \kLinkHVHRight[0]{$u$}{C1}{P1}{0}{0}
\end{kblock}

\begin{lstlisting}
\begin{kblock}
    \kJumpCS{R}{$(0,0)$}

    \kJumpCSRight[-0.5cm]{R}{CR}{0}{3}
    \kJumpCSLeft[-0.5cm]{R}{CR}{0}{9}
    \kJumpCSAbove[-0.5cm]{R}{CR}{0}{12}
    \kJumpCSBelow[-0.5cm]{R}{CR}{0}{6}

    \kTFBelow{R}{C1}{\bfseries{PID}$\bm{(\cdot)}$}
    \kScaleDistX[0.67]
    \kTFBelow{C1}{P1}{$\bm{P(s)}$}
    \kScaleDistX[1]

    \kInLeft[0cm]{C1}{RI}{$r$}{0.1}

    \kMarkNodeLeft[0cm]{}{P1}{ON}
    \kLinkn[]{P1}{ON}
    \kOutLeft[-0.5cm]{ON}{Y}{$y$}{0}
    \kLinkVH[$y$]{ON}{C1}{west}{-0.1}

    \kLinkHVHRight[0]{$u$}{C1}{P1}{0}{0}
\end{kblock}
\end{lstlisting}
\spacetweak

\subsection{}\spacetweak

\begin{kblock}
  \kJumpCS{R1}{$(5,5)$}

  \kTFRight{R1}{P1}{$\bm{P}$}
  \kScaleDistX[0.67]
  \kTFBelow{P1}{C1}{$\bm{C}$}
  \kScaleDistX[1]

  \kInLeft[]{P1}{RI}{$w$}{0.1}
  \kInLeft[]{C1}{RC}{$r$}{-0.1}

  \kLinkHVHRight[0.2]{$y$}{P1}{C1}{-0.1}{0.1}
  \kLinkHVHLeft[0.2]{$u$}{C1}{P1}{0.1}{-0.1}

  \kOutRight[0cm]{P1}{Z}{$z$}{0.1}
  \kOutRight[]{C1}{V}{$v$}{-0.1}

  \kCoverRect[blue!50!]{P1}{0.1cm}{0.1cm}{0.2cm}{0.2cm}
  \kCoverTextAbove{0}{0}{TX1}{Physical System};

  \kCoverRect[red]{C1}{0.1cm}{0.1cm}{0.2cm}{0.2cm}
  \kCoverTextBelow{0cm}{0cm}{TX2}{Computing System};
\end{kblock}

\begin{lstlisting}
\begin{kblock}
  \kJumpCS{R1}{$(5,5)$}

  \kTFRight{R1}{P1}{$\bm{P}$}
  \kScaleDistX[0.67]
  \kTFBelow{P1}{C1}{$\bm{C}$}
  \kScaleDistX[1]

  \kInLeft[]{P1}{RI}{$w$}{0.1}
  \kInLeft[]{C1}{RC}{$r$}{-0.1}

  \kLinkHVHRight[0.2]{$y$}{P1}{C1}{-0.1}{0.1}
  \kLinkHVHLeft[0.2]{$u$}{C1}{P1}{0.1}{-0.1}

  \kOutRight[0cm]{P1}{Z}{$z$}{0.1}
  \kOutRight[]{C1}{V}{$v$}{-0.1}

  \kCoverRect[blue!50!]{P1}{0.1cm}{0.1cm}{0.2cm}{0.2cm}
  \kCoverTextAbove{0}{0}{TX1}{Physical System};

  \kCoverRect[red]{C1}{0.1cm}{0.1cm}{0.2cm}{0.2cm}
  \kCoverTextBelow{0cm}{0cm}{TX2}{Computing System};
\end{kblock}
\end{lstlisting}

\spacetweak

\subsection{}\spacetweak
\begin{kblock}
\kJumpCS{io}{$(0,0)$}
\kJumpCSLeft[-0.5cm]{io}{jl}{0}{9}
\kCoverRect[blue]{jl}{2cm}{2cm}{2cm}{2cm}
\end{kblock}

\begin{lstlisting}
\begin{kblock}
\kJumpCS{io}{$(0,0)$}
\kJumpCSLeft[-0.5cm]{io}{jl}{0}{9}
\kCoverRect[blue]{jl}{2cm}{2cm}{2cm}{2cm}
\end{kblock}
\end{lstlisting}

\spacetweak

\end{document}