使用 tikz 绘制控制系统

使用 tikz 绘制控制系统

我想要绘制如下所示的控制系统图: 图像

到目前为止,我找到的最接近的可以绘制此类内容的指南是这里

但它没有告诉我如何将像“irdref”(在图片中)这样的文本放在一行的开头。

以及如何使线条弯曲。

我如何实现这个目标?

我目前拥有的代码是:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\begin{document}


\tikzstyle{block} = [draw, fill=blue!20, rectangle, 
    minimum height=3em, minimum width=6em]
\tikzstyle{sum} = [draw, fill=blue!20, circle, node distance=1cm]
\tikzstyle{input} = [coordinate]
\tikzstyle{output} = [coordinate]
\tikzstyle{pinstyle} = [pin edge={to-,thin,black}]

% The block diagram code is probably more verbose than necessary
\begin{tikzpicture}[auto, node distance=2cm,>=latex']


    % We start by placing the blocks
    \node [input, name=ID_STAR] {};   %ID*
    \node [input, below of=ID_STAR,, node distance=2cm, name=ID] {}; %ID

    \node [sum, right of=ID_STAR] (ID_SUM) {};

    \node [block, right of=ID_SUM] (VD_GSC) {$VDGSC$}; %place PI block to the right of the summation symbol




    \node [sum, right of=VD_GSC, node distance=2cm] (VD_SUM) {};


     \node [output, right of=VD_SUM] (output1) {};       




    % We draw an edge between the controller and VD_SUM block to 
    % calculate the coordinate u. We need it to place the measurement block. 
    %\draw [->] (VD_GSC) -- node[name=u] {$u$} (VD_SUM);


    %Place the gain blocks
    \node [block, below of=VD_GSC] (Lgq) {Lg};  %gain Lg for the Iq current
    \node [block, below of=Lgq] (Lgd) {Lg};  %gain Lg for the Id current

        %Now place the inputs for these gain blocks
        \node [input, left of=Lgq, name=IQLg] {}; %IQ
        \node [input, left of=Lgd, name=IDLg] {}; %ID

    %Place the Pi ccontoller for the q axis
    \node [block, below of=Lgd] (VQ_GSC) {$VQGSC$};

        %Place the summing juction for the Q axis PI controller
        \node [sum, left of=VQ_GSC, node distance=2cm] (IQ_SUM) {};

            %Place the inputs for IQsum
            \node [input, left of=IQ_SUM, name=IQ_STAR] {}; %IQSTAR
            \node [input, below of=IQ_STAR, name=IQ] {}; %IQ

        %Place the voltage summing junction for the Q axis
        \node [sum, right of=VQ_GSC, node distance=2cm] (IQ_SUM) {};

            %Place the output for the q axis voltage output
            \node [output, right of=IQ_SUM] (VQ_GSC) {};       



    %Now connect them together

        %Connect IDSTAR (ID reference)
        \draw [draw,->] (ID_STAR) -- node {$I_d^*$} (ID_SUM);

        %Connect ID (ID reference)
        \draw [draw,->] (ID) -- node {$I_d$} (ID_SUM);








    % Once the nodes are placed, connecting them is easy. 
    %\draw [draw,->] (input) -- node {$r$} (sum);
    %\draw [->] (sum) -- node {$e$} (controller);
    %\draw [->] (VD_SUM) -- node [name=y] {$y$}(output);
    %\draw [->] (y) |- (Lgq);
    %\draw [->] (Lgq) -| node[pos=0.99] {$-$} 
        %node [near end] {$y_m$} (sum);
\end{tikzpicture}

\end{document}

答案1

  • 由于你的姆韦与显示的图像不同,我很困惑,你想获得什么。最后我决定复制显示的图像...
  • 不幸的是,您认为作为起点的示例“非常”古老,并且使用了现已弃用的语法
  • 所以我决定从头开始绘制你的方案......

应该有图像

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta, calc, chains, positioning, quotes}
\newcommand\ppbb{path picture bounding box}

\tikzset{CNTRL/.style =
{
%
          > = Triangle,
shorten <>/.style = {shorten <=##1, shorten >=##1},
block/.style = {rectangle, draw, fill=##1,
    minimum height=8mm, minimum width=16mm,
    outer sep = 0mm},
dot/.style = {fill=##1,
    circle, inner sep=0mm, outer sep=0mm, minimum size=1mm,
    node contents={}},
%
mlt/.style = {fill=##1,
    rectangle, draw=black, minimum size=6mm,
    path picture={\draw[very thick,shorten <>=1.5mm,-]
    (\ppbb.north west) edge (\ppbb.south east)
    (\ppbb.south west)  --  (\ppbb.north east);
                },% end of node contents
            node contents={}},
%
sum/.style = {fill=##1,
    circle, draw=black, minimum size=6mm,
    path picture={\draw[very thick,shorten <>=1mm,-]
    (\ppbb.north) edge (\ppbb.south)
    (\ppbb.west)   --  (\ppbb.east);
                },% end of node contents
            node contents={}},
}% end of CNTRL style
    }% end of tikzset


\begin{document}
    \begin{tikzpicture}[CNTRL,
    node distance = 6mm and 12mm,
      start chain = A going below,
   block/.default = cyan!30,
     dot/.default = black,
     mlt/.default = cyan!30,
     sum/.default = cyan!30,
                        ]
% We start by placing math operators in third column of scheme's elements
\node [sum, on chain=A];    % A-1
\node [mlt, on chain=A];
\node [dot, on chain=A];
\node [mlt, on chain=A];
\node [sum, on chain=A];
\node [mlt, on chain=A];    % A-6
\node [on chain=A] {$\lambda$}; % A-7
    \draw[->]   (A-3) edge (A-2)    (A-2) edge (A-1)
                (A-3) edge (A-4)    (A-4) edge (A-5)
                (A-6) edge (A-5)    (A-7) edge (A-6);
% nodes in second column
\node (c21) [block,left=of A-1] {$K_3(s)$};
\node (c22) [left=of A-3]    {$L_e(\omega_0 - \omega_r)$};
\node (c23) [block,left=of A-5] {$K_3(s)$};
\node (c24) [left=of A-6]    {$\frac{L_m}{L_s}(\omega_0 - \omega_r)$};
    \draw[->]   (c21) edge ["$u_1$"] (A-1)
                (c23) edge ["$u_2$"] (A-5)
                (c24) edge           (A-6);
    \draw       (c22) edge           (A-3);

% nodes in first column
\node (c11) [sum, left=of c21];
\node (c12) [dot,below=of c11];
\node (c13) [below=of c12]  {$i_{rd}$};
\node (c16) [sum, left=of c23];
\node (c15) [dot,above=of c16];
\node (c14) [above=of c15]  {$i_{rq}$};
    \draw[->]   (c13) -- (c12) -- (c11);
    \draw[->]   (c14) -- (c15) -- (c16);
    \draw[->]   (c11) edge (c21)    (c16) edge (c23);
    %
    \draw[->]   (c12) -- ++ (0.5,0) -- (A-4 -| c23.west) -- (A-4);
    \draw[->]   (c15) -- ++ (0.5,0) -- (A-2 -| c21.west) -- (A-2);
% inputs
\node (in-d) [left=of c11]  {$i_{rd_\mathrm{ref}}$};
\node (in-q) [left=of c16]  {$i_{rq_\mathrm{ref}}$};
    \draw[->]   (in-d) edge (c11)    (in-q) edge (c16);
%
% nodes in fourth column
\node (c41) [right=of A-3] {$\frac{2}{v_{\mathrm{Link}}}$};
% nodes in fifth column
\node (c51) [mlt, right=of A-1 -| c41];
\node (c52) [dot, at={(c41 -| c51)}];
\node (c53) [mlt, right=of A-5 -| c41];
    \draw[->]   (A-1) edge (c51)    (A-5) edge (c53)
                (c52) edge (c51)    (c52) edge (c53);
    \draw       (c41) -- (c52);
% outputs
\node (out-d) [right=of c51]  {$m_{rd}$};
\node (out-q) [right=of c53]  {$i_{rq}$};
    \draw[->]   (c51) edge (out-d)    (c53) edge (out-q);

    \end{tikzpicture}
\end{document}
  • 我希望上面的代码足够不言自明,不需要进一步解释

编辑: 上述改进版本姆韦通过考虑回答马克·维布罗

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta, calc, chains, positioning, quotes}

\tikzset{
%---------------------------------------------------------------%
% for use this \tikzset yiu need to load in the preamble        %
% the folowing tikz libraries:                                  %
% arrows.meta, calc, chains, positioning and  quotes            %
%---------------------------------------------------------------%
alias path picture bounding box/.code=%
    \pgfnodealias{#1}{path picture bounding box},
CNTRL/.style =
{
          > = Triangle,
shorten <>/.style = {shorten <=##1, shorten >=##1},
block/.style = {rectangle, draw, fill=##1,
    minimum height=8mm, minimum width=16mm,
    outer sep = 0mm},
dot/.style = {fill=##1,
    circle, inner sep=0mm, outer sep=0mm, minimum size=1mm,
    node contents={}},
%
mlt/.style = {fill=##1,
    rectangle, draw=black, minimum size=6mm,
    path picture={%
    \tikzset{alias path picture bounding box=@}
    \draw[very thick,shorten <>=1.5mm,-]
    (@.north west) edge (@.south east)
    (@.south west)  --  (@.north east);
                },% end of node contents
            node contents={}},
%
sum/.style = {fill=##1,
    circle, draw=black, minimum size=6mm,
    path picture={%
    \tikzset{alias path picture bounding box=@}
    \draw[very thick,shorten <>=1mm,-]
    (@.north) edge (@.south)
    (@.west)   --  (@.east);
                },% end of node contents
            node contents={}},
% default styles settings:
   block/.default = cyan!30,
     dot/.default = black,
     mlt/.default = cyan!30,
     sum/.default = cyan!30,
}% end of CNTRL style
    }% end of tikzset

\begin{document}
    \begin{tikzpicture}[CNTRL,
    node distance = 6mm and 12mm,
      start chain = A going below,
                        ]
% We start column with math operators (third column of elements in scheme)
\node [sum, on chain=A];    % A-1 <-- node name
\node [mlt, on chain=A];
\node [dot, on chain=A];
\node [mlt, on chain=A];
\node [sum, on chain=A];
\node [mlt, on chain=A];    % A-6
\node [on chain=A] {$\lambda$}; % A-7
    \draw[->]   (A-3) edge (A-2)    (A-2) edge [near end, "$-$"  ] (A-1)
                (A-3) edge (A-4)    (A-4) edge [near end, "$-$" '] (A-5)
                (A-6) edge (A-5)    (A-7) edge (A-6);
% nodes in second column
\node (c21) [block,left=of A-1] {$K_3(s)$};
\node (c22) [left=of A-3]    {$L_e(\omega_0 - \omega_r)$};
\node (c23) [block,left=of A-5] {$K_3(s)$};
\node (c24) [left=of A-6]    {$\frac{L_m}{L_s}(\omega_0 - \omega_r)$};
    \draw[->]   (c21) edge ["$u_1$"] (A-1)
                (c23) edge ["$u_2$"] (A-5)
                (c24) edge           (A-6);
    \draw       (c22) edge           (A-3);
% nodes in first column
\node (c11) [sum, left=of c21];
\node (c12) [dot,below=of c11];
\node (c13) [below=of c12]  {$i_{rd}$};
\node (c16) [sum, left=of c23];
\node (c15) [dot,above=of c16];
\node (c14) [above=of c15]  {$i_{rq}$};
    \draw[->]   (c13) -- (c12) to [near end, "$-$"] (c11);
    \draw[->]   (c14) -- (c15) to [near end, "$-$"] (c16);
    \draw[->]   (c11) edge (c21)    (c16) edge (c23);
    %
    \draw[->]   (c12) -- ++ (0.5,0) -- (A-4 -| c23.west) -- (A-4);
    \draw[->]   (c15) -- ++ (0.5,0) -- (A-2 -| c21.west) -- (A-2);
% inputs
\node (in-d) [left=of c11]  {$i_{rd_\mathrm{ref}}$};
\node (in-q) [left=of c16]  {$i_{rq_\mathrm{ref}}$};
    \draw[->]   (in-d) edge (c11)    (in-q) edge (c16);
%
% nodes in fourth column
\node (c41) [right=of A-3] {$\frac{2}{v_{\mathrm{Link}}}$};
% nodes in fifth column
\node (c51) [mlt, right=of A-1 -| c41];
\node (c52) [dot, at={(c41 -| c51)}];
\node (c53) [mlt, right=of A-5 -| c41];
    \draw[->]   (A-1) edge (c51)    (A-5) edge (c53)
                (c52) edge (c51)    (c52) edge (c53);
    \draw       (c41) -- (c52);
% outputs
\node (out-d) [right=of c51]  {$m_{rd}$};
\node (out-q) [right=of c53]  {$i_{rq}$};
    \draw[->]   (c51) edge (out-d)    (c53) edge (out-q);
    \end{tikzpicture}
\end{document}

结果与上面的例子不同之处在于-在加法器上添加了符号:

在此处输入图片描述

\tikset让我强调一下,您可以在文档中的任何图片中使用带有控件或类似方案的定义。它的优点是,使用它您可以获得以下所有图片:

  • tikz 图片的简短代码
  • CNTRL使用样式对所有图像进行统一样式

相关内容