2

This is my modified code from here:

\documentclass{scrartcl}
\usepackage{tikz}
\begin{document}

  \begin{tikzpicture}[auto,
                      node distance = 3cm,
                      signal/.style = coordinate,
                      sum/.style = {draw,
                                    circle,
                                    node distance = 2cm
                                   },
                      block/.style = {draw,
                                      rectangle,
                                      minimum height = 2em,
                                      minimum width = 4em
                                     },
                      branch/.style = {sum,
                                       fill = black
                                      }
                     ]
    %placing the blocks
    \node[signal] (input) {};
    \node[sum, right of = input] (left sum) {};
    \node[block, right of = {left sum}] (controller) {Regler};
    \node[block, right of = controller] (system) {Strecke, $x(t)$};
    %connecting the controller and system to calculate the coordinate u,
    %it needed to place the measurement block
    \draw
      [->] (controller) -- node[name=u] {$u(t)$} (system);
    \node[block, below of = u] (measurement) {Messglied};
    \node[sum, right of = system] (right sum) {};
    \node[signal, above of = {right sum}] (disturbances) {};
    \node[branch, right of = {right sum}] (branch) {};
    %do the same as above (connect system and controller,
    %to be able to place measurement) didn't work here,
    %because the nodes have different height
    \draw
      (right sum) -- (branch);
    \node[sum, below of = branch] (lower sum) {};
    \node[signal, right of = branch] (output) {};
    \node[signal, right of = {lower sum}] (measurement noise) {};
    %connecting the placed nodes
    \draw
      [->] (input) -- node {$w(t)$} (left sum);
    \draw
      [->] (left sum) -- node {$e(t)$} (controller);
    \draw
      [->] (system) -- (right sum);
    \draw
      [->] (disturbances) -- node {$z(t)$} (right sum);
    \draw
      [->] (branch) -- node {$y(t)$} (output);
    \draw
      [->] (branch) -- (lower sum);
    \draw
      [->] (measurement noise) -- node[above] {$m(t)$} (lower sum);
    \draw
      [->] (lower sum) -- (measurement);
    \draw
      [->] (measurement) -| node[pos = .99] {$-$} (left sum);
  \end{tikzpicture}

\end{document}

And the result of my buggy block diagram:

block diagram

The bugs are:

  1. Described in the title.
  2. Lines marked with red should have approximately the same length.
  3. I failed to manipulate the radius of the circles. Eg. sum/.style = {draw, circle, radius = 1mm, node distance = 2cm} does nothing.

In short: How can one solve the above tasks in a bit automate and optimal manner. Any optimizations and also completely different solutions are welcome!

Thank you for your help and effort in advance!

0

2 Answers 2

2

This might solve all your problems, though I'm not entirely certain what you meant in the first point.

To start at the end, with your point 3. There is no radius key for circular nodes, use minimum size instead, which defines the diameter.

For point 2. When you do right of=a, the distance is measured between the centre points of the nodes. When you have nodes of different sizes, the distances between node borders will then vary. But the <position> of= keys are considered deprecated anyway, see Difference between "right of=" and "right=of" in PGF/TikZ. Instead you should load the positioning library with

\usetikzlibrary{positioning}

and use right=of a and similar. This way, the distance is measured between node borders. (And if you want them measured between node centres, there is the key on grid for that, see the manual.)

Finally, the first point. Assuming that you wanted to place the Messglied node so that the arrow entering it from the right is horizontal, there are various possibilities.

Below I've moved that node to after the lower sum node in the code, and then used

\node[block] (measurement) at (u|-lower sum) {Messglied};

See TikZ: What EXACTLY does the the |- notation for arrows do? for a description of what |- does, if you don't know already.

output of code

\documentclass{scrartcl}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}

  \begin{tikzpicture}[auto,
                      node distance = 1.2cm,
                      signal/.style = coordinate,
                      sum/.style = {draw,
                                    circle,
                                    minimum size=1.5em % <--- modified
                                   },
                      block/.style = {draw,
                                      rectangle,
                                      minimum height = 2em,
                                      minimum width = 4em
                                     },
                      branch/.style = {sum,
                                       fill = black
                                      }
                     ]
    %placing the blocks
    \node[signal] (input) {};
    \node[sum, right=of input] (left sum) {};
    \node[block, right=of left sum] (controller) {Regler};
    \node[block, right=of controller] (system) {Strecke, $x(t)$};
    %connecting the controller and system to calculate the coordinate u,
    %it needed to place the measurement block
    \draw
      [->] (controller) -- node[name=u] {$u(t)$} (system);
    \node[sum, right=of system] (right sum) {};
    \node[signal, above=of right sum] (disturbances) {};
    \node[branch, right=of right sum] (branch) {};
    %do the same as above (connect system and controller,
    %to be able to place measurement) didn't work here,
    %because the nodes have different height
    \draw
      (right sum) -- (branch);
    \node[sum, below=of branch] (lower sum) {};
    \node[signal, right=of branch] (output) {};
    \node[signal, right=of lower sum] (measurement noise) {};
    % place measurement node
    \node[block] (measurement) at (u|-lower sum) {Messglied}; % <-- modified
    %connecting the placed nodes
    \draw
      [->] (input) -- node {$w(t)$} (left sum);
    \draw
      [->] (left sum) -- node {$e(t)$} (controller);
    \draw
      [->] (system) -- (right sum);
    \draw
      [->] (disturbances) -- node {$z(t)$} (right sum);
    \draw
      [->] (branch) -- node {$y(t)$} (output);
    \draw
      [->] (branch) -- (lower sum);
    \draw
      [->] (measurement noise) -- node[above] {$m(t)$} (lower sum);
    \draw
      [,->] (lower sum) -- (measurement);
    \draw
      [->] (measurement) -| node[pos = .99] {$-$} (left sum);
  \end{tikzpicture}

\end{document}
6
  • Hello @Torbjørn T.! Sorry for the long delay and my incorrect english. Thank you for your answer! It looks great! For my needs the sum nodes should be smaller (diameter smaller than the height) than the block nodes. If I do so (eg.sum/.style = {draw, circle, minimum size = 1pt}), than the connection between lower sum and measurement is sloped as I had before, see i.sstatic.net/GZXZV.png. I tried to solve it like you do with \node[block, below = of left sum.south -| u] (measurement) {Messglied} eg. \node[sum, right = of measurement -| branch] (lower sum) {};.
    – Su-47
    Nov 17, 2017 at 22:52
  • Than the connection between measurement is horizontal, but the connection between branch and lower sum is than sloped, see i.sstatic.net/9VelK.png. Also the branch nodes should be smaller than the sum nodes. The minimum size= command don't helps in this case. Thank you for your effort in advance!
    – Su-47
    Nov 17, 2017 at 22:58
  • @Su-47 I think I realized right after posting the answer that I used a stupid way of solving that bit. Anyways, answer updated. Nov 17, 2017 at 23:50
  • Hello @Torbjørn T.! Thank you for your comment! Now it works! Only last task is to do: The branch nodes should be smaller than the sum nodes (the diameter). For every value of the minimum size= command the sum and branch nodes have the same diameter. Is there a way, to leave the sum nodes like it is now and make the branch nodes smaller? Thank you for your effort in advance!
    – Su-47
    Nov 22, 2017 at 6:38
  • @Su-47 Sorry, missed that part. Of course, just add a smaller minimum size in the branch style, after sum. E.g .branch/.style={sum,minimum size=1em,fill=black}. Nov 22, 2017 at 9:18
1

you have more issues in your code:

  • you use obsolete syntax for node positioning. recently require positioning library and nodes are relativela positioned for example as \node[sum, right = of in] (sum-in) {}
  • in sum style definition you determine node distance again, but with different amount as is for others scheme elemewnts
  • in relative positioning you should consider node height (couse that lower sum is not aligned.

correcting this, i obtain:

enter image description here

edit: your code can by simplified with employing of the following tikz libraries: calc,chains and positioning. for beautiful arrows i suggest to use arrows.meta library.

  • scheme block are positioned in chain
  • for block names is used chain name (A, so the first block is A-1)
  • for shorter code for connection lines is added code, which enable draw edges without repeating block names. for example:

standard

\path   (in)    edge ["$w(t)$"] (A-1)
        (A-1)   edge ["$e(t)$"] (A-2)
...

proposed solution enable

\path   (in)    edge ["$w(t)$"] (A-1)
        (A-1)   edge ["$e(t)$"] (A-2)
...
  • for edge labels is used quotes library

complete mwe is:

\documentclass{scrartcl}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, 
                calc, chains, 
                positioning, 
                quotes}

\begin{document}
    \begin{tikzpicture}[auto,
node distance = 1cm and 1.5cm,
  start chain = A going right,
   sum/.style = {circle,
                 draw,
                 inner sep=0mm, minimum size=4mm,
                 node contents={}
                 },
 block/.style = {rectangle, 
                 draw,    
                 minimum height = 2em,
                 minimum width = 4em,
                 inner sep=2mm, outer sep =0mm
                 },
branch/.style = {circle,
                 inner sep=0mm, minimum size=2mm,
                 fill = black,
                 node contents={}
                 },
every edge/.append code = {%
\global\let\currenttarget\tikztotarget % save \tikztotarget in a global variable
\pgfkeysalso{append after command={(\currenttarget)}}% automatically repeat it
                           },
every edge/.append style = {-Straight Barb},
                     ]
%placing the blocks
    \coordinate (in);
    \begin{scope}[every node/.append style={on chain=A}]
\node [sum, right=of in];           % A-1
\node [block]   {Regler};
\node [block]   {Strecke, $x(t)$};
\node [sum];
\node [branch];                     % A-5
    \end{scope};
\coordinate [right=of A-5]  (out);
\node (A-6) [block, below = of $(A-2.south)!0.5!(A-3.south)$]   {Messglied};
    \coordinate[above = of A-4]   (z);
\node (A-7) [sum, at = {(A-6 -| A-5)}];
    \coordinate[right=of A-7]   (m);
% conections
\path   (in)    edge ["$w(t)$"] (A-1)
                edge ["$e(t)$"] (A-2)
                edge ["$u(t)$"] (A-3)
                edge            (A-4)
                edge            (A-5)
                edge ["$y(t)$"] (out)
        (z)     edge ["$z(t)$"] (A-4)
        (A-5)   edge            (A-7)
        (m)     edge ["$m(t)$" ']   (A-7)
                edge            (A-6);
\draw[-Straight Barb]    
        (A-6) -| (A-1) node[below left] {$-$};
  \end{tikzpicture}

\end{document}
3
  • Hello @Zarko! Sorry for the long delay. Your variant is a bit tricky for me. Anyway, thank you for your effort!
    – Su-47
    Nov 17, 2017 at 22:49
  • what is tricky? code is simple, clear and easy to understand, well, at least for me :-) . if you have problems with undertaking some parts, please ask, i will try to explain in more details
    – Zarko
    Nov 17, 2017 at 23:15
  • Hello @Zarko! Thank you for your comment! I understand the variant of Torbjørn T. immediately, so I choose this one. For your variant I have to invest more time. I hope you understand me correctly. I haven't enough time for everything, so I should to choose, like every other person. And thank you for your effort!
    – Su-47
    Nov 22, 2017 at 6:40

You must log in to answer this question.

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