# Creating diagram using tikz

I am trying to create following diagram in latex-

Below is my latex code-

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}

\begin{document}
\tikzset{
box/.style    = {draw, rectangle, minimum height = 2.5em, minimum width = 2.5em},
circl/.style  = {draw, circle,minimum size = 8mm},
input/.style  = {coordinate},
output/.style = {coordinate},
to/.style    = {->,>=stealth',shorten >=1pt,semithick,font=\sffamily\footnotesize}
}

\begin{tikzpicture}[auto, node distance=2cm]
\node (in1) [input] {};
\node (cs) [box, right of=in1] {$C$};
\node (crc1) [circl, right of=cs]{};
\node (gs) [box, right of=crc1] {$G$};
\node (hs) [box, right of=gs] {$H$};
\node (ctl) [box, below of=hs] {Limiter};
\node (crc2) [circl, right of=hs]{};
\node (ze) [input, above of=crc2] {};
\node (ke) [box, right of=crc2] {$K$};
\node (fs) [output, right of=ke] {};

\draw [to] (in1) -- node {$f$}(cs);
\draw [to] (cs) -- (crc1);
\draw [to] (crc1) --(gs);
\draw [to] (gs) -- (hs);
\draw [to] (hs) -- node {$I_{max}$}(ctl);
\draw [to] (ctl) --node {$\theta$}(hs);
\draw [to] (hs) -- node {$z$}(crc2);
\draw [to] (ze) -- node {$C$}(crc2);
\draw [to] (crc2) --(ke);
\draw [to] (ke) -- node {$f(s)$}(fs);

\end{tikzpicture}

\end{document}


I am not able to draw the bottom line and two opposite directional arrow from two boxes, which is marked red in the above image. Below is what latex has generated-

-
You can also have a look to High level digital design in TikZ. – Claudio Fiandrino Aug 26 '14 at 15:42
Could you edit the title of your question to include something more descriptive? – cmhughes Aug 26 '14 at 16:02
This seems similar to Adjusting a block diagram. – Svend Tveskæg Aug 26 '14 at 16:35

try this

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}

\begin{document}
\tikzset{
box/.style    = {draw, rectangle, minimum height = 2.5em, minimum width = 2.5em},
circl/.style  = {draw, circle,minimum size = 8mm},
input/.style  = {coordinate},
output/.style = {coordinate},
to/.style    = {->,>=stealth',shorten >=1pt,semithick,font=\sffamily\footnotesize}
}

\begin{tikzpicture}[auto, node distance=2cm]
\node (in1) [input] {};
\node (cs) [box, right of=in1] {$C$};
\node (crc1) [circl, right of=cs]{};
\node (gs) [box, right of=crc1] {$G$};
\node (hs) [box, right of=gs] {$H$};
\node (ctl) [box, below of=hs] {Limiter};
\node (crc2) [circl, right of=hs]{};
\node (ze) [input, above of=crc2] {};
\node (ke) [box, right of=crc2] {$K$};
\node (fs) [output, right of=ke] {};

\draw [to] (in1) -- node {$f$}(cs);
\draw [to] (cs) -- node[below left,pos=1]{+}(crc1) ;              % 1st modif
\draw [to] (crc1) --(gs);
\draw [to] (gs) -- (hs);
\draw [to] (hs.-70) -- node {$I_{max}$}(ctl.north-|hs.-70);       % 2st modif
\draw [to] (ctl.north-|hs.-110) --node {$\theta$}(hs.-110);       % 3st modif
\draw [to] (hs) -- node {$z$}(crc2);
\draw [to] (ze) -- node {$C$}(crc2);
\draw [to] (crc2) --(ke);
\draw [to] (ke) -- node {$f(s)$}(fs)coordinate[pos=0.5](aa);     % 4 modif
\coordinate[below of =ctl,node distance=2em] (bb);
\draw[to] (aa) |- (bb) -| (crc1);

\end{tikzpicture}

\end{document}


you can also try the package : http://www.ctan.org/pkg/schemabloc also here http://sciences-indus-cpge.papanicola.info/Schema-blocs-avec-PGF-TIKZ-sous

-
Thanks a lot. Two doubts- (1) How can i draw minus sign after plus sign. \draw [to] (crc1) -- node[below left,pos=1]{-}(gs); doesn't work. (2) Where can I get the manual for the packages, you mentioned above. – Ravi Joshi Aug 26 '14 at 15:42
An English translation of schemabloc was announced on ctan-ann list some days ago. It's called blox. – Ignasi Aug 27 '14 at 7:19
thancks to the translator – rpapa Aug 27 '14 at 9:35

First question: the bottom line.

It can be drawn with the following code:

\draw[to]  ($(ke)!.5!(fs)$) -- +(0,-3cm) -| (crc1);


Let me explain it:

• ($(ke)!.5!(fs)$) uses interpolated coordinates and requires \usetikzlibrary{calc}. It specifies a point in the middle (the .5 part) between coordinates (ke) and (fs).
• -- specifies a line to the next coordinate, which is
• +(0,-3cm), here the + in front means that this coordinate is relative to the previous one, so it specifies a point 3cm below the previous coordinate.
• -| specifies two lines, the first one horizontal (starting at the point specified previously) and the second one vertical (ending at the next coordinate, which is (crc1).

Second question: the opposite directional arrows

Each node provides "angle" anchor points which can be useful here. The syntax (nodename.angle) denotes one anchor point which lies in the edge of the node nodename, and is at angle from its center. So, for example (node.90) is the same than (node.north).

You can use these special anchors as starting points for your arrows, so for example since the box labelled "Limiter" is the node called (ctl), you can use (ctl.70) and (ctl.110) as anchors for those lines.

However, you need these lines to be vertical, so we have the problem of specifying their final coordinate. It is easy once you know that tikz allows the syntax (a|-b) as a coordinate, to denote the coordinate placed at the same vertical than (a) and the same horizontal than (b).

Using this idea, the line which starts at (ctl.70) should end at (ctl.70|-hs.south), and the one which starts at (ctl.110) should end at (ctl.110|-hs.south), so the following code draws your required arrows:

\draw [to] (ctl.70) -- node[right] {$I_{max}$} (ctl.70|-hs.south);
\draw [to] (ctl.110|-hs.south) --node[left] {$\theta$} (ctl.110);


The resulting figure is:

-
Typographical glitch: max should be \max. – Svend Tveskæg Aug 26 '14 at 16:36
Thank you for the detailed answer. I would like to ask one question here. (1) How to draw minus sign after plus sign and text above the plus sign? (See image here) – Ravi Joshi Aug 26 '14 at 17:21
@RaviJoshi one possible approach is to place nodes with $+$ and $-$ text at the appropiate places, which are "angle anchors" of the circles, i.e: \node[inner sep=1pt, below left] at (crc1.200) {$+$}; \node[inner sep=1pt, below right] at (crc1.280) {$-$}; for example. – JLDiaz Aug 26 '14 at 21:36