5

My code is:

\documentclass{article}
\usepackage{calligra}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\usepackage[utf8]{inputenc}


\begin{document}


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



% The block diagram code is probably more verbose than necessary
\begin{tikzpicture}[auto, node distance=2cm,>=latex']


% Localizção dos Blocos
\node [input, name=input] {};
\node [sum, right of=input] (sum) {};
\node [block, right of=sum] (controller) {Controlador};
\node [block, right of=controller, pin={[pinstyle]above:Pertubação},node distance=4cm] (system) {Conversor};


% 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] {$d$} (system);
\node [output, right of=system] (output) {};
\node [block, below of=u] (measurements) {Medição};

% Conexão dos nós. 
\draw [draw,->] (input) -- node {$V_{ref}$} (sum);
\draw [->] (sum) -- node {$V_{err}$} (controller);
\draw [->] (system) -- node [name=y] {$V_{out}$}(output);
\draw [->] (y) |- (measurements);
\draw [->] (measurements) -| node[pos=0.99] {$-$} 
node [near end] {$V_{med}$} (sum);

\end{tikzpicture}

\end{document}

The result I desire is

enter image description here

Alan Munn
  • 218,180
SrnLord
  • 307

2 Answers2

5

You can just add a label to the node that contains the $-$. I've also changed your \tikzstyle commands to \tikzset. See Should \tikzset or \tikzstyle be used to define TikZ styles?.

\documentclass{article}
\usepackage{calligra}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning}
\usepackage[utf8]{inputenc}


\begin{document}


\tikzset{block/.style = {draw, fill=blue!20, rectangle, 
minimum height=3em, minimum width=6em},
sum/.style = {draw, fill=blue!30, circle, node distance=1.5cm},
input/.style = coordinate,
output/.style = coordinate,
pinstyle/.style = {pin edge={to-,thin,black}}
}



% The block diagram code is probably more verbose than necessary
\begin{tikzpicture}[auto, node distance=2cm,>=latex']


% Localizção dos Blocos
\node [input, name=input] {};
\node [sum, right of=input] (sum) {};
\node [block, right of=sum] (controller) {Controlador};
\node [block, right of=controller, pin={[pinstyle]above:Pertubação},node distance=4cm] (system) {Conversor};


% 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] {$d$} (system);
\node [output, right of=system] (output) {};
\node [block, below of=u] (measurements) {Medição};

% Conexão dos nós. 
\draw [draw,->,] (input) -- node {$V_{ref}$} (sum);
\draw [->] (sum) -- node {$V_{err}$} (controller);
\draw [->] (system) -- node [name=y] {$V_{out}$}(output);
\draw [->] (y) |- (measurements);
\draw [->] (measurements) -| node[pos=0.99,label=above:$+$] {$-$} 
node [near end] {$V_{med}$} (sum);

\end{tikzpicture}
\end{document}

output of code

Alan Munn
  • 218,180
4

Use the same method that you used for the minus sign, just place the node on another path. Specifically, the arrow going into the sum node:

\draw [->] (input) -- node {$V_{\mathrm{ref}}$} (sum) node[pos=0.95] {$+$};

Other things:

  • I used \mathrm for the subscripted words here.
  • Like Alan, I changed to \tikzset{stylename/.style={...},...}.
  • I added the positioning library, and changed to the syntax defined by that, i.e. right=of ... instead of right of=.... See Difference between "right of=" and "right=of" in PGF/TikZ

enter image description here

\documentclass{article}
\usepackage{calligra}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning} % added positioning
\usepackage[utf8]{inputenc}

\tikzset{
  block/.style={draw, fill=blue!20, rectangle, 
     minimum height=3em, minimum width=6em},
  sum/.style={draw, fill=blue!30, circle, node distance=1.5cm},
  input/.style={coordinate},
  output/.style={coordinate},
  pinstyle/.style={pin edge={to-,thin,black}}
}

\begin{document}

% The block diagram code is probably more verbose than necessary
\begin{tikzpicture}[auto, node distance=2cm,>=latex', on grid] % added on grid


% Localizção dos Blocos
\node [input, name=input] {};
\node [sum, right of=input] (sum) {};
\node [block, right=of sum] (controller) {Controlador};
\node [block, right=4cm of controller, pin={[pinstyle]above:Pertubação}] (system) {Conversor};


% 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] {$d$} (system);
\node [output, right=of system] (output) {};
\node [block, below=of u] (measurements) {Medição};

% Conexão dos nós. 
\draw [->] (input) -- node {$V_{\mathrm{ref}}$} (sum) node[pos=0.95] {$+$};
\draw [->] (sum) -- node {$V_{\mathrm{err}}$} (controller);
\draw [->] (system) -- node [name=y] {$V_{\mathrm{out}}$}(output);
\draw [->] (y) |- (measurements);
\draw [->] (measurements) -| node[pos=0.99] {$-$} 
node [near end] {$V_{\mathrm{med}}$} (sum);

\end{tikzpicture}

\end{document}
Torbjørn T.
  • 206,688
  • Thank you so much. Can you show me how to fill all the page in horizontal mode ? – SrnLord Jun 29 '18 at 18:31
  • @SrnLord Change node distance? Add e.g. xscale=1.5 to the tikzpicture options? Really though, as that is a completely different question, it might be better that you make a new question, seeing as you already have two answers for the node placement. – Torbjørn T. Jun 29 '18 at 18:33