% Some basic examples for signal flow diagrams.
%
% Author: Dr. Karlheinz Ochs, Ruhr-University of Bochum, Germany
% Version: 0.1
% Date: 2007/01/05
\documentclass{article}
\usepackage{signalflowdiagram}

%%%<
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\setlength\PreviewBorder{5pt}%
%%%>

\begin{comment}
:Title: Signal flow building blocks
:Tags: Block diagrams, Macro packages

The signalflow library by Karlheinz Ochs defines a variety of building blocks
that can be used to draw signal flow diagrams. Examples are ``input`` and
``output`` nodes, ``multiplier`` and ``adder`` nodes, and ``filter`` and ``delay``
blocks. The library also extends the node placement syntax by adding the constructs
``right from=``, ``above from=`` etc., that places nodes relative to node boundaries instead of
node centers.

Files:

- Download the version of the ``signalflow`` library used in this example: `signalflow.zip`_

.. _signalflow.zip: http://media.texample.net/tikz/examples/signalflowlibrary/signalflowlibrary.zip

| Author: `Dr. Karlheinz Ochs`__, Ruhr-University of Bochum, Germany

.. __: http://www.nt.ruhr-uni-bochum.de/Extern/en/Group/Who/Engineer/Ochs/person.htm
\end{comment}
\begin{document}

%
% Basic definitions of the symbols used in a signal flow diagram
%
\begin{preview}
% - input and output terminal
\begin{signalflow}{Terminals and branches}
    % - input terminal
    \begin{scope}
        \node[input]      (in)                 {$x(t)$};
        \node[coordinate] (c)  [right from=in] {};
        % signal path
        \path[r>] (in) -- (c);
    \end{scope}
    % - output terminal
    \begin{scope}[xshift=3cm]
        \node[output]     (out)                {$y(t)$};
        \node[coordinate] (c)  [left from=out] {};
        % signal path
        \path[r>] (c) -- (out);
    \end{scope}
    % - branching node
    \begin{scope}[yshift=-2cm]
        \node[input]  (in)                          {$x(t)$};
        \node[node]   (nd)    [right from=in]       {};
        \node[output] (out1)  [above right from=nd] {$x(t)$};
        \node[output] (out2)  [below right from=nd] {$x(t)$};
        % signal paths
        \path[r>] (in) -- (nd);
        \path[r>] (nd) |- (out1);
        \path[r>] (nd) |- (out2);
    \end{scope}
\end{signalflow}

\begin{signalflow}{Multiplier and adder}
    % - multiplier
    \begin{scope}
        \node[input]      (in)                     {$x(t)$};
        \node[multiplier] (mul) [right from=in]  {\nodepart{above}{$\alpha$}};
        \node[output]     (out) [right from=mul] {$\alpha x(t)$};
        % signal paths
        \path[r>] (in)  -- (mul);
        \path[r>] (mul) -- (out);
    \end{scope}
    % - adder
    \begin{scope}[xshift=5cm]
        \node[adder]  (add)                       {};
        \node[input]  (in1) [above left from=add] {$x_1(t)$};
        \node[input]  (in2) [below left from=add] {$x_2(t)$};
        \node[output] (out) [right from=add]      {$x_1(t)+x_2(t)$};
        % signal paths
        \path[r>] (in1) -| (add);
        \path[r>] (in2) -| (add);
        \path[r>] (add) -- (out);
   \end{scope}
\end{signalflow}


% - modulator
\begin{signalflow}{Modulator}
   \node[modulator] (mul)                       {};
   \node[input]     (in1) [above left from=mul] {$x_1(t)$};
   \node[input]     (in2) [below left from=mul] {$x_2(t)$};
   \node[output]    (out) [right from=mul]      {$x_1(t)x_2(t)$};
   % signal paths
   \path[r>] (in1) -| (mul);
   \path[r>] (in2) -| (mul);
   \path[r>] (mul) -- (out);
\end{signalflow}

\begin{signalflow}{Delay element and filter}
    % - delay element
    \begin{scope}
        \node[input]  (in)                   {$x(t)$};
        \node[delay]  (del) [right from=in]  {$T$};
        \node[output] (out) [right from=del] {$x(t-T)$};
        % signal paths
        \path[r>] (in)  -- (del);
        \path[r>] (del) -- (out);
    \end{scope}
    % - filter
    \begin{scope}[xshift=5cm]
        \node[input]  (in)                   {$x(t)$};
        \node[filter] (fil) [right from=in]  {$q(t)$};
        \node[output] (out) [right from=fil] {$x(t)\ast q(t)$};
        % signal paths
        \path[r>] (in)  -- (fil);
        \path[r>] (fil) -- (out);
   \end{scope}
\end{signalflow}
\end{preview}


\end{document}

