[Tex/LaTex] how to draw this block diagram

diagrams

I would like to draw the following pictureenter image description here

I have tried my best but nothing work. My code isn't really worth posting it here. The problem I'm facing is fitting blocks inside one block with proper connection between them. I have tried to use fit, but it is not working or I think I misuse it. Appreciate any help.


Edit:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,fit,arrows, positioning}
\usepackage{graphicx}
\begin{document}

\noindent\resizebox{\textwidth}{!}{
\begin{tikzpicture}[auto,node distance=5cm,>=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=input](input) {};
\node [sum, right of=input] (sum) {$\sum$};
\node [block, right of=sum, minimum height=6cm, minimum width=8cm] (M) {};

\node [coordinate, below of=M, yshift=1cm] (link1) {};
\node [coordinate, above of=M, yshift=-1cm] (link2) {};


\draw [-] (link1) -- node {} (M) ;
\draw [->] (link2) -- node {} (M) ;
\draw [<-] (sum) |- node[yshift=3cm, xshift=-.5cm] {$text$} (link1) ;



\node [block, right of=M,  rotate=90, minimum width=6cm] (n) {$\textbf{text}$};


\node [block, right of=n, minimum height=6cm, minimum width=5cm] (s) {text};
\node [coordinate, above of=s, yshift=-1cm] (link3) {};
\draw [-] (link3) -- node {} (s) ;
\draw [->] (input) -- node {$text$} (sum);
\draw [->] (sum) -- node {} (M);
\draw [->] (M) -- node {$text$} (n);
\draw [->] (n) -- node {$text$} (s);
\draw [-] (link3) -- node[yshift=.6cm,xshift=-5cm] {text} (link2);

\end{tikzpicture}
}


\end{document}

enter image description here

Best Answer

Would this be what you seek? styledefinitions block is for horizontal blocks, blockB is for vertical blocks (being rotated 90). all text phrases are allocated via node with options like above, below, above left, above right, etc., you may want to adjust to fit your needs.

Update: Small modifications to fit the OP's need. Some explanations are added. See %<---

enter image description here

Code:

\documentclass{article}
\usepackage[margin=1cm]{geometry}
\usepackage{tikz}
\usetikzlibrary{calc,fit,arrows, positioning}
\usepackage{graphicx}
\begin{document}

%\noindent\resizebox{\textwidth}{!}{
\begin{tikzpicture}[auto,node distance=3cm,>=stealth']
\tikzset{
block/.style= {draw, rectangle, minimum height=2em,minimum width=4em},
blockB/.style= {draw, rectangle, minimum height=1cm,minimum width=4cm},
sum/.style = {draw, circle, node distance=2cm},
input/.style  = {coordinate},  
output/.style = {coordinate}
}

\node [input, name=input](input) {};
\node [sum, right of=input] (sum1) {$\sum$};
\node [block, right of =  sum1] (t1) {text};
\node [sum, right of =  t1 ] (sum2) {$\sum$};
\node [blockB, node distance=8cm,right of=sum2,  rotate=90] (n1) {$\textbf{text}$};  %<--- the space is determined by the node distance 8cm
\node [block ,minimum height=4cm,right of=n1] (n2) {$\textbf{text}$};                       % <--- to make the horizontal box (block) has the same height of blockB
\node[] at ($(sum2)!0.4!(n1)$) (a) {};
\node [block, above = 1cm of a] (t2) {text};
\node [block, below  = 1cm of  a] (t3) {text};
\node[rectangle, draw, minimum width=7cm,minimum height=7cm][fit=(sum2)(t1)(t2)(t3),label=above:Text](all){};  % change 7cm if want a larger fitting box

\draw [->] (input) -- node {$text$} (sum1);
\draw [->] (sum1) -- node {} (t1);
\draw [->] (t1) -- node {$text$} (sum2);
\draw [<-] (sum2) --++(0,-2cm)node(){text};
\draw [->] (sum2) -- node[pos=0.3] {$text$} (n1);
\draw [->] (n1) -- node[] {text} (n2);
%\draw [->] (n2) -- node[] {text} ++(3,0);   <-- last arrow to the right if still needed remove %
\draw [->] (n2.north)--++(0,2)-|(t2.north)node[above right]{text};  <---  % (0,2) determine the height y=2 of the feedback line
\draw [->] (t2.south) --++ (0,-0.9) to[bend right=90] ++(0,-0.5)--(t3.north);
\draw [->] (t3.south) -- ++(0,-1)-| (sum1.south)node[below left]{text};
\draw [->] (t1.north)--++(0,2)-|node[above left]{text}([xshift=-0.5cm]t2.north);
\end{tikzpicture}
%}
\end{document}

enter image description here

Code

\documentclass{article}
\usepackage[margin=1cm]{geometry}
\usepackage{tikz}
\usetikzlibrary{calc,fit,arrows, positioning}
\usepackage{graphicx}
\begin{document}

%\noindent\resizebox{\textwidth}{!}{
\begin{tikzpicture}[auto,node distance=3cm,>=stealth']
\tikzset{
block/.style= {draw, rectangle, minimum height=2em,minimum width=4em},
blockB/.style= {draw, rectangle, minimum height=1cm,minimum width=4cm},
sum/.style = {draw, circle, node distance=2cm},
input/.style  = {coordinate},  
output/.style = {coordinate}
}

\node [input, name=input](input) {};
\node [sum, right of=input] (sum1) {$\sum$};
\node [block, right of =  sum1] (t1) {text};
\node [sum, right of =  t1 ] (sum2) {$\sum$};
\node [blockB, node distance=5cm,right of=sum2,  rotate=90] (n1) {$\textbf{text}$};
\node [blockB,right of=n1,  rotate=90] (n2) {$\textbf{text}$};
\node [] at ($(sum2)!0.4!(n1)$) (a) {};
\node [block, above = 1cm of a] (t2) {text};
\node [block, below  = 1cm of  a] (t3) {text};
\node [rectangle, draw, minimum width=7cm,minimum height=7cm][fit=(sum2)(t1)(t2)(t3),label=above:Text](all){};

\draw [->] (input) -- node {$text$} (sum1);
\draw [->] (sum1)  -- node {} (t1);
\draw [->] (t1)    -- node {$text$} (sum2);
\draw [<-] (sum2)  --++(0,-2cm)node(){text};
\draw [->] (sum2)  -- node {$text$} (n1);
\draw [->] (n1)    -- node[] {text} (n2);
\draw [->] (n2)    -- node[] {text} ++(3,0);
\draw [->] (n2.east)  -- ++(0,3)-|(t2.north)node[above right]{text};
\draw [->] (t2.south) -- ++(0,-0.9) to[bend right=90] ++(0,-0.5)--(t3.north);
\draw [->] (t3.south) -- ++(0,-1)-| (sum1.south)node[below left]{text};
\draw [->] (t1.north) -- ++(0,2)-|node[above left]{text}([xshift=-0.5cm]t2.north);
\end{tikzpicture}
%}
\end{document}