在框图中添加弯曲箭头?

在框图中添加弯曲箭头?

我目前有一个控制系统框图,我想添加到..目前我有

\documentclass[12pt]{article}
\usepackage{tikz}
\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}]
\usetikzlibrary{shapes,arrows}
\begin{document}
\begin{tikzpicture}[auto, node distance=2cm,>=latex']
    % We start by placing the blocks
    \node [input, name=input] {};
    \node [sum, right of=input] (sum) {};
    \node [block, right of=sum] (controller) {C(s)};
    \node [block, right of=controller, %pin={[pinstyle]above:},
            node distance=4cm] (system) {$G_p$};
    % We draw an edge between the controller and system block to 
    % calculate the coordinate u. We need it to place the measurement block. 
    \draw [->] (controller) -- node[name=u] {$u$} (system);
    \node [output, right of=system] (output) {};
    \node [output,below of=u] (measurements) {};

    \draw [draw,->] (input) -- node {$r$} (sum);
    \draw [->] (sum) -- node {$e$} (controller);
    \draw [->] (system) -- node [name=y] {$y$}(output);
    \draw [-] (y) |- (measurements);
    \draw [->] (measurements) -| node[pos=0.99] {$-$} 
        node [near end] {$y$} (sum);
\end{tikzpicture}
\end{document}

这使 tikz 框图

但我正在尝试添加这个...... 采样器 在标有 $$G_p$$ 的块之后

答案1

对于交换机,我设计了特殊节点。也许你会喜欢这样的解决方案:-)

除此之外,我还使用了不同的 TikZ 库(arrows.meta, bending, positioning),引入了新的命令以缩短 switch 的书写,并\tikzstyle\tikzset以及节点定位语法替换了过时的命令。我还对坐标节点样式定义做了一些更改(它适用于 TikZ 3.1)

\documentclass[12pt,tikz,border=3mm]{standalone}
    \usetikzlibrary{arrows.meta,bending,positioning}
    \newcommand\ppbb{path picture bounding box}% added for shorter code of switch

\tikzset{% replace tikstyle
 block/.style = {draw, fill=blue!20, rectangle,
                 minimum height=3em, minimum width=6em},
   sum/.style = {circle, draw, fill=blue!20, node contents={}},
 input/.style = {coordinate,node contents={}},% changed
output/.style = {coordinate,node contents={}},%c changed
switch/.style = {minimum size=3em,% new style for switch
                 path picture={  \draw
                 ([xshift=-3mm]  \ppbb.center)  -- ++ (45:6mm);
                                 \draw[shorten >=3mm,-]
                 (\ppbb.west) edge (\ppbb.center)
                 (\ppbb.east)  --  (\ppbb.center);
                                 \draw[<->]
                 ([yshift=-2mm] \ppbb.center) arc[start angle=-15, end angle=75, radius=6mm];   
                            },% end of drawing in node
                 label={[yshift=-2mm] above:#1},
                 node contents={}},
%pinstyle/.style = {pin edge={to-,thin,black}]% not used in this image
        }
\begin{document}
\begin{tikzpicture}[auto, node distance=2cm,>={Latex[flex]}]
    % We start by placing the blocks
\node (input)       [input];
\node (sum)         [sum, right of=input];
\node (controller)  [block, right=1cm of sum]       {C(s)};
\node (system)      [block, right=of controller]    {$G_p$};
\node (switch)      [switch=$T$, right=0 cm of system]; % <-- added switch
\node (output)      [output, right=of switch];
    % We draw an edge between the controller and system block to
    % calculate the coordinate u. We need it to place the measurement block.
\draw [->]  (controller) -- node (u) {$u$} (system);
\node  (measurements) [output,below of=u] {};
\draw [->]  (input)  -- node {$r$} (sum);
\draw [->]  (sum)    -- node {$e$} (controller);
\draw [->]  (switch) -- node (y) {$y$} (output);
\draw       (y) |- (measurements);
\draw [->]  (measurements) -| node[pos=0.95] {$-$}
                              node[near end] {$y$} (sum);
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

问题中提供的代码没有产生显示给我的输出,所以我稍微即兴发挥了一下并进行了一些整理。

无论如何,这里有一个临时的方法:

\documentclass[border=10pt,multi,tikz]{standalone}
\usetikzlibrary{arrows.meta,positioning,calc,bending}
\begin{document}
\begin{tikzpicture}
  [
    auto,
    node distance=2cm,
    >=Latex,
    input/.style={},
    block/.style={draw, fill=blue!25},
    sum/.style={draw, circle, fill=blue!25},
    output/.style={},
  ]
    % We start by placing the blocks
    \node [input, name=input] {};
    \node [sum, right of=input] (sum) {};
    \node [block, right of=sum] (controller) {C(s)};
    \node [block, right=20mm of controller, %pin={[pinstyle]above:},
          ] (system) {$G_p$};
    % We draw an edge between the controller and system block to
    % calculate the coordinate u. We need it to place the measurement block.
    \draw [->] (controller) -- node[name=u] {$u$} (system);
    \node [output, right of=system] (output) {};
    \coordinate [below of=u] (measurements) ;
    \draw [draw,->] (input) -- node {$r$} (sum);
    \draw [->] (sum) -- node {$e$} (controller);
    \draw [->] (system) -- ++(5mm,0) coordinate (p) edge [-] +(45:5mm) +(5mm,0) -- node [name=y] {$y$}(output);
    \draw [{Latex[bend,scale=.5]}-{Latex[bend,scale=.5]}] ($(p)+(80:2.5mm)$) [out=0, in=90] to ($(p)+(10:2.5mm)$);
    \draw [-] (y) |- (measurements);
    \draw [->] (measurements) -| node[pos=0.99] {$-$} node [near end] {$y$} (sum);
\end{tikzpicture}
\end{document}

转变

显然,如果适用的话,最好使用专门用于绘制电路或其他内容的软件包之一。

相关内容