如何创建控制系统图?

如何创建控制系统图?

您好,我想复制此图表:

在此处输入图片描述

但我似乎无法得到它。我只能得到顶部部分。我是新手,所以这花了我一段时间。也许有更有效的方法?谢谢。

    \documentclass[11pt,twoside]{report}
    \usepackage{graphicx}
    \usepackage{tikz}
    \usepackage{stix,graphicx}
    \usetikzlibrary{shapes,arrows,positioning}
    \usetikzlibrary{datavisualization}
    \usetikzlibrary{datavisualization.formats.functions}
    \usetikzlibrary{arrows.meta,calc,positioning,quotes}
    \usetikzlibrary{arrows.meta,chains}
    \usepackage{listings}

\begin{figure}[!h]
\centering
   \begin{tikzpicture}[
node distance = 4mm and 6mm,
  start chain = going right,
  base/.style = {draw, fill=white},
 block/.style = {base, minimum height=2em, minimum width=3em},
   sum/.style = {base, circle, node contents={}},
   arr/.style = {ultra thick, -{Latex[length=5pt, width=6pt]}},
every edge/.style = {draw, -Latex},
                        ]
% We start by placing the blocks in chain
    \begin{scope}[nodes={on chain}]
\coordinate (in);
%\node (n1)  [block]    {$K_p$};
\node (n2)  [sum];
\node (n3)  [block]  {$B$};
\node (n4)  [sum];
\node (n5)  [block]  {$1/s$};
\coordinate (n6);
\coordinate (n7);
\node (n8) [block]     {$C$};
\coordinate (out);
    \end{scope}
%
\path   (in) edge["$r$"]   (n2)
        %(n1) edge[near end,"+"] (n2)
        (n2) edge["$u$"]                    (n3)
        (n3) edge[arr,near end,"+"]         (n4)
        (n4) edge[arr,"$\dot{\mathbf{x}}$"] (n5)
        (n5) edge[arr,"$\mathbf{x}$"]       (n8)
        (n8) edge[arr,"$\mathbf{y}$"]       (out);
% Block in backloops
\node (n11)  [block, below=of n5]  {$A$};
\node (n12)  [block, below=of n11] {$K$};
%       
\draw[arr]  (n6)  |- (n11);
\draw[arr]  (n11) -| (n4) node[below right] {$+$};
\draw[arr]  (n7)  |- (n12);
\draw[-Latex]  (n12) -| (n2) node[below right] {$-$};
\end{tikzpicture}
\caption{Closed-loop control system with \(u = \boldsymbol{-Kx}\)} \label{fig7}
\end{figure}

答案1

这能解决问题吗?

\documentclass[11pt,twoside]{report}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{stix,graphicx}
\usetikzlibrary{%
    ,arrows
    ,arrows.meta
    ,calc
    ,fit
    ,positioning
}
\usepackage{listings}

\begin{document}
    \begin{figure}[!h]
    \centering
    \begin{tikzpicture}[%
    inner sep=3pt,
    outer sep=0,
    node distance=2em,
    block/.style = {draw, minimum height=2em, minimum width=1.2em, fill=gray, fill opacity=.5, text opacity=1},
    sum/.style = {draw, circle, fill=gray, fill opacity=.5},
    ar/.style = {-{Latex[length=5pt, width=6pt]}},
    arr/.style = {ultra thick, -{Latex[length=5pt, width=6pt]}},
    ]
    \pgfdeclarelayer{background layer}
    \pgfsetlayers{background layer,main}
    
    \coordinate (in) at (0,0);
    \node (nw) [above left=of in] {};
    
    \node (sum1) [right=of in, sum]  {};
    \node at (sum1) [anchor=south east] {$+$};
    \node at (sum1) [anchor=north west] {$-$};
    \draw [ar] (in) -- (sum1) node [near start, above] {$r$};
    
    \node (B1) [right=of sum1, block] {$B$};
    \draw [ar] (sum1) -- (B1) node [midway, above] {$u$} node [near start] (bifB2) {};
    
    \node (sum2) [right=of B1, sum]  {};
    \node at (sum2) [anchor=south east] {$+$};
    \node at (sum2) [anchor=north west] {$+$};
    \draw [arr] (B1) -- (sum2);
    
    \node (S1) [right=of sum2, block] {$\frac{1}{s}$};
    \draw [ar] (sum2) -- (S1) node [midway, above] {$\dot{\mathbf{x}}$};
    \node (bifA1) [right=of S1] {};
    \node (C1) [right=of bifA1, block] {$C$};
    \draw [arr] (S1) -- (C1) node [near end, above] {$\mathbf{x}$};
    
    \node (A1) [below=of S1, block] {$A$};
    \draw [arr] (bifA1.center) |- (A1);
    \draw [arr] (A1) -| (sum2);
    
    \node (bifsumII3) [right=of C1] {};
    \node (out) [right=of bifsumII3] {};
    \draw [arr] (C1) -- (out) node [near end, above] {$\mathbf{y}$};
    
    \node (K1) [below=of A1, block] {$K$};
    \draw [ar] (K1) -| (sum1);
    
    \node (S2) [below=of K1, block] {$\frac{1}{s}$};
    \node (sumII2) [left=of S2, sum]  {};
    \node at (sumII2) [anchor=south east] {$+$};
    \node at (sumII2) [anchor=north west] {$+$};
    \draw [arr] (sumII2) -- (S2) node [midway, above] {$\hat{\mathbf{x}}$};
    
    \node (sumII1) [left=of sumII2, sum]  {};
    \node at (sumII1) [anchor=south east] {$+$};
    \node at (sumII1) [anchor=north west] {$+$};
    \draw [arr] (sumII1) -- (sumII2);
    
    \node (B2) [left=of sumII1, block] {$B$};
    \draw [arr] (B2) -- (sumII1);
    \draw [ar] (bifB2.center) |- (nw.center) |- (B2);
    
    \node (C2) [block] at (S2-|C1) {$C$};
    \draw [arr] (S2) -- (C2) node [near end, above] {$\hat{\mathbf{x}}$};
    
    \node (sumII3) [sum] at (C2-|bifsumII3) {};
    \node at (sumII3) [anchor=south west] {$-$};
    \node at (sumII3) [anchor=north east] {$+$};
    \draw [arr] (C2) -- (sumII3) node [midway, above] {$\hat{\mathbf{y}}$};
    \draw [arr] (bifsumII3.center) -- (sumII3);
    \node (olp) [above=of B1, anchor=west] {open-loop plant};
    \begin{pgfonlayer}{background layer}
    \node [draw, inner sep=6pt, fit=(olp) (B1) (C1) (A1), fill=gray, fill opacity=.3] {};
    \end{pgfonlayer}
    
    \node (A2) [below=of S2, block] {$A$};
    \draw [arr] (S2-|bifA1) |- (A2);
    \draw [arr] (A2) -| (sumII2);
    \draw [arr] (S2-|bifA1) |- (K1);
    
    \node (L2) [below=of A2, block] {$L$};
    \draw [arr] (sumII3) |- (L2);
    \draw [arr] (L2) -| (sumII1);
    
    \node (owpm) [below=of B2|-L2, anchor=west] {observer with perfect model};
    \begin{pgfonlayer}{background layer}
    \node [draw, inner sep=6pt, fit=(owpm) (B2) (sumII3) (L2), fill=gray, fill opacity=.3] {};
    \end{pgfonlayer}
    
    \end{tikzpicture}
    \caption{Closed-loop control system with \(u = \boldmath{-Kx}\)} \label{fig7}
\end{figure}
\end{document}

在此处输入图片描述

相关内容