You are on page 1of 6

Session R4B

Teaching digital signal processing using PSpice


Paul Tobin
Department of Electronic and Communications Engineering, Dublin Institute of Technology, paul.tobin@dit.ie Ireland Abstract - Circuit design is a combination of many factors: An understanding of circuit theory, an intuitive design sense, and a problem solving ability. PSpice helps students address these factors and here a novel method for teaching digital signal processing (DSP) is explored. Traditionally, DSP is introduced to students using Matlab/Simulink, but I hope to demonstrate how PSpice is a useful alternative introductory learning tool. Topics, such as artificial neural networks, reverb/echo production, and many other applications not normally simulated in PSpice, can produce excellent results. Index Terms PSpice, DSP, education, simulation, artificial neural networks. INTRODUCTION Matlab has certain weaknesses when teaching DSP at an introductory level. For example, the procedure to convolve and plot, two signals, a, and b, in Matlab, is as follows: The signals are a = [1, 2, 3], b = [1, 0.5, 0.25], and the convolution Matlab mfile is conv(), with the output y = conv(a,b) plotted using another mfile, stem(y). Substituting variables into the mfiles does little to explain the convolution process and may lure the students into a false sense of understanding. PSpice, on the other hand, requires the student to understand the convolution process before implementation, as will be demonstrated in the first example [1]. DIGITAL CONVOLUTION This example demonstrates the Flip and Slip convolution method using the signals from the previous Matlab example where a = x(n) , and b = h(n). An impulse applied to the second-order finite impulse response (FIR) filter in Figure 1, produces an impulse response, h(n), and from which we can plot the amplitude response. The sampling time for this system is 125 us, which is the inverse of the sampling frequency. Convolution predicts the output y(n), by convolving an input signal x(n) with h(n), and is expressed as:
y ( n ) = x ( n ) * h ( n ) = x ( k )h ( n k )
k =0 N

(1)

Where the notation * denotes convolution sum. Table 1 lists the product and summation values for the first five values of n in (1).
TABLE I

y(n) y(1) y(2) y(3) y(4) y(5)

x(n)h(n) 1x1 1x0.5 1x0.25

2x1 2x0.5 2x0.25

3x1 3x0.5 3x0.25

xh 1 2.5 4.25 2.0 0.75

Hierarchical blocks h, and hs, are for plotting the signals at different stages of the Flip and Slip process, with the impulse response signal flipped in time before multiplication and summation. A non-causal 750 us (6 delays = 6x125us) reference point is shown in Figure 2, and is achieved by multiplying the input signal by exp(6sT ) . The impulse response signal is also delayed by exp(4sT ) , which is two delays less to accommodate the signal length. The blocks contain Laplace analogue behavioral models (ABM) parts to generate the signals defined in (2) and (3). The delayed input signal, expressed as a function of the z-transform, is: X ( z ) = (1 + 0.5 z 1 + 0.25 z 2 ) z 6 (2) Similarly, the impulse response signal is: H ( z ) = (1 + 2 z 1 + 3z 2 ) z 4 (3) Flipping the impulse response is achieved by assigning the filter coefficients to the impulse response values, but in a reverse, or flipped, order using the useful Param part. This example helps students understand the difficult concept of convolving signals and the flipping and slipping technique. Note: The student may use another schematic to multiply the two convolution signals and compare the result to the convolution output, since convolution in time is equivalent to multiplication in the z-domain.

FIGURE 1 DEMONSTRATING THE FLIP AND SLIP METHOD

San Juan, PR 9th International Conference on Engineering Education R4B-26

July 23 28, 2006

Session R4B

FIGURE 2 THE FLIP AND SLIP WAVEFORMS

DIGITAL BANDPASS FILTER


The second example in Figure 3 shows a second-order bandpass infinite impulse response (IIR) recursive filter whose difference equation is: y (n) = x(n) + bo y (n 1) + b1 y (n 2) (4) The filter coefficients are: bo = 1.2 and b1 = -0.91 and represented by gain parts. This equation states how the present output y(n) is a function of past output values, and is achieved using delay parts. A hierarchical block labeled delay, contains two transmission lines terminated at both ends with a resistance equal to the characteristic impedance. The output of the first delay line gives a delay of 125 us, for a sampling frequency of 8 kHz, and the second tap gives a total delay of 256 us. Maximum gain is measured at the resonant frequency given by:

f0 =

fs b 8000 1.2 cos 1 ( 0 ) = cos 1 ( ) = 1133 Hz (5) 2 2 2 b1 2 0.91

The filter amplitude response is obtained by applying a sine wave and sweeping the input frequency. Alternatively, a narrow impulse applied yields the impulse response from which the amplitude can be obtained. A 10 us impulse signal will produce an infinite number of terms in the output, of which the first four terms are: h(0) = (0) + 1.2h(0 1) 0.91h(0 2) = 1 + 0 0 = 1 h(1) = (1) + 1.2h(1 1) 0.91h(1 2) = 0 + 1.2 x1 0 = 1.2 h(2) = (2) + 1.2h(n 1) 0.91h(n 2) = 0 + 1.2 x1.2 0.91 = 0.53 h(3) = (3) + 1.2h(n 1) 0.91h(n 2)...... (6) We may compare theses four impulse response values to the values displayed in the impulse response in Figure 4. The cursor shows time/amplitude pairs, e.g. the second pulse at 130 us, has an amplitude of 1.2 V.

FIGURE 3 A RECURSIVE BANDPASS FILTER

San Juan, PR 9th International Conference on Engineering Education R4B-27

July 23 28, 2006

Session R4B

FIGURE 4 AMPLITUDE AND IMPULSE RESPONSES

From the impulse response output plot, select the Fast Fourier transform (FFT) icon to change the impulse response to a sinc-type display of amplitude versus frequency. Magnifying the initial portion of this display will show a repeating bandpass amplitude response (the repeating response, at multiples of the sampling frequency, is characteristic of sampled signals). However, to get meaningful measurements, such as the maximum gain, Q-factor, and bandwidth, requires carrying out an ac sweep by changing the input signal to a sine signal (rename the bubble), in order to plot the frequency response shown in Figure 5. The effect on the frequency response of varying the first filter coefficient is also shown. Changes in the Q-factor and resonant frequency, is evident when b1 is varied from 0.95 to 0.99 in steps of 0.01. As b1 approaches unity, the Q-factor becomes higher and the bandwidth narrows.

QUADRATURE SIGNAL PRODUCTION


Quadrature carrier signals are signals having a ninetydegree phase shift between them, and have applications in many areas of telecommunications. The schematic in Figure 6 is a system for producing sustained cosine and sine signals. The difference equation for the cosine output is: y (n) = cos(n ) = cos(n 1) cos sin(n 1) sin (7) Similarly, the difference equation for the sine output is: x(n) = sin(n) = sin(n 1) cos + cos(n 1) sin (8) In these equations, the digital frequency is defined as = 2 f a / f s , where fs is the sampling frequency rate and fa is the frequency of the two output signals. The oscillator circuit is kick-started using an impulse signal to produce the sustained sampled outputs as plotted in Figure 7.

FIGURE 5 THE AMPLITUDE RESPONSE FOR DIFFERENT FILTER COEFFICIENTS

San Juan, PR 9th International Conference on Engineering Education R4B-28

July 23 28, 2006

Session R4B

.
FIGURE 6 QUADRATURE SIGNAL PRODUCTION

FIGURE 7 QUADRATURE SIGNAL OUTPUTS

THE DISCRETE HILBERT TRANSFORM


The Hilbert transform (HT), introduces a constant 90degree phase shift over a band of frequencies and has many applications in telecommunications transmission systems. Figure 8 shows a high-order FIR filter in quadrature with a delay D = ( N 1)T / 2 , where T is the sampling period and N is the filter order [2]. There are seventeen FIR filter coefficients but half of them are zero. The FIR filter uses Laplace analogue behavioral model (ABM) parts, with the filter transfer function entered into the ABM numerator as a series of weighted exponential terms having a form -0.0909exp(-s*T), and with a unity denominator. The filter uses two ABM parts to overcome the Laplace evaluation part limit of 132 characters.

San Juan, PR 9th International Conference on Engineering Education R4B-29

July 23 28, 2006

Session R4B

FIGURE 8 THE DISCRETE HILBERT TRANSFORM USING FIR FILTERING

Figure 9 shows the 1 V input impulse signal and the impulse response pulses whose amplitudes corresponding to the filter coefficients. Figure 10 shows the amplitude response with ripple in the passband region that can be reduced by

increasing the filter order. The phase response is plotted using a pair of phase markers showing the required constant 90 degree phase shift over the desired frequency band.

FIGURE 9 THE IMPULSE RESPONSE

FIGURE 10 FREQUENCY AND PHASE RESPONSE

San Juan, PR 9th International Conference on Engineering Education R4B-30

July 23 28, 2006

Session R4B
SINGLE SIDEBAND MODULATOR
The schematic in Figure 11 is a single sideband modulator (SSB), for suppressing the upper sideband and carrier. This increases the overall transmission efficiency and the signal to noise ratio compared to a double sideband suppressed/full carrier modulator (DSBSC/FC). The Hilbert Transform hierarchical block, HilbertTransform, shifts the two sinusoidal modulating test signals by 90 degrees before being applied to each balanced modulator. The sine and cosine discrete local oscillators, examined previously, are located in the QuadOsc block and produce quadrature DSBSC outputs. Subtracting the two outputs, produce an SSB signal whose output spectra in Figure 12, shows how the carrier and upper sideband have been eliminated from the output spectrum.

Figure 11
SSB MODULATOR

FIGURE 12 SSB SIGNAL SPECTRA

CONCLUSIONS
Understanding the fundamental concepts of DSP (indeed any engineering subject), is important in order for the student to progress satisfactorily to more advanced treatment of the subject. An ever-increasing worrying trend throughout engineering education is a gradual diminution of fundamental principles, in order to accommodate the vast amounts of software/protocol techniques being created. With PSpice, the student is forced to construct the schematic from basic principles. I have found over the last six years that this method produces a better understanding when compared to the Matlab approach. However, Matlab excels for more advanced DSP analysis. PSpice has also been used to examine decimation, interpolation, digital receivers, and filter design methods such as the bilinear transform, impulse invariant, and window technique. Echo/reverb [4] and other musical effects etc. have also been investigated successfully using a segment of speech (in ASCII format) imported into PSpice. A shareware program, Wav2Ascii [3], enables a twosecond segment of speech to be recorded and inputted into PSpice. This program also allows the user to listen to the simulated output thus creating an air of realism into the simulation. Other topics not covered, because of space limitation, are artificial neural networks (ANN). Here again, simple circuits were created from basic concepts and were useful in introducing students to ANN network learning such as the delta and perceptron learning paradigms.

REFERENCES
[1] [2] [3] [4] Tobin, Paul A, PSpice for Telecommunications and DSP with over 500 worked examples (To be published in 2006). Bateman, Andrew and Paterson-Stephens, Iain. The DSP handbook, Prentice Hall PTR; CD-Rom edition (October 16, 2002) Tobin Lee E Shareware software copyright Mitra K Sanjit, Digital Signal Processing. A computer-based Approach WCB/McGraw-Hill, 1st edition (1998)

San Juan, PR 9th International Conference on Engineering Education R4B-31

July 23 28, 2006

You might also like