
我查看了這篇文章中的 LaTex 程式碼:使用 Tikz 的框圖
我的問題是,我可以在哪裡獲得輸入、總和、區塊的描述……我想使用乘法,但我在任何地方都找不到這些元素的文檔。
編輯:我得到了這些塊來自哪裡的答案,現在我想問是否有某種預製塊可以導入,對我來說用 LaTex 繪製真的很困難,而且我覺得沒有能力製作我自己的塊。
\tikzset{
block/.style = {draw, fill=white, rectangle, minimum height=3em, minimum width=3em},
tmp/.style = {coordinate},
sum/.style= {draw, fill=white, circle, node distance=1cm},
input/.style = {coordinate},
output/.style= {coordinate},
pinstyle/.style = {pin edge={to-,thin,black}
}
}
\begin{tikzpicture}[auto, node distance=2cm,>=latex']
\node [input, name=rinput] (rinput) {};
\node [sum, right of=rinput] (sum1) {};
\node [block, right of=sum1] (controller) {$k_{p\beta}$};
\node [block, above of=controller,node distance=1.3cm] (up){$\frac{k_{i\beta}}{s}$};
\node [block, below of=controller,node distance=1.3cm] (rate) {$sk_{d\beta}$};
\node [sum, right of=controller,node distance=2cm] (sum2) {};
\node [block, above = 2cm of sum2](extra){$\frac{1}{\alpha_{\beta2}}$}; %
\node [block, right of=sum2,node distance=2cm] (system)
{$\frac{a_{\beta 2}}{s+a_{\beta 1}}$};
\node [output, right of=system, node distance=2cm] (output) {};
\node [tmp, below of=controller] (tmp1){$H(s)$};
\draw [->] (rinput) -- node{$R(s)$} (sum1);
\draw [->] (sum1) --node[name=z,anchor=north]{$E(s)$} (controller);
\draw [->] (controller) -- (sum2);
\draw [->] (sum2) -- node{$U(s)$} (system);
\draw [->] (system) -- node [name=y] {$Y(s)$}(output);
\draw [->] (z) |- (rate);
\draw [->] (rate) -| (sum2);
\draw [->] (z) |- (up);
\draw [->] (up) -| (sum2);
\draw [->] (y) |- (tmp1)-| node[pos=0.99] {$-$} (sum1);
\draw [->] (extra)--(sum2);
\draw [->] ($(0,1.5cm)+(extra)$)node[above]{$d_{\beta 2}$} -- (extra);
\end{tikzpicture}
答案1
如果我正確理解你的問題,。你實際上對 PI 控制器方案不感興趣,而是對如何設計一些元素感興趣......我將嘗試分兩步回答:
使用現在更可取的語法使您的 MWE 現代化(如果您仔細比較這兩種解決方案,您將很容易發現差異)
建議如何設計一些用於繪製控制方案的“構建塊”
MWE 的第一次修訂:
\documentclass[border=3mm,
tikz]{standalone}
\usetikzlibrary{arrows,
calc,
quotes,
positioning,
babel} % <--- added for
\tikzset{
block/.style = {rectangle, draw, %fill=white,
minimum size=3em},
tmp/.style = {coordinate},
sum/.style = {circle, draw, minimum size=1ex, inner sep=1pt,
node contents={} },
dot/.style = {sum, fill=black, minimum size=2pt,
node contents={} },
input/.style = {coordinate},
output/.style = {coordinate},
pinstyle/.style = {pin edge={to-,thin,black}}
}
\begin{document}
\begin{tikzpicture}[auto,
node distance = 3mm and 13mm,
> = latex']
\coordinate (input) at (0,0);
\node (sum1) [sum, right=of input];
\node (input') [dot, right=of sum1];
\node (cntrl) [block, right=of input'] {$k_{p\beta}$};
\node (up) [block, above=of cntrl] {$\frac{k_{i\beta}}{s}$};
\node (rate) [block, below=of cntrl] {$sk_{d\beta}$};
\node (sum2) [sum, right=of cntrl];
\node (extra)[block,
above=of up.north -| sum2] {$\frac{1}{\alpha_{\beta2}}$}; %
\node (extra') [above=of extra] {$d_{\beta 2}$};
\node (system) [block, right=of sum2] {$\frac{a_{\beta 2}}{s+a_{\beta 1}}$};
\coordinate[right=of system] (output);
\node [tmp, below=of cntrl] (tmp1) {$H(s)$};
%
\draw[->] (input) to ["$R(s)$"] (sum1)
(sum1) edge["$E(s)$"] (input')
(input') edge (cntrl)
(cntrl) edge (sum2)
(sum2) edge["$U(s)$"] (system)
(system) edge["$Y(s)$"] (output)
(extra') edge (extra);
\draw[->] (input') |- (up);
\draw[->] (input') |- (rate);
\draw[->] (up) -| (sum2);
\draw[->] (rate) -| (sum2);
\draw (extra) -- (extra |- up);
\draw[->] ($(system.east)!0.5!(output)$) node[dot] -- + (0,-22mm) -| (sum1);
\end{tikzpicture}
\end{document}
您已經可以在這裡觀察如何設計sum
和dot
。求和以及乘法的符號都沒有標準化(實際上,它們是標準化的,但很少使用...)。因此,您首先需要決定您喜歡它們的外觀。以下是在訊號處理和控制中也很常見的那些符號的範例。
\documentclass[border=1mm,
tikz,{standalone}
\usetikzlibrary{arrows,
calc,
quotes,
positioning,
babel}
\begin{document}
\begin{tikzpicture}[
shorten <>/.style = {shorten >=#1, shorten <=#1},
mlt-s/.style={fill=#1, % <-- symb. for multiplication, square
rectangle, draw, minimum size=6mm,
path picture={\draw[very thick,shorten <>=1.5mm]
(path picture bounding box.north west)edge(path picture bounding box.south east)
(path picture bounding box.south west) -- (path picture bounding box.north east);
},% end of node contents
node contents={}},
mlt-c/.style={fill=#1, % <-- symb. for multiplication, circle
circle, draw, minimum size=6mm,
path picture={\draw[very thick,shorten <>=2mm]
(path picture bounding box.north west)edge(path picture bounding box.south east)
(path picture bounding box.south west) -- (path picture bounding box.north east);
},% end of node contents
node contents={}},
sum/.style={fill=#1, % <-- symb. for summation
circle, draw, minimum size=6mm,
path picture={\draw[very thick,shorten <>=1mm]
(path picture bounding box.north)edge(path picture bounding box.south)
(path picture bounding box.west) -- (path picture bounding box.east);
},% end of node contents
node contents={}},
]
\node (a) [sum=gray!10];
\node (b) [mlt-s=gray!10,right=of a];
\node (c) [mlt-c=gray!20,right=of b];
\draw (a) -- (b);
\end{tikzpicture}
\end{document}
範例圖像演示了這些符號的使用。注意:由於該符號沒有任何文本,因此它們被設計為空文本是節點定義的一部分,因此不需要空花括號。這要求節點名稱應該位於節點定義之前(請參閱上面的程式碼)。
編輯:TikZ 函式庫的使用quotes
對使用過的 babel 套件很敏感。對於某些語言(斯洛維尼亞語是其中之一),請更改引號的 catcode。為了消除這個問題而設計了函式庫babel
。因此,對於英語以外的語言的文檔,添加它是明智的預防措施,就像現在在上述兩個程式碼中所做的那樣。