3

I want to draw block inside another block as the following picture

enter image description here

I do apologize if the picture is not clear. My problem is how can I draw block inside another block? I don't have a problem with the rest of the picture.

CroCo
  • 5,902

2 Answers2

6

This is a way to draw the diagram.

enter image description here

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,fit,arrows}

\begin{document}
\begin{center}
\begin{tikzpicture}[auto,node distance=2cm,>=stealth']
\tikzset{block/.style= {draw, rectangle, minimum height=2em,minimum width=4em},
sum/.style = {draw, circle, node distance=2cm},
input/.style  = {coordinate},  
output/.style = {coordinate}}
\node [input, name=rinput](rinput) {};
\node [sum, right of=rinput] (sum) {$\sum$};
\node [block, right of=sum] (controller) {};
\node [block, right of=controller,node distance=3cm] (system) {};
\node[block, right of =system, node distance=4cm] (output){Output};
\node[above of = output] (A) {};
\node[fit= (A) (output), dashed,draw,inner sep=0.45cm] (Box){Some text};
\draw [->] (controller) -- node[name=u] {}(system);
\node [coordinate, below of=u] (measurements) {};
\draw [->] (rinput) -- node {} (sum);
\draw [->] (sum) -- node {} (controller);
\draw [->] (system) -- ( system -| Box.west);
\draw [-] (output.south) |- (measurements);  
\draw [->] (measurements) -| node[pos=0.99] {$-$}
                            node [near end] {} (sum);
\end{tikzpicture}
\end{center}

\end{document}

Update: Since the OP has a follow-up, an addendum is added. Here a new node (B) to the right of output is added, so that an arrow can be drawn to connect (B).

enter image description here

\begin{document}
\begin{center}
\begin{tikzpicture}[auto,node distance=2cm,>=stealth']
\tikzset{block/.style= {draw, rectangle, minimum height=2em,minimum width=4em},
sum/.style = {draw, circle}}
\node [coordinate]   (rinput)                     {};
\node [sum,   right of=rinput]     (sum)          {$\sum$};
\node [block, right of=sum]        (controller)   {C};
\node [block, right of=controller] (system)       {SYS};
\node [block, right of =system, node distance=3cm] (output)   {Output};
\node (A) [above =0.3cm of  output]  {Some text here};
\node[fit= (A) (output), dashed,draw,inner sep=0.2cm] (Box)   {};
\node [coordinate, right = 2cm of output] (B)                 {};   %%% newly added
\draw [->] (controller) -- node[name=u] (system)              {};
\node [coordinate, below=1.5cm of u] (measurements)           {};
\draw [->] (rinput) -- (sum);
\draw [->] (sum) -- (controller);
\draw [->] (system) -- (system -| Box.west);
\draw [->] (Box.east |- B) -- (B);                                  %%% newly added
\draw [-] (output.south) |- (measurements);  
\draw [->] (measurements) -| node[pos=0.99] {$-$} node [near end] {} (sum);
\end{tikzpicture}
\end{center}

\end{document}
Jesse
  • 29,686
1

just small modification/simplification of Jesse code:

\documentclass[tikz,border=5mm]{standalone}% my modification
    \usetikzlibrary{arrows,fit,positioning}
\begin{document}
    \begin{tikzpicture}[node distance=2cm, >=stealth',
block/.style = {draw, rectangle, minimum height=2em,minimum width=4em},
  sum/.style = {draw, circle},
                        ]
\coordinate                             (rinput);
\node[sum,   right = of rinput]         (sum)           {$\sum$};
\node[block, right = of sum]            (controller)    {control};
\node[block, right = 3cm of  controller](system)        {system};
\node[block, right = 4cm of system]     (output)        {Output};
\node[above = of output]                (A)             {};
\node[fit= (A) (output), 
      dashed, draw, inner sep=0.45cm]   (Box)           {Some text};
\draw [->] (controller) -- (system);
\draw [->] (rinput) -- (sum);
\draw [->] (sum) -- (controller);
\draw [->] (system) -- (system -| Box.west);
\coordinate[below = of sum]            (measurements);
\draw [->] (output.south) |- (measurements) -- (sum.south) node[below left] {$-$};
    \end{tikzpicture}
\end{document}
Zarko
  • 296,517