7

So I want to reproduce this picture (i don't want to change my style but just get the links between the blocks as in figure):

enter image description here

This is my code:

   \documentclass{article}
   \usepackage{tikz}

  \usetikzlibrary{shapes,arrows,calc,positioning,decorations.pathmorphing} 
   \tikzset{
     pinstyle/.style={pin edge={to-,thin,black}},
     block/.style = {draw, rectangle,
       minimum height=1cm,
      align = center
    %   minimum width=2cm
    },
    input/.style = {coordinate,node distance=1cm},
     output/.style = {coordinate,node distance=1cm},
     arrow/.style={draw, -latex,node distance=2cm},
     pinstyle/.style = {pin edge={latex-, black,node distance=2cm}},
     sum/.style = {draw, circle, node distance=1cm},
     gain/.style = {regular polygon, regular polygon sides=3,
      draw, fill=white, text width=1em,
      inner sep=0mm, outer sep=0mm,
      shape border rotate=-90}
 }

 \begin{document}

   \begin{figure}
    \begin{center}
    \begin{tikzpicture}[auto,>=latex',every node/.append style=
    {font=\scriptsize}]

    %DEFINIZIONE BLOCCHI
    \node [input, name=input] {};
    \node [sum, right=of input] (speed_sum) {};
    \node [gain, right=of speed_sum] (Kp) {$K_{p}$};
    \node [gain, below=of Kp] (Ki) {$K_{i}$};
    \node [block, right=of Ki] (integrator) {$\frac{1}{s}$};
    \node [gain, right=2cm of integrator] (Kc) {$K_{c}$};
    \node [gain, right=2cm of Kc] (Kt) {$K_{t}$};
    \node [block, right=of Kt] (system) {$L(s)$};
    \node [output, right=of system] (output) {};

    \node at ($(speed_sum)!0.5!(Kp)$) (snodo1) {};
    \node [sum, right=of Kp] (control_sum) {};

    %DEFINIZIONE COLLEGAMENTI IN CATENA DIRETTA
    \draw [->] (input) -- node {$\omega_{M}^{\mathrm{DES}}(s)$}(speed_sum);
    \draw [->] (speed_sum) -- node {$E_{v}(s)$}(snodo1);
    \draw [->] (snodo1) -- (Kp);
    \draw [->] (snodo1) --(Ki);
    \draw [->] (Ki) --(integrator);
    \draw [->] (Kp) -- (control_sum);
    \draw [->] (integrator) --(control_sum);
    \draw [->] (control_sum) --(Kc);
    \draw [->] (Kc) -- node {$I^{\mathrm{DES}}(s)=I(s)$}(Kt);
    \draw [->] (Kt) -- node {$C_{\mathrm{M}}(s)$}(system);
    \draw [->] (system) -- node [name=motor_speed] {$s\theta_{M}(s)$}
     (output);

    %DEFINIZIONE COLLEGAMENTI FEEDBACK
    \draw [->] (motor_speed) -- ++ (0,-2) -| node [pos=0.99] {$-$} 
   (speed_sum);

    \end{tikzpicture}
    \end{center}

   \caption{Anello di controllo di velocit\`a implementato}
    \label{fig:speed_loop_semplificato}
    \end{figure} 

     \end{document}

And this is the awful result I have: enter image description here

  • 1
    tex.stackexchange.com/questions/45347 might be of interest. – Torbjørn T. May 24 '17 at 8:23
  • Yes, this is very usefull. I don't understand how to create the "dot" (node) to start 2 arrows from one. – iacopo May 24 '17 at 8:35
  • 1
    dot/.style={circle,fill,draw,inner sep=0pt,minimum size=3pt} and \node[dot] {};? – Torbjørn T. May 24 '17 at 8:37
  • Ok, thank you! Last question for you. How can i set Kp to be above and right of speed_sum? – iacopo May 24 '17 at 8:40
  • above right=of (have a look at chapter 17.5, "Positioning nodes" in the manual). – Torbjørn T. May 24 '17 at 9:10
7

Based on my comments.

enter image description here

\documentclass{article}
\usepackage{tikz}

\usetikzlibrary{shapes,arrows,calc,positioning,decorations.pathmorphing} 
\tikzset{
  -|-/.style={
    to path={
      (\tikztostart) -| ($(\tikztostart)!#1!(\tikztotarget)$) |- (\tikztotarget)
      \tikztonodes
    }
  },
  -|-/.default=0.5,
  |-|/.style={
    to path={
      (\tikztostart) |- ($(\tikztostart)!#1!(\tikztotarget)$) -| (\tikztotarget)
      \tikztonodes
    }
  },
  |-|/.default=0.5,
}
\tikzset{
%   pinstyle/.style={pin edge={to-,thin,black}}, % you have another one below
   block/.style = {draw, rectangle,
       minimum height=1cm,
       align = center
    %   minimum width=2cm
   },
   input/.style = {coordinate,node distance=1cm},
   output/.style = {coordinate,node distance=1cm},
   arrow/.style={draw, -latex,node distance=2cm},
   pinstyle/.style = {pin edge={latex-, black,node distance=2cm}},
   sum/.style = {draw, circle, node distance=1cm},
   gain/.style = {
     regular polygon, regular polygon sides=3,
     draw, fill=white, text width=1em,
     inner sep=0mm, outer sep=0mm,
     shape border rotate=-90
   },
   dot/.style={circle,fill,draw,inner sep=0pt,minimum size=3pt}
 }

\begin{document}

\begin{figure}
\centering
\begin{tikzpicture}[auto,>=latex',every node/.append style=
    {font=\scriptsize}]

    %DEFINIZIONE BLOCCHI
\node [input, name=input] {};
\node [sum, right=of input] (speed_sum) {};
\node [gain, above right=of speed_sum] (Kp) {$K_{p}$};
\node [gain, below=of Kp] (Ki) {$K_{i}$};
\node [dot] at ($(speed_sum)!0.5!(Kp)$) (snodo1) {};
\node [sum, right=of Kp] (control_sum) {};
\node [block] (integrator) at (Ki-|control_sum) {$\frac{1}{s}$};
\node [gain, right=2cm of integrator] (Kc) {$K_{c}$};
\node [gain, right=2cm of Kc] (Kt) {$K_{t}$};
\node [block, right=of Kt] (system) {$L(s)$};
\node [output, right=of system] (output) {};


    %DEFINIZIONE COLLEGAMENTI IN CATENA DIRETTA
\draw [->] (input) -- node {$\omega_{M}^{\mathrm{DES}}(s)$}(speed_sum);
\draw [->] (speed_sum) |- node {$E_{v}(s)$}(snodo1);
\draw [->] (snodo1) |- (Kp);
\draw [->] (snodo1) |-(Ki);
\draw [->] (Ki) --(integrator);
\draw [->] (Kp) -- (control_sum);
\draw [->] (integrator) -- (control_sum);
\draw [->] (control_sum) to[-|-] (Kc);
\draw [->] (Kc) -- node {$I^{\mathrm{DES}}(s)=I(s)$}(Kt);
\draw [->] (Kt) -- node {$C_{\mathrm{M}}(s)$}(system);
\draw [->] (system) -- node [name=motor_speed] {$s\theta_{M}(s)$}
     (output);

    %DEFINIZIONE COLLEGAMENTI FEEDBACK
\draw [->] (motor_speed) -- ++ (0,-2) -| node [pos=0.99] {$-$} 
   (speed_sum);
\node [dot] at (motor_speed.south) {};
\end{tikzpicture}
\caption{Anello di controllo di velocit\`a implementato}
\label{fig:speed_loop_semplificato}
\end{figure} 

\end{document}

Updated

This is more like your image:

enter image description here

\documentclass{article}
\usepackage{tikz}

\usetikzlibrary{shapes,arrows,calc,positioning,fit} 

\tikzset{
%   pinstyle/.style={pin edge={to-,thin,black}}, % you have another one below
   block/.style = {draw, rectangle,
       minimum height=1cm,
       align = center
    %   minimum width=2cm
   },
   input/.style = {coordinate,node distance=1cm},
   output/.style = {coordinate,node distance=1cm},
   arrow/.style={draw, -latex,node distance=2cm},
   pinstyle/.style = {pin edge={latex-, black,node distance=2cm}},
   sum/.style = {draw, circle, node distance=1cm},
   gain/.style = {
     regular polygon, regular polygon sides=3,
     draw, fill=white, text width=1em,
     inner sep=0mm, outer sep=0mm,
     shape border rotate=-90
   },
   dot/.style={circle,fill,draw,inner sep=0pt,minimum size=3pt}
 }

\begin{document}

\begin{figure}
\centering
\begin{tikzpicture}[>=latex',every node/.append style=
    {font=\scriptsize},node distance=5mm]

    %DEFINIZIONE BLOCCHI
\node [input, name=input] {};
\node [sum, right=of input] (speed_sum) {};
\node [dot, right=8mm of speed_sum] (snodo1) {};
\node [gain, above right=7mm and 5mm of snodo1] (Kp) {$K_{p}$};
\node [gain, below right=7mm and 5mm of snodo1] (Ki) {$K_{i}$};

\node [block,right=of Ki] (integrator) {$\frac{1}{s}$};
\node [sum, xshift=7mm] at (snodo1-|integrator) (control_sum) {};
\node [gain, right=1cm of control_sum] (Kc) {$K_{c}$};
\node [gain, right=1cm of Kc] (Kt) {$K_{t}$};
\node [block, right=8mm of Kt] (system) {$L(s)$};
\node [output, right=of system] (output) {};


    %DEFINIZIONE COLLEGAMENTI IN CATENA DIRETTA
\begin{scope}[auto]
\draw [->] (input) -- node {$\omega_{M}^{\mathrm{DES}}(s)$} (speed_sum);
\draw [->] (speed_sum) -- node {$E_{v}(s)$}(snodo1);
\draw [->] (snodo1) |- (Kp);
\draw [->] (snodo1) |- (Ki);
\draw [->] (Ki) -- (integrator);
\draw [->] (Kp) -| (control_sum) node[very near end,swap] {$-$};
\draw [->] (integrator) -| (control_sum) node[very near end] {$-$};
\draw [->] (control_sum) -- (Kc);
\draw [->] (Kc) -- node [align=center] {$I^{\mathrm{DES}}(s)$\\$=$\\$I(s)$}(Kt);
\draw [->] (Kt) -- node {$C_{\mathrm{M}}(s)$}(system);
\draw [->] (system) -- node [name=motor_speed] {$s\theta_{M}(s)$}
     (output);
\end{scope}

    %DEFINIZIONE COLLEGAMENTI FEEDBACK
\draw [->] (motor_speed) -- ++ (0,-2.5) -| node [pos=0.99,right] {$-$} node[dot,pos=0.28] (snodo2) {}
   (speed_sum);
\node [dot] at (motor_speed.south) {};

\draw [->] (snodo2) -- ++(0,0.5) node[above,draw] (KiKd) {Ki.Kd};
\draw [->] (KiKd) -- ++(0,1) -- node[above,pos=0.5] {$-$}(control_sum);

\node [draw,dashed,inner ysep=5mm,fit=(speed_sum)(Kp)(KiKd)(snodo2)] (sc) {};
\node [above right] at (sc.south west) {Speed controller};
\end{tikzpicture}
\caption{Anello di controllo di velocit\`a implementato}
\label{fig:speed_loop_semplificato}
\end{figure} 

\end{document}
  • Thank you, now i will go on my self to try solve the problem and if i am capable i will post the solution here. – iacopo May 24 '17 at 9:47
  • 1
    @iacopo I updated my answer. – Torbjørn T. May 24 '17 at 10:34
  • Awesome, i will post my solution in some minutes just to show another way (different) to do it. I am just trying to improve my skills too :) – iacopo May 24 '17 at 10:40
1

This is my try after @Torbjorn T. helps. There are some different things from the first .png picture since i had to do some edits:

enter image description here

 \documentclass{article}
 \usepackage{tikz}

  \usetikzlibrary{shapes,arrows,calc,positioning,decorations.pathmorphing} 
  \tikzset{
 -|-/.style={
  to path={
  (\tikztostart) -| ($(\tikztostart)!#1!(\tikztotarget)$) |- (\tikztotarget)
  \tikztonodes
}
 },
  -|-/.default=0.5,
  |-|/.style={
to path={
  (\tikztostart) |- ($(\tikztostart)!#1!(\tikztotarget)$) -| (\tikztotarget)
  \tikztonodes
   }
 },
 |-|/.default=0.5,
}
\tikzset{
%   pinstyle/.style={pin edge={to-,thin,black}}, % you have another one 
  below
    block/.style = {draw, rectangle,
   minimum height=1cm,
   align = center
  %   minimum width=2cm
  },
  input/.style = {coordinate,node distance=1cm},
  output/.style = {coordinate,node distance=1cm},
  arrow/.style={draw, -latex,node distance=2cm},
  pinstyle/.style = {pin edge={latex-, black,node distance=2cm}},
  sum/.style = {draw, circle, node distance=1cm},
 gain/.style = {
 regular polygon, regular polygon sides=3,
 draw, fill=white, text width=1em,
 inner sep=0mm, outer sep=0mm,
 shape border rotate=-90
 },
  dot/.style={circle,fill,draw,inner sep=0pt,minimum size=3pt}
}

 \begin{document}

\begin{figure}
\centering
\begin{tikzpicture}[auto,>=latex',every node/.append style=
    {font=\scriptsize}]

%DEFINIZIONE BLOCCHI
\node [input, name=input] {};
\node [sum, right=of input] (speed_sum) {};
\node [gain, above right=2cm of speed_sum] (Kp) {$K_{p}$};
\node [gain, below right=2cm of speed_sum] (Ki) {$K_{i}$};
\node [dot,right=of speed_sum] (snodo1) {};
\node [sum, right=4cm of speed_sum] (control_sum) {};
\node [block, right=of Ki] (integrator) {$\frac{1}{s}$};
\node [gain, right=2.5cm of control_sum] (Kc) {$K_{c}$};
\node [gain, right=2cm of Kc] (Kt) {$K_{t}$};
\node [block, right=of Kt] (system) {$L(s)$};
\node [output, right=of system] (output) {};

\node [dot] at (6.68,-3.75) (snodo2){};
\node [block, right=1cm of integrator] (derivative) {$s\cdot K_{d}\cdot 
 K_{i}$};


%DEFINIZIONE COLLEGAMENTI IN CATENA DIRETTA
\draw [->] (input) -- node {$\omega_{M}^{\mathrm{DES}}(s)$}(speed_sum);
\draw [-] (speed_sum) -- (snodo1);
\draw [->] (snodo1) |- (Kp);
\draw [->] (snodo1) |- (Ki);
\draw [->] (Ki) --(integrator);
\draw [->] (Kp) -| node [pos=0.99] {$+$} (control_sum);
\draw [->] (integrator) -| node [pos=0.99] {$+$} (control_sum);
\draw [->] (control_sum) to[-|-] (Kc);
\draw [->] (Kc) -- node {$I^{\mathrm{DES}}(s)=I(s)$}(Kt);
\draw [->] (Kt) -- node {$C_{\mathrm{M}}(s)$}(system);
\draw [->] (system) -- node [name=motor_speed] {$s\theta_{M}(s)$}
 (output);

%DEFINIZIONE COLLEGAMENTI FEEDBACK
\draw [->] (motor_speed) -- ++ (0,-4) -| node [pos=0.99] {$-$} 
(speed_sum);
\node [dot] at (motor_speed.south) {};
\draw [->] (snodo2) -- (derivative);
\draw [->] (derivative) -- node [near end, above right] {$-$} (control_sum);

%DEFINIZIONE BOX CONTROLLORE DI VELOCITA'
\draw [color=cyan,thick](0.65,-4.3) rectangle (7.7,2.7);
\node at (0.65,3) [above=5mm, right=0mm] {\textsc{Controllore di 
velocit\`a}};

\end{tikzpicture}
\caption{Anello di controllo di velocit\`a implementato}
\label{fig:speed_loop_semplificato}
\end{figure} 

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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