Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am new to drawing a block diagram using tikzpicture. The following MWE

\documentclass[a4paper,11pt]{article}

\usepackage{amsmath}
\usepackage{tikz} %http://www.texample.net/tikz/examples/control-system-principles/
\usetikzlibrary{shapes,arrows}
\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}]

\begin{document}
\begin{tikzpicture}[auto, node distance=2cm,>=latex']
% We start by placing the blocks
\node [input, name=input] {};
\node [sum, right of=input, name=sum] (sum) {};
\node [block, right of=sum,label=below:controller] (controller) {?};
\node [sum, right of=controller,node distance=2cm,pin={[pinstyle]above:$D(s)$}] (sum2) {};
\node [block, right of=sum2,node distance=2cm,label=below:process dynamics] (system) {$\dfrac{32}{s(s+4)(s+16)}$};
% 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] {} (system);
\node [output, right of=system] (output) {};
\node [block, below of=u,label=below:sensor] (measurements) {1};
% Once the nodes are placed, connecting them is easy. 
\draw [draw,->] (input) -- node {$\varphi_d$} (sum);
\draw [->] (sum) -- node {} (controller);
\draw [->] (controller) -- node {} (sum2);
\draw [->] (sum2) -- node {} (system);
\draw [->] (system) -- node [name=y] {$\varphi$}(output);
\draw [->] (y) |- (measurements);
\draw [->] (measurements) -| node[pos=0.99] {\tiny $-$} 
    node [near end] {} (sum);
\end{tikzpicture}
\end{document}

yields

Block diagram

How can I let the arrow connecting the second sum tot the block 'process dynamics' start on the right side of the sum, rather than on the left side (see orange arrow)?

share|improve this question
1  
There are two arrows. Use \draw [->,red] (sum2.north) -- node {} (system); and you'll see that the right arrow has the correct size. The problem is the other one. –  Sigur Mar 29 at 15:31

1 Answer 1

You can use (sum2.east) to connect at the right.

\draw [->] (controller) -- node {} (sum2.west);            %% used west
\draw [->] (sum2.east) -- node {} (system);                %% used east

Further, I have changed the \draw to \path in

\path [->] (controller) -- node[name=u] {} (system);      %% changed \draw to \path

Full code:

\documentclass[a4paper,11pt]{article}

\usepackage{amsmath}
\usepackage{tikz} %http://www.texample.net/tikz/examples/control-system-principles/
\usetikzlibrary{shapes,arrows,positioning}
\tikzset{block/.style = {draw, fill=blue!20, rectangle,
                         minimum height=3em, minimum width=6em},
        sum/.style = {draw, fill=blue!20, circle, node distance=1cm},
        input/.style = {coordinate},
        output/.style = {coordinate},
        pinstyle/.style = {pin edge={to-,thin,black}}
}

\begin{document}
\begin{tikzpicture}[auto, >=latex']
% We start by placing the blocks
\node [input, name=input] {};
\node [sum, right =of input, name=sum] (sum) {};
\node [block, right = of sum,label=below:controller] (controller) {?};
\node [sum, right =of controller,pin={[pinstyle]above:$D(s)$}] (sum2) {};
\node [block, right = of sum2,label=below:process dynamics] (system) {$\dfrac{32}{s(s+4)(s+16)}$};
% We draw an edge between the controller and system block to
% calculate the coordinate u. We need it to place the measurement block.
\path [->] (controller) -- node[name=u] {} (system);      %% changed \draw to \path
\node [output, right = of system] (output) {};
\node [block, below =of u,label=below:sensor] (measurements) {1};
% Once the nodes are placed, connecting them is easy.
\draw [draw,->] (input) -- node {$\varphi_d$} (sum);
\draw [->] (sum) -- node {} (controller);
\draw [->] (controller) -- node {} (sum2.west);            %% used west
\draw [->] (sum2.east) -- node {} (system);                %% used east
\draw [->] (system) -- node [name=y] {$\varphi$}(output);
\draw [->] (y) |- (measurements);
\draw [->] (measurements) -| node[pos=0.99] {\tiny $-$}
    node [near end] {} (sum);
\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer
    
Nice! We can not remove the line with superfluous arrow since it is being used to calculate u. So we have to use path instead draw. Great. –  Sigur Mar 29 at 15:38
1  
Why the node sum2 is not on the middle point between the two rectangles? It looks like its west anchor is there. –  Sigur Mar 29 at 15:46
1  
@Sigur Now it is at the center. Culprit was the of= syntax. I used positioning library and right =of. Also removed the spurious node distance=2cm –  Harish Kumar Mar 29 at 16:04
    
Nice! Now the horizontal space between controller and process is exactly the width of sensor. Looks beautiful. –  Sigur Mar 29 at 16:07
    
@MWijnand Accepting and upvoting are the conventional ways of thanking in this site. For details, please refer: How do you accept an answer –  Harish Kumar Mar 30 at 0:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.