5

I would like to produce a block diagram similar to the image attached, but I can't get the adder blocks right. Is there a function/command to create a summer block with a plus and a minus in it. Also I would like to change the Ki and Kp block to a triangle if possible. any help would be great.

\documentclass[tikz,14pt,border=10pt]{standalone}
\usepackage{textcomp}
\usetikzlibrary{shapes,arrows}

\begin{document}
\tikzset{%
    block/.style    = {draw, thick, rectangle, minimum height = 3em,
        minimum width = 3em},
    sum/.style      = {draw, circle, node distance = 2cm}, % Adder
    input/.style    = {coordinate}, % Input
    output/.style   = {coordinate} % Output
}
% Defining string as labels of certain blocks.
\newcommand{\suma}{\Large$+$}
\newcommand{\inte}{$\displaystyle \int$}
\newcommand{\derv}{\huge$\frac{d}{dt}$}
    \begin{tikzpicture}[auto, thick, node distance=2cm, >=triangle 45]
    \draw
    % Drawing the blocks of first filter :
    node at (-0.5,0)     {$\theta_a$} 
    node at (0,0)      [input,name=input1,thick,above]{}
    node at (-0.5,-2.5)  {$\omega_g$} 
    node at (0,-2.5)   [input,name=input2,thick,above]{}

    node at (1,0)[sum] (sum1) {}
    node at (2,-0.15) (joint1) {}
    node at (4,0) [block](inte1) {\inte}
    node at (6,0) [block](ki){$K_i$}
    node at (4,2) [block](kp){$K_p$}
    node at (7.5,0)[sum] (sum2) {}
    node at (8.5,0)[sum] (sum3) {}
    node at (10,0) [block](inte2) {\inte}
    node at (11,0.15) (joint2) {}
    node at (11,-1.5)(joint3) {}
    node at (11.5,0) (out) {}
    node at (12,0)  {$\theta_f$};

% Commands \draw with options like [->] must be written individually
    \draw[->](input1) -- node {}(sum1);
    \draw[->](sum1) -- node {} (inte1);
    \draw[->](joint1) |- node {} (kp);
    \draw[->](inte1) -- node {} (ki);
    \draw[->](ki) -- node {} (sum2);
    \draw[->](kp) -| node {} (sum2);
    \draw[->](input2) -| node {} (sum3);
    \draw[->](sum2) -- node {} (sum3);
    \draw[->](sum3) -- node {} (inte2);
    \draw[->](inte2) -- node {} (out);
    \draw(joint2) -- node {} (joint3);
    \draw[->](joint3) -| node {} (sum1);
    \end{tikzpicture}
    \end{document}

enter image description here

Sean Allred
  • 27,421

1 Answers1

4

Triangle gain blocks can be realized using the shape isosceles triangle.

As of the sum block, I'm dealing with the same problem recently. The code is as follows; I added a style for joints and pruned the intermediate coordinate joint3.

\documentclass[tikz,14pt,border=10pt]{standalone}
\usepackage{textcomp}
\usetikzlibrary{shapes,arrows}

\begin{document}
\tikzset{%
    block/.style    = {draw, thick, rectangle, minimum height = 3em,
        minimum width = 3em},
    gain/.style     = {draw, thick, isosceles triangle, minimum height = 3em,
        isosceles triangle apex angle=60},
    port/.style     = {inner sep=0pt, font=\tiny},
    sum/.style n args = {4}{draw, circle, node distance = 2cm, minimum size=5mm, alias=sum,
        append after command={
            node at (sum.north) [port, below=1pt] {$#1$}
            node at (sum.west) [port, right=1pt] {$#2$}
            node at (sum.south) [port, above=1pt] {$#3$}
            node at (sum.east) [port, left=1pt] {$#4$}
        },
    }, % Adder
    joint/.style    = {circle, draw, fill, inner sep=0pt, minimum size=2pt},
    input/.style    = {coordinate}, % Input
    output/.style   = {coordinate} % Output
}
% Defining string as labels of certain blocks.
\newcommand{\suma}{\Large$+$}
\newcommand{\inte}{$\displaystyle \int$}
\newcommand{\derv}{\huge$\frac{d}{dt}$}
    \begin{tikzpicture}[auto, thick, node distance=2cm, >=triangle 45]
    \draw
    % Drawing the blocks of first filter :
    node at (-0.5,0)     {$\theta_a$} 
    node at (0,0)      [input,name=input1,thick,above]{}
    node at (-0.5,-2.5)  {$\omega_g$} 
    node at (0,-2.5)   [input,name=input2,thick,above]{}

    node at (1,0)[sum={}{-}{+}{}] (sum1) {}
    node at (2,0) [joint] (joint1) {}
    node at (4,0) [block](inte1) {\inte}
    node at (6,0) [gain](ki){$K_i$}
    node at (4,2) [gain](kp){$K_p$}
    node at (7.5,0)[sum={+}{+}{}{}] (sum2) {}
    node at (8.5,0)[sum={}{-}{+}{}] (sum3) {}
    node at (10,0) [block](inte2) {\inte}
    node at (11,0) [joint] (joint2) {}
    node at (11.5,0) (out) {}
    node at (12,0)  {$\theta_f$};

% Commands \draw with options like [->] must be written individually
    \draw[->](input1) -- node {}(sum1);
    \draw[->](sum1) -- node {} (inte1);
    \draw[->](joint1) |- node {} (kp);
    \draw[->](inte1) -- node {} (ki);
    \draw[->](ki) -- node {} (sum2);
    \draw[->](kp) -| node {} (sum2);
    \draw[->](input2) -| node {} (sum3);
    \draw[->](sum2) -- node {} (sum3);
    \draw[->](sum3) -- node {} (inte2);
    \draw[->](inte2) -- node {} (out);
    \draw(joint2) -- ++(0,-1.5) [->] -| node {} (sum1);
    \end{tikzpicture}
    \end{document}

result

salviati
  • 423