%$Id: generato.tex,v 21.13 2002/03/25 05:37:03 al Exp $
% man  commands  generato  .
% Copyright (C) 2001 Albert Davis
% Author: Albert Davis <aldavis@ieee.org>
%
% This file is part of "Gnucap", the Gnu Circuit Analysis Package
%
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 2, or (at your option)
% any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
% 02111-1307, USA.
%------------------------------------------------------------------------
\section{{\tt GENERATOR} command}
\index{Generator command}
\index{user defined transient input}
\index{user source}
\index{transient input}
\index{input: transient analysis}
\index{function generator}
%------------------------------------------------------------------------
\subsection{Syntax}
\begin{verse}
{\tt Generator} \{{\it option-name}={\it value} ...\}
\end{verse}
%------------------------------------------------------------------------
\subsection{Purpose}

Sets up an input waveform for {\tt transient} and {\tt Fourier} analysis.
Emulates a laboratory type function generator.
%------------------------------------------------------------------------
\subsection{Comments}

This command sets up a singal source that is conceptually separate
from the circuit.  To use it, make the value of a component
"generator(1)", or substitute a scale factor for the parameter.

The SPICE style input functions also work, but are considered to
be part of the circuit, instead of part of the test equipment.

The parameters available are designed to emulate the controls on a function
generator.  There are actually two generators here: sine wave and pulse.  If
both are on (by setting non-zero parameters) the sine wave is modulated by
the pulse, but either can be used alone.

Unless you change it, it is a unit-step function at time 0.  The purpose of
the command is to change it.

This command does not affect {\tt AC} or {\tt DC} analysis in any way.  It
is only for {\tt transient} and {\tt Fourier} analysis.  In {\tt AC}
analysis, the input signal is always a sine wave at the analysis frequency.

Typical usage is the name of the control followed by its value, or just plain
{\tt Generator} to display the present values.

The actual time when switching takes place is ambiguous by one time step.  If
precise time switching is necessary, use the {\tt Skip} option on the
transient analysis command, to force more resolution.  This ambiguity can
usually be avoided by specifying finite rise and fall times.
\index{ambiguous time}
\index{switch time errors}
%------------------------------------------------------------------------
\subsection{Parameters}

\begin{description}

\item[{\tt Frequency}] The frequency of the sine wave generator for a transient
analysis.  The sine wave is modulated by the pulse generator.  A frequency
of zero puts the pulse generator on line directly.

\item[{\tt Amplitude}] The overall amplitude of the pulse and sine wave.  A
scale factor.  It applies to everything except the {\it offset} and {\it
init} values.

\item[{\tt Phase}] The phase of the sine wave, at the instant it is first
turned on.

\item[{\tt MAx}] The amplitude of the pulse, when it is `on'.  (During the
{\it width} time) If the sine wave is on (frequency not zero) this is the
amplitude of the sine wave during the first part of the period.  The {\it
max} is scaled by {\it ampl}.

\item[{\tt MIn}] The amplitude of the pulse, when it is `off'.  (After it
falls, but before the next period begins.)  Although we have called these
{\it min} and {\it max}, there is no requirement that {\it max} be larger
than {\it min}.  If the sine wave is on, this is its amplitude during the
second part of the period.  The {\it min} is scaled by {\it ampl}.

\item[{\tt Offset}] The DC offset applied to the entire signal, at all times
after the initial delay.  The {\it offset} is {\bf not} scaled by {\it ampl}.

\item[{\tt Init}] The initial value of the pulse generator output.  It will
have this value starting at time 0, until {\it Delay} time has elapsed.  It
will never return to this value, unless you restart at time 0.

\item[{\tt Rise}] The rise time, or the time it takes to go from {\it MIn}
to {\it MAx}, or for the first rise, {\it Init} to {\it MAx}.  The rise is
linear.

\item[{\tt Fall}] The fall time.  (The time required to go from {\it MAx}
back to {\it MIn}.)

\item[{\tt Delay}] The waiting time before the first rise.

\item[{\tt Width}] The length of time the output of the generator has the
value {\it Max}.  A width of zero means that the output remains high for the
remainder of the period.  If you really want a width of zero, use a very
small number, less than the step size.

\item[{\tt Period}] The time for repetition of the pulse.  It must be
greater than the sum of rise + fall + width.  A period of zero means that
the signal is not periodic and so will not repeat.

\end{description}
%------------------------------------------------------------------------
\subsection{Examples}

The generator command ...

\begin{description}

\item[{\tt gen}] Display the present settings.

\item[{\tt gen Freq=1k}] Sets the sine wave to 1 kHz.  All other parameters
are as they were before.

\item[{\tt gen Freq=0}] Turns off the sine wave, leaving only the pulse.

\item[{\tt gen Ampl=0}] Sets the amplitude to zero, which means the circuit
has no input, except for possibly a DC offset.

\item[{\tt gen Period=.001 Freq=1m}] Sets the period back to 1 millisecond.
Applies 1 mHz modulation to the pulse, resulting in a pulsed sine wave.  In
this case, a 100 microsecond 10 volt burst, repeating every millisecond.
Between bursts, you will get 2.5 volts, with reversed phase.  The old
values, in this case from 2 lines back (above) are kept.  ({\tt Ampl 5 Rise
10u Fall 10u} ...)

\item[{\tt gen Freq=60 Phase=90 Delay=.1}] The sine wave frequency is 60
Hertz.  Its phase is 90 degrees when it turns on, at time .1 seconds.  It
turns on sharply at the peak.

\end{description}

A component using it ...

\begin{description}

\item[{\tt V12 1 0 generator(1)}] Use the generator as the circuit
input through this voltage source.  The DC and AC values are 0.

\item[{\tt V12 1 0 tran generator(1) ac 10 dc 5}] Same as before, except
that the AC value is 10 and DC value is 5.

\item[{\tt Rinput 1 0 tran generator(1)}] Unlike SPICE, the functions
can be used on other components.  The resistance varies in time
according to the "generator".

\end{description}

%------------------------------------------------------------------------
%------------------------------------------------------------------------
