1

I'm making the following block diagram, but I don't know how to move or center the first column of 4 blocks, in a way there is the same number up and down respect the line of U

MWE

\documentclass{article}
\usepackage{lscape}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning,calc}
\begin{document}

\tikzset{
    block/.style = {draw, fill=white, rectangle, minimum height=3em, minimum width=3em},
    tmp/.style  = {coordinate}, 
    sum/.style= {draw, fill=white, circle, node distance=1cm},
    input/.style = {coordinate},
    output/.style= {coordinate},
    pinstyle/.style = {pin edge={to-,thin,black}}
}



\begin{tikzpicture}[auto, node distance=2cm,>=latex',scale=0.1]

    \node [input, name=rinput] (rinput) {};
    \node [sum, right of=rinput] (sum1) {};
    \node [block, right of=sum1] (controller) {$k_{p\beta}$};
    \node [block, above of=controller,node distance=1.3cm] (up){$\frac{k_{i\beta}}{s}$};
    \node [block, above of=up,node distance=1.3cm] (up2){$\frac{k_{i\beta}}{s}$};
    \node [block, below of=controller,node distance=1.3cm] (rate) {$sk_{d\beta}$};
    \node [sum, right of=controller,node distance=2cm] (sum2) {};
    \draw [->] (up2) -| (sum2);

    \node [block, right of=sum2,node distance=2cm] (system) 
{$\frac{a_{\beta 2}}{s+a_{\beta 1}}$};
    \node [output, right of=system, node distance=2cm] (output) {};
    \node [tmp, below of=controller] (tmp1){$H(s)$};
    \draw [->,color=white] (rinput) -- node{$R(s)$} (sum1);
    \draw [->,color=white] (sum1) --node[name=z,anchor=center]{} (controller);
    \draw [->] (controller) -- (sum2);
    \draw [->] (sum2) -- node{$U(s)$} (system);
    \draw [-] (system) -- node [name=y] {$Y(s)$}(output);
    \draw [->,color=white] (sum1) |- (rate);
    \draw [->] (rate) -| (sum2);
    \draw [->,color=white] (sum1) |- (up);
    \node [input, right of=output, node distance=2cm] (input2) {};
    \draw [->] (up) -| (sum2);
%    \draw [-] (output) -- node [name=y2] { }(sum2);
    \node [sum, right of=output] (sum2) {};
    \draw [->] (output) -- node [name=y2] { }(sum2);
    \node [block, right of=sum2] (controllera) {$k_{p\beta}$};
    \node [block, above of=controllera,node distance=1.3cm] (upa){$\frac{k_{i\beta}}{s}$};
    \node [block, below of=controllera,node distance=1.3cm] (ratea) {$sk_{d\beta}$};
   \draw [->] (sum2) |- node{$R1(s)$} (upa);
   \draw [->] (sum2) -- node{$R2(s)$} (controllera);
   \draw [->] (sum2) |- node{$R3(s)$} (ratea);
    \node [block, right of=controllera,node distance=2cm] (sumador) {};
   \draw [->] (upa) -| node{$ $} (sumador);
   \draw [->] (controllera) -- node{$R2(s)$} (sumador);
   \draw [->] (ratea) -| node{$R3(s)$} (sumador);
    \node [input, right of=sumador, node distance=2cm] (Salida) {$H(s)$};
   \draw [->] (sumador) --  (Salida);
    \end{tikzpicture}
\caption{EQ}

\end{document}

Nevermind the captios or labels, I'm fixing it.

Thanks. enter image description here

2 Answers 2

4

Using coordinate-calculation:

Change the code for node sum2 from

\node [sum, right of=controller,node distance=2cm] (sum2) {};

to

\node [sum, right=of $(controller.east)!.5!(up.east)$, node distance=2cm] (sum2) {};

and adjust \draw [->] (controller) -- (sum2); to \draw [->] (controller) -| (sum2);.

Limitation: You have to manually pick a pair of symmetric node when the number of node is even. And it seems one have to firstly draw these controller node, then node sum1.

Using a matrix:

The vertical centering alignment is easier to achieve with all the controller nodes wrapped in a tikz matrix:

    \matrix[nodes=block, row sep={1.3cm,between origins}, right of=sum1] (controllers) {
      \node (controller) {$k_{p\beta}$};    \\
      \node (up) {$\frac{k_{i\beta}}{s}$};  \\
      \node (up2) {$\frac{k_{i\beta}}{s}$}; \\
      \node (rate) {$sk_{d\beta}$};         \\
    };
    \node [sum, right of=controllers, node distance=2cm] (sum2) {};

Full example

\documentclass{article}
\usepackage{lscape}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning,calc}
\begin{document}

\tikzset{
  block/.style = {draw, fill=white, rectangle, minimum height=3em, minimum width=3em},
  tmp/.style  = {coordinate}, 
  sum/.style= {draw, fill=white, circle, node distance=1cm},
  input/.style = {coordinate},
  output/.style= {coordinate},
  pinstyle/.style = {pin edge={to-,thin,black}}
}

\begin{tikzpicture}[auto, node distance=2cm,>=latex',scale=0.1]
    \node [input, name=rinput] (rinput) {};
    \node [sum, right of=rinput] (sum1) {};
    \matrix[nodes=block, row sep={1.3cm,between origins}, right of=sum1] (controllers) {
      \node (controller) {$k_{p\beta}$};    \\
      \node (up) {$\frac{k_{i\beta}}{s}$};  \\
      \node (up2) {$\frac{k_{i\beta}}{s}$}; \\
      \node (rate) {$sk_{d\beta}$};         \\
    };
    \node [sum, right of=controllers, node distance=2cm] (sum2) {};
    \draw [->] (up2) -| (sum2);

    \node [block, right of=sum2,node distance=2cm] (system) 
{$\frac{a_{\beta 2}}{s+a_{\beta 1}}$};
    \node [output, right of=system, node distance=2cm] (output) {};
    \node [tmp, below of=controller] (tmp1){$H(s)$};
    \draw [->,color=white] (rinput) -- node{$R(s)$} (sum1);
    \draw [->,color=white] (sum1) --node[name=z,anchor=center]{} (controller);
    \draw [->] (controller) -| (sum2);
    \draw [->] (sum2) -- node{$U(s)$} (system);
    \draw [-] (system) -- node [name=y] {$Y(s)$}(output);
    \draw [->,color=white] (sum1) |- (rate);
    \draw [->] (rate) -| (sum2);
    \draw [->,color=white] (sum1) |- (up);
    \node [input, right of=output, node distance=2cm] (input2) {};
    \draw [->] (up) -| (sum2);
%    \draw [-] (output) -- node [name=y2] { }(sum2);
    \node [sum, right of=output] (sum2) {};
    \draw [->] (output) -- node [name=y2] { }(sum2);
    \node [block, right of=sum2] (controllera) {$k_{p\beta}$};
    \node [block, above of=controllera,node distance=1.3cm] (upa){$\frac{k_{i\beta}}{s}$};
    \node [block, below of=controllera,node distance=1.3cm] (ratea) {$sk_{d\beta}$};
   \draw [->] (sum2) |- node{$R1(s)$} (upa);
   \draw [->] (sum2) -- node{$R2(s)$} (controllera);
   \draw [->] (sum2) |- node{$R3(s)$} (ratea);
    \node [block, right of=controllera,node distance=2cm] (sumador) {};
   \draw [->] (upa) -| node{$ $} (sumador);
   \draw [->] (controllera) -- node{$R2(s)$} (sumador);
   \draw [->] (ratea) -| node{$R3(s)$} (sumador);
    \node [input, right of=sumador, node distance=2cm] (Salida) {$H(s)$};
   \draw [->] (sumador) --  (Salida);
    \end{tikzpicture}
\end{document}

enter image description here

3
  • the matrix approach is very interesting, and indeed its easier to get the alignment done, but I dont get how the arrows are drawed from the 4 blocks towards the sum 2. Ir is done with one sentence? \$ \node [sum, right of=controllers, node distance=2cm] (sum2) {};\$ And by the way, Thanks you are very kind.
    – riccs_0x
    Commented Nov 12, 2021 at 6:40
  • 1
    I didn't changed the arrow drawing code in your example, except changing \draw [->] (controller) -- (sum2); to \draw [->] (controller) -| (sum2);. Since each node in the matrix is named, you can use their names in following paths as usual. Commented Nov 12, 2021 at 7:12
  • Yeah, I just understand. Thanks a lot again.
    – riccs_0x
    Commented Nov 12, 2021 at 7:33
2

Probably off-topic ... By use of calc and chains TikZ libraries a possible solution can be:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                calc,chains, 
                positioning,
                quotes
                }
\tikzset{
block/.style = {draw, semithick, minimum size=3em, inner ysep=0pt},
  sum/.style = {circle, draw, minimum size=10pt, inner sep=0pt},
every edge/.style = {draw, ->}
        }

\begin{document}
    \begin{tikzpicture}[auto, 
node distance = 2mm and 11mm,
            > = Stealth,
  start chain = going below,       
            ]
    \begin{scope}[nodes={block, on chain}]
\node (m1) {$k_{i\beta}$};
\node (m2) {$\frac{k_{i\beta}}{s}$};
\node (m3) {$k_{p\beta}$};
\node (m4) {$sk_{d\beta}$};
    \end{scope} 
\coordinate[left=of $(m2.south)!0.5!(m3.north)$] (in);
%
\node (s1)  [sum] at (in) {~};
\node (s2)  [sum,  right=of in -| m3.east] {$+$};
\node (s3)  [block, right=of s2] {$\frac{a_{\beta 2}}{s+a_{\beta 1}}$};
\node (s4)  [sum,  right=of s3] {~};
%
\draw[->]   (m1) -| (s2);
\draw       (m2) -- (m2 -| s2);
\draw       (m3) -- (m3 -| s2);
\draw[->]   (m4) -| (s2);
%
\node (n2) [block, right=of s4]  {$\frac{k_{i\beta}}{s}$};
\node (n1) [block, above=of n2]  {$k_{p\beta}$};
\node (n3) [block, below=of n2]  {$sk_{d\beta}$};
%
\node (s5)  [block, right=of n2] {};
\coordinate[right=of s5] (out);
%
\draw[->]   (s4) |- (n1) node[pos=0.75,above] {$R_1(s)$};
\draw[->]   (s4) |- (n3) node[pos=0.75,above] {$R_3(s)$};
%
\draw[->]   (n1) -| (s5);
\draw[->]   (n3) -| (s5) node[pos=0.25,above] {$R_3(s)$};
%%%
\coordinate[right=of s5] (out);
\path   (s2) edge ["$U(s)$"] (s3)
        (s3) edge ["$Y(s)$"] (s4)
        (s4) edge ["$R_2(s)$"] (n2)
        (n2) edge ["$R_2(s)$"] (s5)
        (s5) edge (out);
    \end{tikzpicture}
\end{document}

enter image description here

3
  • calc, chains? Those are new to me, thanks for advising me.!!! Great diagram too.
    – riccs_0x
    Commented Nov 12, 2021 at 20:16
  • 1
    @riccs_0x, ups, in MWE are calc and chins TikZ libraries. Also exist calc package, but it is nod used in my answer. Sorry, if this make any confusion. Corrected now.
    – Zarko
    Commented Nov 12, 2021 at 20:28
  • don't mind, Im studying the new libraries, thanks.!!!
    – riccs_0x
    Commented Nov 12, 2021 at 21:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .