Abm
Abm
Abm
Applications
table of contents
Preface
A collection of
application notes on
maximizing PSpice
10
14
17
Voltage-Controlled Oscillators
26
analog behavioral
modeling capabilities.
Preface
This book is a collection of application notes which are focused on the
subject of using PSpices Analog Behavioral Modeling (ABM) features
to model specific devices or characteristics in simulations. Some of these
application notes are old standbys, and some are newer; they all contain relevant and useful examples that demonstrate the flexibility and
capabilities of ABM. Addenda have been appended to application
notes to provide clarifications as necessary.
Analog Behavioral
Modeling Using PSpice
Device Modeling
Introduction
Time domain
System Modeling
Behavioral Modeling as Abstraction
In the early stages of system design, the emphasis is on high-level issues
rather than on low-level details. Behavioral models allow systems to be
simulated with reduced complexity and with improved computational
efficiency.
Figure 2. Behavioral model for a tunnel diode
Parameterization
Consider modeling devices with parameters different from the example
set used above, for example to produce a library of devices for general
use. The polynomial approach would require a set of coefficients for
each distinct device. This becomes impractical for anything more than a
handful of devices. It may be possible to define a generic tunnel
diode device and map inputs and outputs appropriately, but it is not
intuitively obvious what mapping to use.
Behavioral Model: Each of the three main components of the PLL can be
expressed succinctly in PSpice's extended Behavioral Modeling syntax.
The Phase Detector is a multiplier with the output range constrained to
[-1,+1]. It uses gain blocks, limiters, and a multiplier.
The Loop filter is single pole RC. The output of the loop filter is the
error signal. The Loop Filter could also be conveniently described by
giving its Laplace Transform, using s-domain notation.
The limiter block is a non-linear table, which shifts levels for the
VCO input.
Once locked the error signal tracks small frequency changes of the
input signal by generating additional phase error between the VCO
and the input signal. This signal is converted to the DC error voltage by
the phase detector and low-pass filter.
At the upper lock range frequency, the model loses lock, and the error
voltage suddenly drops. and then becomes a beat note.
Circuit Level Model: A model of the same PLL was developed using
bipolar transistor circuits.
The VCO was an astabel multivibrator with the charging current proportional to the VCO control voltage. The multiplier was a double-balanced modulor using 6 BJTs. The Loop Filter consisted of two resistors
and a capacitor.
A complete description consists of these circuit fragments, together
with power supplies, bias resistors, bypass capacitors, etc.
Comparing the two Approaches: Table 1 contrasts the two approaches
to modeling the PLL.
Compared with the Circuit model, it took about 20% of the time to
develop the Behavioral model, and the transient analysis ran in about
4% of the time.
The time required to run the analysis is significant. The Behavioral
model allows many more analyses to be run in a given time, permitting
a higher degree of design refinement and/or test.
Model
Behavior
Circuit
Devt. Time
Simulation Time
* lines
1 day
24 sec*
9
5 days
606 sec*
43
Managing Convergence
and Time-Step Control
PSpice has also been considerably enhanced: many more math operations are now available for use in behavioral modeling expressions,
including an if-then-else function; the convergence algorithms have
been improved to better handle the unusual behavior that can be specified given the flexibility of behavioral modeling; the frequency domain
expressions are now more flexible and more robust when simulated in
the time domain; etc.
For other forms the proposed output at a given time step could be
compared with the previous output and absolute and/or relative delta
criteria applied. If the test failed, the time step would be reduced. The
criteria could be specified per device, with global default values.
Controlling the time step may be necessary not only for convergence,
but also from sampling considerations. Interpolation schemes are used
for graphical display of the simulation results. The time step must be
constrained so that voltage/current changes are within the scope of the
interpolator.
It is not possible to deduce the frequency domain behavior of devices
specified by arbitrary expressions. There is a risk of aliasing occurring if
the initial and subsequent choices of timestep produce reasonable
(but subsampled) values of a periodic function. For example, suppose
there is a 1 MHz source in the circuit and the initial time step is chosen
as 10 S. If each subsequent time step is also 10 S, the apparent value
of the source will be 0.
In practice, this kind of subsampling will be readily noticed. It can be
avoided by manually setting the step ceiling.
References
Addendum
Since the publication of this paper, University of California at Berkeley
has introduced several newer versions of SPICE. The latest of these supports behavioral modeling constructs that provide some of the capabilities offered by PSpice, but is not backward compatible with the
10
We can also introduce ideal nonlinearities using the table lookup form
of Analog Behavioral Modeling. For example, the one-line, ideal
opamp model:
Eampout0table {200K*(v(in_hi)-v(in_lo))}=
+(-15,-15)(15,15)
has high gain, but its output is clamped between 15 volts. The input
to the table is the differential gain formula, but the lookup table has
only two entries: so the output of the table is interpolated between
these two endpoints and clamped when the input exceeds the tables
range. This is a convenient use of the table lookup form, which is not
available in generic SPICE.
Small systems of behavioral models are easy to design, also. For example, a true-RMS circuit can be built by decomposing the RMS function:
(i) square the signal, (ii) integrate over time, and (iii) take the squareroot of the time average. These three operations can be bundled in a
tiny subcircuit for use as a module:
The parameter H defines the size of the hysteresis, and is used in the
formula input to the table. The combination of the formula and table
defines a dead-band outside of which the output follows the input
with an offset of H/2. The capacitor serves as memory for the circuit
and is nearly ideal except for the DC-bias resistor, which provides a
droop time constant of one billion(!) seconds. The voltage follower, E1,
prevents output loading problems. E1 could also have gain representing the gear ratio of a mechanical system; then voltage would represent the total turn angle of each gear, and H the amount of angular
backlash.
The current source, G1, squares the signal, which is then integrated in
the capacitor. The voltage on the capacitor is time averaged, and
the square-root is taken (the resistor is a dummy load that satisfies the
SPICE algorithms). The voltage source E1 shows that the value of
simulated time is available in Analog Behavioral Modeling, and may
11
12
Creating Impedances
with Behavioral Modeling
MicroSim Corporation Newsletter, October 1990
.param H=1
*
V1 in 0 SIN (0 1 1)
Xrms 1 rms RMSXhys 1 hys HYS
param: H=1
*
.tran 10m 1
.end
A1 Hz sine wave was used for the stimulus to the RMS and HYS circuits.
is a linear conductance with a value of 1 milli-mho (i.e., a 1 kilo-ohm
resistor). The controlling nodes are the same as the output nodes. For a
nonlinear conductance the appropriate nonlinear function is used, but
the device still has the same controlling and output nodes:
In Figure 4 we see a Probe plot of the input, and the outputs from each
circuit. Note that the RMS circuit outputs the well-known result of
0.707 volts after one input cycle, while the HYS circuit lags the input by
a half volt in each direction for a total hysteresis of one volt. Perhaps
these examples will give you ideas for other functions which would be
most difficult to create with generic SPICE.
13
14
For example:
E1 is a linear resistor with a value of 1 kilo-ohm. V1 is needed to measure the current through E1. A quadratic resistor is then:
15
16
Filter Models
Implemented with ABM
by Bashir Al-Hashimi, PhD, School of Engineering, Staffordshire
University, Stafford, England
Analog behavior modeling (ABM) allows the simulation of analog
circuits using mathematical equations. This article shows how filter
behavioral models are developed and implemented using the Laplace
function of PSpice. Given the filter bandwidth and order, the models
simulate lowpass, highpass, bandpass, and band-reject filters. For
ease of use, the models are developed as parameterized subcircuits.
Simulation examples are included to demonstrate the use of these
models.
Introduction
Filters are often described in terms of a number of parameters including type, order, and response. There are four filter types:
Lowpass
Highpass
Bandpass
Band-reject
17
18
The model implements the overall voltage transfer function of the filter
using a controlled voltage source (E component) that has the Laplace
description. Although the concept is general in that it allows an nthorder lowpass filter to be simulated, Figure 2 shows that the model is
limited to simulating a maximum of a ninth-order filter, which is made
up of one first-order section and four second-order sections. It is often
considered that a ninth-order filter is adequate for most applications.
The filter model can easily be increased to simulate filters greater than
9th order by adding second-order sections.
The transfer functions are specified through .FUNC statements. The
parameters a1 through a4 and b1 through b4 determine which filter
sections of the model are selected by using a simple selection algorithm,
based on the order of the filter specified by the user. The selection algorithm is implemented using .PARAM statements as shown in the listing.
The filter order is defined by the subcircuit parameter, ORD. Note that
the PSpice function stp, which is used in the model, describes a step
function where stp(x) is 1 if x>0 and is 0 otherwise. The , 0, and Q
values of the Butterworth response are defined as lookup tables using
19
The subcircuit has two parameters: the filter cutoff frequency (FC) and
its order (ORD). These subcircuit parameters are given default values,
which are arbitrarily set to 1. They will be changed to the required cutoff frequency and order when the subcircuit is called.
Similar Chebyshev and Bessel lowpass filter models can be easily developed. The Chebyshev filter model is called Ch2p5_LP, while the Bessel
model is called Bessel_LP. Chebyshev filtering response exists for a
range of passband ripple [1]. The ripple has been fixed at 0.25dB in the
case of the Ch2p5_LP model. To develop Chebyshev models with different values of ripple, the values , 0, and Q are needed for the required
ripple, which are readily available [1]. Note that both of these models
are capable of simulating up to ninth-order filters.
Example 1
To illustrate the use of the models, consider the following example.
Here, the Butterworth lowpass filter model is used to obtain a family of
curves for second- through ninth-order responses. Assume the filter has
a cutoff frequency of 10 kHz. Using Orcad Capture, the circuit of
Figure 4 is drawn.
20
The filter Butt_LP has an AC source on its input and a 1K load resistor
on its output. On the Butt_LP symbol, the attribute FC has a value of
10K, and ORD is set to the global variable defined in the global parameter block (PARAM). Finally, a VDB voltage marker is placed on the
output node to view the results.
In Orcad Capture, be sure to configure the part library filters.olb
(obtained from the ftp site) in the schematic Editor, and the model
library filters.lib in the Libraries tab of the Simulation Settings.
The analysis consists of a 100 point per decade AC sweep and a parametric analysis. The parametric analysis steps the global parameter,
ORD, from 2 to 9. The simulated frequency response of the filter for
various orders is shown in Figure 5.
Figure 6. Behavioral Butterworth Bandpass Filter Model
Example 2
To demonstrate the use of the bandpass filter models, consider simulating a bandpass circuit with the following specifications:
lower 3dB point=1kHz
upper 3dB point=5kHz
30dB minimum at 0.3kHz and 20kHz
Figure 5. Butterworth Lowpass Filter Frequency Response for Various Orders
21
22
The Butt_BP filter symbol has attributes FCL=1kHz and FCH=5kHz for
low and high cutoff frequencies, respectively. A single AC source is
frequency swept over 0.25kHz to 50kHz (1000 points). The simulated
frequency response of the filter is shown in Figure 8.
Example 3
Figure 10 contains a fifth-order, .25dB ripple Chebyshv band-reject filter
with a lower -3dB point at 1kHz and th eupper -3dB point at 5kHz.
23
24
Voltage-Controlled Oscillators
In this discussion, lets take a look at modeling Voltage Controlled
Oscillators (VCOs), and see how several different VCOs can be modeled
using PSpice. Most of the examples use PSpices Analog Behavioral
Modeling (ABM) capabilities.
Library Availability
The symbol and model libraries used in this article are contained in a
self-extracting zip file which can be downloaded from
ftp://ftp.orcad.com/dwn_file/Pspice/Tech_support/filters.exe
References
[1] Van Valkenburg, M.E., Analog Filter Design, Holt, Rinehart &
Winston, New York, 1982.
[2] Williams, A.B., Electronic Filter Design Handbook, McGraw Hill Book
Company, USA, 1981.
[3] Al-Hashimi, B.M. The Art of Simulation Using PSpice: Analog &
Digital, CRC Press, USA, 1995.
In this ABM expression, twopi, fc and phi are all (constant) global
parameters defined with a parameter block (PARAM part).
In order to obtain good resultution from a simulation using the above
exression it will be necessary to set the maximum time step to be taken
by the simulator. A simple approach is to set the time step ceiling for
the Transient Analysis. For example, to view 10 cycles of a 1 MHz
source, with 20 samples per cycle, a good choice for the step ceiling
would be 50ns.
The single frequency source can be turned into a VCO by making phi a
function of a controlling voltage instead of a constant:
y(t) = sin (2fct + (t))
25
26
where k1 is in Hertz/volt.
Using PSpice, the integrator can be modeled as a controlled current
source plus a capacitor. The varying phase term is added into the controlled voltage (sine) source. To complete the example, a controlling
voltage is required. Here is a piece-wise linear stimulus that starts at 0 v,
remains at this level for 5 s, then steps to 1 v and stays there:
pwl(0,0v5us,0v5.01us,1v)
Used with the VCO above and setting fc to 1 MHz and k1 to 1 MHz/volt
gives an output signal that is 1 MHz for the first 5 s and 2 MHz for the
next 5 s.
{k*(pwr(x,2)+pwr(y,2)-pwr(z,2))}
27
28
29
30
As shown in Figure 11, the Wien bridge consists of two resistors and
two voltage-controlled capacitors.
31
32
Reference
[1] I. M. Filanovsky, Sinusoidal VCO with Control of Frequency and
Amplitude, Proceedings of the 32nd Symposium on Circuits and
Systems, IEEE, Vol I, 446-449 (1989).
33
34