[Tex/LaTex] Node above other node fails with “cannot parse this coordinate”

drawprogrammingtikz-pgf

I'm Alex stuying automation engineering and have to write my master thesis with tex. Until now, I haven't really used tikz or used a program to draw graphics and exported them to tikz. Now for the control concept (2 degrees of freedom), I wanted to use tikz. I found an example and tried to modify it. Nevertheless, I have problems. One is, when I use this example as defined below, I get the error:

! Package tikz Error: Cannot parse this coordinate.

See the tikz package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.33    \draw
        [-] (y) |- (prectrl2);
?

with this code:

\tikzstyle{block} = [draw, fill=blue!20, rectangle, 
minimum height=3em, minimum width=3em]
\tikzstyle{sum} = [draw, fill=blue!20, circle, node distance=2cm]
\tikzstyle{input} = [coordinate]
\tikzstyle{output} = [coordinate]
\tikzstyle{pinstyle} = [pin edge={-,thin,black}]

% The block diagram code is probably more verbose than necessary
\begin{tikzpicture}[auto, node distance=2cm]
% We start by placing the blocks
\node [input, name=input] {};
\node [block, right of=input,
        node distance=3cm] (prectrl) {Vorsteuerung};
\node [sum, right of=prectrl,
node distance=3cm] (sum) {};
\node [block, right of=sum] (controller) {Regler};
\node [sum, right of=controller] (sum2) {};
\node [block, right of=sum2] (system) {System};
\node [output, right of=system,
node distance=3.5cm] (output) {};
\node [input, below of=controller] (measurements) {};
\node [input, above of=controller] (prectrl2) {};

% Once the nodes are placed, connecting them is easy. 
\draw [draw,->] (input) -- node {$x_a^*, x_b^*$} (prectrl);
\draw [->] (prectrl) -- node {$x^*$} (sum);
\draw [->] (sum) -- node {$x^*$} (controller);
\draw [->] (controller) -- node {$u_R$} (sum2);
\draw [->] (sum2) -- node {$u$} (system);
\draw [->] (system) -- node [name=y] {$x \rightarrow y= c^T x$}(output);
\draw [-] (y) |- (measurements);
\draw [->] (measurements) -| node[pos=0.99] {$-$}
\draw [-] (y) |- (prectrl2);
\draw [->] (prectrl2) -| node[pos=-6.99] {$-$}
node [near end] {$y_m$} (sum);
\end{tikzpicture}`

If I remove either "measurements" or "prectrl2", then everything works fine. My second question is: How do I point the arrow to the second sum?

Hopefully afterwards I can draw an arrow from prectrl to the second sum, which is my goal. I defined prectrl2 and measurements, because I didn't find a possibility to draw the angle directly from "y" to the first sum and from "prectrl" to the second sum.

It would be nice if you can give me a hind, since I'm stuck at this point for over 3 hours.

With kind regards,

Alex

Best Answer

In addition to what Torbjørn T. said in his comment, you need to add a node there. And probably you do not really want to use pos=-6.99, right? I also replaced \tikzstyle by \tikzset and load the positioning library.

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{positioning}
\tikzset{block/.style={draw, fill=blue!20, rectangle, 
minimum height=3em, minimum width=3em},
sum/.style={draw, fill=blue!20, circle, node distance=2cm},
input/.style ={coordinate},
output/.style ={coordinate},
pinstyle/.style = {pin edge={-,thin,black}}}

\begin{document}
\begin{tikzpicture}[auto, node distance=2cm]
% We start by placing the blocks
\node[input] (input) {};
\node[block, right=of input,
        node distance=3cm] (prectrl) {Vorsteuerung};
\node [sum, right=3cm of prectrl] (sum) {};
\node [block, right=of sum] (controller) {Regler};
\node [sum, right=of controller] (sum2) {};
\node [block, right=of sum2] (system) {System};
\node [output, right=3.5cm of system] (output) {};
\node [input, below=of controller] (measurements) {};
\node [input, above=of controller] (prectrl2) {};
% Once the nodes are placed, connecting them is easy. 
\draw [draw,->] (input) -- node {$x_a^*, x_b^*$} (prectrl);
\draw [->] (prectrl) -- node {$x^*$} (sum);
\draw [->] (sum) -- node {$x^*$} (controller);
\draw [->] (controller) -- node {$u_R$} (sum2);
\draw [->] (sum2) -- node {$u$} (system);
\draw [->] (system) -- node [name=y] {$x \rightarrow y= c^T x$}(output);
\draw [-] (y) |- (measurements);
\draw [->] (measurements) -| (sum) node[pos=0.99] {$-$};
\draw [-] (y) |- (prectrl2);
\draw [->] (prectrl2) -| node[pos=0.99] {$-$} node [near end] {$y_m$} (sum);
\end{tikzpicture}
\end{document}

enter image description here

Related Question