Simulate digital filters with PSpice

-May 14, 2015

PSpice has become an industry standard tool for analog circuit simulations. Analog circuits have real physical realizations and can be simulated with their schematic representation, and the frequency response is a consequence of the circuit time constants. In contrast, digital filters perform mathematical operations on a sequence of samples. The digital filter’s time constants are hidden in the sampling interval T. So, digital filters are usually simulated only mathematically by their transfer functions, and to do this, it is important to have an easy way of simulating the sampling delay T=1/fs, introduced by the sampling rate fs, because this delay defines and scales the overall filter response.

Usually, the Laplace transform is used for behavior modeling of analog circuits because it transforms the time domain into the complex frequency s-domain. The frequency response of a digital filter serves a particular case, and can be derived from the Time-shift theorem (Delay theorem) of the Laplace transform. The theorem states that, if a time function f(t) is delayed by a time T in the time domain, the result in the frequency domain is a multiplication by e-sT, see Eq. (1).

 The term esT is often referred to as a delay operator, and if it is replaced by the symbol z, as in Eq. (2), the Laplace transform rises to the so called z-transform. Thus, coming back to the time domain, z-n corresponds to the delayed nth sample, z0 is the current sample, and zn denotes the future nth sample. 

            zn = ensT                       (2)

This Design Idea presents a fast, simple, and intuitive approach for digital filter frequency response simulation in PSpice. The PSpice analog behavior modeling symbol library abm.slb contains the LAPLACE part (Laplace Voltage Controlled Voltage Source), where any s-domain transfer function can be written in its numerator (NUM) and denominator (DENOM) forms. To simulate a z-domain transfer function, first, the sampling interval T should be defined in the circuit parameter list. Next, the z-domain transfer function should be written in the LAPLACE part by replacing zn with Eq. (2). In PSpice, this replacement can be done by defining a function (Eq. (3)), and this function is the heart of the Design Idea.

.FUNC      z(n)    {exp(n*s*T)}                     (3)

For example, if z(-10) is written somewhere in the numerator or denominator forms, PSpice will replace z(-10) with e-10sT (s is the Laplace variable used by the LAPLACE part). Eq. (3) can be placed in an included file, or more conveniently, in the template of a new schematic part, FUNCTIONS.

The PSpice schematic for AC simulation of a digital moving-average filter is shown in Figure 1. The moving-average filters reject any signals with frequencies in the filter zeros.

For example, let the sampling frequency be fs = 2kHz, or T = 0.5ms. To reject 50Hz power-line (PL) interference, the samples from one period must be averaged. At 2kHz sampling rate, one PL period consists of 20ms/0.5ms = 40 samples. The averager can be simulated directly by a transfer function (output MAV40T), or by a structure close to its real algorithmic realization using delay blocks, gain blocks, and summing and difference junctions (output MAV40R). The simulation has notches at all harmonics of PL interference, as seen in Figure 2.

Figure 1  PSpice schematic for AC line interference averager (comb filter)


Figure 2  Frequency response of the averager


The presented approach is fast and easy. I have used it for 10 years, and was inspired to share my knowledge after discovering the Design Idea in Reference 1. Other examples of digital filters simulated with the presented approach can be found in Reference 2. And here are some design files.



  1. Lopez D., Transmission lines simulate digital filters in PSpice, EDN, 2008


Also see:



Loading comments...

Write a Comment

To comment please Log In